Skip to content
Snippets Groups Projects
Commit 16cc7008 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

salesproject: Classifications

parent acf0d6e9
No related branches found
No related tags found
No related merge requests found
Showing
with 236 additions and 62 deletions
......@@ -2,14 +2,19 @@
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.5" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.5">
<name>SalesprojectClassificationEntry_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<grantCreate v="false" />
<grantDelete v="false" />
<recordContainerType>JDITO</recordContainerType>
<titleProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/titleProcess.js</titleProcess>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<fields>
<element>UID</element>
<element>TYPE</element>
<element>NAME</element>
<element>VALUE</element>
</fields>
<contentProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/contentProcess.js</contentProcess>
<onUpdate>%aditoprj%/entity/SalesprojectClassificationEntry_entity/onUpdate.js</onUpdate>
<entityFields>
<entityIncomingField>
<name>#INCOMING</name>
......@@ -17,6 +22,8 @@
<entityIncomingField>
<name>SalesprojectClassificatonEntry_dfi</name>
<fieldType>DEPENDENCY_IN</fieldType>
<title>kkkkkkkkkkkkkkk</title>
<titleProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/entityfields/salesprojectclassificatonentry_dfi/titleProcess.js</titleProcess>
<dependencies>
<entityDependency>
<name>a7414022-56d3-4ca0-b15f-33601b655d78</name>
......@@ -30,25 +37,37 @@
<name>SalesprojectId_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<mandatory v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>ClassId_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<mandatory v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityField>
<name>UID</name>
<title>Uid</title>
<fieldName>UID</fieldName>
</entityField>
<entityField>
<name>NAME</name>
<title>Name</title>
<fieldName>NAME</fieldName>
</entityField>
<entityField>
<name>VALUE</name>
<title>Value</title>
<fieldName>VALUE</fieldName>
<possibleItemsProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/entityfields/value/possibleItemsProcess.js</possibleItemsProcess>
</entityField>
<entityField>
<name>TYPE</name>
<title>Type</title>
<fieldName>TYPE</fieldName>
<state>INVISIBLE</state>
</entityField>
</entityFields>
</entity>
......@@ -4,49 +4,103 @@ import("system.db");
import("Keyword_lib");
import("Sql_lib");
var allOldTypesCondition, allOldTypes, typesCondition, classId, salesprojectId, entryKeywords;
var allOldTypesCondition, allOldTypes, classificationsCondition, classifications, classId, salesprojectId, entryKeywords;
classifications = [];
if (vars.exists("$param.ClassId_param") && vars.exists("$param.SalesprojectId_param")) {
classId = vars.getString("$param.ClassId_param");
salesprojectId = vars.getString("$param.SalesprojectId_param");
entryKeywords = KeywordUtils.get("SALESPROJECT.CLASS", classId)[2].keywords;
if (entryKeywords && classId && salesprojectId) {
// correct db if kewords changed
allOldTypesCondition = new SqlCondition();
allOldTypesCondition.andPrepare("SALESPROJECT_CLASSIFICATION.SALESPROJECT_ID", salesprojectId)
.andPrepare("SALESPROJECT_CLASSIFICATION.CLASS", classId);
entryKeywords.forEach(function(entry) {
allOldTypesCondition.andPrepare("SALESPROJECT_CLASSIFICATION.TYPE", entry, "# <> ?")
});
allOldTypes = db.array(db.COLUMN, allOldTypesCondition.buildSelect("select TYPE from SALESPROJECT_CLASSIFICATION", "1 = 0", "group by TYPE"));
if (allOldTypes.length > 0) {
// TODO maybe ask user????!!!!!
db.deleteData("SALESPROJECT_CLASSIFICATION", allOldTypesCondition.build("1 = 0"))
}
//typesCondition =
/*
<column name="CLASS" type="CHAR(1)"/>
<column name="TYPE" type="VARCHAR(50)"/>
<column name="VALUE" type="INTEGER"/>*/
}
if (classId && salesprojectId) {
/*
entries = [];
entryKeywords.forEach(function(entryKeyword) {
entry = kwUtils.getStandardArray(entryKeyword)
entries.push([entry[0], entry[1]])
});*/
entryKeywords = KeywordUtils.get("SALESPROJECT.CLASS", classId)[2].keywords;
}
if (entryKeywords && classId && salesprojectId) {
// correct db if kewords changed
allOldTypesCondition = _getClassificationCondition(false);
allOldTypes = db.array(db.COLUMN, allOldTypesCondition.buildSelect("select TYPE from SALESPROJECT_CLASSIFICATION", "1 = 0", "group by TYPE"));
if (allOldTypes.length > 0) {
// TODO maybe ask user????!!!!!
db.deleteData("SALESPROJECT_CLASSIFICATION", allOldTypesCondition.build("1 = 0"))
}
// load classifications for the class
classificationsCondition = _getClassificationCondition(true);
classifications = db.table(classificationsCondition.buildSelect("select SALESPROJECT_CLASSIFICATIONID, TYPE, VALUE from SALESPROJECT_CLASSIFICATION", "1 = 0"));
logging.log(entryKeywords.toSource())
classifications = entryKeywords.map(function(entryKeyword) {
for (i = 0; i < classifications.length; i++) {
if (classifications[i][1] == entryKeyword[0]) {
return [classifications[i][0], entryKeyword[0], entryKeyword[1], classifications[i][2]]
}
}
// if not found create new:
var values = [
util.getNewUUID(),
salesprojectId,
classId,
entryKeyword[0],
"1",
vars.get("$sys.user"),
vars.get("$sys.date")
];
db.insertData(
"SALESPROJECT_CLASSIFICATION",
[
"SALESPROJECT_CLASSIFICATIONID",
"SALESPROJECT_ID",
"CLASS",
"TYPE",
"VALUE",
"USER_NEW",
"DATE_NEW"
],
null,
values
);
return [values[0], values[3], values[3] , values[4]]
});
/*
classifications = classifications.map(function(entry) {
let entryKeyword = KeywordUtils.get(entry[1], entry[2]);
return [entry[0], entry[1], entryKeyword[1] , entry[2]]
});
*/
}
}
}
logging.log(classifications.toSource())
result.object(classifications);
/**
* creates a SqlCondition() to get the classification items
*
* @param include if true the condition includes all types of the class else it excludes them and selects all other types
* @return the condition object
*/
function _getClassificationCondition(include) {
var resultingCondition = new SqlCondition();
resultingCondition.andPrepare("SALESPROJECT_CLASSIFICATION.SALESPROJECT_ID", salesprojectId)
.andPrepare("SALESPROJECT_CLASSIFICATION.CLASS", classId);
var typeCondition = new SqlCondition();
result.object([]);
\ No newline at end of file
entryKeywords.forEach(function(entry) {
if (include) {
typeCondition.orPrepare("SALESPROJECT_CLASSIFICATION.TYPE", entry[0], "# = ?");
} else {
typeCondition.andPrepare("SALESPROJECT_CLASSIFICATION.TYPE", entry[0], "# <> ?");
}
});
resultingCondition.andSqlCondition(typeCondition, "1 = 0");
return resultingCondition;
}
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.NAME") + "123")
\ No newline at end of file
import("system.result");
import("system.logging");
import("system.vars");
import("Keyword_lib");
logging.log(vars.get("$field.TYPE"))
var type = vars.get("$field.TYPE");
if (type) {
result.object(KeywordUtils.getStandardArray(type));
}
\ No newline at end of file
import("system.db");
import("system.vars");
import("system.logging");
import("Sql_lib");
logging.log(vars.get("$local.changed").toSource())
var condition = new SqlCondition();
condition.andPrepare("SALESPROJECT_CLASSIFICATION.SALESPROJECT_CLASSIFICATIONID", vars.getString("$field.UID"));
var values = [
vars.getString("$field.VALUE"),
vars.get("$sys.user"),
vars.get("$sys.date")
];
db.updateData(
"SALESPROJECT_CLASSIFICATION",
[
"VALUE",
"USER_EDIT",
"DATE_EDIT"
],
null,
values,
condition.build("1 = 0")
);
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.NAME"))
\ No newline at end of file
......@@ -31,10 +31,12 @@
<entityParameter>
<name>ClassId_param</name>
<code>%aditoprj%/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/classid_param/code.js</code>
<triggerRecalculation v="true" />
</entityParameter>
<entityParameter>
<name>SalesprojectId_param</name>
<code>%aditoprj%/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/salesprojectid_param/code.js</code>
<triggerRecalculation v="true" />
</entityParameter>
</children>
</entityOutgoingField>
......
import("system.result");
import("system.logging");
import("system.vars");
import("Keyword_lib");
result.object(KeywordUtils.getStandardArray("SALESPROJECT.CLASS"));
var keyword = KeywordUtils.createKeyword("SALESPROJECT.CLASS");
//TODO correct db if kewords changed
\ No newline at end of file
if (vars.exists("$local.idvalues")) {
var idValues = vars.get("$local.idvalues");
if (idValues.length > 0) {
keyword.filter(function(id) {
return id == idValues[0];
});
}
}
result.object(keyword.toArray(["id", "name"]));
//TODO correct db if kewords changed
import("system.result");
import("system.vars");
import("system.logging");
logging.log("Parameter 1 gesetzt")
result.string(vars.getString("$field.UID"));
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.logging");
logging.log("Parameter 2 gesetzt")
result.string(vars.getString("$param.SalesprojectId_param"));
\ No newline at end of file
//f
\ No newline at end of file
import("system.vars")
import("system.logging")
logging.log(vars.get("$local.changed").toSource())
\ No newline at end of file
import("system.db");
import("system.result");
import("system.vars");
import("system.logging");
import("Sql_lib");
var cond = new SqlCondition();
logging.log(vars.get("$param.SalesprojectId_param"))
cond.andPrepareVars("SALESPROJECT_CYCLE.SALESPROJECT_ID", "$param.SalesprojectId_param");
//TODO: use a preparedCondition when available
......
import("system.result");
import("system.vars");
import("system.logging");
import("Keyword_lib");
var items = KeywordUtils.getStandardArray("SALESPROJECT.CYCLE.TYPE");
logging.log(items.toSource())
result.object(items);
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.logging");
import("Keyword_lib");
var items, keyword, type;
......@@ -8,7 +7,6 @@ var items, keyword, type;
items = [];
type = vars.getString("$field.TYPE");
logging.log(type.toSource())
// load the possible values based on the type.
if (type) {
......
import("system.result");
import("Keyword_lib");
var items;
items = KeywordUtils.getStandardArray("SALESPROJECT.PHASE");
result.object(items);
\ No newline at end of file
result.object(KeywordUtils.getStandardArray("SALESPROJECT.PHASE"));
\ No newline at end of file
import("system.vars");
import("system.logging");
import("Salesproject_lib");
var typeValue, fieldVar
......
......@@ -2,6 +2,9 @@
<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.0.0">
<name>SalesprojectClassificationEntry_context</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<mainview>SalesprojectClassificationEntryPreview_view</mainview>
<filterview>SalesprojectClassificationEntryPreview_view</filterview>
<editview>SalesprojectClassificationEntryEdit_view</editview>
<preview>SalesprojectClassificationEntryPreview_view</preview>
<entity>SalesprojectClassificationEntry_entity</entity>
<references>
......@@ -9,5 +12,9 @@
<name>7cddda68-3dcb-4daf-84a4-1546298cabb6</name>
<view>SalesprojectClassificationEntryPreview_view</view>
</neonViewReference>
<neonViewReference>
<name>80205380-7785-43a3-af7b-73ef8112ca38</name>
<view>SalesprojectClassificationEntryEdit_view</view>
</neonViewReference>
</references>
</neonContext>
<?xml version="1.0" encoding="UTF-8"?>
<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0">
<name>SalesprojectClassificationEntryEdit_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<boxLayout>
<name>layout</name>
</boxLayout>
</layout>
<children>
<genericViewTemplate>
<name>SalesprojectClassificationEntryData_template</name>
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>003f3304-b8fb-4009-ba55-b56d005191e3</name>
<entityField>NAME</entityField>
</entityFieldLink>
<entityFieldLink>
<name>90630f8e-8e32-4743-9b79-a1faa6e26414</name>
<entityField>VALUE</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
<?xml version="1.0" encoding="UTF-8"?>
<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0">
<name>SalesprojectClassificationEntryPreview_view</name>
<title>asdf</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<boxLayout>
......@@ -8,23 +9,23 @@
</boxLayout>
</layout>
<children>
<tableViewTemplate>
<titledListViewTemplate>
<name>SalesprojectClassificationEntryData_template</name>
<entityField>#ENTITY</entityField>
<columns>
<neonTableColumn>
<name>2de7d794-3c72-42a1-ab5b-1eaf7608b0f3</name>
<entityField>UID</entityField>
<name>91aa4685-98f7-40e9-87be-877583a91143</name>
<entityField>NAME</entityField>
</neonTableColumn>
<neonTableColumn>
<name>e4ae9891-2db2-427e-9f28-0d07ad4dcc4c</name>
<entityField>NAME</entityField>
<name>88105c9a-fdf8-4d2b-ac96-d57ef4f41aa4</name>
<entityField>TYPE</entityField>
</neonTableColumn>
<neonTableColumn>
<name>7a61d1ed-3359-4c74-b598-f09b69cc6f75</name>
<name>b862235e-6595-4ae0-8bd0-5f942d975c67</name>
<entityField>VALUE</entityField>
</neonTableColumn>
</columns>
</tableViewTemplate>
</titledListViewTemplate>
</children>
</neonView>
......@@ -8,8 +8,26 @@
</boxLayout>
</layout>
<children>
<genericViewTemplate>
<name>rfff</name>
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>51712a19-9a8c-4967-bd15-a448b5bffb77</name>
<entityField>CLASSNAME</entityField>
</entityFieldLink>
<entityFieldLink>
<name>48312725-e22d-4c13-ab92-7be9f7d477e7</name>
<entityField>UID</entityField>
</entityFieldLink>
<entityFieldLink>
<name>5f9a5d73-67e1-4dcd-b31d-70fe908fb74d</name>
<entityField>SalesprojectId_param</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<neonViewReference>
<name>ee9b0c38-f2f9-4e5e-9ab8-2c4658ffca83</name>
<name>c6c26fdd-3812-495f-bd30-d3a6cdcd4eb0</name>
<entityField>SalesprojectClassificationEntry_dfo</entityField>
<view>SalesprojectClassificationEntryPreview_view</view>
</neonViewReference>
......
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