From 1119c41551a3ba165396ffaf18f8000ca44e9d59 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Mon, 4 Mar 2019 16:05:39 +0100 Subject: [PATCH] AttributeType Keyword added --- aliasDefinition/Data_alias/Data_alias.aod | 14 ++++++++++ .../AttributeRelation_entity.aod | 16 +++++++++++ .../displayValueProcess.js | 21 ++++++++++++-- .../possibleItemsProcess.js | 19 +++++++++++++ .../attributerelation_value/valueProcess.js | 11 +++++--- .../children/containername_param/code.js | 9 ++++++ entity/Attribute_entity/Attribute_entity.aod | 17 +++++++++++ .../keyword_container/possibleItemsProcess.js | 8 ++++++ .../keyword_container/stateProcess.js | 12 ++++++++ .../entityfields/test/onActionProcess.js | 3 ++ .../AttributeEdit_view/AttributeEdit_view.aod | 4 +++ .../2019.2/AditoBasic/init_AttributeType.xml | 22 +++++++++++++++ .../basic/2019.2/AttributeKeyword.xml | 8 ++++++ .../data_alias/basic/2019.2/changelog.xml | 2 ++ process/Attribute_lib/process.js | 28 +++++++++++++------ 15 files changed, 178 insertions(+), 16 deletions(-) create mode 100644 entity/AttributeRelation_entity/entityfields/keyword/children/containername_param/code.js create mode 100644 entity/Attribute_entity/entityfields/keyword_container/possibleItemsProcess.js create mode 100644 entity/Attribute_entity/entityfields/keyword_container/stateProcess.js create mode 100644 entity/Attribute_entity/entityfields/test/onActionProcess.js create mode 100644 others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml create mode 100644 others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index f92410dc6e4..ec71532e913 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -3983,6 +3983,20 @@ <title></title> <description></description> </entityFieldDb> + <entityFieldDb> + <name>KEYWORD_CONTAINER</name> + <dbName></dbName> + <primaryKey v="false" /> + <columnType v="12" /> + <size v="80" /> + <scale v="0" /> + <notNull v="false" /> + <isUnique v="false" /> + <index v="false" /> + <documentation></documentation> + <title></title> + <description></description> + </entityFieldDb> </entityFields> </entityDb> <entityDb> diff --git a/entity/AttributeRelation_entity/AttributeRelation_entity.aod b/entity/AttributeRelation_entity/AttributeRelation_entity.aod index a73ca00b9c3..141186a6077 100644 --- a/entity/AttributeRelation_entity/AttributeRelation_entity.aod +++ b/entity/AttributeRelation_entity/AttributeRelation_entity.aod @@ -118,6 +118,22 @@ <element>PROCESS</element> </onValueChangeTypes> </entityField> + <entityConsumer> + <name>Keyword</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>KeywordEntry_entity</entityName> + <fieldName>SpecificContainerKeywords</fieldName> + </dependency> + <children> + <entityParameter> + <name>containerName_param</name> + <code>%aditoprj%/entity/AttributeRelation_entity/entityfields/keyword/children/containername_param/code.js</code> + <triggerRecalculation v="true" /> + </entityParameter> + </children> + </entityConsumer> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js index a740c792ce4..722aed0f3fa 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js @@ -2,10 +2,25 @@ import("system.db"); import("system.result"); import("system.vars"); import("Attribute_lib"); +import("Keyword_lib"); var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType(); - +var value; if (attrType == $AttributeTypes.COMBO) - result.string(AttributeUtil.getSimpleAttributeName(vars.get("$field.ID_VALUE"))); + value = AttributeUtil.getSimpleAttributeName(vars.get("$field.ID_VALUE")); + +//TODO this is a workaround for keywords, when it's possible to use the consumer remove this else if +else if (attrType == $AttributeTypes.KEYWORD) +{ + var keywordContainer = db.cell( + SqlCondition.begin() + .andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$field.AB_ATTRIBUTE_ID") + .buildSql("select KEYWORD_CONTAINER from AB_ATTRIBUTE") + ); + value = KeywordUtils.getViewValue(keywordContainer, vars.get("$field.ID_VALUE")); +} + else - result.string(vars.get("$field.ATTRIBUTERELATION_VALUE")); + value = vars.get("$field.ATTRIBUTERELATION_VALUE"); + +result.string(value); diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js index 41294703389..60c66562b77 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js @@ -1,3 +1,4 @@ +import("system.translate"); import("system.db"); import("system.result"); import("system.vars"); @@ -16,3 +17,21 @@ if (attrType == $AttributeTypes.COMBO) var valueList = db.table(valueSql); result.object(valueList); } + +//TODO this is a workaround for keywords, when it's possible to use the consumer remove this +else if (attrType == $AttributeTypes.KEYWORD) +{ + var attrKeywordSelect = "select KEYWORD_CONTAINER from AB_ATTRIBUTE"; + attrKeywordSelect = SqlCondition.begin() + .andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$field.AB_ATTRIBUTE_ID") + .buildSql(attrKeywordSelect); + + var sql = SqlCondition.begin() + .andPrepare("AB_KEYWORD_ENTRY.CONTAINER", db.cell(attrKeywordSelect)) + .buildSql("select AB_KEYWORD_ENTRY.KEYID, AB_KEYWORD_ENTRY.TITLE from AB_KEYWORD_ENTRY"); + var keywords = db.table(sql).map(function (row) + { + return [row[0], translate.text(row[1])]; + }); + result.object(keywords); +} diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js index 835bccd1aba..02b623bee27 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js @@ -2,12 +2,10 @@ import("system.neon"); import("system.result"); import("system.vars"); import("Attribute_lib"); -import("system.logging"); -logging.log("recordstate: " + vars.get("$sys.recordstate")); if(vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) { - var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType(); + var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField(); var value = null; if (attrType != null) //load the value from the correct field for the type { @@ -26,11 +24,16 @@ if(vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) value = vars.get("$field.BOOL_VALUE"); break; case $AttributeTypes.COMBO.toString(): + case $AttributeTypes.KEYWORD.toString(): value = vars.get("$field.ID_VALUE"); break; } - } + //var attrField = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField(); + //var value = null; + //if (attrField != null) //load the value from the correct field for the type + // value = vars.get("$field." + attrField); + if(value != null && value != "") result.string(value); } diff --git a/entity/AttributeRelation_entity/entityfields/keyword/children/containername_param/code.js b/entity/AttributeRelation_entity/entityfields/keyword/children/containername_param/code.js new file mode 100644 index 00000000000..b1de1317f0c --- /dev/null +++ b/entity/AttributeRelation_entity/entityfields/keyword/children/containername_param/code.js @@ -0,0 +1,9 @@ +import("system.db"); +import("system.result"); +import("Sql_lib") + +var attrKeywordSelect = "select KEYWORD_CONTAINER from AB_ATTRIBUTE"; +attrKeywordSelect = SqlCondition.begin() + .andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$field.AB_ATTRIBUTE_ID") + .buildSql(attrKeywordSelect); +result.string(db.cell(attrKeywordSelect)); \ No newline at end of file diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index 19200a77d9f..6126cfac10b 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -128,6 +128,19 @@ <state>INVISIBLE</state> <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js</valueProcess> </entityField> + <entityActionField> + <name>test</name> + <fieldType>ACTION</fieldType> + <title>test</title> + <onActionProcess>%aditoprj%/entity/Attribute_entity/entityfields/test/onActionProcess.js</onActionProcess> + </entityActionField> + <entityField> + <name>KEYWORD_CONTAINER</name> + <title>Keyword</title> + <possibleItemsProcess>%aditoprj%/entity/Attribute_entity/entityfields/keyword_container/possibleItemsProcess.js</possibleItemsProcess> + <state>AUTO</state> + <stateProcess>%aditoprj%/entity/Attribute_entity/entityfields/keyword_container/stateProcess.js</stateProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -174,6 +187,10 @@ <name>ATTRIBUTE_LEVEL.value</name> <recordfield>AB_ATTRIBUTE.ATTRIBUTE_LEVEL</recordfield> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>KEYWORD_CONTAINER.value</name> + <recordfield>AB_ATTRIBUTE.KEYWORD_CONTAINER</recordfield> + </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> </recordContainers> diff --git a/entity/Attribute_entity/entityfields/keyword_container/possibleItemsProcess.js b/entity/Attribute_entity/entityfields/keyword_container/possibleItemsProcess.js new file mode 100644 index 00000000000..57ceecb4fb3 --- /dev/null +++ b/entity/Attribute_entity/entityfields/keyword_container/possibleItemsProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("Keyword_lib"); + +var res = KeywordUtils.getContainerNames().map(function (e) +{ + return [e, e];//currently the first column is ID, second view value - which is the same because there is no ID for keyword-containers +}); +result.object(res); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/keyword_container/stateProcess.js b/entity/Attribute_entity/entityfields/keyword_container/stateProcess.js new file mode 100644 index 00000000000..42c609201e6 --- /dev/null +++ b/entity/Attribute_entity/entityfields/keyword_container/stateProcess.js @@ -0,0 +1,12 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); +import("Attribute_lib"); + +var fieldState; +if (vars.get("$field.ATTRIBUTE_TYPE") == $AttributeTypes.KEYWORD) + fieldState = neon.COMPONENTSTATE_AUTO; +else + fieldState = neon.COMPONENTSTATE_INVISIBLE; + +result.string(neon.COMPONENTSTATE_AUTO);//result.string(fieldState); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/test/onActionProcess.js b/entity/Attribute_entity/entityfields/test/onActionProcess.js new file mode 100644 index 00000000000..2fcdd32dea2 --- /dev/null +++ b/entity/Attribute_entity/entityfields/test/onActionProcess.js @@ -0,0 +1,3 @@ +import("system.logging"); +import("Attribute_lib"); +logging.log(AttributeRelationUtils.getSqlUtil().toSource()); \ No newline at end of file diff --git a/neonView/AttributeEdit_view/AttributeEdit_view.aod b/neonView/AttributeEdit_view/AttributeEdit_view.aod index bae017aaf8b..510c41d637b 100644 --- a/neonView/AttributeEdit_view/AttributeEdit_view.aod +++ b/neonView/AttributeEdit_view/AttributeEdit_view.aod @@ -25,6 +25,10 @@ <name>8cbc6049-2530-4960-b45f-830f3220889e</name> <entityField>ATTRIBUTE_TYPE</entityField> </entityFieldLink> + <entityFieldLink> + <name>529f9734-182e-46f3-ad89-14dc5656f307</name> + <entityField>KEYWORD_CONTAINER</entityField> + </entityFieldLink> <entityFieldLink> <name>d26696ac-199c-45f0-9147-b75dee3f4b65</name> <entityField>ATTRIBUTE_ACTIVE</entityField> diff --git a/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml b/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml new file mode 100644 index 00000000000..b3d3d1c074c --- /dev/null +++ b/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml @@ -0,0 +1,22 @@ +<?xml version="1.1" encoding="UTF-8" standalone="no"?> +<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> + <changeSet author="s.listl" id="14dc77c2-067f-4b45-a6ad-f2f973091d64"> + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="9d2f9605-1a5e-47d3-8920-168f5637e37f"/> + <column name="KEYID" value="KEYWORD"/> + <column name="TITLE" value="Keyword"/> + <column name="CONTAINER" value="AttributeType"/> + <column name="SORTING" valueNumeric="7"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="1"/> + </insert> + <rollback> + <delete tableName="AB_KEYWORD_ENTRY"> + <where>AB_KEYWORD_ENTRYID = ?</where> + <whereParams> + <param value="9d2f9605-1a5e-47d3-8920-168f5637e37f"/> + </whereParams> + </delete> + </rollback> + </changeSet> +</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml b/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml new file mode 100644 index 00000000000..4fe1d78f5b9 --- /dev/null +++ b/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml @@ -0,0 +1,8 @@ +<?xml version="1.1" encoding="UTF-8" standalone="no"?> +<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> + <changeSet author="s.listl" id="f527a5cc-f1e5-497f-a069-33aee944d421"> + <addColumn tableName="AB_ATTRIBUTE"> + <column name="KEYWORD_CONTAINER" type="VARCHAR(80)"/> + </addColumn> + </changeSet> +</databaseChangeLog> \ No newline at end of file diff --git a/others/db_changes/data_alias/basic/2019.2/changelog.xml b/others/db_changes/data_alias/basic/2019.2/changelog.xml index 80b5f1a6c1b..fdf1e21a755 100644 --- a/others/db_changes/data_alias/basic/2019.2/changelog.xml +++ b/others/db_changes/data_alias/basic/2019.2/changelog.xml @@ -72,5 +72,7 @@ <include relativeToChangelogFile="true" file="AditoBasic/init_SalesProjectPhase.xml"/> <include relativeToChangelogFile="true" file="AditoBasic/init_TaskPriority.xml"/> <include relativeToChangelogFile="true" file="AditoBasic/init_SalesprojectCompetitionState.xml"/> + <include relativeToChangelogFile="true" file="AditoBasic/init_AttributeType.xml"/> <include relativeToChangelogFile="true" file="SalesProjectCompetitionPhase.xml"/> + <include relativeToChangelogFile="true" file="AttributeKeyword.xml"/> </databaseChangeLog> diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 755d9c19051..b961c693309 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -172,22 +172,25 @@ AttributeRelationUtils.setAttribute = function () */ AttributeRelationUtils.getSqlUtil = function () { - var types = Object.keys($AttributeTypes); var sqlMap = { columns : [], typeColMap : {} }; - types.forEach(function (type) + for (let type in $AttributeTypes) { - var typeKey = type.toString(); - var colIndex = this.columns.indexOf(type.databaseField); - if (colIndex == -1) + type = $AttributeTypes[type]; + if (type.databaseField) { - colIndex = this.columns.length; - this.columns.push(type.databaseField); + var typeKey = type.toString(); + var colIndex = sqlMap.columns.indexOf(type.databaseField); + if (colIndex == -1) + { + colIndex = sqlMap.columns.length; + sqlMap.columns.push(type.databaseField); + } + sqlMap.typeColMap[typeKey] = colIndex; } - this.typeColMap[typeKey] = colIndex; - }, sqlMap); + } sqlMap.sqlSelect = "select ATTRIBUTE_TYPE, " + sqlMap.columns.join(", ") + " from AB_ATTRIBUTERELATION " + " join AB_ATTRIBUTE on AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID "; @@ -345,6 +348,13 @@ $AttributeTypes.GROUP = { databaseField : null, entityField : null }; +$AttributeTypes.KEYWORD = { + toString : function () {return this.keyword}, + keyword : "KEYWORD", + contentType : "UNKNOWN", + databaseField : "ID_VALUE", + entityField : "ID_VALUE" +}; /** -- GitLab