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

Keyword AttributeType

parent 6683818f
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("system.vars");
import("system.result");
import("Attribute_lib");
var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeContentType();
logging.log("type is " + attrType)
result.string(attrType);
\ No newline at end of file
......@@ -18,8 +18,8 @@
<entityField>
<name>ATTRIBUTE_TYPE</name>
<title>Type</title>
<consumer>KeywordAttributeType</consumer>
<mandatory v="true" />
<possibleItemsProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/possibleItemsProcess.js</possibleItemsProcess>
</entityField>
<entityField>
<name>AB_ATTRIBUTEID</name>
......@@ -73,6 +73,21 @@
<possibleItemsProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_active/possibleItemsProcess.js</possibleItemsProcess>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_active/valueProcess.js</valueProcess>
</entityField>
<entityConsumer>
<name>KeywordAttributeType</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/Attribute_entity/entityfields/keywordattributetype/children/containername_param/code.js</code>
</entityParameter>
</children>
</entityConsumer>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.result");
import("Attribute_lib");
result.object(AttributeTypes.getTypeList());
\ No newline at end of file
import("system.result");
import("Keyword_lib");
result.string($KeywordRegistry.get.AttributeType);
\ No newline at end of file
......@@ -232,6 +232,12 @@
<fieldName>KeywordKeywordAttributeTypes</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>078bbd52-87fa-44cc-9902-04af935b5fbc</name>
<entityName>Attribute_entity</entityName>
<fieldName>KeywordAttributeType</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
......
......@@ -23,4 +23,5 @@
<include relativeToChangelogFile="true" file="ab_keyword_entry/init_TaskStatus.xml"/>
<include relativeToChangelogFile="true" file="ab_keyword_entry/init_TaskType.xml"/>
<include relativeToChangelogFile="true" file="ab_keyword_entry/init_KeywordAttributeType.xml"/>
<include relativeToChangelogFile="true" file="ab_keyword_entry/init_AttributeType.xml"/>
</databaseChangeLog>
<?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="55a6a9df-5852-4bd4-ad72-8c575c0a27f6">
<insert tableName="AB_KEYWORD_ENTRY">
<column name="AB_KEYWORD_ENTRYID" value="972e5eb1-a457-4b75-b966-1183896dac2c"/>
<column name="KEYID" value="TEXT"/>
<column name="TITLE" value="Text"/>
<column name="CONTAINER" value="AttributeType"/>
<column name="SORTING" valueNumeric="0"/>
<column name="ISACTIVE" valueNumeric="1"/>
<column name="ISESSENTIAL" valueNumeric="0"/>
</insert>
<insert tableName="AB_KEYWORD_ENTRY">
<column name="AB_KEYWORD_ENTRYID" value="cb7ecaea-b4e6-460e-9006-4a3d059b9857"/>
<column name="KEYID" value="DATE"/>
<column name="TITLE" value="Date"/>
<column name="CONTAINER" value="AttributeType"/>
<column name="SORTING" valueNumeric="1"/>
<column name="ISACTIVE" valueNumeric="1"/>
<column name="ISESSENTIAL" valueNumeric="0"/>
</insert>
<insert tableName="AB_KEYWORD_ENTRY">
<column name="AB_KEYWORD_ENTRYID" value="14de196a-aaa6-41b9-b503-3df1d45acc1e"/>
<column name="KEYID" value="NUMBER"/>
<column name="TITLE" value="${NUMBER}"/>
<column name="CONTAINER" value="AttributeType"/>
<column name="SORTING" valueNumeric="2"/>
<column name="ISACTIVE" valueNumeric="1"/>
<column name="ISESSENTIAL" valueNumeric="0"/>
</insert>
<insert tableName="AB_KEYWORD_ENTRY">
<column name="AB_KEYWORD_ENTRYID" value="8a9791c1-655f-4340-91b4-cfdf6372fc75"/>
<column name="KEYID" value="BOOLEAN"/>
<column name="TITLE" value="Checkbox"/>
<column name="CONTAINER" value="AttributeType"/>
<column name="SORTING" valueNumeric="3"/>
<column name="ISACTIVE" valueNumeric="1"/>
<column name="ISESSENTIAL" valueNumeric="0"/>
</insert>
<insert tableName="AB_KEYWORD_ENTRY">
<column name="AB_KEYWORD_ENTRYID" value="1390813c-6b94-4336-9986-9bcaddab69ac"/>
<column name="KEYID" value="COMBO"/>
<column name="TITLE" value="Combobox"/>
<column name="CONTAINER" value="AttributeType"/>
<column name="SORTING" valueNumeric="3"/>
<column name="ISACTIVE" valueNumeric="1"/>
<column name="ISESSENTIAL" valueNumeric="0"/>
</insert>
<insert tableName="AB_KEYWORD_ENTRY">
<column name="AB_KEYWORD_ENTRYID" value="2c188a17-2961-45df-bd68-34b55352375c"/>
<column name="KEYID" value="GROUP"/>
<column name="TITLE" value="Group"/>
<column name="CONTAINER" value="AttributeType"/>
<column name="SORTING" valueNumeric="3"/>
<column name="ISACTIVE" valueNumeric="1"/>
<column name="ISESSENTIAL" valueNumeric="0"/>
</insert>
<rollback>
<delete tableName="AB_KEYWORD_ENTRY">
<where>AB_KEYWORD_ENTRYID = ?</where>
<whereParams>
<param value="972e5eb1-a457-4b75-b966-1183896dac2c"/>
</whereParams>
</delete>
<delete tableName="AB_KEYWORD_ENTRY">
<where>AB_KEYWORD_ENTRYID = ?</where>
<whereParams>
<param value="cb7ecaea-b4e6-460e-9006-4a3d059b9857"/>
</whereParams>
</delete>
<delete tableName="AB_KEYWORD_ENTRY">
<where>AB_KEYWORD_ENTRYID = ?</where>
<whereParams>
<param value="14de196a-aaa6-41b9-b503-3df1d45acc1e"/>
</whereParams>
</delete>
<delete tableName="AB_KEYWORD_ENTRY">
<where>AB_KEYWORD_ENTRYID = ?</where>
<whereParams>
<param value="8a9791c1-655f-4340-91b4-cfdf6372fc75"/>
</whereParams>
</delete>
<delete tableName="AB_KEYWORD_ENTRY">
<where>AB_KEYWORD_ENTRYID = ?</where>
<whereParams>
<param value="1390813c-6b94-4336-9986-9bcaddab69ac"/>
</whereParams>
</delete>
<delete tableName="AB_KEYWORD_ENTRY">
<where>AB_KEYWORD_ENTRYID = ?</where>
<whereParams>
<param value="2c188a17-2961-45df-bd68-34b55352375c"/>
</whereParams>
</delete>
</rollback>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -89,7 +89,7 @@ AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the typ
attrTypeSelect = SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", this.attributeId)
.buildSql(attrTypeSelect);
this._attributeType = db.cell(attrTypeSelect);
this._attributeType = db.cell(attrTypeSelect).trim();
}
return this._attributeType;
}
......@@ -127,63 +127,54 @@ AttributeHandler.prototype.setAttributeValue = function (pValue)
* This Object is only for the general definition of attribute types and for getting
* data about every type, anything that has to do with a specific attribute (= the function requires an attribute id)
* should be done in AttributeUtils.
*/
var AttributeTypes = {
_attributeTypeConfig : {},
TEXT : "TEXT",
DATE : "DATE",
NUMBER : "NUMBER",
BOOLEAN : "BOOLEAN",
COMBO : "COMBO",
GROUP : "GROUP"
};
/**
* These objects hold important data for the attribute types.
* The values for each type are:
*
* name = the displayed name when selecting the type of an attribute
* contentType = the value that is returned in the contentType process for the attribute
* databaseField = the database field that holds values of attributes with the type
* entityField = the field in the AttributeRelation enity that holds the value of the attribute for that type
*
* The display name is controlled by the keyword 'AttributeType'
*/
AttributeTypes._attributeTypeConfig[AttributeTypes.TEXT] = { //TODO: it would probably be better if the name was a keyword
name : "Text",
contentType : "TEXT",
databaseField : "CHAR_VALUE",
entityField : "CHAR_VALUE"
};
AttributeTypes._attributeTypeConfig[AttributeTypes.DATE] = {
name : "Date",
contentType : "DATE",
databaseField : "DATE_VALUE",
entityField : "DATE_VALUE"
};
AttributeTypes._attributeTypeConfig[AttributeTypes.NUMBER] = {
name : "${NUMBER}",
contentType : "NUMBER",
databaseField : "NUMBER_VALUE",
entityField : "NUMBER_VALUE"
};
AttributeTypes._attributeTypeConfig[AttributeTypes.BOOLEAN] = {
name : "Checkbox",
contentType : "BOOLEAN",
databaseField : "BOOL_VALUE",
entityField : "BOOL_VALUE"
};
AttributeTypes._attributeTypeConfig[AttributeTypes.COMBO] = {
name : "Combobox",
contentType : "TEXT",
databaseField : "ID_VALUE",
entityField : "ID_VALUE"
};
AttributeTypes._attributeTypeConfig[AttributeTypes.GROUP] = {
name : "Group",
contentType : null,
databaseField : null,
entityField : null
var AttributeTypes = {
TEXT : {
toString : function () {return "TEXT"},
contentType : "TEXT",
databaseField : "CHAR_VALUE",
entityField : "CHAR_VALUE"
},
DATE : {
toString : function () {return "DATE"},
contentType : "DATE",
databaseField : "DATE_VALUE",
entityField : "DATE_VALUE"
},
NUMBER : {
toString : function () {return "NUMBER"},
contentType : "NUMBER",
databaseField : "NUMBER_VALUE",
entityField : "NUMBER_VALUE"
},
BOOLEAN : {
toString : function () {return "BOOLEAN"},
contentType : "BOOLEAN",
databaseField : "BOOL_VALUE",
entityField : "BOOL_VALUE"
},
COMBO : {
toString : function () {return "COMBO"},
contentType : "TEXT",
databaseField : "ID_VALUE",
entityField : "ID_VALUE"
},
GROUP : {
toString : function () {return "GROUP"},
contentType : null,
databaseField : null,
entityField : null
}
};
/**
* returns the required contentType for the given attribute type
*
......@@ -193,8 +184,8 @@ AttributeTypes._attributeTypeConfig[AttributeTypes.GROUP] = {
*/
AttributeTypes.getContentType = function (pAttributeType)
{
if (pAttributeType in AttributeTypes._attributeTypeConfig)
return AttributeTypes._attributeTypeConfig[pAttributeType].contentType;
if (pAttributeType in AttributeTypes)
return AttributeTypes[pAttributeType].contentType;
return null;
}
......@@ -207,8 +198,8 @@ AttributeTypes.getContentType = function (pAttributeType)
*/
AttributeTypes.getEntityField = function (pAttributeType)
{
if (pAttributeType in AttributeTypes._attributeTypeConfig)
return AttributeTypes._attributeTypeConfig[pAttributeType].entityField;
if (pAttributeType in AttributeTypes)
return AttributeTypes[pAttributeType].entityField;
return null;
}
......@@ -221,8 +212,8 @@ AttributeTypes.getEntityField = function (pAttributeType)
*/
AttributeTypes.getDatabaseField = function (pAttributeType)
{
if (pAttributeType in AttributeTypes._attributeTypeConfig)
return AttributeTypes._attributeTypeConfig[pAttributeType].databaseField;
if (pAttributeType in AttributeTypes)
return AttributeTypes[pAttributeType].databaseField;
return null;
}
......@@ -235,25 +226,7 @@ AttributeTypes.getDatabaseField = function (pAttributeType)
*/
AttributeTypes.getName = function (pAttributeType)
{
if (pAttributeType in AttributeTypes._attributeTypeConfig)
return translate.text(AttributeTypes._attributeTypeConfig[pAttributeType].name);
if (pAttributeType in AttributeTypes)
return translate.text(AttributeTypes[pAttributeType].displayName);
return null;
}
/**
* Makes a two-dimensional array of the attribute types and the corresponding names.
* This is used for the selection of the type when creating an attribute.
*
* @return {String[][]} array with attribute types and names
*/
AttributeTypes.getTypeList = function ()
{
return [
[AttributeTypes.TEXT, AttributeTypes.getName(AttributeTypes.TEXT)],
[AttributeTypes.COMBO, AttributeTypes.getName(AttributeTypes.COMBO)],
[AttributeTypes.NUMBER, AttributeTypes.getName(AttributeTypes.NUMBER)],
[AttributeTypes.DATE, AttributeTypes.getName(AttributeTypes.DATE)],
[AttributeTypes.BOOLEAN, AttributeTypes.getName(AttributeTypes.BOOLEAN)],
[AttributeTypes.GROUP, AttributeTypes.getName(AttributeTypes.GROUP)]
];
}
......@@ -23,6 +23,7 @@ function $KeywordRegistry(){}
//static property
$KeywordRegistry.get = {
AttributeType: "AttributeType",
KeywordAttributeType: "KeywordAttributeType",
ContractPayment: "ContractPayment",
ContractStatus: "ContractStatus",
......
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