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

WorkflowTask_entity performance optimized

(cherry picked from commit 7f1d7b45)
parent 8fa41842
No related branches found
No related tags found
No related merge requests found
import("Employee_lib");
import("system.entities");
import("Context_lib");
import("Workflow_lib");
......@@ -11,7 +12,7 @@ var processKey = vars.get("$local.rowdata")["KEY.value"];
if (Array.isArray(variables.targetId) && variables.targetId.length > 0)
_startForIds(variables.targetId.slice(), variables);
else if (variables.targetId)
else if (!Array.isArray(variables.targetId) && variables.targetId)
_startForIds([variables.targetId], variables);
else if (targetIdFilter)
{
......@@ -24,13 +25,20 @@ else if (targetIdFilter)
loadConfig.filter(JSON.stringify(targetIdFilter.filter));
var rowCount = entities.getRowCount(loadConfig);
var pageSize = 400;
var pageSize = 1000;
for (let startRow = 0; startRow < rowCount; startRow += pageSize)
{
loadConfig.startrow(startRow).count(pageSize);
let targetIds = entities.getRows(loadConfig).map(function (row) {return row["#UID"];});
_startForIds(targetIds, variables);
}
//TODO: entities.getRows currently doesn't work on the server
// process.executeAsync("startWorkflowInstances_serverProcess", {
// processVariables : JSON.stringify(variables),
// processKey : processKey,
// entityFilter : targetIdFilter.filter ? JSON.stringify(targetIdFilter.filter) : ""
// }, false, EmployeeUtils.getCurrentUserName(), process.THREADPRIORITY_NORM, process.TIMERTYPE_SERVER);
}
function _startForIds (pTargetIds, pVariables)
......
......@@ -104,6 +104,7 @@
<title>Link</title>
<linkedContextProcess>%aditoprj%/entity/WorkflowTask_entity/entityfields/target_id/linkedContextProcess.js</linkedContextProcess>
<state>READONLY</state>
<displayValueProcess>%aditoprj%/entity/WorkflowTask_entity/entityfields/target_id/displayValueProcess.js</displayValueProcess>
</entityField>
<entityParameter>
<name>TaskTitle_param</name>
......@@ -192,9 +193,6 @@
<jDitoRecordFieldMapping>
<name>TARGET_ID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>TARGET_ID.displayValue</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CLAIM_TIME.value</name>
</jDitoRecordFieldMapping>
......
import("Context_lib");
import("system.result");
import("system.neon");
import("system.vars");
if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && vars.get("$field.TARGET_ID"))
result.string(ContextUtils.loadContentTitle(ContextUtils.getEntity(vars.get("$field.TARGET_CONTEXT")), vars.get("$field.TARGET_ID")));
......@@ -45,16 +45,22 @@ result.object((function ()
// loadConfig.candidateIdentifier(EmployeeUtils.getCurrentUserId());
tasks = JSON.parse(workflow.getTasks(loadConfig));
}
var assigneeCache = {
get : function (pKey)
{
if (!pKey)
return "";
if (!(pKey in this))
this[pKey] = ContextUtils.loadContentTitle("Employee_entity", pKey);
return this[pKey];
}
};
tasks = tasks.map(function (task)
{
var variables = JSON.parse(workflow.getTaskVariables(task.id));
var targetTitle = "";
if (variables.targetId && variables.targetContext)
targetTitle = ContextUtils.loadContentTitle(project.getContextStructure(variables.targetContext).entity, variables.targetId);
var assigneeName = task.assignee ? ContextUtils.loadContentTitle("Employee_entity", task.assignee) : "";
return [
task.id,
task.name,
......@@ -67,12 +73,11 @@ result.object((function ()
task.description || "",
task.category || "",
task.assignee || "",
assigneeName,
assigneeCache.get(task.assignee),
task.dueDate ? Date.parse(task.dueDate).toString() : "",
task.owner || "",
variables.targetContext || "",
variables.targetId || "",
targetTitle,
task.claimTime,
task.active,
task.priority
......
<?xml version="1.0" encoding="UTF-8"?>
<neonNotificationType xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonNotificationType/1.1.0">
<name>WorkflowsStarted</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
</neonNotificationType>
import("system.util");
import("system.notification");
import("system.workflow");
import("system.entities");
import("Context_lib");
import("system.vars");
//!!! Don't use this process, entities.getRows does not yet work on the server !!!
throw new Error("startWorkflowInstances_serverProcess: no")
var processKey = vars.get("$local.processKey");
var variables = JSON.parse(vars.get("$local.processVariables"));
var filter = vars.get("$local.entityFilter");
var entity = ContextUtils.getEntity(variables.targetContext);
var loadConfig = entities.createConfigForLoadingRows()
.entity(entity)
.fields(["#UID"]);
if (filter)
loadConfig.filter(filter);
var rowCount = entities.getRowCount(loadConfig);
var pageSize = 400;
for (let startRow = 0; startRow < rowCount; startRow += pageSize)
{
loadConfig.startrow(startRow).count(pageSize);
let targetIds = entities.getRows(loadConfig).map(function (row) {return row["#UID"];});
_startForIds(targetIds, variables);
}
function _startForIds (pTargetIds, pVariables)
{
pTargetIds.forEach(function (id)
{
pVariables.targetId = id;
workflow.startProcessByKey(processKey, pVariables);
});
}
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>startWorkflowInstances_serverProcess</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/startWorkflowInstances_serverProcess/process.js</process>
<alias>Data_alias</alias>
<variants>
<element>EXECUTABLE</element>
</variants>
</process>
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