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

Object relation fixes & administration

parent a7422443
No related branches found
No related tags found
No related merge requests found
Showing
with 339 additions and 48 deletions
......@@ -33,6 +33,7 @@
<node name="KeywordEntry" kind="10077" />
<node name="KeywordAttribute" kind="10077" />
<node name="Employee" kind="10077" />
<node name="ObjectRelationType" kind="10077" />
<node name="INTERNAL_ADMINISTRATOR" kind="159" />
</node>
</node>
......
......@@ -41,6 +41,14 @@
<entityProvider>
<name>Context</name>
<fieldType>DEPENDENCY_IN</fieldType>
<dependencies>
<entityDependency>
<name>dab09827-2eeb-403d-a070-ba805d2640ee</name>
<entityName>ObjectRelationType_entity</entityName>
<fieldName>Contexts</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
<name>excludeContexts_param</name>
......
......@@ -2,6 +2,7 @@
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.1">
<name>ObjectRelationType_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<icon>VAADIN:SPLIT</icon>
<titleProcess>%aditoprj%/entity/ObjectRelationType_entity/titleProcess.js</titleProcess>
<recordContainer>jdito</recordContainer>
<entityFields>
......@@ -21,7 +22,10 @@
<valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/uid/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>RELATION_TITLE</name>
<name>SOURCE_RELATION_TITLE</name>
<title>Relation type 1</title>
<mandatory v="true" />
<displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/source_relation_title/displayValueProcess.js</displayValueProcess>
</entityField>
<entityParameter>
<name>SourceObjectType_param</name>
......@@ -46,17 +50,100 @@
<expose v="true" />
<triggerRecalculation v="true" />
</entityParameter>
<entityParameter>
<name>OnlyFirstSide_param</name>
<valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/objectrelationtypes/children/onlyfirstside_param/valueProcess.js</valueProcess>
<expose v="false" />
</entityParameter>
</children>
</entityProvider>
<entityParameter>
<name>OnlyFirstSide_param</name>
<valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/onlyfirstside_param/valueProcess.js</valueProcess>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityField>
<name>RELATION_TYPE</name>
</entityField>
<entityField>
<name>DIRECTION</name>
</entityField>
<entityField>
<name>HIERARCHY</name>
<title>Hierarchy</title>
<contentType>BOOLEAN</contentType>
<possibleItemsProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/hierarchy/possibleItemsProcess.js</possibleItemsProcess>
<valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/hierarchy/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>DEST_OBJECT_TYPE</name>
<title>Context 2</title>
<consumer>Contexts</consumer>
<displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_object_type/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>SOURCE_OBJECT_TYPE</name>
<title>Context 1</title>
<consumer>Contexts</consumer>
<mandatory v="true" />
<displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/source_object_type/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>AB_OBJECTRELATIONTYPE1</name>
</entityField>
<entityField>
<name>AB_OBJECTRELATIONTYPE2</name>
</entityField>
<entityField>
<name>SIDE</name>
</entityField>
<entityField>
<name>DEST_OBJECTRELATIONTYPEID</name>
</entityField>
<entityField>
<name>DEST_RELATION_TITLE</name>
<title>Relation type 2</title>
<displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_relation_title/displayValueProcess.js</displayValueProcess>
</entityField>
<entityConsumer>
<name>Contexts</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>Context_entity</entityName>
<fieldName>Context</fieldName>
</dependency>
</entityConsumer>
<entityActionField>
<name>removeUsage</name>
<fieldType>ACTION</fieldType>
<title>Delete all usage</title>
<onActionProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/removeusage/onActionProcess.js</onActionProcess>
<iconId>NEON:TRASH</iconId>
</entityActionField>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<onInsert>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/onInsert.js</onInsert>
<onUpdate>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
<onDelete>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/onDelete.js</onDelete>
<recordFields>
<element>UID.value</element>
<element>RELATION_TITLE.value</element>
<element>SOURCE_RELATION_TITLE.value</element>
<element>RELATION_TYPE.value</element>
<element>DIRECTION.value</element>
<element>HIERARCHY.value</element>
<element>DEST_OBJECT_TYPE.value</element>
<element>SOURCE_OBJECT_TYPE.value</element>
<element>AB_OBJECTRELATIONTYPE1.value</element>
<element>AB_OBJECTRELATIONTYPE2.value</element>
<element>SIDE.value</element>
<element>DEST_OBJECTRELATIONTYPEID.value</element>
<element>DEST_RELATION_TITLE.value</element>
</recordFields>
</jDitoRecordContainer>
</recordContainers>
......
import("Context_lib");
import("system.result");
import("system.neon");
import("system.vars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.DEST_OBJECT_TYPE")) {
result.string("");
} else if (vars.exists("$field.DEST_OBJECT_TYPE") && vars.get("$field.DEST_OBJECT_TYPE")) {
result.string(ContextUtils.getContext(vars.get("$field.DEST_OBJECT_TYPE"))[2]);
}
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.translate");
result.string(translate.text(vars.get("$field.DEST_RELATION_TITLE")));
\ No newline at end of file
import("system.translate");
import("system.result");
result.object([
["1", translate.text("Yes")]
,["0", translate.text("No")]
]);
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
result.string("0")
}
\ No newline at end of file
import("system.result");
result.string("0")
\ No newline at end of file
import("system.result");
result.string("1");
\ No newline at end of file
import("system.translate");
import("system.question");
import("system.vars");
import("system.db");
import("Sql_lib");
if (vars.get("$field.UID") && vars.get("$field.DEST_OBJECTRELATIONTYPEID"))
{
db.deleteData("AB_OBJECTRELATION", SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID")
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID").build("1=2"));
question.showMessage(translate.withArguments("Deleted all usages of \"%0\".", [translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))]), question.INFORMATION, translate.text("Successful"))
}
import("Context_lib");
import("system.result");
import("system.neon");
import("system.vars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.SOURCE_OBJECT_TYPE")) {
result.string("");
} else if (vars.exists("$field.SOURCE_OBJECT_TYPE") && vars.get("$field.SOURCE_OBJECT_TYPE")) {
result.string(ContextUtils.getContext(vars.get("$field.SOURCE_OBJECT_TYPE"))[2]);
}
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.translate");
result.string(translate.text(vars.get("$field.SOURCE_RELATION_TITLE")));
\ No newline at end of file
import("system.logging");
import("system.result");
import("system.vars");
import("ObjectRelation_lib");
result.object(ObjectRelationUtils.getPossibleRelationTypes(vars.get("$param.SourceObjectType_param")));
\ No newline at end of file
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
{
result.object([ObjectRelationUtils.getRelationType(vars.get("$local.idvalues")[0])]);
}
else
{
result.object(ObjectRelationUtils.getPossibleRelationTypes(vars.get("$param.SourceObjectType_param"), true, vars.get("$param.OnlyFirstSide_param") == "1"));
}
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.db");
import("system.translate");
import("system.question");
import("Sql_lib");
var usageCount = db.cell(SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID")
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID")
.buildSql("select count(*) from AB_OBJECTRELATION", "1=2"))
if (usageCount <= 0)
{
db.deleteData("AB_OBJECTRELATIONTYPE", SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATIONTYPE.RELATION_TYPE", "$field.RELATION_TYPE")
.build("1=2"));
}
else
{
// TODO: server hängt bei question.showMessage
//question.showMessage(translate.withArguments("There are still %0 relations using the type %1.", [usageCount, translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))]), question.WARNING, translate.text("Cannot remove relation type"))
}
\ No newline at end of file
import("system.util");
import("ObjectRelation_lib");
import("system.vars");
import("system.db");
import("system.util");
var newRelationType = util.getNewUUID();
db.insertData("AB_OBJECTRELATIONTYPE", [
"AB_OBJECTRELATIONTYPEID",
"OBJECT_TYPE",
"RELATION_TITLE",
"RELATION_TYPE",
"SIDE",
"HIERARCHY"
], null, [
util.getNewUUID(),
vars.get("$field.SOURCE_OBJECT_TYPE"),
vars.get("$field.SOURCE_RELATION_TITLE"),
newRelationType,
1,
vars.get("$field.HIERARCHY")
]);
if ((vars.get("$field.SOURCE_RELATION_TITLE") != vars.get("$field.DEST_RELATION_TITLE") || vars.get("$field.SOURCE_OBJECT_TYPE") != vars.get("$field.DEST_OBJECT_TYPE"))
&& vars.get("$field.DEST_OBJECT_TYPE") && vars.get("$field.DEST_RELATION_TITLE"))
{
db.insertData("AB_OBJECTRELATIONTYPE", [
"AB_OBJECTRELATIONTYPEID",
"OBJECT_TYPE",
"RELATION_TITLE",
"RELATION_TYPE",
"SIDE",
"HIERARCHY"
], null, [
util.getNewUUID(),
vars.get("$field.DEST_OBJECT_TYPE"),
vars.get("$field.DEST_RELATION_TITLE"),
newRelationType,
2,
vars.get("$field.HIERARCHY")
]);
}
\ No newline at end of file
import("system.util");
import("Sql_lib");
import("system.db");
import("system.vars");
var usageCount = db.cell(SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID")
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID")
.buildSql("select count(*) from AB_OBJECTRELATION", "1=2"))
if (usageCount <= 0)
{
var type1Fields = {};
var type2Fields = {};
vars.get("local.changed").forEach(function(pChange)
{
var fieldName = pChange.split(".")[0];
switch (pChange.split("_")[0])
{
case "SOURCE":
type1Fields[fieldName.replace("SOURCE_", "")] = vars.get("$field." + fieldName);
break;
case "DEST":
type2Fields[fieldName.replace("DEST_", "")] = vars.get("$field." + fieldName);
break;
default:
type1Fields[fieldName] = vars.get("$field." + fieldName);
type2Fields[fieldName] = vars.get("$field." + fieldName);
}
});
var updates = [];
var type1Cond = SqlCondition.begin().andPrepareVars("AB_OBJECTRELATIONTYPE.AB_OBJECTRELATIONTYPEID", "$field.UID").build("1=2");
var type2Cond = SqlCondition.begin().andPrepareVars("AB_OBJECTRELATIONTYPE.AB_OBJECTRELATIONTYPEID", "$field.DEST_OBJECTRELATIONTYPEID").build("1=2");
for (let field in type1Fields) {
updates.push(["AB_OBJECTRELATIONTYPE", [field], null, [type1Fields[field]], type1Cond]);
}
// delete, if type2 is empty -> convert it to a "same"-type
if ((vars.get("$field.SOURCE_RELATION_TITLE") == vars.get("$field.DEST_RELATION_TITLE") && vars.get("$field.SOURCE_OBJECT_TYPE") == vars.get("$field.DEST_OBJECT_TYPE"))
|| !vars.get("$field.DEST_OBJECT_TYPE") && !vars.get("$field.DEST_RELATION_TITLE"))
{
db.deleteData("AB_OBJECTRELATIONTYPE", type2Cond);
}
else
{ // update if already existing
if (vars.get("$field.DIRECTION") != "same")
{
for (let field in type2Fields) {
updates.push(["AB_OBJECTRELATIONTYPE", [field], null, [type2Fields[field]], type2Cond]);
}
}
else
{ // insert if it was "same" before
if ((vars.get("$field.SOURCE_RELATION_TITLE") != vars.get("$field.DEST_RELATION_TITLE") || vars.get("$field.SOURCE_OBJECT_TYPE") != vars.get("$field.DEST_OBJECT_TYPE"))
&& vars.get("$field.DEST_OBJECT_TYPE") && vars.get("$field.DEST_RELATION_TITLE"))
{
db.insertData("AB_OBJECTRELATIONTYPE", [
"AB_OBJECTRELATIONTYPEID",
"OBJECT_TYPE",
"RELATION_TITLE",
"RELATION_TYPE",
"SIDE",
"HIERARCHY"
], null, [
util.getNewUUID(),
vars.get("$field.DEST_OBJECT_TYPE"),
vars.get("$field.DEST_RELATION_TITLE"),
vars.get("$field.RELATION_TYPE"),
2,
vars.get("$field.HIERARCHY")
]);
}
}
}
db.updates(updates);
}
else
{
// TODO: server hängt bei question.showMessage
//question.showMessage(translate.withArguments("There are still %0 relations using the type %1.", [usageCount, translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))]), question.WARNING, translate.text("Cannot remove relation type"))
}
......@@ -2,4 +2,11 @@ import("system.translate");
import("system.vars");
import("system.result");
result.string(translate.text(vars.get("$field.RELATION_TITLE")))
\ No newline at end of file
if (vars.exists("$param.OnlyFirstSide_param") && vars.get("$param.OnlyFirstSide_param") == "1" && vars.get("$field.DIRECTION") != "same")
{
result.string(translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE")));
}
else
{
result.string(translate.text(vars.get("$field.SOURCE_RELATION_TITLE")));
}
\ No newline at end of file
<?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.3.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.1">
<name>ObjectTree_entity</name>
<title>Object tree</title>
<title>Object relation</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<recordContainer>jdito</recordContainer>
<entityFields>
......@@ -108,6 +108,7 @@
<title>Relation</title>
<consumer>Objects</consumer>
<linkedContextProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js</linkedContextProcess>
<mandatory v="true" />
<searchable v="false" />
<stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/stateProcess.js</stateProcess>
<displayValueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/displayValueProcess.js</displayValueProcess>
......@@ -127,6 +128,7 @@
<name>OBJECTRELATIONTYPEID</name>
<title>Relationtype</title>
<consumer>ObjectRelationTypes</consumer>
<mandatory v="true" />
<stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/stateProcess.js</stateProcess>
<valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js</displayValueProcess>
......@@ -167,9 +169,8 @@
<name>edit</name>
<fieldType>ACTION</fieldType>
<onActionProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/edit/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>NEON:PENCIL</iconId>
<state>DISABLED</state>
<stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js</stateProcess>
</entityActionField>
</children>
</entityActionGroup>
......
import("system.logging");
import("system.result");
import("system.neon");
import("system.vars");
logging.log("aaaaaaaaaaaaa " + vars.get("$sys.selection"))
logging.log("aaaaaaaaaaaaa " + vars.get("$sys." + "viewmode"))
if (vars.get("$sys." + "viewmode") == neon.FRAME_VIEWMODE_COMPONENT)
if (vars.exists("$sys." + "selection") && vars.get("$sys." + "selection"))
{
var selectedRows = JSON.parse(vars.get("$sys." + "selection"));
var isObjectRelationNode = false;
if (selectedRows.length > 0)
{
logging.log(selectedRows.toSource())
var uid = JSON.parse(selectedRows[0]);
logging.log(uid.toSource())
isObjectRelationNode = typeof uid[2] == "string";
}
logging.log(isObjectRelationNode)
if (isObjectRelationNode)
{
result.string(neon.COMPONENTSTATE_EDITABLE)
}
else
{
result.string(neon.COMPONENTSTATE_DISABLED)
}
}
else
result.string(neon.COMPONENTSTATE_DISABLED)
\ No newline at end of file
......@@ -30,8 +30,6 @@ if (uidParam)
_insertEntry(tree, _getEntryData(uid[0], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[6]), "", 0, uid[3], relationTypeData[10]);
}
/* else
tree = [["", "", "", "", "", "", "", ""]]*/
}
else
{
......@@ -163,17 +161,12 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
if (direction == "same")
relationTypeIdForNew = thisRelationTypeId
// add both sides. Only one will succeed, because the prevObjectId will be filtered and it will just return []
let uids = _insertEntry(tree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 0);
// add both sides. Only one will succeed, because the prevObjectId will be filtered
_insertEntry(tree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 0);
if (direction == "same")
{
var otherEntryData = _getEntryData(pNodeId[0], "normal", relationType1, relationType2, prevObjectId, true);
uids = uids.concat(_insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 1));
}
for (let i = 0; i < uids.length; i++)
{
_loadObjectRelationTree(uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData);
uids.concat(_insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 1));
}
}
}
......
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