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

Addresses: resovled country name is now loaded via the record container

parent 852c2148
No related branches found
No related tags found
No related merge requests found
......@@ -490,6 +490,10 @@
<name>USER_NEW.value</name>
<recordfield>ADDRESS.USER_NEW</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>COUNTRY.displayValue</name>
<expression>%aditoprj%/entity/Address_entity/recordcontainers/db/recordfieldmappings/country.displayvalue/expression.js</expression>
</dbRecordFieldMapping>
</recordFieldMappings>
</dbRecordContainer>
<indexRecordContainer>
......
import("system.result");
import("CountryInfo_lib");
var res = CountryUtils.getResolvedNameFromIso2Sql("ADDRESS.COUNTRY");
result.string(res);
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>CountryInfoData_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/CountryInfoData_lib/process.js</process>
<variants>
<element>LIBRARY</element>
</variants>
</process>
import("system.entities");
import("system.logging");
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.
*/
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;
});
};
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;
});
};
import("system.entities");
import("system.db");
import("system.translate");
import("Sql_lib");
......@@ -29,4 +30,21 @@ CountryUtils.getLatinNameByIso2 = function(pIso2, pLocale)
.buildSql("select AB_COUNTRYINFO.NAME_LATIN from AB_COUNTRYINFO"));
countryName = pLocale ? translate.text(countryName, pLocale) : translate.text(countryName);
return countryName;
};
//SqlUtils.getResolvingCaseWhen(keywordData, pDbFieldName, pLocale);
/**
* resolves ISO2 codes of countries to the translated name
*
* @param {String} pDbFieldName name fo the database field where the KEYID-value is stored
* @param {String} [pLocale=current client language] specifies the locale for translating the title; can be false if nothing shalle be translated
*
* @return {String} a SQL-expression (case-when-statement) that resolves the ISO2-code into the name (=title)
*/
CountryUtils.getResolvedNameFromIso2Sql = function(pDbFieldName, pLocale)
{
var countryData = CountryInfoData.getIso2NameData();
var resSql = SqlUtils.getResolvingCaseWhen(countryData, pDbFieldName, pLocale);
return db.translateStatement(resSql);
};
\ No newline at end of file
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