diff --git a/entity/AttributeRelation_entity/AttributeRelation_entity.aod b/entity/AttributeRelation_entity/AttributeRelation_entity.aod index 3578214cbac67af0c73eefba164dd0f65b00e198..a9171ba77ef57604e0dd9a688b7d0fc9a84fb55e 100644 --- a/entity/AttributeRelation_entity/AttributeRelation_entity.aod +++ b/entity/AttributeRelation_entity/AttributeRelation_entity.aod @@ -34,6 +34,7 @@ <title>Value</title> <contentTypeProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/contentTypeProcess.js</contentTypeProcess> <resolution>DAY</resolution> + <possibleItemsProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js</possibleItemsProcess> <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js</valueProcess> <onValueChange>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js</onValueChange> </entityField> diff --git a/entity/AttributeRelation_entity/entityfields/attribute_parent_id/possibleItemsProcess.js b/entity/AttributeRelation_entity/entityfields/attribute_parent_id/possibleItemsProcess.js index 2449074c9672b85ce7ddec1e78cfce6710a1e7fb..4a159dc81d7a388e26c6fe81aeb554be0707f34b 100644 --- a/entity/AttributeRelation_entity/entityfields/attribute_parent_id/possibleItemsProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attribute_parent_id/possibleItemsProcess.js @@ -2,4 +2,4 @@ import("system.vars"); import("system.result"); import("Attribute_lib"); -result.object(AttributeUtil.getPossibleAttributes(vars.get("$param.objectType_param"))); +result.object(AttributeUtil.getPossibleAttributes(vars.get("$param.objectType_param"), true)); diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5a3b4bd6a75ffa18fb6043c3d8ea606ad36542f4 --- /dev/null +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js @@ -0,0 +1,19 @@ +import("system.db"); +import("system.result"); +import("system.vars"); +import("Attribute_lib"); +import("Sql_lib"); + +var attributeId = vars.get("$field.AB_ATTRIBUTE_ID"); +var attrType = AttributeHandler.begin(attributeId).getAttributeType(); + +if (attrType == AttributeTypes.COMBO) +{ + var valueSql = SqlCondition.begin() + .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId) + .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", AttributeTypes.COMBOVALUE) + .buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE"); + var valueList = db.table(valueSql); + + result.object(valueList); +} \ No newline at end of file diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js index 334477e1aa56d1d19d6d61d6dcd1df3036a602b5..6edf4b6ff88e72f63624b72cb19b02195494171c 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js @@ -2,25 +2,25 @@ import("system.result"); import("system.vars"); import("Attribute_lib"); -var attrField = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField(); +var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType(); -if (attrField != null) //load the value from the correct field for the type +if (attrType != null) //load the value from the correct field for the type { - switch (attrField) + switch (attrType) { - case "CHAR_VALUE": + case AttributeTypes.TEXT: result.string(vars.get("$field.CHAR_VALUE")); break; - case "DATE_VALUE": + case AttributeTypes.DATE: result.string(vars.get("$field.DATE_VALUE")); break; - case "NUMBER_VALUE": + case AttributeTypes.NUMBER: result.string(vars.get("$field.NUMBER_VALUE")); break; - case "BOOL_VALUE": + case AttributeTypes.BOOLEAN: result.string(vars.get("$field.BOOL_VALUE")); break; - case "ID_VALUE": + case AttributeTypes.COMBO: result.string(vars.get("$field.ID_VALUE")); break; } diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index 6a7b1297888bd82a331f6c1d6f8417112012f9ba..33e1964169271873ff953454f59e825ef6e957be 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -5,6 +5,7 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/Attribute_entity/documentation.adoc</documentation> <iconId>VAADIN:TAG</iconId> + <titleProcess>%aditoprj%/entity/Attribute_entity/titleProcess.js</titleProcess> <recordContainer>db</recordContainer> <entityFields> <entityProvider> @@ -22,6 +23,8 @@ <title>Type</title> <consumer>KeywordAttributeType</consumer> <mandatory v="true" /> + <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>AB_ATTRIBUTEID</name> @@ -53,12 +56,6 @@ <triggerRecalculation v="true" /> <mandatory v="false" /> </entityParameter> - <entityParameter> - <name>attributeLevel_param</name> - <code>%aditoprj%/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js</code> - <triggerRecalculation v="true" /> - <mandatory v="false" /> - </entityParameter> </children> </entityConsumer> <entityProvider> @@ -124,11 +121,6 @@ </entityParameter> </children> </entityConsumer> - <entityParameter> - <name>attributeLevel_param</name> - <expose v="true" /> - <description>PARAMETER</description> - </entityParameter> <entityField> <name>ATTRIBUTE_LEVEL</name> <title>Level</title> diff --git a/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js index 5098441456e49ebb7530ad34d47f27c41b925849..1c37c30f461e97c9b5efb040f290f762fefc2166 100644 --- a/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js @@ -1,10 +1,16 @@ +import("system.db"); import("system.neon"); import("system.result"); import("system.vars"); +import("Sql_lib"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) - if (vars.exists("$param.attributeLevel_param") && vars.get("$param.attributeLevel_param") - && vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) - result.string(parseInt(vars.get("$param.attributeLevel_param")) + 1); + if (vars.get("$field.ATTRIBUTE_PARENT_ID") != "") + { + var level = db.cell(SqlCondition.begin() + .andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", vars.get("$field.ATTRIBUTE_PARENT_ID")) + .buildSql("select ATTRIBUTE_LEVEL from AB_ATTRIBUTE")); + result.string(parseInt(level) + 1); + } else result.string("0"); diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js index 24c340a034a026f42e40928fa7713e86dac60cb8..c220255e0cc463df414f28ab79f209beb4e10ce6 100644 --- a/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js @@ -1,9 +1,5 @@ -import("system.neon"); import("system.result"); import("system.vars"); import("Attribute_lib"); -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) - result.string(AttributeUtil.getAttributeNameById(vars.get("$param.attrParentId_param"))); -else - result.string(AttributeUtil.getAttributeNameById(vars.get("$field.ATTRIBUTE_PARENT_ID"))) \ No newline at end of file +result.string(AttributeUtil.getAttributeNameById(vars.get("$field.ATTRIBUTE_PARENT_ID"))) \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..22960d0b70d45a32a197347dfcd7ef7fa6b134ee --- /dev/null +++ b/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js @@ -0,0 +1,13 @@ +import("system.db"); +import("system.neon"); +import("system.result"); +import("system.vars"); +import("Attribute_lib"); +import("Keyword_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") +{ + var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType(); + if (type == AttributeTypes.COMBO) + result.string(KeywordUtils.getViewValue($KeywordRegistry.get.AttributeType, AttributeTypes.COMBOVALUE)); +} \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..6dff8bf600174bb8a066354a96df0a0124013f8d --- /dev/null +++ b/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js @@ -0,0 +1,12 @@ +import("system.db"); +import("system.neon"); +import("system.result"); +import("system.vars"); +import("Attribute_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") +{ + var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType(); + if (type == AttributeTypes.COMBO) + result.string(AttributeTypes.COMBOVALUE); +} \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js b/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js deleted file mode 100644 index 5790e0cc445659af95e472d70969cf8ac3d0394a..0000000000000000000000000000000000000000 --- a/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.vars"); -import("system.result"); - -result.string(vars.getString("$field.ATTRIBUTE_LEVEL")); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js b/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js index 58f3a0fedf29dab04eb8575c9e82442d575b39fe..11e081d0178e93143dbf826dcdfa676c05b9f8e2 100644 --- a/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js +++ b/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js @@ -2,7 +2,8 @@ import("system.vars"); import("system.result"); import("Attribute_lib"); -if (vars.getString("$field.ATTRIBUTE_TYPE").trim() == AttributeTypes.GROUP) +var type = vars.getString("$field.ATTRIBUTE_TYPE").trim(); +if (type == AttributeTypes.GROUP || type == AttributeTypes.COMBO) result.string(vars.getString("$field.AB_ATTRIBUTEID")); else result.string(""); diff --git a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js index 8b53a13f9cfd7a1ff4f7e4cee0eba93aa551fb4e..f43b26a529d56a95d77dfc31ac8ad36af5d346e0 100644 --- a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js @@ -2,8 +2,9 @@ import("system.db"); import("system.vars"); import("system.result"); import("Sql_lib"); +import("Attribute_lib"); -var condition = "1=2"; +var condition = "AB_ATTRIBUTE.ATTRIBUTE_TYPE = '" + AttributeTypes.GROUP + "'"; if (vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) condition = "AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + getAllChildren(vars.getString("$param.attrParentId_param")).join("','") + "')"; diff --git a/entity/Attribute_entity/titleProcess.js b/entity/Attribute_entity/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..09b4ecb2cceec0f6d09f3b1bd72c2fe60aba970d --- /dev/null +++ b/entity/Attribute_entity/titleProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.ATTRIBUTE_NAME")); \ No newline at end of file diff --git a/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod b/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod index 75bd616a56f2377853f08fbf281d5d29a85ea125..fbcf895c91a45e539a0b4aa4cb9d56875a007d49 100644 --- a/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod +++ b/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod @@ -27,7 +27,9 @@ </tableViewTemplate> <treetableViewTemplate> <name>Tree</name> - <titleField>ATTRIBUTERELATION_VALUE</titleField> + <parentField>ATTRIBUTE_PARENT_ID</parentField> + <titleField>AB_ATTRIBUTE_ID</titleField> + <descriptionField>ATTRIBUTERELATION_VALUE</descriptionField> <entityField>#ENTITY</entityField> </treetableViewTemplate> </children> diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index e756e95ca39b8289d7bca081c1b3a9b760d07d2d..dac5966054c8d01f41d4db7d903935db62c57cc6 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -18,23 +18,25 @@ function AttributeUtil () {} * process for the attribute id in AttributeRelation * * @param {String} pObjectType the object type (= context) + * @param {boolean} pIncludeGroups * * @return {String[][]} two-dimensional array of attributeIds and names */ -AttributeUtil.getPossibleAttributes = function (pObjectType) +AttributeUtil.getPossibleAttributes = function (pObjectType, pIncludeGroups) { if (pObjectType == null) return []; var attrSql = "select AB_ATTRIBUTEID from AB_ATTRIBUTE" + " join AB_ATTRIBUTEUSAGE on AB_ATTRIBUTEID = AB_ATTRIBUTE_ID"; - attrSql = SqlCondition.begin() + attrCond = SqlCondition.begin() .andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType) - .and("ATTRIBUTE_TYPE != '" + AttributeTypes.GROUP + "'") - .and("ATTRIBUTE_ACTIVE = 1") - .buildSql(attrSql); + .and("ATTRIBUTE_ACTIVE = 1"); + + if (!pIncludeGroups) + attrCond.and("ATTRIBUTE_TYPE != '" + AttributeTypes.GROUP + "'"); - var attributes = db.array(db.COLUMN, attrSql).map(function (id) + var attributes = db.array(db.COLUMN, attrCond.buildSql(attrSql)).map(function (id) { return [id, AttributeUtil.getAttributeNameById(id)]; }); @@ -115,7 +117,7 @@ AttributeHandler.begin = function (pAttrId) * * @return {String} attribute type */ -AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the type should be an own field in the entity instead of getting the type from the attribute id +AttributeHandler.prototype.getAttributeType = function () //TODO: maybe the type should be an own field in the entity instead of getting the type from the attribute id { if (this._attributeType == null && this.attributeId != null) { @@ -135,7 +137,7 @@ AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the typ */ AttributeHandler.prototype.getAttributeField = function () { - return AttributeTypes.getEntityField(this._getAttributeType()); + return AttributeTypes.getEntityField(this.getAttributeType()); } /** @@ -145,7 +147,7 @@ AttributeHandler.prototype.getAttributeField = function () */ AttributeHandler.prototype.getAttributeContentType = function () { - return AttributeTypes.getContentType(this._getAttributeType()); + return AttributeTypes.getContentType(this.getAttributeType()); } AttributeHandler.prototype.setAttributeValue = function (pValue) @@ -200,6 +202,12 @@ var AttributeTypes = { databaseField : "ID_VALUE", entityField : "ID_VALUE" }, + COMBOVALUE : { + toString : function () {return "COMBOVALUE"}, + contentType : null, + databaseField : null, + entityField : null + }, GROUP : { toString : function () {return "GROUP"}, contentType : null,