2022-10-12 14:21:19 +00:00
|
|
|
/**
|
|
|
|
* Returns the moddelElement if it is a process, otherwise, returns the
|
|
|
|
*
|
|
|
|
* @param container
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2022-10-19 20:16:54 +00:00
|
|
|
export function findDataObjects(parent) {
|
2022-10-12 14:21:19 +00:00
|
|
|
let dataObjects = [];
|
2022-10-19 20:16:54 +00:00
|
|
|
let process;
|
|
|
|
if (!parent) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
if (parent.processRef) {
|
|
|
|
process = parent.processRef;
|
|
|
|
} else {
|
|
|
|
process = parent;
|
|
|
|
}
|
|
|
|
if (!process.flowElements) {
|
|
|
|
return [];
|
2022-10-12 14:21:19 +00:00
|
|
|
}
|
|
|
|
for (const element of process.flowElements) {
|
2022-11-24 19:59:09 +00:00
|
|
|
if (
|
|
|
|
element.$type === 'bpmn:DataObject' &&
|
|
|
|
dataObjects.indexOf(element) < 0
|
|
|
|
) {
|
2022-10-12 14:21:19 +00:00
|
|
|
dataObjects.push(element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dataObjects;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function findDataObject(process, id) {
|
|
|
|
for (const dataObj of findDataObjects(process)) {
|
|
|
|
if (dataObj.id === id) {
|
|
|
|
return dataObj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function findDataReferenceShapes(processShape, id) {
|
|
|
|
let refs = [];
|
|
|
|
for (const shape of processShape.children) {
|
|
|
|
if (shape.type === 'bpmn:DataObjectReference') {
|
|
|
|
if (shape.businessObject.dataObjectRef && shape.businessObject.dataObjectRef.id === id) {
|
|
|
|
refs.push(shape);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return refs;
|
|
|
|
}
|
2022-11-17 19:58:28 +00:00
|
|
|
|
|
|
|
export function idToHumanReadableName(id) {
|
2022-11-24 19:59:09 +00:00
|
|
|
const words = id.match(/[A-Za-z][a-z]*/g) || [id];
|
2022-11-17 19:58:28 +00:00
|
|
|
return words.map(capitalize).join(' ');
|
|
|
|
|
|
|
|
function capitalize(word) {
|
|
|
|
return word.charAt(0).toUpperCase() + word.substring(1);
|
|
|
|
}
|
|
|
|
}
|