-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enrich links between edges and shapes in the internal model #2638
Changes from 10 commits
62fe6d3
15eabfd
5aac3de
5df3e62
12f2339
711ac90
9b7df68
6e20d89
263277e
c355f70
fd744ae
0b05c2f
d78b627
0e2105a
8019ae6
c5712a9
dedaaf9
1ad20e5
f2c963a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,11 @@ export default class ProcessConverter { | |
|
||
deserialize(processes: string | TProcess | (string | TProcess)[]): void { | ||
ensureIsArray(processes).forEach(process => this.parseProcess(process)); | ||
|
||
// Need to call this after all processes have been parsed, because to link a call activity to the elements of the called process, we have to parse all processes before. | ||
ensureIsArray(processes).forEach(process => this.assignParentOfProcessElementsCalledByCallActivity(process.id)); | ||
|
||
this.assignIncomingAndOutgoingIdsFromFlows(); | ||
} | ||
|
||
private assignParentOfProcessElementsCalledByCallActivity(processId: string): void { | ||
|
@@ -87,6 +90,26 @@ export default class ProcessConverter { | |
} | ||
} | ||
|
||
private assignIncomingAndOutgoingIdsFromFlows(): void { | ||
const fillShapeBpmnElementAttribute = ( | ||
shapeBpmnElementId: string, | ||
shapeBpmnElementAttributeName: keyof Pick<ShapeBpmnElement, 'outgoingIds' | 'incomingIds'>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: for simplicity, we may declare instead: shapeBpmnElementAttributeName: 'outgoingIds' | 'incomingIds' The 2 attributes won't be renamed (as they are part of the public API) so there is no risk of error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @tbouffard, I understand your suggestion to simplify the code by declaring the property names directly. Thanks for sharing your thoughts though! 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, that's fine. |
||
valueToAdd: string, | ||
): void => { | ||
const shapeBpmnElement = | ||
this.convertedElements.findFlowNode(shapeBpmnElementId) ?? this.convertedElements.findLane(shapeBpmnElementId) ?? this.convertedElements.findPoolById(shapeBpmnElementId); | ||
if (shapeBpmnElement && !shapeBpmnElement[shapeBpmnElementAttributeName].includes(valueToAdd)) { | ||
shapeBpmnElement[shapeBpmnElementAttributeName].push(valueToAdd); | ||
} | ||
}; | ||
|
||
const flows = [...this.convertedElements.getMessageFlows(), ...this.convertedElements.getSequenceFlows(), ...this.convertedElements.getAssociationFlows()]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I guess we didn't measure the impact of this new lookup on the parsing performance in particular on large diagram. We could modify the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we decided with @tbouffard, we will manage the perfomance tests in another issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After discussions with @csouchet, we decided to create a dedicated issue for the "parser performance": #2665 |
||
flows.forEach(flow => { | ||
fillShapeBpmnElementAttribute(flow.sourceRefId, 'outgoingIds', flow.id); | ||
fillShapeBpmnElementAttribute(flow.targetRefId, 'incomingIds', flow.id); | ||
}); | ||
} | ||
|
||
private parseProcess(process: TProcess): void { | ||
const processRef = process.id; | ||
const pool = this.convertedElements.findPoolByProcessRef(processRef); | ||
|
@@ -106,7 +129,7 @@ export default class ProcessConverter { | |
ShapeUtil.flowNodeKinds() | ||
.filter(kind => kind != ShapeBpmnElementKind.EVENT_BOUNDARY) | ||
.forEach(kind => this.buildFlowNodeBpmnElements(process[kind], kind, parentId, process.id)); | ||
// process boundary events afterwards as we need its parent activity to be available when building it | ||
// process boundary events afterward as we need its parent activity to be available when building it | ||
this.buildFlowNodeBpmnElements(process.boundaryEvent, ShapeBpmnElementKind.EVENT_BOUNDARY, parentId, process.id); | ||
|
||
// containers | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: why defining this function here and not as a private method of the class?
This is not consistent with the rest of the code (we always create private methods in this case).
It may be a good reason, in that case, I suggest to document it as this is unclear to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a technical method, only used within this context and I wasn't sure where to put it, I preferred to leave it here. But I am open to any ideas. ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK fine. Let's keep it as it is.