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

fix merge

parent 46b22bff
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.2.0">
<name>Context_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<titleProcess>%aditoprj%/entity/Context_entity/titleProcess.js</titleProcess>
<recordContainer>jdito</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
<name>40037d07-01a3-474a-aaf6-875aaf250bbf</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Context_dfo</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>7b7e6760-5f1f-47d5-a164-72c9e16b9e20</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Contexts</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityField>
<name>UID</name>
<title>Context id</title>
</entityField>
<entityField>
<name>CONTEXT_NAME</name>
<title>Context name</title>
</entityField>
<entityParameter>
<name>ContextId_param</name>
<expose v="true" />
<mandatory v="false" />
<description>PARAMETER</description>
</entityParameter>
<entityProvider>
<name>Context</name>
<fieldType>DEPENDENCY_IN</fieldType>
<children>
<entityParameter>
<name>ContextId_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
</children>
</entityProvider>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/Context_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<recordFields>
<element>UID.value</element>
<element>UID.displayValue</element>
<element>CONTEXT_NAME.value</element>
</recordFields>
</jDitoRecordContainer>
</recordContainers>
</entity>
import("system.vars");
import("system.result");
import("system.project");
import("system.logging");
import("Context_lib");
if (vars.exists("$param.ContextId_param") && vars.get("$param.ContextId_param"))
{
result.object(_contextDataMapping(project.getDataModel(project.DATAMODEL_KIND_CONTEXT, vars.get("$param.ContextId_param"))));
}
else
{
result.object(project.getDataModels(project.DATAMODEL_KIND_CONTEXT).map(_contextDataMapping).sort(function(pContext1, pContext2) {
if (pContext1[2] > pContext2[2])
return 1;
if (pContext1[2] < pContext2[2])
return -1;
return 0;
}));
}
function _contextDataMapping(pContext)
{
var contextName = ContextUtils.getContextName(pContext[0]);
return [pContext[0], contextName, (pContext[1] ? pContext[1] : contextName)];
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
<entityField>
<name>OBJECT1_TYPE</name>
<title>Type 1</title>
<consumer>Context_dfo</consumer>
<consumer>Contexts</consumer>
<stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js</stateProcess>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js</displayValueProcess>
......@@ -33,7 +33,7 @@
<entityField>
<name>OBJECT2_TYPE</name>
<title>Type 2</title>
<consumer>Context_dfo</consumer>
<consumer>Contexts</consumer>
<linkedContext>Context_context</linkedContext>
<stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js</stateProcess>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js</valueProcess>
......@@ -237,7 +237,7 @@
</children>
</entityProvider>
<entityConsumer>
<name>Context_dfo</name>
<name>Contexts</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
......
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.2.0">
<name>Object_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<recordContainer>jdito</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<recordContainer>jdito</recordContainer>
<children>
<entityParameter>
<name>ObjectRowId_param</name>
<expose v="false" />
</entityParameter>
</children>
</entityProvider>
<entityField>
<name>UID</name>
</entityField>
<entityField>
<name>TITLE</name>
</entityField>
<entityParameter>
<name>ObjectType_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>ObjectRowId_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityProvider>
<name>OneObject</name>
<fieldType>DEPENDENCY_IN</fieldType>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
<name>a85ea94b-20dc-42f2-9fd6-412995ea7f03</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Object1</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>47b7bc71-753e-41c5-8d17-296c5ae707ba</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Object2</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
<name>ObjectRowId_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityParameter>
<name>ObjectType_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
</children>
</entityProvider>
<entityProvider>
<name>AllObjects</name>
<fieldType>DEPENDENCY_IN</fieldType>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
<name>9810264a-4e53-4775-98eb-7025668c0021</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Objects1</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>f7b2a5c1-f108-43b9-afa4-5fe6a67bed4c</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Objects2</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
<name>ObjectRowId_param</name>
<expose v="false" />
<mandatory v="false" />
</entityParameter>
<entityParameter>
<name>ObjectType_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
</children>
</entityProvider>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/Object_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<recordFields>
<element>UID.value</element>
<element>TITLE.value</element>
</recordFields>
</jDitoRecordContainer>
</recordContainers>
</entity>
import("system.result");
import("Context_lib");
// TODO: no subselect?
result.string(ContextUtils.getNameSubselectSql("OBJECT2_TYPE", "OBJECT2_ROWID"))
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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>Context_context</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<lookupview>ContextLookup_view</lookupview>
<entity>Context_entity</entity>
<references>
<neonViewReference>
<name>ddec38ae-82e6-4ac7-a50e-8a735eb9a075</name>
<view>ContextFilter_view</view>
</neonViewReference>
<neonViewReference>
<name>f9fed52b-de56-49a0-89cd-84d1a9e82536</name>
<view>ContextLookup_view</view>
</neonViewReference>
<neonViewReference>
<name>86650dd4-9569-433e-b3e5-fb9d62a7e45d</name>
<view>ContextLookup_vieww</view>
</neonViewReference>
</references>
</neonContext>
<?xml version="1.0" encoding="UTF-8"?>
<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>Object_context</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<entity>Object_entity</entity>
</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.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.1">
<name>ContextLookup_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<boxLayout>
<name>layout</name>
</boxLayout>
</layout>
<children>
<tableViewTemplate>
<name>contexts</name>
<entityField>#ENTITY</entityField>
<columns>
<neonTableColumn>
<name>e3178147-3010-48e2-b23c-022e1badc3f7</name>
<entityField>CONTEXT_NAME</entityField>
</neonTableColumn>
</columns>
</tableViewTemplate>
</children>
</neonView>
import("system.logging");
import("system.project");
import("system.SQLTYPES");
import("system.vars");
import("Sql_lib");
......@@ -12,26 +14,17 @@ function ContextUtils() {}
/**
* Get the id of the current context
* TODO: We need a function to either get the current contextname or BETTER: a function to get a UUID of the current context which doesn't change
* TODO: use a UUID of the current context which doesn't change
*
* @return {String} Id of the current context
*/
ContextUtils.getCurrentContextId = function()
{
var entityName = vars.getString("$sys.currententityname");
// TODO: replace with Core-method instead of switch-case!!!
switch (entityName)
{
// if an Entity doesn't have a fitting context, add a case.
default:
// TODO: workaround: remove "entity" and add "context". This is a Workaround and has to be changed (see above todo)!
return entityName.substr(0, entityName.length-6) + "context";
}
return vars.getString("$sys.currentcontextname");
}
/**
* TODO: use System function
* TODO: use System function. Currently the Name is also the id.
* Returns the Name of a context by the Id
*
* @param {String} pContextId the id of a context
......@@ -43,23 +36,71 @@ ContextUtils.getContextName = function(pContextId)
return pContextId;
}
/**
* Get all contexts of the project.
*
* @return {String[][]} [ ["contextid", "contextName" ], [..., ...], ...]
*/
ContextUtils.getContexts = function()
{
// TODO: The name is currently also the id. This may change.
return project.getDataModelNames(project.DATAMODEL_KIND_CONTEXT).map(function(contextName) {
return [contextName, ContextUtils.getContextName(contextName)];
});
}
/**
* TODO: !!!temporary function until you can get fields from another Entity!!!
*/
ContextUtils._getSelectMap = function()
{
var maskingUtils = new SqlMaskingUtils();
return {
// contextId nameField Tablename, IDField
"Org_context": ["\"NAME\"", "ORG", "ORGID"],
"Pers_context": [maskingUtils.concat(["FIRSTNAME", "LASTNAME"]), "PERS", "PERSID"],
"Activity_context": ["SUBJECT", "ACTIVITY", "ACTIVITYID"],
"Salesproject_context": [maskingUtils.concat([maskingUtils.cast("PROJECTCODE", SQLTYPES.VARCHAR, 10), "':'", "PROJECTTITLE"]), "SALESPROJECT", "SALESPROJECTID"],
// TODO: keywords sind noch nicht in der DB somit gibt es nichts ähnliches zu getKeySQL.
// maskingUtils.concat([SqlMaskingUtils.cast("CONTRACTCODE", "varchar", 10), getKeySQL("CONTRACTTYPE", "CONTRACTTYPE" )])
"Contract_context": [maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10), "CONTRACT", "CONTRACTID"]
}
}
/**
* TODO: !!!temporary function until you can get fields from another Entity!!!
*/
ContextUtils.getNameSubselectSql = function(pContextIdDbField, pRowIdDbField)
{
var select = "(case " + pContextIdDbField + " ";
var maskingUtils = new SqlMaskingUtils();
select += "when 'Organisation_context' then (select \"NAME\" from ORG where ORG.ORGID = " + pRowIdDbField + ") ";
select += "when 'Contact_context' then (select " + maskingUtils.concat(["FIRSTNAME", "LASTNAME"]) + " from PERS where PERS.PERSID = " + pRowIdDbField + ") ";
select += "when 'Activity_context' then (select SUBJECT from ACTIVITY where ACTIVITY.ACTIVITYID = " + pRowIdDbField + ") ";
select += "when 'Salesproject_context' then (select " + maskingUtils.concat([maskingUtils.cast("PROJECTCODE", SQLTYPES.VARCHAR, 10), "':'", "PROJECTTITLE"]) + " from SALESPROJECT where SALESPROJECT.SALESPROJECTID = " + pRowIdDbField + ") ";
// TODO: keywords sind noch nicht in der DB somit gibt es nichts ähnliches zu getKeySQL.
//select += "when 'Contract_context' then (select " + maskingUtils.concat([SqlMaskingUtils.cast("CONTRACTCODE", "varchar", 10), getKeySQL("CONTRACTTYPE", "CONTRACTTYPE" )]) + " from CONTRACT where CONTRACT.CONTRACTID = " + pRowIdDbField + ") ";
select += "when 'Contract_context' then (select " + maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10) + " from CONTRACT where CONTRACT.CONTRACTID = " + pRowIdDbField + ") ";
var selectMap = ContextUtils._getSelectMap()
for (let contextId in selectMap)
{
select += "when '" + contextId + "' then (select " + selectMap[contextId][0] + " from " + selectMap[contextId][1] + " where " + selectMap[contextId][2] + " = " + pRowIdDbField + ") ";
}
select += "else 'Not defined in ContextUtils.getNameSql()!'";
select += "end)";
return select;
}
/**
* TODO: !!!temporary function until you can get fields from another Entity!!!
*/
ContextUtils.getNameSql = function(pContextId, pRowId)
{
var selectMap = ContextUtils._getSelectMap()
return SqlCondition.begin().andPrepare(selectMap[pContextId][1] + "." + selectMap[pContextId][2], pRowId).buildSql("select " + selectMap[contextId][0] + " from " + selectMap[contextId][1], "1=2");
}
/**
* TODO: Evtl ein anderer Weg ohne hard gecodedeten Selects.
*/
ContextUtils.getContextDataSql = function(pContextId, pRowId)
{
var selectMap = ContextUtils._getSelectMap()
return SqlCondition.begin().andPrepare(selectMap[pContextId][1] + "." + selectMap[pContextId][2], pRowId).buildSql("select " + selectMap[contextId][2] + ", " + selectMap[contextId][0] + " from " + selectMap[contextId][1], "1=1");
}
\ No newline at end of file
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