Skip to content

Commit

Permalink
rename source & target in sourceIds & targetId
Browse files Browse the repository at this point in the history
  • Loading branch information
csouchet committed Oct 3, 2023
1 parent c8ca3d0 commit fd8932a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/component/parser/json/converter/ProcessConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export default class ProcessConverter {
for (const [eventDefinition, bpmnEvent] of this.eventsByLinkEventDefinition) {
if (bpmnEvent instanceof ShapeBpmnThrowEvent) {
const target = linkEventDefinitions.find(([targetEventDefinition]) => eventDefinition.target === targetEventDefinition.id);
bpmnEvent.target = target?.[1]?.id;
bpmnEvent.targetId = target?.[1]?.id;
} else if (bpmnEvent instanceof ShapeBpmnCatchEvent) {
bpmnEvent.source = linkEventDefinitions
bpmnEvent.sourceIds = linkEventDefinitions
.filter(([sourceEventDefinition]) =>
Array.isArray(eventDefinition.source) ? eventDefinition.source.includes(sourceEventDefinition.id) : eventDefinition.source === sourceEventDefinition.id,
)
Expand Down
4 changes: 2 additions & 2 deletions src/component/registry/bpmn-model-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export class BpmnModelRegistry {
callActivityGlobalTaskKind: bpmnElement instanceof ShapeBpmnCallActivity ? bpmnElement.globalTaskKind : undefined,
callActivityKind: bpmnElement instanceof ShapeBpmnCallActivity ? bpmnElement.callActivityKind : undefined,
eventDefinitionKind: bpmnElement instanceof ShapeBpmnEvent ? bpmnElement.eventDefinitionKind : undefined,
linkEventSource: bpmnElement instanceof ShapeBpmnCatchEvent ? bpmnElement.source : undefined,
linkEventTarget: bpmnElement instanceof ShapeBpmnThrowEvent ? bpmnElement.target : undefined,
linkEventSourceIds: bpmnElement instanceof ShapeBpmnCatchEvent ? bpmnElement.sourceIds : undefined,
linkEventTargetId: bpmnElement instanceof ShapeBpmnThrowEvent ? bpmnElement.targetId : undefined,
incomingIds: bpmnElement.incomingIds,
outgoingIds: bpmnElement.outgoingIds,
parentId: bpmnElement.parentId,
Expand Down
4 changes: 2 additions & 2 deletions src/component/registry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ export interface ShapeBpmnSemantic extends BaseBpmnSemantic {
callActivityKind?: ShapeBpmnCallActivityKind;
/** Set when the {@link BaseBpmnSemantic.kind} relates to a BPMN event. */
eventDefinitionKind?: ShapeBpmnEventDefinitionKind;
linkEventSource?: string[];
linkEventTarget?: string;
linkEventSourceIds?: string[];
linkEventTargetId?: string;
incomingIds: string[];
outgoingIds: string[];
/**
Expand Down
4 changes: 2 additions & 2 deletions src/model/bpmn/internal/shape/ShapeBpmnElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class ShapeBpmnEvent extends ShapeBpmnElement {
* @internal
*/
export class ShapeBpmnCatchEvent extends ShapeBpmnEvent {
source: string[] = [];
sourceIds: string[] = [];
constructor(
id: string,
name: string,
Expand All @@ -117,7 +117,7 @@ export class ShapeBpmnCatchEvent extends ShapeBpmnEvent {
* @internal
*/
export class ShapeBpmnThrowEvent extends ShapeBpmnEvent {
target?: string;
targetId?: string;

constructor(
id: string,
Expand Down
2 changes: 1 addition & 1 deletion test/shared/model/bpmn-semantic-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function expectedFlowNode(bpmnSemantic: ShapeBpmnSemantic, expected: ExpectedFlo
expect(bpmnSemantic.outgoingIds).toEqual(expected.outgoing ?? []);
}

export type ExpectedEventElement = ExpectedFlowNodeElement & Pick<ShapeBpmnSemantic, 'eventDefinitionKind' | 'linkEventSource' | 'linkEventTarget'>;
export type ExpectedEventElement = ExpectedFlowNodeElement & Pick<ShapeBpmnSemantic, 'eventDefinitionKind' | 'linkEventSourceIds' | 'linkEventTargetId'>;

function expectEvent(bpmnSemantic: ShapeBpmnSemantic, expected: ExpectedEventElement): void {
expectedFlowNode(bpmnSemantic, expected);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/component/registry/bpmn-model-registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Bpmn Model registry', () => {
outgoing: ['outgoing_1', 'outgoing_2'],
parentId: 'parentId',
eventDefinitionKind: ShapeBpmnEventDefinitionKind.LINK,
linkEventSource: ['sourceId'],
linkEventSourceIds: ['sourceId'],
});
});

Expand All @@ -75,7 +75,7 @@ describe('Bpmn Model registry', () => {
outgoing: ['outgoing_1', 'outgoing_2'],
parentId: 'parentId',
eventDefinitionKind: ShapeBpmnEventDefinitionKind.LINK,
linkEventTarget: 'targetId',
linkEventTargetId: 'targetId',
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/unit/helpers/bpmn-model-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ export const verifyShape = (

if (expectedEvent.eventDefinitionKind === ShapeBpmnEventDefinitionKind.LINK) {
if (ShapeUtil.isCatchEvent(expectedShape.bpmnElementKind)) {
expect((event as ShapeBpmnCatchEvent).source).toEqual((expectedEvent as ExpectedCatchEventShape).source ?? []);
expect((event as ShapeBpmnCatchEvent).sourceIds).toEqual((expectedEvent as ExpectedCatchEventShape).source ?? []);
} else {
expect((event as ShapeBpmnThrowEvent).target).toEqual((expectedEvent as ExpectedThrowEventShape).target);
expect((event as ShapeBpmnThrowEvent).targetId).toEqual((expectedEvent as ExpectedThrowEventShape).target);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/unit/helpers/bpmn-model-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ export const associationFlowInModel = (id: string, name: string, source: string,
return flowInModel(newAssociationFlow, id, name, source, target);
};

export const startEventInModel = (id: string, name: string, extras?: ShapeBpmnElementExtraProperties, source?: string[]): BpmnModel => {
export const startEventInModel = (id: string, name: string, extras?: ShapeBpmnElementExtraProperties, sourceIds?: string[]): BpmnModel => {
const bpmnModel = newBpmnModel();
bpmnModel.flowNodes.push(newStartEvent('parentId', id, name, extras, source));
bpmnModel.flowNodes.push(newStartEvent('parentId', id, name, extras, sourceIds));
return bpmnModel;
};

export const endEventInModel = (id: string, name: string, extras?: ShapeBpmnElementExtraProperties, target?: string): BpmnModel => {
export const endEventInModel = (id: string, name: string, extras?: ShapeBpmnElementExtraProperties, targetId?: string): BpmnModel => {
const bpmnModel = newBpmnModel();
bpmnModel.flowNodes.push(newEndEvent('parentId', id, name, extras, target));
bpmnModel.flowNodes.push(newEndEvent('parentId', id, name, extras, targetId));
return bpmnModel;
};

Expand All @@ -103,14 +103,14 @@ export type ShapeBpmnElementExtraProperties = {
outgoingIds?: string[];
};

const newStartEvent = (parent: string, id: string, name: string, extras?: ShapeBpmnElementExtraProperties, source: string[] = []): Shape => {
const newStartEvent = (parent: string, id: string, name: string, extras?: ShapeBpmnElementExtraProperties, sourceIds: string[] = []): Shape => {
const bpmnElement = new ShapeBpmnStartEvent(id, name, ShapeBpmnEventDefinitionKind.LINK, parent);
bpmnElement.source = source;
bpmnElement.sourceIds = sourceIds;
return new Shape(buildShapeId(id), withExtras(bpmnElement, extras));
};
const newEndEvent = (parent: string, id: string, name: string, extras?: ShapeBpmnElementExtraProperties, target?: string): Shape => {
const newEndEvent = (parent: string, id: string, name: string, extras?: ShapeBpmnElementExtraProperties, targetId?: string): Shape => {
const bpmnElement = new ShapeBpmnThrowEvent(id, name, ShapeBpmnElementKind.EVENT_END, ShapeBpmnEventDefinitionKind.LINK, parent);
bpmnElement.target = target;
bpmnElement.targetId = targetId;
return new Shape(buildShapeId(id), withExtras(bpmnElement, extras));
};
const newBoundaryEvent = (parent: string, id: string, name: string): Shape =>
Expand Down

0 comments on commit fd8932a

Please sign in to comment.