Skip to content
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] Add new methods to only retrieve the BPMN semantic of elements in the model #2813

Closed
2 tasks done
Tracked by #2402
tbouffard opened this issue Aug 24, 2023 · 0 comments · Fixed by #2841
Closed
2 tasks done
Tracked by #2402
Assignees
Labels
BPMN diagram usability Something about the way we can interact with BPMN diagrams decision record Track project and architectural decisions enhancement New feature or request
Milestone

Comments

@tbouffard
Copy link
Member

tbouffard commented Aug 24, 2023

Is your feature request related to a problem? Please describe.
In v0.38.1, the BpmnElementsRegistry allows to retrieve elements of the model as BpmnSemantic type with their associated graphical representation in the DOM. In a lot of cases, callers don’t need the graphical part and have to do

const bpmnElements = bpmnVisualization.bpmnElementsRegistry.getElementsByIds(shapeId);
// Getting an array with only the semantic part
const bpmnSemantics = bpmnElements.map(elt => elt.bpmnSemantic);
....
// Or, processing the semantic part of all elements
for (const elt of bpmnElements) {
  const bpmnSemantic = elt.bpmnSemantic;
  ...
}

In this case, there is also extra processing on the bpmn-visualization side to get the HTMLElement (with query selectors).

Describe the solution you'd like
I propose to introduce 2 new methods in BpmnElementsRegistry to retrieve only the semantic of the model elements. This will also cover a part of #2402

getModelElementsByIds(bpmnElementIds: string | string[]): BpmnSemantic[];

// here we could document how to retrieve all elements
getModelElementsByKinds(bpmnKinds: BpmnElementKind | BpmnElementKind[]): BpmnSemantic[];

Decision about the implementation of getModelElementsByKinds

The existing getElementsByKindsretrieve the elements by first looking in the DOM, then get the BPMN Semantic.
For the new method, if we don't want to check the DOM, this requires to have a way to search in the model. The existing search by ids used a Map in SearchableModel which is pre-computed after the model has been loaded. We could create a new one by kinds.

As a first implementatoin, we decided with @csouchet to use the "DOM way". Having a new cache will impact all users (memory consumpting, time to pre-populate the cache) and we should ideally run tests and get metrics.
We don't want to do that for now (we don't have the test infrastructure to do it) and we prefer to impact only users that will use the new feature (if the DOM lookup has performance issues).
We may modify the implementation in the future depending on any feedback we receive.

Tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BPMN diagram usability Something about the way we can interact with BPMN diagrams decision record Track project and architectural decisions enhancement New feature or request
Projects
Archived in project
1 participant