diff --git a/entity/WorkflowInstance_entity/recordcontainers/jdito/onInsert.js b/entity/WorkflowInstance_entity/recordcontainers/jdito/onInsert.js index b305ebf995a10ce86e8a01b10a6e1c225f08a3a9..0c2f12489ab8ca2bab6589150163ed8cb3e1876e 100644 --- a/entity/WorkflowInstance_entity/recordcontainers/jdito/onInsert.js +++ b/entity/WorkflowInstance_entity/recordcontainers/jdito/onInsert.js @@ -1,3 +1,4 @@ +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) diff --git a/entity/WorkflowTask_entity/WorkflowTask_entity.aod b/entity/WorkflowTask_entity/WorkflowTask_entity.aod index 378580b2459a6093f7ff363314a3a285d0de3b07..f7a1b1a9539d11f520ea7dbbf9c294e6a9efcb95 100644 --- a/entity/WorkflowTask_entity/WorkflowTask_entity.aod +++ b/entity/WorkflowTask_entity/WorkflowTask_entity.aod @@ -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> diff --git a/entity/WorkflowTask_entity/entityfields/target_id/displayValueProcess.js b/entity/WorkflowTask_entity/entityfields/target_id/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..6114f95287815c744c4e9592fa363eeee8c70005 --- /dev/null +++ b/entity/WorkflowTask_entity/entityfields/target_id/displayValueProcess.js @@ -0,0 +1,7 @@ +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"))); diff --git a/entity/WorkflowTask_entity/recordcontainers/jdito/contentProcess.js b/entity/WorkflowTask_entity/recordcontainers/jdito/contentProcess.js index 60769b4b453cfa5ca56d8affa0db09a9337ec809..03a58967392cf3ff096c41a8f3fecdf2b665a36e 100644 --- a/entity/WorkflowTask_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/WorkflowTask_entity/recordcontainers/jdito/contentProcess.js @@ -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 diff --git a/neonNotificationType/WorkflowsStarted/WorkflowsStarted.aod b/neonNotificationType/WorkflowsStarted/WorkflowsStarted.aod new file mode 100644 index 0000000000000000000000000000000000000000..a4104e98672a86f9cdc603aa66ac55af4307082d --- /dev/null +++ b/neonNotificationType/WorkflowsStarted/WorkflowsStarted.aod @@ -0,0 +1,5 @@ +<?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> diff --git a/process/startWorkflowInstances_serverProcess/process.js b/process/startWorkflowInstances_serverProcess/process.js new file mode 100644 index 0000000000000000000000000000000000000000..cdb18b037c154aa3e6668bb228e754e5f24099e0 --- /dev/null +++ b/process/startWorkflowInstances_serverProcess/process.js @@ -0,0 +1,39 @@ +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); + }); +} diff --git a/process/startWorkflowInstances_serverProcess/startWorkflowInstances_serverProcess.aod b/process/startWorkflowInstances_serverProcess/startWorkflowInstances_serverProcess.aod new file mode 100644 index 0000000000000000000000000000000000000000..5d5de80f53c69c20e9c3190e3d8eb99775217a65 --- /dev/null +++ b/process/startWorkflowInstances_serverProcess/startWorkflowInstances_serverProcess.aod @@ -0,0 +1,10 @@ +<?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>