diff --git a/entity/Activity_entity/entityfields/icon/valueProcess.js b/entity/Activity_entity/entityfields/icon/valueProcess.js index 505a2c92f1097e44b662beacd05f9f43dd4b4b50..19bec4e77a8305f04a4b851908011003ffacc34e 100644 --- a/entity/Activity_entity/entityfields/icon/valueProcess.js +++ b/entity/Activity_entity/entityfields/icon/valueProcess.js @@ -2,9 +2,13 @@ import("system.vars"); import("system.result"); import("system.neon"); import("Keyword_lib"); +import("KeywordRegistry_basic"); var category = vars.getString("$field.CATEGORY"); -var kwd = LegacyKeywordUtils.createKeyword("ACTIVITY.CATEGORY");//getPropForKey -var icon = kwd.getPropForKey(category, "defaultAvatarRepresentation", true); - +var icon; +if (category) +{ + var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(category, $KeywordRegistry.activityCategory()) + icon = keywordAttributes.defaultAvatarRepresentation; +} result.string(icon || "NEON:HISTORY"); diff --git a/entity/Communication_entity/entityfields/addr/contentTypeProcess.js b/entity/Communication_entity/entityfields/addr/contentTypeProcess.js index a960f567b9adb79d447efe58f6e7bbbb12bd48d1..25141c53776680b9c9c714926c752fda5419deaa 100644 --- a/entity/Communication_entity/entityfields/addr/contentTypeProcess.js +++ b/entity/Communication_entity/entityfields/addr/contentTypeProcess.js @@ -1,17 +1,16 @@ import("Keyword_lib"); +import("KeywordRegistry_basic"); import("system.vars"); import("system.result"); import("system.neon"); -var medium, contentType; //TODO: add constants for contentTypes #1022547 -medium = vars.get("$field.MEDIUM_ID"); -if (medium){ - contentType = LegacyKeywordUtils.createKeyword("COMMUNICATION.MEDIUM").getPropForKey(medium, "contentType", true) || "TEXT"; +var medium = vars.get("$field.MEDIUM_ID"); +var contentType; +if (medium) +{ + var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(medium, $KeywordRegistry.communicationMedium()); + contentType = keywordAttributes.contentType; } -else { - contentType = "TEXT"; -} -result.string(contentType); - +result.string(contentType || "TEXT"); \ No newline at end of file diff --git a/entity/Communication_entity/entityfields/addr/onValidation.js b/entity/Communication_entity/entityfields/addr/onValidation.js index bf2171c209dd9e13aceb6c2601f1f7269db9c3a4..54a9148c82d2064819c16312df0acd1d96e60870 100644 --- a/entity/Communication_entity/entityfields/addr/onValidation.js +++ b/entity/Communication_entity/entityfields/addr/onValidation.js @@ -7,13 +7,17 @@ import("Keyword_lib"); import("Communication_lib"); import("Util_lib"); import("Entity_lib"); +import("KeywordRegistry_basic"); -var kwd = LegacyKeywordUtils.createKeyword("COMMUNICATION.MEDIUM"); var commMedium = vars.get("$field.MEDIUM_ID"); -var commCategory = kwd.getPropForKey(commMedium, "contentType", true);//TODO: maybe accessible via $property - then it's not needed to keep this information within the keyword + +//TODO: maybe accessible via $property - then it's not needed to load that info twice +var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(commMedium, $KeywordRegistry.communicationMedium()); +var commCategory = keywordAttributes.contentType || "TEXT"; var fn = CommValidationUtil.makeValidationFn(commCategory); -if (fn != null){ +if (fn != null) +{ var commAddr = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.ADDR")); var additional = CommValidationUtil.getExtensionsBlueprint(); additional.countryCode = vars.get("$param.ContactsMainCountry_param");//TODO: try to use users language first and then the companies diff --git a/entity/Task_entity/iconIdProcess.js b/entity/Task_entity/iconIdProcess.js index 446b9205ba8168cddc02ac6dc0e96b7418361417..c7a5eb886768027f7020cd78e8d135e1c29f69ec 100644 --- a/entity/Task_entity/iconIdProcess.js +++ b/entity/Task_entity/iconIdProcess.js @@ -2,9 +2,11 @@ import("system.vars"); import("system.result"); import("system.neon"); import("Keyword_lib"); +import("KeywordRegistry_basic"); var category = vars.getString("$field.PRIORITY"); -var kwd = LegacyKeywordUtils.createKeyword("TASK.PRIORITY"); -var icon = kwd.getPropForKey(category, "defaultAvatarRepresentation", true); + +var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(category, $KeywordRegistry.taskPriority()); +var icon = keywordAttributes.defaultAvatarRepresentation; result.string(icon || "VAADIN:TASKS"); \ No newline at end of file diff --git a/process/Communication_lib/process.js b/process/Communication_lib/process.js index f704ccfc6d6f2caa62fee555e5890d3b97abd4eb..ef697556352da4fe78183428d6d77463617423ce 100644 --- a/process/Communication_lib/process.js +++ b/process/Communication_lib/process.js @@ -22,7 +22,7 @@ function CommUtil(){} */ CommUtil.getMediumIdsByCategory = function (pCategory) { - var kwd = LegacyKeywordUtils.createKeyword("COMMUNICATION.MEDIUM"); + var kwd = LegacyKeywordUtils.createKeyword("COMMUNICATION.MEDIUM");//filter keyword on category kwd.filter(function(id, name, customs){ return customs.category == pCategory; }); diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js index c11bd2e8b7494eef6697e0ee0fbeb1486ab1daa2..a56c542f38089e6894774c81d01c264d49a335f2 100644 --- a/process/Keyword_lib/process.js +++ b/process/Keyword_lib/process.js @@ -62,14 +62,45 @@ KeywordUtils.getViewValue = function(keywordContainer, key) * @return {Object} key-value-pair of the keyword-attributes; contains all attribute-keys for the keywords-entries container; * if there is no value set for a key the null-value is given */ -KeywordUtils.getKeywordAttributeRelations = function (pEntryId) +KeywordUtils.getAttributeRelationsByEntryId = function(pEntryId) { - var sql = SqlCondition.begin() - .andPrepare("AB_KEYWORD_ENTRY.AB_KEYWORD_ENTRYID", pEntryId) - .buildSql("select AB_KEYWORD_ATTRIBUTE.NAME, AB_KEYWORD_ATTRIBUTE.TYPE, \n\ + var cond = SqlCondition.begin() + .andPrepare("AB_KEYWORD_ENTRY.AB_KEYWORD_ENTRYID", pEntryId); + + return KeywordUtils._getKeywordAttributeRelations(cond); +}; + +/** + * collects possible and defined keyword-attributes per keyword entry and returns them + * + * @param {String} pKeyId the key of an element within a containerName - this is the value that is stored in the reference-table (e.g. "DE") + * @param {String} pContainerName specifies the type of the keyword and therefore the list elements; + * e.g. "COUNTRY"; use an entry of the $KeywordRegistry here + * @return {Object} key-value-pair of the keyword-attributes; contains all attribute-keys for the keywords-entries container; + * if there is no value set for a key the null-value is given + */ +KeywordUtils.getAttributeRelationsByKey = function(pKeyId, pContainerName) +{ + var cond = SqlCondition.begin() + .andPrepare("AB_KEYWORD_ENTRY.KEYID", pKeyId) + .andPrepare("AB_KEYWORD_ENTRY.CONTAINER", pContainerName); + + return KeywordUtils._getKeywordAttributeRelations(cond); +}; + +/** + * internal function that collects possible and defined keyword-attributes per keyword entry and returns them + * + * @param {SqlCondition} pSqlCondition condition that shrinks a resultset to one AB_KEYWORD_ENTRY + * @return {Object} SQL-Condition object that filters + */ +KeywordUtils._getKeywordAttributeRelations = function (pSqlCondition) +{ + var cond = pSqlCondition; + var sql = cond.buildSql("select AB_KEYWORD_ATTRIBUTE.NAME, AB_KEYWORD_ATTRIBUTE.TYPE, \n\ AB_KEYWORD_ATTRIBUTERELATION.CHAR_VALUE, AB_KEYWORD_ATTRIBUTERELATION.NUMBER_VALUE, AB_KEYWORD_ATTRIBUTERELATION.BOOL_VALUE \n\ from AB_KEYWORD_ENTRY \n\ - left join AB_KEYWORD_ATTRIBUTE on (AB_KEYWORD_ATTRIBUTE.CONTAINER = AB_KEYWORD_ENTRY.CONTAINER) \n\ + join AB_KEYWORD_ATTRIBUTE on (AB_KEYWORD_ATTRIBUTE.CONTAINER = AB_KEYWORD_ENTRY.CONTAINER) \n\ left join AB_KEYWORD_ATTRIBUTERELATION \n\ on (AB_KEYWORD_ATTRIBUTERELATION.AB_KEYWORD_ATTRIBUTE_ID = AB_KEYWORD_ATTRIBUTE.AB_KEYWORD_ATTRIBUTEID\n\ and AB_KEYWORD_ATTRIBUTERELATION.AB_KEYWORD_ENTRY_ID = AB_KEYWORD_ENTRY.AB_KEYWORD_ENTRYID)"); diff --git a/process/Organisation_lib/process.js b/process/Organisation_lib/process.js index 27589bda8a5c0746e093e9fcc99fe8f719010339..5296413175e339fcdf392f7c3f07835fe210fa00 100644 --- a/process/Organisation_lib/process.js +++ b/process/Organisation_lib/process.js @@ -133,7 +133,7 @@ OrgUtils.openOrgReport = function(pOrgId) histData.forEach(function (row) { row[0] = datetime.toDate(row[0], dateFormat); - row[1] = LegacyKeywordUtils.getViewValue($KeywordRegistry.activityCategory(), row[1]); + row[1] = KeywordUtils.getViewValue($KeywordRegistry.activityCategory(), row[1]); _joinArrayVals(row, 2, 2); }); histData = ReportData.begin(["ENTRYDATE", "MEDIUM", "LOGIN", "INFO"]).add(histData);