Skip to content
Snippets Groups Projects
Commit 1119c415 authored by S.Listl's avatar S.Listl
Browse files

AttributeType Keyword added

parent 99142fc9
No related branches found
No related tags found
No related merge requests found
Showing
with 178 additions and 16 deletions
......@@ -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>
......
......@@ -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>
......
......@@ -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);
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);
}
......@@ -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);
}
......
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
......@@ -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>
......
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
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
import("system.logging");
import("Attribute_lib");
logging.log(AttributeRelationUtils.getSqlUtil().toSource());
\ No newline at end of file
......@@ -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>
......
<?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
<?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
......@@ -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>
......@@ -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"
};
/**
......
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