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

AttributeRelation FilteredAttributeIds

parent 5f0f0194
No related branches found
No related tags found
No related merge requests found
Showing
with 146 additions and 103 deletions
......@@ -229,10 +229,6 @@
<name>GetTree_param</name>
<expose v="false" />
</entityParameter>
<entityParameter>
<name>FilteredAttributes_param</name>
<triggerRecalculation v="true" />
</entityParameter>
</children>
</entityProvider>
<entityField>
......@@ -251,12 +247,6 @@
<name>USER_NEW</name>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/user_new/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>FilteredAttributes_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>DisplaySimpleName_param</name>
<expose v="true" />
......
......@@ -18,44 +18,56 @@ var showEmpty = vars.exists("$param.ShowEmpty_param") && vars.getString("$param.
var displaySimpleName = vars.exists("$param.DisplaySimpleName_param") && vars.get("$param.DisplaySimpleName_param");
var sqlSelect = "select AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, '', '', '', ATTRIBUTE_NAME from AB_ATTRIBUTE";
var attrCond = SqlCondition.begin();
var attributeRelationJoin = "join AB_ATTRIBUTERELATION on AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID";
var sqlCondition = new SqlCondition();
var subCondition = new SqlCondition();
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
{
var idVals = vars.get("$local.idvalues");
var idCond = SqlCondition.begin();
let idVals = vars.get("$local.idvalues");
let idCond = new SqlCondition();
idVals.forEach(function (id)
{
idCond.orPrepare("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", id);
});
attrCond.andSqlCondition(idCond);
this.orPrepare("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", id);
}, subCondition);
sqlCondition.andSqlCondition(subCondition);
getTree = false;
}
else if (showEmpty)
else if (showEmpty || rowId)
{
var possibleAttributes = AttributeUtil.getPossibleAttributes(objectType);
possibleAttributes.forEach(function (attributeId)
if (showEmpty)
{
this.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", attributeId);
}, attrCond);
}
else if (rowId)
{
attrCond.andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", rowId);
if (objectType != null)
attrCond.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", objectType);
if (vars.exists("$param.FilteredAttributes_param") && vars.get("$param.FilteredAttributes_param"))
let idCond = new SqlCondition();
let possibleAttributes = AttributeUtil.getPossibleAttributes(objectType);
possibleAttributes.forEach(function (attributeId)
{
this.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", attributeId);
}, idCond);
sqlCondition.andSqlCondition(idCond);
attributeRelationJoin = "left " + attributeRelationJoin;
}
if (rowId)
{
subCondition.andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", rowId);
if (objectType != null)
subCondition.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", objectType);
attributeRelationJoin += " and " + subCondition;
sqlCondition.preparedValues = subCondition.preparedValues.concat(sqlCondition.preparedValues);
}
if (vars.exists("$param.FilteredAttributeIds_param") && vars.get("$param.FilteredAttributeIds_param"))
{
var filteredIds = JSON.parse(vars.getString("$param.FilteredAttributes_param"));
var filteredIdsCondition = new SqlCondition();
let filteredIds = JSON.parse(vars.getString("$param.FilteredAttributeIds_param"));
subCondition.clear();
let filteredIdChildren = AttributeUtil.getAllChildren(filteredIds);
filteredIds.forEach(function(id)
filteredIds.concat(filteredIdChildren).forEach(function(id)
{
this.orPrepare("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID", id);
}, filteredIdsCondition);
this.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, subCondition);
attrCond.andSqlCondition(filteredIdsCondition);
sqlCondition.andSqlCondition(subCondition);
}
}
......@@ -71,10 +83,11 @@ var defaultFields = [
];
//these fields hold the attributeRelation value, depending on the attribute type
var valueFields = AttributeTypeUtil.getAllDatabaseFields();
var attributeSql = attrCond.buildSql("select " + defaultFields.join(", ") + ", " + valueFields.join(", ")
+ " from AB_ATTRIBUTE" + (showEmpty ? " left" : "")
+ " join AB_ATTRIBUTERELATION on AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID"
var attributeSql = sqlCondition.buildSql("select " + defaultFields.join(", ") + ", " + valueFields.join(", ")
+ " from AB_ATTRIBUTE "
+ attributeRelationJoin
+ " left join AB_ATTRIBUTE COMBOVAL on " + $AttributeTypes.COMBO.databaseField + " = COMBOVAL.AB_ATTRIBUTEID" //for the view value of combobox attributes
, "1=2"
);
var attributeValues = db.table(attributeSql).map(function (row)
......@@ -112,14 +125,14 @@ result.object(allAttributes);
*/
function _fetchAttributes (pAttributeIds)
{
var condition = SqlCondition.begin();
var sqlCondition = SqlCondition.begin();
var nextIds = [];
pAttributeIds.forEach(function (id)
{
if (!(id in this))
condition.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
sqlCondition.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, attributeObj);
db.table(condition.buildSql(sqlSelect, "1=2"))
db.table(sqlCondition.buildSql(sqlSelect, "1=2"))
.forEach(function (row)
{
this[row[0]] = true;
......@@ -131,4 +144,4 @@ function _fetchAttributes (pAttributeIds)
}, attributeObj);
if (nextIds.length)
_fetchAttributes(nextIds);
}
\ No newline at end of file
}
import("Sql_lib");
import("system.util");
import("system.db");
import("system.vars");
import("Attribute_lib");
var type = AttributeUtil.getAttributeType(vars.get("$field.AB_ATTRIBUTE_ID"));
var columns = [
"AB_ATTRIBUTE_ID",
"DATE_EDIT",
"USER_EDIT"
];
var values = [
vars.get("$field.AB_ATTRIBUTE_ID"),
vars.get("$field.DATE_EDIT"),
vars.get("$field.USER_EDIT")
];
var dbFields = AttributeTypeUtil.getAllDatabaseFields();
dbFields.forEach(function (row)
{
columns.push(row);
values.push(""); //set every field but the correct value field to null
});
values[AttributeTypeUtil.getTypeColumnIndex(type) + 3] = vars.get("$field.VALUE");
db.updateData("AB_ATTRIBUTERELATION", columns, null, values,
SqlCondition.equals("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", vars.get("$field.UID"), "1=2"));
\ No newline at end of file
import("Sql_lib");
import("system.util");
import("system.db");
import("system.vars");
import("Attribute_lib");
var type = AttributeUtil.getAttributeType(vars.get("$field.AB_ATTRIBUTE_ID"));
var columns, values;
if (vars.get("$field.DATE_NEW"))
{
columns = [
"AB_ATTRIBUTE_ID",
"DATE_EDIT",
"USER_EDIT"
];
values = [
vars.get("$field.AB_ATTRIBUTE_ID"),
vars.get("$field.DATE_EDIT"),
vars.get("$field.USER_EDIT")
];
var dbFields = AttributeTypeUtil.getAllDatabaseFields();
dbFields.forEach(function (row)
{
columns.push(row);
values.push(""); //set every field but the correct value field to null
});
values[AttributeTypeUtil.getTypeColumnIndex(type) + 3] = vars.get("$field.VALUE");
db.updateData("AB_ATTRIBUTERELATION", columns, null, values,
SqlCondition.equals("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", vars.get("$field.UID"), "1=2"));
}
else
{
columns = [
"AB_ATTRIBUTERELATIONID",
"AB_ATTRIBUTE_ID",
"OBJECT_ROWID",
"OBJECT_TYPE",
"DATE_NEW",
"USER_NEW"
];
values = [
vars.get("$field.UID"),
vars.get("$field.AB_ATTRIBUTE_ID"),
vars.get("$param.ObjectRowId_param"),
vars.get("$param.ObjectType_param"),
vars.get("$sys.date"),
vars.get("$sys.user")
];
let valueField = AttributeTypeUtil.getDatabaseField(type);
if (valueField)
{
columns.push(valueField);
values.push(vars.get("$field.VALUE"));
}
db.insertData("AB_ATTRIBUTERELATION", columns, null, values);
}
\ No newline at end of file
......@@ -792,10 +792,6 @@
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/attributeconditions/children/objecttype_param/valueProcess.js</valueProcess>
<triggerRecalculation v="true" />
</entityParameter>
<entityParameter>
<name>FilteredAttributes_param</name>
<triggerRecalculation v="true" />
</entityParameter>
<entityParameter>
<name>DisplaySimpleName_param</name>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/attributeconditions/children/displaysimplename_param/valueProcess.js</valueProcess>
......
import("system.logging");
import("system.db");
import("system.result");
result.object(db.table("select AB_ATTRIBUTEID from ADITO.AB_ATTRIBUTE where ATTRIBUTE_PARENT_ID = 'ab545654-1fce-4993-b763-0ec469781302'"));
\ No newline at end of file
import("system.result");
result.object(["ab545654-1fce-4993-b763-0ec469781302"]);
\ No newline at end of file
......@@ -235,14 +235,14 @@
<name>DisplaySimpleName_param</name>
<valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/attributes/children/displaysimplename_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>FilteredAttributes_param</name>
<valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/attributes/children/filteredattributes_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>ObjectRowId_param</name>
<valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/attributes/children/objectrowid_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>FilteredAttributeIds_param</name>
<valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/attributes/children/filteredattributeids_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityField>
......
import("system.result");
result.object([
'8af37871-d407-4414-98ad-e64dbaa5794a', // Price politics
'558419b2-6113-4060-b88d-cc6324754765', // Strength
'71226196-2812-4d70-b90f-c3e2c14fd4d1' // Weakness
import("system.result");
result.object([
'8af37871-d407-4414-98ad-e64dbaa5794a', // Price politics
'558419b2-6113-4060-b88d-cc6324754765', // Strength
'71226196-2812-4d70-b90f-c3e2c14fd4d1' // Weakness
]);
\ No newline at end of file
......@@ -55,8 +55,8 @@ AttributeUtil.getPossibleAttributes = function (pObjectType, pIncludeGroups, pFi
if (pFilteredAttributeIds != undefined && pFilteredAttributeIds.length > 0)
{
var filteredIdsCondition = new SqlCondition();
var filteredIdChildren = [];
pFilteredAttributeIds.forEach(function(id)
var filteredIdChildren = AttributeUtil.getAllChildren(pFilteredAttributeIds);
pFilteredAttributeIds.concat(filteredIdChildren).forEach(function(id)
{
this.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, filteredIdsCondition);
......@@ -133,22 +133,24 @@ AttributeUtil.getSimpleAttributeName = function (pAttributeId)
/**
* returns the ids of all subordinated attributes of an attribute
*
* @param {String} pAttributeId the id of the attribute
* @param {String|Array} pAttributeIds the id(s) of the attribute(s)
*
* @result {String[]} array with the ids of every subordinated attribute
*/
AttributeUtil.getAllChildren = function (pAttributeId)
AttributeUtil.getAllChildren = function (pAttributeIds)
{
var childIds = [];
var attributes= [pAttributeId];
while (attributes.length > 0)
if (typeof(pAttributeIds) == "string")
pAttributeIds = [pAttributeIds];
while (pAttributeIds.length > 0)
{
attributes = db.array(db.COLUMN, SqlCondition.begin()
.and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + attributes.join("','") + "')")
pAttributeIds = db.array(db.COLUMN, SqlCondition.begin()
.and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + pAttributeIds.join("','") + "')")
.buildSql("select AB_ATTRIBUTEID from AB_ATTRIBUTE")
);
if (attributes.length > 0)
childIds = childIds.concat(attributes);
if (pAttributeIds.length > 0)
childIds = childIds.concat(pAttributeIds);
}
return childIds;
}
......
......@@ -3,4 +3,7 @@
<name>DocumentTemplate_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/DocumentTemplate_lib/process.js</process>
<variants>
<element>LIBRARY</element>
</variants>
</process>
......@@ -35,6 +35,7 @@ function DocumentTemplate (pTemplateContent, pType)
DocumentTemplate.types = {
TXT : "TXT",
HTML : "HTML",
EML : "EML",
ODT : "ODT",
DOCX : "DOCX"
};
......@@ -50,6 +51,7 @@ DocumentTemplate.loadTemplate = function (pTemplateId)
var typeMap = {
txt : DocumentTemplate.types.TXT,
html : DocumentTemplate.types.HTML,
eml : DocumentTemplate.types.EML,
odt : DocumentTemplate.types.ODT,
docx : DocumentTemplate.types.DOCX
};
......@@ -78,10 +80,12 @@ DocumentTemplate.prototype.getReplacedText = function (pReplacements)
pReplacements[i] = text.replaceAll(pReplacements[i], {"\n" : "<br>"});
case DocumentTemplate.types.TXT:
return text.replaceAll(this.content, pReplacements);
case DocumentTemplate.types.EML:
return this._getReplacedEML(pReplacements);
case DocumentTemplate.types.ODT:
return this._getReplacedODT(pReplacements);
// return this._getReplacedODT(pReplacements);
case DocumentTemplate.types.DOCX:
return this._getReplacedDOCX(pReplacements);
// return this._getReplacedDOCX(pReplacements);
default:
return null;
}
......@@ -95,6 +99,12 @@ DocumentTemplate.prototype.getReplacedTextByContactId = function (pContactId)
return this.getReplacedText(replacements);
}
DocumentTemplate.prototype._getReplacedEML = function (pReplacements)
{
var email = mail.parseRFC(this.content);
}
/*
* replaces a given Odt-File on the server and returns the replaced base64-file
*
......
......@@ -3,6 +3,7 @@ import("system.text");
import("system.db");
import("system.util");
import("Communication_lib");
import("DocumentTemplate_lib");
import("system.neon");
import("system.mail");
......@@ -73,7 +74,7 @@ function Email (pToRecipients, pSender, pSubject, pBody, pCcRecipients, pBccReci
*/
Email.prototype.setTemplate = function (pTemplateId)
{
this.body = DocumentTemplateUtils.getTemplateText(pTemplateId);
this.body = String(DocumentTemplate.loadTemplate());
}
/**
......
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