Skip to content
Snippets Groups Projects
Commit 883f5074 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

Countries_entity: added record container caching

parent 5154453f
No related branches found
No related tags found
No related merge requests found
......@@ -98,6 +98,8 @@
<alias>Data_alias</alias>
<isPageable v="false" />
<orderClauseProcess>%aditoprj%/entity/Countries_Entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
<cacheType>GLOBAL</cacheType>
<cacheKeyProcess>%aditoprj%/entity/Countries_Entity/recordcontainers/db/cacheKeyProcess.js</cacheKeyProcess>
<linkInformation>
<linkInformation>
<name>cc219004-43fd-4a3f-bee0-be5e732c61f1</name>
......
import("CachedRecordContainer_lib");
import("system.result")
var res = CachedRecordContainerUtils.getCommonKey();
result.string(res);
\ No newline at end of file
import("system.entities");
import("system.translate");
import("system.db");
import("DataCaching_lib");
import("Sql_lib");
/*
This is a experimental library.
The code will definetly change in the future while not keeping the same functionparameters and calls. You should not use this except you excatly know what you're doing.
Since the functions will change, comments are written for the future functions.
The idea behind this is to maintain data in cached form (client-context-side)) for various keyword-constructs.
*/
/**
* provides functions for retrieving common forms of countrydata
* Do not create an instance of this!
*
* @class
* @static
*/
function CountryInfoData(){}
CountryInfoData.getMainData = function (pLocale)
{
var cache = new CachedData("CountryInfoData.getMainData", true, pLocale);
return cache.load(function (pTranslationNecessary, pLocale){
var loadingConfig = entities.createConfigForLoadingRows().entity("Countries_Entity").fields(["ISO2", "NAME_TRANSLATED"]);//TODO: into cachedDatalib
var countryData = entities.getRows(loadingConfig);//TODO: ignore grants?
return countryData;
});
};
/**
* loads the ISO2 code and name of the countries_entity
*
* @param {String} [pLocale=current language] <p/>specifies the locale for translating the name, if not given the locale of the current image-context
* (server or client) is used
*
* @return {Array} 2D array where each row is an array of: [<<iso2-code>>, <<country-name>>]
*
*/
CountryInfoData.getIso2NameData = function (pLocale)
{
var cache = new CachedData("CountryInfoData.getIso2NameData", true, pLocale);
return cache.load(function (pTranslationNecessary, pLocale){
var countryData = CountryInfoData.getMainData(pLocale);
countryData = countryData.map(function (row){
return [row["ISO2"], row["NAME_TRANSLATED"]];
});
return countryData;
var fieldsToLoad = ["ISO2"];
if (pLocale)
fieldsToLoad.push("NAME");
else
fieldsToLoad.push("NAME_TRANSLATED");
var loadingConfig = entities.createConfigForLoadingRows()
.ignorePermissions(true)
.entity("Countries_Entity")//default record container is cached
.fields(fieldsToLoad);
var countryData = entities.getRows(loadingConfig);
var res = countryData.map(function (entityRow){
var name = pLocale ? translate.text(entityRow["NAME"], pLocale) : entityRow["NAME_TRANSLATED"];
return [entityRow["ISO2"], name];
});
return res;
};
\ No newline at end of file
......@@ -34,8 +34,6 @@ CountryUtils.getLatinNameByIso2 = function(pIso2, pLocale)
return countryName;
};
//SqlUtils.getResolvingCaseWhen(keywordData, pDbFieldName, pLocale);
/**
* resolves ISO2 codes of countries to the translated name
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment