diff --git a/entity/Activity_entity/entityfields/icon/valueProcess.js b/entity/Activity_entity/entityfields/icon/valueProcess.js index 6cb990d62b05f123426dfa2e60d2b377aa4afa62..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"); -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/Activity_entity/entityfields/subject_details/valueProcess.js b/entity/Activity_entity/entityfields/subject_details/valueProcess.js index 7cecd3b427054a5a7558dcc24adaf976c33bc034..c30d6b2520c493830ac572123194912dd8ef0d1b 100644 --- a/entity/Activity_entity/entityfields/subject_details/valueProcess.js +++ b/entity/Activity_entity/entityfields/subject_details/valueProcess.js @@ -1,6 +1,7 @@ import("system.vars"); import("system.result"); import("Keyword_lib"); +import("KeywordRegistry_basic"); var histMedium = vars.get("$field.CATEGORY"); -result.string(vars.get("$field.SUBJECT") + (histMedium ? " (" + LegacyKeywordUtils.getViewValue("ACTIVITY.CATEGORY", histMedium) + ")" : "")); +result.string(vars.get("$field.SUBJECT") + (histMedium ? " (" + KeywordUtils.getViewValue($KeywordRegistry.activityCategory(), histMedium) + ")" : "")); 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/Communication_entity/entityfields/medium_id/valueMappingProcess.js b/entity/Communication_entity/entityfields/medium_id/valueMappingProcess.js deleted file mode 100644 index a567223ae010bfe6382ee6e14fa7449fc4e1d670..0000000000000000000000000000000000000000 --- a/entity/Communication_entity/entityfields/medium_id/valueMappingProcess.js +++ /dev/null @@ -1,7 +0,0 @@ -import("system.result"); -import("Keyword_lib"); - -var kwdUtils, items; - -items = LegacyKeywordUtils.getStandardArray("COMMUNICATION.MEDIUM"); -result.object(items); \ No newline at end of file diff --git a/entity/Salesproject_entity/entityfields/image/valueProcess.js b/entity/Salesproject_entity/entityfields/image/valueProcess.js index 90f0619c9f05b2c4862a7b0c93e15648467ac16f..c04626b8e075d07b742f63f4810cde51d710516e 100644 --- a/entity/Salesproject_entity/entityfields/image/valueProcess.js +++ b/entity/Salesproject_entity/entityfields/image/valueProcess.js @@ -1,5 +1,6 @@ import("system.vars"); import("system.result"); import("Keyword_lib"); +import("KeywordRegistry_basic"); -result.string("TEXT:" + LegacyKeywordUtils.getViewValue("SALESPROJECT.STATE", vars.getString("$field.STATE")) ); \ No newline at end of file +result.string("TEXT:" + KeywordUtils.getViewValue($KeywordRegistry.salesprojectState(), vars.getString("$field.STATE")) ); \ No newline at end of file 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/KeywordRegistry_basic/process.js b/process/KeywordRegistry_basic/process.js index ce5e562a291f0b76d4c96c392579d53cd38bbbf0..6d8a44d2954a8733e03de4ad59b7da5bf78d3929 100644 --- a/process/KeywordRegistry_basic/process.js +++ b/process/KeywordRegistry_basic/process.js @@ -23,7 +23,10 @@ $KeywordRegistry.contractPayment = function(){return "ContractPayment"}; $KeywordRegistry.contractStatus = function(){return "ContractStatus"}; $KeywordRegistry.contractType = function(){return "ContractType"}; $KeywordRegistry.activityDirection = function(){return "ActivityDirection"}; + $KeywordRegistry.contactStatus = function(){return "ContactStatus"}; +$KeywordRegistry.contactStatus$active = function(){return "BSIC0rel-stat-actv-ae03-b6b04430e90b"}; + $KeywordRegistry.currency = function(){return "Currency"}; $KeywordRegistry.productGroupcode = function(){return "ProductGroupcode"}; $KeywordRegistry.offerStatus = function(){return "OfferStatus"}; @@ -31,7 +34,10 @@ $KeywordRegistry.organisationType = function(){return "OrganisationType"}; $KeywordRegistry.personGender = function(){return "PersonGender"}; $KeywordRegistry.taskStatus = function(){return "TaskStatus"}; $KeywordRegistry.taskType = function(){return "TaskType"}; + $KeywordRegistry.productPricelist = function(){return "ProductPricelist"}; +$KeywordRegistry.productPricelist$standardList = function(){return "02553fc7-4611-4914-8ff5-0b7c4e7531c9"}; + $KeywordRegistry.quantityUnit = function(){return "QuantityUnit"}; $KeywordRegistry.salesprojectMemberRole = function(){return "SalesprojectMemberRole"}; $KeywordRegistry.salesprojectSource = function(){return "SalesprojectSource"}; 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/Offer_lib/process.js b/process/Offer_lib/process.js index fac87a5a41c758ad886812fb8ad124640a534e9d..6cf2ac0f1641836470f3adc8b34c6306761ba91d 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -138,7 +138,7 @@ OfferUtils.openOfferReport = function(pOfferID) var rptdata = db.table(offerCondition.buildSql("select " + fields.join(", ") + offerFromSql, "1 = 0")); //TODO: use new keyword logic for language when possible - var language = "DE"; // LegacyKeywordUtils.get("LANGUAGE", rptdata[0][2])[1]; + var language = "DE"; var relid = rptdata[0][1]; // TODO: AddrObject implementieren diff --git a/process/Organisation_lib/process.js b/process/Organisation_lib/process.js index 4eb2065194eef9d9bdbc4db00a7faf6561db38cb..b54d93d93e6d247add42a7e46bd52461788935bf 100644 --- a/process/Organisation_lib/process.js +++ b/process/Organisation_lib/process.js @@ -76,7 +76,7 @@ OrgUtils.openOrgReport = function(pOrgId) //resolve keyword commData.forEach(function (row) { - row[0] = LegacyKeywordUtils.getViewValue("COMMUNICATION.MEDIUM", row[0]); + row[0] = KeywordUtils.getViewValue($KeywordRegistry.communicationMedium(), row[0]); }); commData = ReportData.begin(["KINDOFCOMM", "COMMVALUE"]).add(commData); @@ -86,7 +86,7 @@ OrgUtils.openOrgReport = function(pOrgId) + " from PERSON join CONTACT on PERSONID = PERSON_ID"; persSql = SqlCondition.begin() .andPrepare("CONTACT.ORGANISATION_ID", pOrgId) - .and("CONTACT.STATUS = 'BSIC0rel-stat-actv-ae03-b6b04430e90b'") //TODO: replace this with something that isn't a hard coded id + .and("CONTACT.STATUS = '" + $KeywordRegistry.contactStatus$active() + "'") //TODO: replace this with something that isn't a hard coded id .buildSql(persSql, "", " order by PERSON.LASTNAME asc"); var persData = db.table(persSql); @@ -114,7 +114,7 @@ OrgUtils.openOrgReport = function(pOrgId) //resolve keyword persData[i][3] = persDataComm.map(function (row) { - return LegacyKeywordUtils.getViewValue("COMMUNICATION.MEDIUM", row[0]) + ": " + row[1]; + return KeywordUtils.getViewValue($KeywordRegistry.communicationMedium(), row[0]) + ": " + row[1]; } ).join("\n"); } @@ -133,7 +133,7 @@ OrgUtils.openOrgReport = function(pOrgId) histData.forEach(function (row) { row[0] = datetime.toDate(row[0], dateFormat); - row[1] = LegacyKeywordUtils.getViewValue("ACTIVITY.CATEGORY", row[1]); + row[1] = KeywordUtils.getViewValue($KeywordRegistry.activityCategory(), row[1]); _joinArrayVals(row, 2, 2); }); histData = ReportData.begin(["ENTRYDATE", "MEDIUM", "LOGIN", "INFO"]).add(histData); diff --git a/process/PostalAddress_lib/process.js b/process/PostalAddress_lib/process.js index 8d31f07afec4252a16224dd689792654c647187c..c18e69398a84f6f99591b495c4d5622167679884 100644 --- a/process/PostalAddress_lib/process.js +++ b/process/PostalAddress_lib/process.js @@ -1,3 +1,4 @@ +import("KeywordRegistry_basic"); import("system.db"); import("Sql_lib"); import("Contact_lib"); @@ -137,7 +138,7 @@ AddressUtils.getAllPossibleAddresses = function(pRelationId) { .buildSql("select ADDRESSID, ADDR_TYPE, ADDRIDENTIFIER from ADDRESS join CONTACT on CONTACTID = CONTACT_ID or CONTACT_ID = ORGANISATION_ID", "1=0")); return addresses.map(function(pAddress) { - return [pAddress[0], LegacyKeywordUtils.get("ADDRESS.TYPE", pAddress[1])[1] + " " + pAddress[2]] + return [pAddress[0], KeywordUtils.getViewValue($KeywordRegistry.addressType(), pAddress[1]) + ": " + pAddress[2]]; }); } diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 217d65e53246c9cedf00aac7915c2791c2da7d36..33c29bed91e7e06274fb6acb36c78b445aa03ca3 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -4,6 +4,7 @@ import("system.datetime"); import("system.db"); import("system.vars"); import("system.translate"); +import("KeywordRegistry_basic"); import("Util_lib"); import("Binary_lib"); import("Sql_lib"); @@ -44,7 +45,7 @@ ProductUtils.getCurrentProductPrice = function(pid, buySell) { var productPriceData = db.array(db.ROW, actualPriceCondition.buildSql("select PRICE, CURRENCY from PRODUCTPRICE", "1 = 2", "order by VALID_FROM desc")); if (productPriceData[0] && productPriceData[1]) - return productPriceData[0] + " " + LegacyKeywordUtils.get("CURRENCY", productPriceData[1])[1]; + return productPriceData[0] + " " + KeywordUtils.getViewValue($KeywordRegistry.currency(), productPriceData[1]); else return ""; } else { @@ -272,7 +273,7 @@ ProductUtils.getProductDetails = function(pid, priceListFilter, additionalProduc return priceLists[list]; } //default price list - if (priceLists[list].priceList == "1") { + if (priceLists[list].priceList == $KeywordRegistry.productPricelist$standardList()) { return priceLists[list]; } } diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index 05a07d2c9a1c9baeecaab65bd05a1e93044257bf..98e631dea84403ba8da2969a74db4a5247d1a0d3 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -1208,7 +1208,7 @@ SqlUtils.getResolvingCaseWhen = function(pKeyValueArray, pDbFieldName, pLocale) { var keyData = pKeyValueArray; if (keyData.length == 0) - return ["''"]; + return ["''", []]; //a helper function for easy translation var translateValue = function(value){