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

Timetracking renaming fixed

parent 336fa351
No related branches found
No related tags found
No related merge requests found
Showing
with 923 additions and 923 deletions
import("system.translate");
import("system.util");
import("Util_lib");
import("system.vars");
import("system.result");
import("system.db");
import("Attribute_lib");
import("Sql_lib");
var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param");
var rowId = vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param");
//getTree: if true, the attribute groups are loaded as parents
var getTree = vars.exists("$param.GetTree_param") && vars.getString("$param.GetTree_param") == "true";
//showEmpty: if true, all selectable attributes are loaded as records, even if they don't have a attributeRelation
var showEmpty = vars.exists("$param.ShowEmpty_param") && vars.getString("$param.ShowEmpty_param") == "true";
var displaySimpleName = vars.exists("$param.DisplaySimpleName_param") && vars.get("$param.DisplaySimpleName_param");
var sqlCondition = new SqlCondition(); //where-condition (condition for the Attribute)
var joinCondition = new SqlCondition(); //condition for the joined values (for AttributeRelation)
//=> these are two distinct conditions because if showEmpty is true, a left join is used for the relations
var possibleAttributes = AttributeUtil.getPossibleAttributes(objectType);
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
{
let idVals = vars.get("$local.idvalues");
let attrId = idVals.length === 1 && idVals[0].split(",")[1];
if (!attrId)
showEmpty = false;
if (showEmpty)
sqlCondition.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", attrId);
else
{
sqlCondition.andIn("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", idVals);
rowId = null;
}
getTree = false;
}
else if (showEmpty || rowId)
{
if (showEmpty)
{
let filtered = vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param");
sqlCondition.andIn("AB_ATTRIBUTE.AB_ATTRIBUTEID", possibleAttributes);
}
if (vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param"))
{
let filteredIds = JSON.parse(vars.getString("$param.FilteredAttributeIds_param"));
let filteredCondition = new SqlCondition();
let filteredIdChildren = AttributeUtil.getAllChildren(filteredIds);
filteredCondition.andIn("AB_ATTRIBUTE.AB_ATTRIBUTEID", filteredIdChildren);
filteredCondition.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE, "# != ?")
// return nothing if filteredAttributeIds is an empty array. (--> and 1=2)
sqlCondition.andSqlCondition(filteredCondition, "1=2");
}
}
if (rowId)
{
joinCondition.andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", rowId);
if (objectType != null)
joinCondition.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", objectType);
// add condition to match all returned by joins (override default 1=2 of build)
sqlCondition.and("1=1");
}
joinCondition.and("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID");
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"
];
//these fields hold the attributeRelation value, depending on the attribute type
var valueFields = AttributeTypeUtil.getAllDatabaseFields();
var attributeSql = SqlBuilder.begin()
.select(defaultFields.concat(valueFields))
.from("AB_ATTRIBUTE")
.where(sqlCondition);
if (showEmpty)
attributeSql.leftJoin("AB_ATTRIBUTERELATION", joinCondition.build("1=2"));
else
attributeSql.join("AB_ATTRIBUTERELATION", joinCondition.build("1=2"));
attributeSql.leftJoin("AB_ATTRIBUTE", "COMBOVAL.AB_ATTRIBUTEID = " + $AttributeTypes.COMBO.databaseField, "COMBOVAL");
var countCheck = {};
if (getTree)
{
let minUsages = db.table(SqlCondition.begin()
.andIn("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", possibleAttributes)
.andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", objectType)
.buildSql("select AB_ATTRIBUTE_ID, MIN_COUNT from AB_ATTRIBUTEUSAGE", "1=2")
);
minUsages.forEach(function (usage)
{
this[usage[0]] = {
count : 0,
min : usage[1]
};
}, countCheck);
}
var attributeValues = db.table(attributeSql.build()).map(function (row)
{
var attributeId = row[1];
var attributeName = translate.text(row[4]);
var type = row[3].trim();
if (!getTree && !displaySimpleName && row[2])
{
let parentName = AttributeUtil.getFullAttributeName(row[2]);
attributeName = (parentName ? parentName + " / " : "") + attributeName;
}
var value = row[AttributeTypeUtil.getTypeColumnIndex(row[3]) + defaultFields.length];
var viewValue;
if (type == $AttributeTypes.COMBO)
viewValue = translate.text(row[6]);
else
viewValue = AttributeTypeUtil.getAttributeViewValue(type, value, row[5]);
if (attributeId in countCheck)
countCheck[attributeId].count++;
//TODO: what should be the uid if showEmpty is true?
// V-- set "," to mark this as new generated UUID
return [row[0] || util.getNewUUID() + "," + attributeId, row[2], value, viewValue, attributeId, attributeName, ""];
});
for (let i = 0; i < attributeValues.length; i++)
{
let attrId = attributeValues[i][4];
if (attrId in countCheck && countCheck[attrId].min >= countCheck[attrId].count)
attributeValues[i][6] = "true";
}
var parentAttributes = [];
var attributeObj = {}; //object of attribute ids to avoid duplicates
if (getTree)
_fetchAttributes(attributeValues.map(function (row) {return row[1]}));
allAttributes = TreeUtils.sortArrayForTree(parentAttributes, 0, 1).concat(attributeValues);
result.object(allAttributes);
/*
* recursive function that loads all superordinate attributes for the tree
*/
function _fetchAttributes (pAttributeIds)
{
var sqlCondition = SqlCondition.begin();
var nextIds = [];
pAttributeIds.forEach(function (id)
{
if (!(id in this))
sqlCondition.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, attributeObj);
db.table(sqlCondition.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, ATTRIBUTE_NAME from AB_ATTRIBUTE", "1=2"))
.forEach(function (row)
{
this[row[0]] = true; //make entry in attributeObj to avoid duplicates
if (row[1])
nextIds.push(row[1]);
else
row[1] = null;
row[2] = translate.text(row[2]); //translate attribute name
parentAttributes.push([row[0], row[1], "", "", "", row[2], "true"]);
}, attributeObj);
if (nextIds.length)
_fetchAttributes(nextIds);
import("system.translate");
import("system.util");
import("Util_lib");
import("system.vars");
import("system.result");
import("system.db");
import("Attribute_lib");
import("Sql_lib");
var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param");
var rowId = vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param");
//getTree: if true, the attribute groups are loaded as parents
var getTree = vars.exists("$param.GetTree_param") && vars.getString("$param.GetTree_param") == "true";
//showEmpty: if true, all selectable attributes are loaded as records, even if they don't have a attributeRelation
var showEmpty = vars.exists("$param.ShowEmpty_param") && vars.getString("$param.ShowEmpty_param") == "true";
var displaySimpleName = vars.exists("$param.DisplaySimpleName_param") && vars.get("$param.DisplaySimpleName_param");
var sqlCondition = new SqlCondition(); //where-condition (condition for the Attribute)
var joinCondition = new SqlCondition(); //condition for the joined values (for AttributeRelation)
//=> these are two distinct conditions because if showEmpty is true, a left join is used for the relations
var possibleAttributes = AttributeUtil.getPossibleAttributes(objectType);
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
{
let idVals = vars.get("$local.idvalues");
let attrId = idVals.length === 1 && idVals[0].split(",")[1];
if (!attrId)
showEmpty = false;
if (showEmpty)
sqlCondition.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", attrId);
else
{
sqlCondition.andIn("AB_ATTRIBUTERELATION.AB_ATTRIBUTERELATIONID", idVals);
rowId = null;
}
getTree = false;
}
else if (showEmpty || rowId)
{
if (showEmpty)
{
let filtered = vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param");
sqlCondition.andIn("AB_ATTRIBUTE.AB_ATTRIBUTEID", possibleAttributes);
}
if (vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param"))
{
let filteredIds = JSON.parse(vars.getString("$param.FilteredAttributeIds_param"));
let filteredCondition = new SqlCondition();
let filteredIdChildren = AttributeUtil.getAllChildren(filteredIds);
filteredCondition.andIn("AB_ATTRIBUTE.AB_ATTRIBUTEID", filteredIdChildren);
filteredCondition.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE, "# != ?")
// return nothing if filteredAttributeIds is an empty array. (--> and 1=2)
sqlCondition.andSqlCondition(filteredCondition, "1=2");
}
}
if (rowId)
{
joinCondition.andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", rowId);
if (objectType != null)
joinCondition.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", objectType);
// add condition to match all returned by joins (override default 1=2 of build)
sqlCondition.and("1=1");
}
joinCondition.and("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID");
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"
];
//these fields hold the attributeRelation value, depending on the attribute type
var valueFields = AttributeTypeUtil.getAllDatabaseFields();
var attributeSql = SqlBuilder.begin()
.select(defaultFields.concat(valueFields))
.from("AB_ATTRIBUTE")
.where(sqlCondition);
if (showEmpty)
attributeSql.leftJoin("AB_ATTRIBUTERELATION", joinCondition.build("1=2"));
else
attributeSql.join("AB_ATTRIBUTERELATION", joinCondition.build("1=2"));
attributeSql.leftJoin("AB_ATTRIBUTE", "COMBOVAL.AB_ATTRIBUTEID = " + $AttributeTypes.COMBO.databaseField, "COMBOVAL");
var countCheck = {};
if (getTree)
{
let minUsages = db.table(SqlCondition.begin()
.andIn("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", possibleAttributes)
.andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", objectType)
.buildSql("select AB_ATTRIBUTE_ID, MIN_COUNT from AB_ATTRIBUTEUSAGE", "1=2")
);
minUsages.forEach(function (usage)
{
this[usage[0]] = {
count : 0,
min : usage[1]
};
}, countCheck);
}
var attributeValues = db.table(attributeSql.build()).map(function (row)
{
var attributeId = row[1];
var attributeName = translate.text(row[4]);
var type = row[3].trim();
if (!getTree && !displaySimpleName && row[2])
{
let parentName = AttributeUtil.getFullAttributeName(row[2]);
attributeName = (parentName ? parentName + " / " : "") + attributeName;
}
var value = row[AttributeTypeUtil.getTypeColumnIndex(row[3]) + defaultFields.length];
var viewValue;
if (type == $AttributeTypes.COMBO)
viewValue = translate.text(row[6]);
else
viewValue = AttributeTypeUtil.getAttributeViewValue(type, value, row[5]);
if (attributeId in countCheck)
countCheck[attributeId].count++;
//TODO: what should be the uid if showEmpty is true?
// V-- set "," to mark this as new generated UUID
return [row[0] || util.getNewUUID() + "," + attributeId, row[2], value, viewValue, attributeId, attributeName, ""];
});
for (let i = 0; i < attributeValues.length; i++)
{
let attrId = attributeValues[i][4];
if (attrId in countCheck && countCheck[attrId].min >= countCheck[attrId].count)
attributeValues[i][6] = "true";
}
var parentAttributes = [];
var attributeObj = {}; //object of attribute ids to avoid duplicates
if (getTree)
_fetchAttributes(attributeValues.map(function (row) {return row[1]}));
allAttributes = TreeUtils.sortArrayForTree(parentAttributes, 0, 1).concat(attributeValues);
result.object(allAttributes);
/*
* recursive function that loads all superordinate attributes for the tree
*/
function _fetchAttributes (pAttributeIds)
{
var sqlCondition = SqlCondition.begin();
var nextIds = [];
pAttributeIds.forEach(function (id)
{
if (!(id in this))
sqlCondition.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
}, attributeObj);
db.table(sqlCondition.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, ATTRIBUTE_NAME from AB_ATTRIBUTE", "1=2"))
.forEach(function (row)
{
this[row[0]] = true; //make entry in attributeObj to avoid duplicates
if (row[1])
nextIds.push(row[1]);
else
row[1] = null;
row[2] = translate.text(row[2]); //translate attribute name
parentAttributes.push([row[0], row[1], "", "", "", row[2], "true"]);
}, attributeObj);
if (nextIds.length)
_fetchAttributes(nextIds);
}
\ 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.10" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.10">
<name>CampaignAddParticipants_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<title>Add participants to Campaign</title>
<onValidation>%aditoprj%/entity/CampaignAddParticipants_entity/onValidation.js</onValidation>
<recordContainer>jdito</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
</entityProvider>
<entityField>
<name>CAMPAIGN_ID</name>
<title>Campaign</title>
<consumer>CampaignConsumer</consumer>
<mandatory v="true" />
<state>AUTO</state>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValueChange.js</onValueChange>
<onValueChangeTypes>
<element>MASK</element>
<element>PROCESS</element>
<element>PROCESS_SETVALUE</element>
<element>RECORD</element>
</onValueChangeTypes>
</entityField>
<entityField>
<name>CAMPAIGNSTEP_ID</name>
<title>Campaign Step</title>
<consumer>CampaignStepConsumer</consumer>
<mandatory v="true" />
<state>EDITABLE</state>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstep_id/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstep_id/onValueChange.js</onValueChange>
</entityField>
<entityField>
<name>campaignParticipantMessage</name>
<state>READONLY</state>
<onValueChangeTypes>
<element>PROCESS</element>
</onValueChangeTypes>
</entityField>
<entityParameter>
<name>campaignParticipantsRowIds_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityConsumer>
<name>CampaignConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Campaign_entity</entityName>
<fieldName>Campaigns</fieldName>
</dependency>
</entityConsumer>
<entityConsumer>
<name>CampaignStepConsumer</name>
<dependency>
<name>dependency</name>
<entityName>CampaignStep_entity</entityName>
<fieldName>CampaignSteps</fieldName>
</dependency>
<children>
<entityParameter>
<name>campaignId_param</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepconsumer/children/campaignid_param/valueProcess.js</valueProcess>
<expose v="true" />
</entityParameter>
</children>
</entityConsumer>
<entityField>
<name>UID</name>
</entityField>
<entityParameter>
<name>currentCampaignId_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>currentCampaignStepId_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>isUpdate_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityConsumer>
<name>CampaignAnalyses</name>
<dependency>
<name>dependency</name>
<entityName>CampaignAnalysis_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
</entityConsumer>
<entityField>
<name>campaignStepCurrentParticipantCount</name>
<title>Current participants</title>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>campaignStepMaxParticipantCount</name>
<title>Max participants</title>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepmaxparticipantcount/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>isUpdate</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isupdate/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>campaignParticipantsCondition_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>dataSourceTableName_param</name>
<expose v="true" />
</entityParameter>
<entityField>
<name>isOperationValid</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<onInsert>%aditoprj%/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js</onInsert>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
</entity>
<?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.10" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.10">
<name>CampaignAddParticipants_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<title>Add participants to Campaign</title>
<onValidation>%aditoprj%/entity/CampaignAddParticipants_entity/onValidation.js</onValidation>
<recordContainer>jdito</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
</entityProvider>
<entityField>
<name>CAMPAIGN_ID</name>
<title>Campaign</title>
<consumer>CampaignConsumer</consumer>
<mandatory v="true" />
<state>AUTO</state>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValueChange.js</onValueChange>
<onValueChangeTypes>
<element>MASK</element>
<element>PROCESS</element>
<element>PROCESS_SETVALUE</element>
<element>RECORD</element>
</onValueChangeTypes>
</entityField>
<entityField>
<name>CAMPAIGNSTEP_ID</name>
<title>Campaign Step</title>
<consumer>CampaignStepConsumer</consumer>
<mandatory v="true" />
<state>EDITABLE</state>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstep_id/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstep_id/onValueChange.js</onValueChange>
</entityField>
<entityField>
<name>campaignParticipantMessage</name>
<state>READONLY</state>
<onValueChangeTypes>
<element>PROCESS</element>
</onValueChangeTypes>
</entityField>
<entityParameter>
<name>campaignParticipantsRowIds_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityConsumer>
<name>CampaignConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Campaign_entity</entityName>
<fieldName>Campaigns</fieldName>
</dependency>
</entityConsumer>
<entityConsumer>
<name>CampaignStepConsumer</name>
<dependency>
<name>dependency</name>
<entityName>CampaignStep_entity</entityName>
<fieldName>CampaignSteps</fieldName>
</dependency>
<children>
<entityParameter>
<name>campaignId_param</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepconsumer/children/campaignid_param/valueProcess.js</valueProcess>
<expose v="true" />
</entityParameter>
</children>
</entityConsumer>
<entityField>
<name>UID</name>
</entityField>
<entityParameter>
<name>currentCampaignId_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>currentCampaignStepId_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>isUpdate_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityConsumer>
<name>CampaignAnalyses</name>
<dependency>
<name>dependency</name>
<entityName>CampaignAnalysis_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
</entityConsumer>
<entityField>
<name>campaignStepCurrentParticipantCount</name>
<title>Current participants</title>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>campaignStepMaxParticipantCount</name>
<title>Max participants</title>
<displayValueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/campaignstepmaxparticipantcount/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>isUpdate</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isupdate/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>campaignParticipantsCondition_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>dataSourceTableName_param</name>
<expose v="true" />
</entityParameter>
<entityField>
<name>isOperationValid</name>
<valueProcess>%aditoprj%/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<onInsert>%aditoprj%/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js</onInsert>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
</entity>
import("Campaign_lib");
import("system.result");
import("system.translate");
import("system.vars");
import("system.neon");
var campaignParticipantsAmount = 0;
var targetTable = vars.get("$param.dataSourceTableName_param");
var selectionRowIds = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param"));
var selectedCampaignId = vars.get("$field.CAMPAIGN_ID");
var selectedCampaignStepId = vars.get("$field.CAMPAIGNSTEP_ID");
var isUpdate = vars.get("$field.isUpdate");
var participantCondition = "";
var messageString = "";
var resultValue = "false";
if(selectedCampaignId != '')
{
/*
* First determines how many of the selected are already in the campaign
* If there are no valid participants at all or too many in respect of the
* selected steps max number of participants, nothing will be added.
* A message describing this situation will be written.
*
* If none of those criteria match, all participants are good to be added.
*/
var countParticipantsAlreadyInCampaign = 0;
var countParticipantsToAdd = 0;
var countValidParticipantsToAdd = 0;
var whereCondition = "";
var rowIdsComparisonField = "";
//if theres a selection, we have to use it, otherwise use the condition
if(selectionRowIds != null && selectionRowIds.length > 0)
{
countParticipantsToAdd = selectionRowIds.length;
/*
* The field against which will be checked, if the selection is already contained in the campaignStep
* depends on wether isUpdate is true or not.
* If true, the selected IDs are CampaignParticipantIds, otherwise contactIds.
* This happens because on true the action is called in the participants filterview to move participants
* between steps, on false new participants are in the process of being added to a step.
*/
if(isUpdate == "true")
{
rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID";
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'";
}
else
{
rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CONTACT_ID";
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
}
countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByRowId(whereCondition, rowIdsComparisonField, selectionRowIds);
}
else
{
participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition;
let useRightJoinToGetOrgs = "false";
if(targetTable == "ORGANISATION")
{
useRightJoinToGetOrgs = "true";
//Necessary because organisations don't have a personid'
participantCondition += " and PERSON.PERSONID is NULL"
}
countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition, isUpdate, useRightJoinToGetOrgs);
/*
* If the update mode is active, the goal is to move participants between steps.
* therefore the check if the affected participants already are added to a particluar step has to be on the step level.
*
* If not, participants are to be added. It has to be checked if a participant is in a campaign, regardless of the particular
* step because one participant can be in a campaign just once.
*/
if(isUpdate == "true")
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'";
else
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByCondition(whereCondition, participantCondition, useRightJoinToGetOrgs);
}
countValidParticipantsToAdd = countParticipantsToAdd - countParticipantsAlreadyInCampaign;
if(countParticipantsToAdd <= 0)
{
messageString = translate.text("No contacts selected");
}
else if(countValidParticipantsToAdd <= 0)
{
messageString = translate.text("All selected participants already are in the campaign");
}
else
{
let excess = getParticipantExcess(countValidParticipantsToAdd);
if (excess > 0)
{
messageString = translate.withArguments("Not enough slots for %0/%1 participant(s)", [excess, countParticipantsToAdd]);
}
else
{
messageString = translate.withArguments("%0/%1 participant(s) will be added to the selected campaign step", [countValidParticipantsToAdd, countParticipantsToAdd]);
resultValue = "true";
}
}
neon.setFieldValue("$field.campaignParticipantMessage", messageString);
result.string(resultValue);
}
function getParticipantExcess (pCountToAdd)
{
let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId)
let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId)
return (parseInt(currentParticipants) + parseInt(pCountToAdd)) - maxParticipants;
import("Campaign_lib");
import("system.result");
import("system.translate");
import("system.vars");
import("system.neon");
var campaignParticipantsAmount = 0;
var targetTable = vars.get("$param.dataSourceTableName_param");
var selectionRowIds = JSON.parse(vars.getString("$param.campaignParticipantsRowIds_param"));
var selectedCampaignId = vars.get("$field.CAMPAIGN_ID");
var selectedCampaignStepId = vars.get("$field.CAMPAIGNSTEP_ID");
var isUpdate = vars.get("$field.isUpdate");
var participantCondition = "";
var messageString = "";
var resultValue = "false";
if(selectedCampaignId != '')
{
/*
* First determines how many of the selected are already in the campaign
* If there are no valid participants at all or too many in respect of the
* selected steps max number of participants, nothing will be added.
* A message describing this situation will be written.
*
* If none of those criteria match, all participants are good to be added.
*/
var countParticipantsAlreadyInCampaign = 0;
var countParticipantsToAdd = 0;
var countValidParticipantsToAdd = 0;
var whereCondition = "";
var rowIdsComparisonField = "";
//if theres a selection, we have to use it, otherwise use the condition
if(selectionRowIds != null && selectionRowIds.length > 0)
{
countParticipantsToAdd = selectionRowIds.length;
/*
* The field against which will be checked, if the selection is already contained in the campaignStep
* depends on wether isUpdate is true or not.
* If true, the selected IDs are CampaignParticipantIds, otherwise contactIds.
* This happens because on true the action is called in the participants filterview to move participants
* between steps, on false new participants are in the process of being added to a step.
*/
if(isUpdate == "true")
{
rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID";
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'";
}
else
{
rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CONTACT_ID";
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
}
countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByRowId(whereCondition, rowIdsComparisonField, selectionRowIds);
}
else
{
participantCondition = JSON.parse(vars.getString("$param.campaignParticipantsCondition_param")).condition;
let useRightJoinToGetOrgs = "false";
if(targetTable == "ORGANISATION")
{
useRightJoinToGetOrgs = "true";
//Necessary because organisations don't have a personid'
participantCondition += " and PERSON.PERSONID is NULL"
}
countParticipantsToAdd = CampaignUtils.GetContactCountByCondition(participantCondition, isUpdate, useRightJoinToGetOrgs);
/*
* If the update mode is active, the goal is to move participants between steps.
* therefore the check if the affected participants already are added to a particluar step has to be on the step level.
*
* If not, participants are to be added. It has to be checked if a participant is in a campaign, regardless of the particular
* step because one participant can be in a campaign just once.
*/
if(isUpdate == "true")
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'";
else
whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByCondition(whereCondition, participantCondition, useRightJoinToGetOrgs);
}
countValidParticipantsToAdd = countParticipantsToAdd - countParticipantsAlreadyInCampaign;
if(countParticipantsToAdd <= 0)
{
messageString = translate.text("No contacts selected");
}
else if(countValidParticipantsToAdd <= 0)
{
messageString = translate.text("All selected participants already are in the campaign");
}
else
{
let excess = getParticipantExcess(countValidParticipantsToAdd);
if (excess > 0)
{
messageString = translate.withArguments("Not enough slots for %0/%1 participant(s)", [excess, countParticipantsToAdd]);
}
else
{
messageString = translate.withArguments("%0/%1 participant(s) will be added to the selected campaign step", [countValidParticipantsToAdd, countParticipantsToAdd]);
resultValue = "true";
}
}
neon.setFieldValue("$field.campaignParticipantMessage", messageString);
result.string(resultValue);
}
function getParticipantExcess (pCountToAdd)
{
let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId)
let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId)
return (parseInt(currentParticipants) + parseInt(pCountToAdd)) - maxParticipants;
}
\ No newline at end of file
import("system.result");
import("Sql_lib");
import("system.db");
import("system.vars");
import("system.neon");
import("Campaign_lib");
var commres = CampaignUtils.checkforCommRestrictions(vars.get("$field.CONTACT_ID"), vars.get("$field.CAMPAIGNSTEP_ID"));
if(commres)
{
result.string(neon.PRIORITY_HIGH_COLOR);
}
else
{
result.string(neon.PRIORITY_LOW_COLOR);
}
import("system.result");
import("Sql_lib");
import("system.db");
import("system.vars");
import("system.neon");
import("Campaign_lib");
var commres = CampaignUtils.checkforCommRestrictions(vars.get("$field.CONTACT_ID"), vars.get("$field.CAMPAIGNSTEP_ID"));
if(commres)
{
result.string(neon.PRIORITY_HIGH_COLOR);
}
else
{
result.string(neon.PRIORITY_LOW_COLOR);
}
import("system.vars");
import("system.result");
import("KeywordRegistry_basic");
import("Keyword_lib");
import("Sql_lib");
import("system.db");
import("Campaign_lib");
var commres = CampaignUtils.checkforCommRestrictions(vars.get("$field.CONTACT_ID"), vars.get("$field.CAMPAIGNSTEP_ID"));
if(commres)
{
var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(commres, $KeywordRegistry.communicationMediumCampaign())
result.string(keywordAttributes.AdvertisingBanIcon);
}
else
{
result.string("VAADIN:CHECK");
import("system.vars");
import("system.result");
import("KeywordRegistry_basic");
import("Keyword_lib");
import("Sql_lib");
import("system.db");
import("Campaign_lib");
var commres = CampaignUtils.checkforCommRestrictions(vars.get("$field.CONTACT_ID"), vars.get("$field.CAMPAIGNSTEP_ID"));
if(commres)
{
var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(commres, $KeywordRegistry.communicationMediumCampaign())
result.string(keywordAttributes.AdvertisingBanIcon);
}
else
{
result.string("VAADIN:CHECK");
}
\ No newline at end of file
This diff is collapsed.
......@@ -2,6 +2,6 @@ import("system.db");
import("system.vars");
import("system.result");
var minutes = db.cell("select sum(MINUTES) from TIMETRACKING");
var minutes = db.cell("select sum(TRACKINGMINUTES) from TIMETRACKING");
result.string(minutes);
\ No newline at end of file
import("system.vars");
import("system.result");
import("Timetracking_lib");
result.string(Timetracking.minutesToReadableHour(parseInt(vars.getString("$field.MINUTES"))));
\ No newline at end of file
import("system.vars");
import("system.result");
import("Timetracking_lib");
result.string(Timetracking.minutesToReadableHour(parseInt(vars.getString("$field.TRACKINGMINUTES"))));
\ No newline at end of file
......@@ -2,6 +2,6 @@ import("system.vars");
import("system.result");
import("system.neon");
var year = vars.get("$field.DATE")
var year = vars.get("$field.TRACKINGDATE")
result.string(year);
\ No newline at end of file
<?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.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2">
<name>AttributeEdit_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<isSmall v="true" />
<layout>
<noneLayout>
<name>layout</name>
</noneLayout>
</layout>
<children>
<genericViewTemplate>
<name>Edit</name>
<editMode v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>2d269ed7-a664-40c3-aadb-f274f7c00a66</name>
<entityField>ATTRIBUTE_PARENT_ID</entityField>
</entityFieldLink>
<entityFieldLink>
<name>0c6cd7c6-cced-4719-b0c5-08f8e3d13f2f</name>
<entityField>ATTRIBUTE_NAME</entityField>
</entityFieldLink>
<entityFieldLink>
<name>8cbc6049-2530-4960-b45f-830f3220889e</name>
<entityField>ATTRIBUTE_TYPE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>529f9734-182e-46f3-ad89-14dc5656f307</name>
<entityField>DROPDOWNDEFINITION</entityField>
</entityFieldLink>
<entityFieldLink>
<name>d26696ac-199c-45f0-9147-b75dee3f4b65</name>
<entityField>ATTRIBUTE_ACTIVE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>c8a5f45e-8092-45f4-ac22-681700447235</name>
<entityField>ATTRIBUTE_LEVEL</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<neonViewReference>
<name>8387ef27-9565-400f-a0d5-ef1d2019b722</name>
<entityField>AttributeUsages</entityField>
<view>AttributeUsageMultiEdit_view</view>
</neonViewReference>
</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.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2">
<name>AttributeEdit_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<isSmall v="true" />
<layout>
<noneLayout>
<name>layout</name>
</noneLayout>
</layout>
<children>
<genericViewTemplate>
<name>Edit</name>
<editMode v="true" />
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>2d269ed7-a664-40c3-aadb-f274f7c00a66</name>
<entityField>ATTRIBUTE_PARENT_ID</entityField>
</entityFieldLink>
<entityFieldLink>
<name>0c6cd7c6-cced-4719-b0c5-08f8e3d13f2f</name>
<entityField>ATTRIBUTE_NAME</entityField>
</entityFieldLink>
<entityFieldLink>
<name>8cbc6049-2530-4960-b45f-830f3220889e</name>
<entityField>ATTRIBUTE_TYPE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>529f9734-182e-46f3-ad89-14dc5656f307</name>
<entityField>DROPDOWNDEFINITION</entityField>
</entityFieldLink>
<entityFieldLink>
<name>d26696ac-199c-45f0-9147-b75dee3f4b65</name>
<entityField>ATTRIBUTE_ACTIVE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>c8a5f45e-8092-45f4-ac22-681700447235</name>
<entityField>ATTRIBUTE_LEVEL</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<neonViewReference>
<name>8387ef27-9565-400f-a0d5-ef1d2019b722</name>
<entityField>AttributeUsages</entityField>
<view>AttributeUsageMultiEdit_view</view>
</neonViewReference>
</children>
</neonView>
import("Sql_lib");
import("system.db");
import("system.neon");
import("Context_lib");
/**
* Methods used for time tracking.
* Do not create an instance of this!
*
* @class
*/
function Timetracking() {}
/**
* calculates the total time of all time trackings of the object
*
* @param {String} pRowId the rowId
*
* @return {Number} total time in minutes
*/
Timetracking.getTotalTrackingTime = function (pRowId)
{
var objectId = ContextUtils.getCurrentContextId();
var totalMinutes = db.cell(SqlCondition.begin()
.andPrepare("TIMETRACKING.OBJECT_ID", objectId)
.andPrepare("TIMETRACKING.ROW_ID", pRowId)
.buildSql("select sum(MINUTES) from TIMETRACKING", "1=0"));
return Number(totalMinutes);
}
/**
* Create a new time tracking
*
* @param {String} pRowId the rowId
*
* @return {Number} total time in minutes
*/
Timetracking.createNewTimeTracking = function (pRowId)
{
var objectId = ContextUtils.getCurrentContextId();
var params = {
"ObjectId_param" : objectId,
"RowId_param" : pRowId
};
neon.openContext("Timetracking", null, null, neon.OPERATINGSTATE_NEW, params);
}
/*
* converts minutes tho hours and minuets. e.g. 105 to 1:45
*
* @param {integer} pMinutes req
*
* @return {String} Hours:Minutes
*/
Timetracking.minutesToReadableHour = function(pMinutes)
{
var timeHour = parseInt(pMinutes / 60);
var minutes = parseInt(pMinutes % 60);
return "" + timeHour + ":" + ((minutes <= 9) ? "0" + minutes : minutes);
import("Sql_lib");
import("system.db");
import("system.neon");
import("Context_lib");
/**
* Methods used for time tracking.
* Do not create an instance of this!
*
* @class
*/
function Timetracking() {}
/**
* calculates the total time of all time trackings of the object
*
* @param {String} pRowId the rowId
*
* @return {Number} total time in minutes
*/
Timetracking.getTotalTrackingTime = function (pRowId)
{
var objectId = ContextUtils.getCurrentContextId();
var totalMinutes = db.cell(SqlCondition.begin()
.andPrepare("TIMETRACKING.OBJECT_ID", objectId)
.andPrepare("TIMETRACKING.ROW_ID", pRowId)
.buildSql("select sum(TRACKINGMINUTES) from TIMETRACKING", "1=0"));
return Number(totalMinutes);
}
/**
* Create a new time tracking
*
* @param {String} pRowId the rowId
*
* @return {Number} total time in minutes
*/
Timetracking.createNewTimeTracking = function (pRowId)
{
var objectId = ContextUtils.getCurrentContextId();
var params = {
"ObjectId_param" : objectId,
"RowId_param" : pRowId
};
neon.openContext("Timetracking", null, null, neon.OPERATINGSTATE_NEW, params);
}
/*
* converts minutes tho hours and minuets. e.g. 105 to 1:45
*
* @param {integer} pMinutes req
*
* @return {String} Hours:Minutes
*/
Timetracking.minutesToReadableHour = function(pMinutes)
{
var timeHour = parseInt(pMinutes / 60);
var minutes = parseInt(pMinutes % 60);
return "" + timeHour + ":" + ((minutes <= 9) ? "0" + minutes : minutes);
}
\ 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