Skip to content

Commit

Permalink
Merge pull request #29 from PROCEED-Labs/supply-chain-communication
Browse files Browse the repository at this point in the history
Supply chain communication
  • Loading branch information
LucasMGo committed Jun 1, 2023
2 parents 4a8749c + 555dc37 commit 47548de
Show file tree
Hide file tree
Showing 16 changed files with 422 additions and 13 deletions.
14 changes: 14 additions & 0 deletions src/engine/e2e_tests/process/deployment/deployment.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,7 @@ describe('Test deploying a process', () => {
intermediateVariablesState: {},
milestones: {},
priority: 1,
performers: [],
},
]);

Expand All @@ -2043,6 +2044,7 @@ describe('Test deploying a process', () => {
instanceID: instanceId,
attrs: expect.any(Object),
priority: 1,
performers: [],
progress: 0,
startTime: expect.any(Number),
endTime: null,
Expand Down Expand Up @@ -2096,6 +2098,7 @@ describe('Test deploying a process', () => {
intermediateVariablesState: {},
milestones: {},
priority: 1,
performers: [],
},
]);

Expand All @@ -2119,6 +2122,7 @@ describe('Test deploying a process', () => {
instanceID: instanceId,
attrs: expect.any(Object),
priority: 1,
performers: [],
progress: 0,
startTime: expect.any(Number),
endTime: null,
Expand All @@ -2129,6 +2133,7 @@ describe('Test deploying a process', () => {
instanceID: instanceId,
attrs: expect.any(Object),
priority: 1,
performers: [],
progress: 0,
startTime: expect.any(Number),
endTime: null,
Expand Down Expand Up @@ -2163,6 +2168,7 @@ describe('Test deploying a process', () => {
progress: { value: 0, manual: false },
milestones: {},
priority: 1,
performers: [],
});

expect(instanceInfo.adaptationLog).toEqual([
Expand All @@ -2183,6 +2189,7 @@ describe('Test deploying a process', () => {
instanceID: instanceId,
attrs: expect.any(Object),
priority: 1,
performers: [],
progress: 0,
startTime: expect.any(Number),
endTime: null,
Expand Down Expand Up @@ -2264,6 +2271,7 @@ describe('Test deploying a process', () => {
instanceID: instanceId,
attrs: expect.any(Object),
priority: 1,
performers: [],
progress: 0,
startTime: expect.any(Number),
endTime: null,
Expand Down Expand Up @@ -2474,6 +2482,7 @@ describe('Test deploying a process', () => {
intermediateVariablesState: {},
milestones: {},
priority: 1,
performers: [],
},
]);
expect(instanceInfo.log).toEqual([
Expand Down Expand Up @@ -2505,6 +2514,7 @@ describe('Test deploying a process', () => {
progress: { value: 100, manual: false },
milestones: {},
priority: 1,
performers: [],
},
]);

Expand Down Expand Up @@ -2645,6 +2655,7 @@ describe('Test deploying a process', () => {
progress: { value: 0, manual: false },
milestones: {},
priority: 1,
performers: [],
},
{
tokenId: expect.any(String),
Expand All @@ -2661,6 +2672,7 @@ describe('Test deploying a process', () => {
progress: { value: 100, manual: false },
milestones: {},
priority: 1,
performers: [],
},
{
tokenId: expect.any(String),
Expand Down Expand Up @@ -2816,6 +2828,7 @@ describe('Test deploying a process', () => {
progress: { value: 0, manual: false },
milestones: {},
priority: 1,
performers: [],
},
{
tokenId: expect.any(String),
Expand All @@ -2832,6 +2845,7 @@ describe('Test deploying a process', () => {
progress: { value: 100, manual: false },
milestones: {},
priority: 1,
performers: [],
},
{
tokenId: expect.any(String),
Expand Down
9 changes: 8 additions & 1 deletion src/engine/universal/core/src/engine/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ class Engine {
machine: this.machineInformation,
progress: token.currentFlowNodeProgress,
priority: token.priority,
performers: token.performers,
});
}
});
Expand Down Expand Up @@ -744,7 +745,12 @@ class Engine {

const pendingUserTasksWithTokenInfo = pendingUserTasks.map((uT) => {
const token = this.getToken(uT.processInstance.id, uT.tokenId);
return { ...uT, priority: token.priority, progress: token.currentFlowNodeProgress.value };
return {
...uT,
priority: token.priority,
progress: token.currentFlowNodeProgress.value,
performers: token.performers,
};
});
return pendingUserTasksWithTokenInfo;
}
Expand All @@ -765,6 +771,7 @@ class Engine {
...uT,
priority: userTaskLogEntry.priority,
progress: userTaskLogEntry.progress.value,
performers: userTaskLogEntry.performers,
};
});
return inactiveUserTasksWithLogInfo;
Expand Down
7 changes: 7 additions & 0 deletions src/engine/universal/core/src/engine/hookCallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ module.exports = {
newInstance.updateToken(execution.tokenId, { priority: undefined });
}

if (token.performers) {
newInstance.updateLog(execution.flowElementId, execution.tokenId, {
performers: token.performers,
});
newInstance.updateToken(execution.tokenId, { performers: undefined });
}

const flowElement = newInstance.getFlowElement(execution.flowElementId);
if (flowElement && flowElement.$type === 'bpmn:UserTask') {
// update user task in list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
getMilestonesFromElementById,
getMetaData,
convertISODurationToMiliseconds,
getPerformersFromElementById,
} = require('@proceed/bpmn-helper');

/**
Expand Down Expand Up @@ -36,6 +37,7 @@ function onUserTask(engine, instance, tokenId, userTask) {

const token = engine.getToken(instance.id, tokenId);
const metaData = await getMetaData(bpmn, userTask.id);
const performers = await getPerformersFromElementById(bpmn, userTask.id);

const startTime = token.currentFlowElementStartTime;
let endTime = null;
Expand Down Expand Up @@ -72,6 +74,7 @@ function onUserTask(engine, instance, tokenId, userTask) {
instance.updateToken(tokenId, {
currentFlowNodeProgress: { value: 0, manual: false },
priority: metaData.defaultPriority | 1,
performers,
});

const initializedMilestones = (await getMilestonesFromElementById(bpmn, userTask.id)).reduce(
Expand Down
2 changes: 2 additions & 0 deletions src/engine/universal/core/src/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ const Management = {
...uT,
priority: userTaskToken.priority,
progress: userTaskToken.currentFlowNodeProgress.value,
performers: userTaskToken.performers,
};
} else {
const userTaskLogEntry = archivedInstance.log.find(
Expand All @@ -558,6 +559,7 @@ const Management = {
...uT,
priority: userTaskLogEntry.priority,
progress: userTaskLogEntry.progress.value,
performers: userTaskToken.performers,
};
}
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function showTaskList(tasks) {
state: task.dataset.state,
progress: task.dataset.progress,
priority: task.dataset.priority,
performers: task.dataset.performers,
}));

tasks.forEach((task) => {
Expand Down
34 changes: 34 additions & 0 deletions src/helper-modules/bpmn-helper/src/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,20 @@ async function getMilestonesFromElementById(bpmn, elementId) {
return getMilestonesFromElement(element);
}

/**
* Get the performers for given element id
*
* @param {(string|object)} bpmn - the process definition as XML string or BPMN-Moddle Object
* @param {String} elementId the id of the element
* @returns {Array} array with all performers
*/
async function getPerformersFromElementById(bpmn, elementId) {
const bpmnObj = typeof bpmn === 'string' ? await toBpmnObject(bpmn) : bpmn;
const element = getElementById(bpmnObj, elementId);

return getPerformersFromElement(element);
}

/**
* Parses the locations from a bpmn-moddle element
*
Expand Down Expand Up @@ -865,6 +879,24 @@ function getResourcesFromElement(element) {
return { consumableMaterial, tool, inspectionInstrument };
}

function getPerformersFromElement(element) {
if (element.resources) {
const potentialOwner = element.resources.find(
(resource) => resource.$type === 'bpmn:PotentialOwner'
);

if (
potentialOwner &&
potentialOwner.resourceAssignmentExpression &&
potentialOwner.resourceAssignmentExpression.expression &&
potentialOwner.resourceAssignmentExpression.expression.body
) {
return JSON.parse(potentialOwner.resourceAssignmentExpression.expression.body);
}
}
return [];
}

/**
* Parses ISO Duration String to number of years, months, days, hours, minutes and seconds
* @param {String} isoDuration
Expand Down Expand Up @@ -975,6 +1007,8 @@ module.exports = {
getMilestonesFromElementById,
getResourcesFromElement,
getLocationsFromElement,
getPerformersFromElement,
getPerformersFromElementById,
parseISODuration,
convertISODurationToMiliseconds,
};
Loading

0 comments on commit 47548de

Please sign in to comment.