Skip to content
Snippets Groups Projects
Commit 8dd7e9ab authored by S.Listl's avatar S.Listl Committed by Sebastian Listl
Browse files

AttributeRelation refactored to make sure uids don't change

(cherry picked from commit cb3fa119)

(cherry picked from commit 5c48cda2)
parent 5e5b7941
No related branches found
No related tags found
No related merge requests found
Showing
with 278 additions and 241 deletions
......@@ -22,11 +22,13 @@
<entityParameter>
<name>ObjectType_param</name>
<expose v="true" />
<mandatory v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>ObjectRowId_param</name>
<expose v="true" />
<mandatory v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityProvider>
......@@ -156,6 +158,7 @@
</entityConsumer>
<entityParameter>
<name>GetTree_param</name>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/gettree_param/valueProcess.js</valueProcess>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
......@@ -261,6 +264,7 @@
</entityField>
<entityParameter>
<name>DisplaySimpleName_param</name>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/displaysimplename_param/valueProcess.js</valueProcess>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
......@@ -271,6 +275,7 @@
</entityParameter>
<entityParameter>
<name>ShowEmpty_param</name>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/showempty_param/valueProcess.js</valueProcess>
<expose v="true" />
<documentation>%aditoprj%/entity/AttributeRelation_entity/entityfields/showempty_param/documentation.adoc</documentation>
</entityParameter>
......@@ -293,6 +298,7 @@
</entityParameter>
<entityParameter>
<name>GetTheme_param</name>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/gettheme_param/valueProcess.js</valueProcess>
<expose v="true" />
</entityParameter>
<entityField>
......@@ -333,6 +339,10 @@
<entityProvider>
<name>ThemeProvider</name>
</entityProvider>
<entityField>
<name>AB_ATTRIBUTERELATIONID</name>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/ab_attributerelationid/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......@@ -346,6 +356,9 @@
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>AB_ATTRIBUTERELATIONID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PARENT_ID.value</name>
</jDitoRecordFieldMapping>
......
import("system.util");
import("system.neon");
import("system.vars");
import("system.result");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null)
result.string(util.getNewUUID());
\ No newline at end of file
import("system.result");
result.string(false);
\ No newline at end of file
import("system.result");
result.string(false);
\ No newline at end of file
import("system.result");
result.string(false);
\ No newline at end of file
import("system.result");
result.string(false);
\ No newline at end of file
......@@ -3,5 +3,10 @@ import("system.result");
import("system.neon");
import("system.util");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null)
result.string("," + util.getNewUUID()); // set "," to mark this as new generated UUID
\ No newline at end of file
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
if (vars.getString("$param.ShowEmpty_param") == "true")
result.string(JSON.stringify([vars.get("$field.AB_ATTRIBUTERELATIONID"), vars.get("$field.AB_ATTRIBUTE_ID")]));
else
result.string(vars.get("$field.AB_ATTRIBUTERELATIONID"));
}
\ No newline at end of file
......@@ -7,251 +7,256 @@ import("system.db");
import("Attribute_lib");
import("Sql_lib");
var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param");
var objectRowId = vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param");
var idvalues = vars.exists("$local.idvalues") ? vars.get("$local.idvalues") : null;
var getTree = !idvalues && vars.getString("$param.GetTree_param") == "true";
var loadFullAttributeName = vars.getString("$param.DisplaySimpleName_param") != "true";
var idvalues = vars.exists("$local.idvalues") && vars.get("$local.idvalues");
var getTree = vars.exists("$param.GetTree_param") && vars.getString("$param.GetTree_param") == "true";
var getTheme = vars.exists("$param.IsTheme_param") && vars.getString("$param.IsTheme_param") == "true";
var showEmpty = vars.exists("$param.ShowEmpty_param") && vars.getString("$param.ShowEmpty_param") == "true";
var displaySimpleName = vars.exists("$param.DisplaySimpleName_param") && vars.getString("$param.DisplaySimpleName_param") == "true";
var defaultFields = [
"AB_ATTRIBUTERELATIONID",
"AB_ATTRIBUTE.AB_ATTRIBUTEID",
"AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID",
"AB_ATTRIBUTE.ATTRIBUTE_TYPE",
"AB_ATTRIBUTE.ATTRIBUTE_NAME",
"AB_ATTRIBUTE.DROPDOWNDEFINITION",
"COMBOVAL.ATTRIBUTE_NAME",
"AB_ATTRIBUTERELATION.DATE_NEW",
"AB_ATTRIBUTERELATION.USER_NEW",
"AB_ATTRIBUTERELATION.DATE_EDIT",
"AB_ATTRIBUTERELATION.USER_EDIT",
"AB_ATTRIBUTE.DROPDOWNFILTER"
];
//these fields hold the attributeRelation value, depending on the attribute type
var valueFields = AttributeTypeUtil.getAllDatabaseFields();
var attributeSql = newSelect(defaultFields.concat(valueFields))
.from("AB_ATTRIBUTE")
.orderBy("AB_ATTRIBUTE.SORTING asc")
.where(); // go into where mode
var possibleAttributes;
var typeWhitelist, typeBlacklist;
if (vars.getString("$param.GetTheme_param") == "true")
typeWhitelist = [$AttributeTypes.THEME.toString()];
else
typeBlacklist = [$AttributeTypes.THEME.toString()];
var loadEmptyAttributes = vars.getString("$param.ShowEmpty_param") == "true";
var filteredAttributeIds = vars.exists("$param.FilteredAttributeIds_param") && vars.get("$param.FilteredAttributeIds_param");
if (filteredAttributeIds)
filteredAttributeIds = JSON.parse(filteredAttributeIds);
var objectRowId = vars.get("$param.ObjectRowId_param");
var objectType = vars.get("$param.ObjectType_param");
if (idvalues)
{
let attrId = idvalues.length === 1 && idvalues[0].split(",")[1];
if (!attrId)
showEmpty = false;
var attributeQueryMaker = {
defaultQueryFields : [
"AB_ATTRIBUTERELATIONID",
"AB_ATTRIBUTE.AB_ATTRIBUTEID",
"AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID",
"AB_ATTRIBUTE.ATTRIBUTE_TYPE",
"AB_ATTRIBUTE.ATTRIBUTE_NAME",
"AB_ATTRIBUTE.DROPDOWNDEFINITION",
"COMBOVAL.ATTRIBUTE_NAME",
"AB_ATTRIBUTERELATION.DATE_NEW",
"AB_ATTRIBUTERELATION.USER_NEW",
"AB_ATTRIBUTERELATION.DATE_EDIT",
"AB_ATTRIBUTERELATION.USER_EDIT",
"AB_ATTRIBUTE.DROPDOWNFILTER"
],
valueQueryFields : AttributeTypeUtil.getAllDatabaseFields(),
if (showEmpty)
attributeSql.and("AB_ATTRIBUTE.AB_ATTRIBUTEID", attrId);
else
getConditionForIdValues : function (pIdValues, pLoadEmptyAttributes)
{
attributeSql.andIfSet("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", idvalues.map(function(pId)
var idCondition = newWhere();
if (pLoadEmptyAttributes)
{
return pId[0] == "," ? pId.split(",")[1] : pId;
}), SqlBuilder.IN());
objectRowId = null;
}
getTree = false;
}
else if (showEmpty || objectRowId)
{
if (getTheme)
attributeSql.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.THEME);
else
attributeSql.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.THEME, SqlBuilder.NOT_EQUAL());
if (showEmpty)
{
possibleAttributes = AttributeUtil.getPossibleAttributes(objectType);
let filtered = vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param");
pIdValues.forEach(function (id)
{
var [attributeRelationId, attributeId] = JSON.parse(id);
idCondition.or("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", attributeRelationId);
idCondition.or(newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID is null")
.and("AB_ATTRIBUTE.AB_ATTRIBUTEID", attributeId));
});
}
else
idCondition.andIfSet("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", pIdValues, SqlBuilder.IN());
attributeSql.andIfSet("AB_ATTRIBUTE.AB_ATTRIBUTEID", possibleAttributes, SqlBuilder.IN());
}
if (vars.get("$param.FilteredAttributeIds_param"))
return idCondition;
},
getConditionForLinkedObject : function (pObjectType, pLoadEmptyAttributes, pAttributeIds, pTypeBlacklist, pTypeWhitelist)
{
let filteredIds = JSON.parse(vars.getString("$param.FilteredAttributeIds_param"));
var attributeCondition = newWhereIfSet("AB_ATTRIBUTE.ATTRIBUTE_TYPE", pTypeBlacklist, SqlBuilder.NOT_IN());
attributeCondition.andIfSet("AB_ATTRIBUTE.ATTRIBUTE_TYPE", pTypeWhitelist, SqlBuilder.IN());
let filteredIdChildren = AttributeUtil.getAllChildren(filteredIds);
if (pLoadEmptyAttributes)
attributeCondition.andIfSet("AB_ATTRIBUTE.AB_ATTRIBUTEID", AttributeUtil.getPossibleAttributes(pObjectType), SqlBuilder.IN());
let filteredCondition = newWhere();
if (pAttributeIds)
{
let attributeChildren = AttributeUtil.getAllChildren(pAttributeIds);
let attributeIdCondition = newWhere();
if (attributeChildren.length > 0)
{
attributeIdCondition.and("AB_ATTRIBUTE.AB_ATTRIBUTEID", attributeChildren, SqlBuilder.IN())
attributeIdCondition.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE, SqlBuilder.NOT_EQUAL());
}
// return nothing if filteredAttributeIds is an empty array. (--> and 1=2)
if (!attributeIdCondition.hasCondition())
return null;
attributeCondition.and(attributeIdCondition);
}
return attributeCondition;
},
getAttributeQuery : function (pIdValues, pObjectRowId, pObjectType, pLoadEmptyAttributes, pAttributeIds, pTypeBlacklist, pTypeWhitelist)
{
var attributeQuery = newSelect(this.defaultQueryFields.concat(this.valueQueryFields))
.from("AB_ATTRIBUTE")
.orderBy("AB_ATTRIBUTE.SORTING asc");
if (filteredIdChildren.length > 0)
if (pIdValues)
attributeQuery.where(this.getConditionForIdValues(pIdValues, pLoadEmptyAttributes));
else if (pObjectRowId)
{
filteredCondition.and("AB_ATTRIBUTE.AB_ATTRIBUTEID", filteredIdChildren, SqlBuilder.IN())
.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE, SqlBuilder.NOT_EQUAL());
let condition = this.getConditionForLinkedObject(pObjectType, pLoadEmptyAttributes, pAttributeIds, pTypeBlacklist, pTypeWhitelist);
if (condition === null)
return null;
attributeQuery.where(condition);
}
// return nothing if filteredAttributeIds is an empty array. (--> and 1=2)
if (filteredCondition.hasCondition())
attributeSql.and(filteredCondition);
else
attributeSql.and("1=2");
}
}
var attributeRelationCond = newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID"); //condition for the joined values (for AttributeRelation)
var attributeRelationCond = newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID"); //condition for the joined values (for AttributeRelation)
if (objectRowId)
{
attributeRelationCond.and("AB_ATTRIBUTERELATION.OBJECT_ROWID", objectRowId);
if (objectType)
attributeRelationCond.and("AB_ATTRIBUTERELATION.OBJECT_TYPE", objectType);
}
if (!pIdValues && pObjectRowId)
{
attributeRelationCond.and("AB_ATTRIBUTERELATION.OBJECT_ROWID", pObjectRowId);
attributeRelationCond.andIfSet("AB_ATTRIBUTERELATION.OBJECT_TYPE", pObjectType);
}
if (pLoadEmptyAttributes)
attributeQuery.leftJoin("AB_ATTRIBUTERELATION", attributeRelationCond);
else
attributeQuery.join("AB_ATTRIBUTERELATION", attributeRelationCond);
if (showEmpty)
attributeSql.leftJoin("AB_ATTRIBUTERELATION", attributeRelationCond);
else
attributeSql.join("AB_ATTRIBUTERELATION", attributeRelationCond);
attributeQuery.leftJoin("AB_ATTRIBUTE", "COMBOVAL.AB_ATTRIBUTEID = " + $AttributeTypes.COMBO.databaseField, "COMBOVAL");
return attributeQuery;
}
}
attributeSql.leftJoin("AB_ATTRIBUTE", "COMBOVAL.AB_ATTRIBUTEID = " + $AttributeTypes.COMBO.databaseField, "COMBOVAL")
var attributeQuery = attributeQueryMaker.getAttributeQuery(idvalues, objectRowId, objectType, loadEmptyAttributes, filteredAttributeIds, typeBlacklist, typeWhitelist);
var attributeRelations = attributeQuery != null ? attributeQuery.table(false) : [];
//Builds an object containing the minimal counts of the attributes, this is required for
//checking if an attribute is used not often enough or just often enough. When this is the case,
//deletion of this attributeRelation will be prohibited.
var minCountInsurance = {};
if (getTree)
{
if (!possibleAttributes)
possibleAttributes = AttributeUtil.getPossibleAttributes(objectType);
var minCountInsurance = {
minCounts : {},
usageCounts : {},
let minUsages = newSelect("AB_ATTRIBUTE_ID, MIN_COUNT")
.from("AB_ATTRIBUTEUSAGE")
.whereIfSet("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", possibleAttributes, SqlBuilder.IN())
.and("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", objectType)
.table(true);
minUsages.forEach(function (usage)
loadMinCounts : function (pObjectType)
{
this[usage[0]] = {
count : 0,
min : usage[1]
};
}, minCountInsurance);
}
var minUsages = newSelect("AB_ATTRIBUTE_ID, MIN_COUNT")
.from("AB_ATTRIBUTEUSAGE")
.whereIfSet("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", Object.keys(this.usageCounts), SqlBuilder.IN())
.and("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType)
.table(true);
var attrRelations = attributeSql.table(true).map(
function (row)
{
var [attrRelId, attrId, attrParentId, attrType, attrName, dropDownDef, comboViewVal, dateNew, userNew, dateEdit, userEdit, dropDownFilter] = row;
attrName = translate.text(attrName);
attrType = attrType.trim();
if (!getTree && !displaySimpleName && attrParentId)
minUsages.forEach(function ([attributeId, minCount])
{
let parentName = AttributeUtil.getFullAttributeName(attrParentId);
attrName = (parentName ? parentName + " / " : "") + attrName;
}
var value = row[AttributeTypeUtil.getTypeColumnIndex(attrType) + defaultFields.length];
var viewValue;
if (attrType == $AttributeTypes.COMBO)
viewValue = translate.text(comboViewVal);
else
viewValue = AttributeTypeUtil.getAttributeViewValue(attrType, value, dropDownDef);
this.minCounts[attributeId] = minCount;
}, this);
},
incrUsageCount : function (pAttributeId)
{
if (pAttributeId in this.usageCounts)
this.usageCounts[pAttributeId]++;
else
this.usageCounts[pAttributeId] = 1;
},
attributeNotDeletable : function (pAttributeId)
{
return this.minCounts[pAttributeId] >= this.usageCounts[pAttributeId];
}
};
if (attrId in minCountInsurance)
minCountInsurance[attrId].count++;
//TODO: what should be the uid if showEmpty is true?
// V-- set "," to mark this as new generated UUID
return [
attrRelId || util.getNewUUID() + "," + attrId,
attrParentId,
value,
viewValue,
attrId,
attrName,
"",
attrType.trim(),
dateNew,
userNew,
dateEdit,
userEdit,
value,
viewValue,
dropDownDef,
dropDownFilter
];
attributeRelations = attributeRelations.map(function (row)
{
var [attrRelId, attrId, attrParentId, attrType, attrName, dropDownDef, comboViewVal, dateNew, userNew, dateEdit, userEdit, dropDownFilter] = row;
attrName = translate.text(attrName);
attrType = attrType.trim();
if (!getTree && loadFullAttributeName && attrParentId)
{
let parentName = AttributeUtil.getFullAttributeName(attrParentId);
attrName = (parentName ? parentName + " / " : "") + attrName;
}
);
var value = row[AttributeTypeUtil.getTypeColumnIndex(attrType) + attributeQueryMaker.defaultQueryFields.length];
var viewValue;
if (attrType == $AttributeTypes.COMBO)
viewValue = translate.text(comboViewVal);
else
viewValue = AttributeTypeUtil.getAttributeViewValue(attrType, value, dropDownDef);
_protectMinCountAttributes(attrRelations, minCountInsurance);
minCountInsurance.incrUsageCount(attrId);
//if loadEmptyAttributes is true, the id is contains the attributeRelation id and the attribute id.
//in case there is no attributeRelation, a random id is used
return [
loadEmptyAttributes ? JSON.stringify([attrRelId || util.getNewUUID(), attrId]) : attrRelId,
attrRelId,
attrParentId,
value,
viewValue,
attrId,
attrName,
"", //protected
attrType.trim(),
dateNew,
userNew,
dateEdit,
userEdit,
value,
viewValue,
dropDownDef,
dropDownFilter
];
});
minCountInsurance.loadMinCounts(objectType);
attributeRelations.forEach(function (attributeRelation)
{
var attrId = attributeRelation[4];
if (minCountInsurance.attributeNotDeletable(attrId))
attributeRelation[7] = "true";
});
//object of attribute ids to avoid duplicates (more than one attribute can have the same parent)
var attrCatalog = {};
if (getTree)
attrRelations = _buildAttributeTree(attrRelations);
attributeRelations = _buildAttributeTree(attributeRelations);
result.object(attrRelations);
result.object(attributeRelations);
/*
* loads the parents for a tree
*/
function _buildAttributeTree (pAttrRelations)
{
var parentAttributes = [];
_fetchParentAttributes(pAttrRelations.map(function (row) {return row[1]}), parentAttributes);
return TreeUtils.sortArrayForTree(parentAttributes, 0, 1).concat(pAttrRelations);
}
//object of attribute ids to avoid duplicates (more than one attribute can have the same parent)
var attrCatalog = {};
/*
* recursive function that loads all superordinate attributes for the tree
*/
function _fetchParentAttributes (pAttributeIds, pParentAttributes)
{
var attributeCond = newSelect("AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, ATTRIBUTE_NAME")
.from("AB_ATTRIBUTE")
.where()
var nextIds = [];
pAttributeIds.forEach(function (id)
{
if (!(id in this))
attributeCond.andIfSet("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, attrCatalog);
var parentAttributes = [];
_fetchParentAttributes(pAttrRelations.map(function (row) {return row[2]}), parentAttributes);
return TreeUtils.sortArrayForTree(parentAttributes, 0, 2).concat(pAttrRelations);
attributeCond.table(true)
.forEach(function ([attrId, parentId, attrName])
{
this[attrId] = true; //make entry in attrCatalog to avoid duplicates
if (parentId)
nextIds.push(parentId);
pParentAttributes.push([
attrId,
parentId,
"",
"",
"",
translate.text(attrName), //translate attribute name
"true",
"",
"",
"",
"",
"",
"",
"",
"",
"",
]);
}, attrCatalog);
if (nextIds.length)
_fetchParentAttributes(nextIds, pParentAttributes);
}
function _protectMinCountAttributes (pAttrRelations, pMinCountInsurance)
{
for (let i = 0; i < pAttrRelations.length; i++)
/*
* recursive function that loads all superordinate attributes for the tree
*/
function _fetchParentAttributes (pAttributeIds, pParentAttributes)
{
let attrId = pAttrRelations[i][4];
if (attrId in pMinCountInsurance && pMinCountInsurance[attrId].min >= pMinCountInsurance[attrId].count)
pAttrRelations[i][6] = "true";
var attributeCond = newSelect("AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, ATTRIBUTE_NAME")
.from("AB_ATTRIBUTE")
.where()
var nextIds = [];
pAttributeIds.forEach(function (id)
{
if (!(id in this))
attributeCond.orIfSet("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, attrCatalog);
attributeCond.table(true)
.forEach(function ([attrId, parentId, attrName])
{
this[attrId] = true; //make entry in attrCatalog to avoid duplicates
if (parentId)
nextIds.push(parentId);
pParentAttributes.push([
attrId, "", parentId, "", "", "", //0-5
translate.text(attrName), //translate attribute name
"true", //7
"", "", "", "", "", "", "", "", "" //8-16
]);
}, attrCatalog);
if (nextIds.length)
_fetchParentAttributes(nextIds, pParentAttributes);
}
}
\ No newline at end of file
}
......@@ -17,7 +17,7 @@ var columns = [
var rowdata = vars.get("$local.rowdata");
var uid = rowdata["UID.value"];
var values = [
uid[0] == "," ? uid.substr(1) : uid, // if first char is "," it is a newly generated UUID
rowdata["AB_ATTRIBUTERELATIONID.value"],
rowdata["AB_ATTRIBUTE_ID.value"],
vars.get("$param.ObjectRowId_param"),
vars.get("$param.ObjectType_param"),
......
......@@ -8,31 +8,11 @@ import("Attribute_lib");
var rowdata = vars.get("$local.rowdata");
var attributeId = rowdata["AB_ATTRIBUTE_ID.value"]
var type = AttributeUtil.getAttributeType(attributeId);
var uid = vars.get("$local.uid").split(",");
var attributeRelationId = vars.getString("$param.ShowEmpty_param") == "true"
? JSON.parse(vars.get("$local.uid"))[0]
: vars.get("$local.uid");
// if first char is "," it is a newly generated UUID
if (uid.length === 1)
{
var fieldValues = {
"AB_ATTRIBUTE_ID" : attributeId,
"DATE_EDIT" : rowdata["DATE_EDIT.value"],
"USER_EDIT" : rowdata["USER_EDIT.value"]
};
var dbFields = AttributeTypeUtil.getAllDatabaseFields();
dbFields.forEach(function (row)
{
fieldValues[row] = ""; //set every field but the correct value field to null
});
fieldValues[AttributeTypeUtil.getDatabaseField(type)] = AttributeTypeUtil.useLookup(type)
? rowdata["VALUE_LOOKUP.value"]
: rowdata["VALUE.value"];
newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", "$local.uid")
.updateFields(fieldValues);
}
else
if (vars.getString("$param.ShowEmpty_param") == "true" && !rowdata["AB_ATTRIBUTERELATIONID.value"])
{
var columns = [
"AB_ATTRIBUTERELATIONID",
......@@ -44,7 +24,7 @@ else
];
var values = [
uid[0], // if first char is "," it is a newly generated UUID
attributeRelationId,
attributeId,
vars.get("$param.ObjectRowId_param"),
vars.get("$param.ObjectType_param"),
......@@ -62,6 +42,27 @@ else
}
db.insertData("AB_ATTRIBUTERELATION", columns, null, values);
}
else
{
var fieldValues = {
"AB_ATTRIBUTE_ID" : attributeId,
"DATE_EDIT" : rowdata["DATE_EDIT.value"],
"USER_EDIT" : rowdata["USER_EDIT.value"]
};
var dbFields = AttributeTypeUtil.getAllDatabaseFields();
dbFields.forEach(function (row)
{
fieldValues[row] = ""; //set every field but the correct value field to null
});
fieldValues[AttributeTypeUtil.getDatabaseField(type)] = AttributeTypeUtil.useLookup(type)
? rowdata["VALUE_LOOKUP.value"]
: rowdata["VALUE.value"];
newWhere("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", attributeRelationId)
.updateFields(fieldValues);
}
if (vars.get("$param.ObjectType_param") == "Person")
DataPrivacyUtils.notifyNeedDataPrivacyUpdate(vars.get("$param.ObjectRowId_param"), vars.get("$param.ShowDsgvoMessage_param"));
\ No newline at end of file
......@@ -8,7 +8,6 @@
<contentTitleProcess>%aditoprj%/entity/Attribute_entity/contentTitleProcess.js</contentTitleProcess>
<afterUiInit>%aditoprj%/entity/Attribute_entity/afterUiInit.js</afterUiInit>
<onValidation>%aditoprj%/entity/Attribute_entity/onValidation.js</onValidation>
<afterOperatingState>%aditoprj%/entity/Attribute_entity/afterOperatingState.js</afterOperatingState>
<iconId>VAADIN:TAG</iconId>
<titlePlural>Attributes</titlePlural>
<recordContainer>jdito</recordContainer>
......
import("system.vars");
import("system.neon");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW && vars.get("$param.ParentIdPreset_param"))
neon.refreshAll();
\ 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