Skip to content

Commit

Permalink
remove target.qname.prefix usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Sep 13, 2024
1 parent dda9611 commit ba8b40d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function usePotentialWaypointControls(
shapeId: edge.data?.dmnShapeTarget["@_id"],
},
keepWaypoints: false,
existingEdgeId: targetData.dmnObjectQName.prefix + ":" + edgeId, // produces value like: included0:_2081EEE3-7B1B-48B3-B3B9-944F0A013CF1
existingEdgeId: edgeId,
});
} else {
/**
Expand Down Expand Up @@ -215,17 +215,7 @@ export function usePotentialWaypointControls(
}

dmnEditorStoreApi.setState((state) => {
const edge = state.computed(state).getDiagramData(externalModelsByNamespace).edgesById.get(edgeId);
const targetData = state
.computed(state)
.getDiagramData(externalModelsByNamespace)
.nodesById.get(edge!.target)?.data;
const dmnEdgeIndex = state
.computed(state)
.indexedDrd()
.dmnEdgesByDmnElementRef.get(
(targetData?.dmnObjectQName.prefix ? targetData?.dmnObjectQName.prefix + ":" : "") + edgeId
)?.index;
const dmnEdgeIndex = state.computed(state).indexedDrd().dmnEdgesByDmnElementRef.get(edgeId)?.index;
if (dmnEdgeIndex === undefined) {
console.debug(`DMN MUTATION: DMNEdge for '${edgeId}' edge has missing index.`);
return;
Expand Down
21 changes: 19 additions & 2 deletions packages/dmn-editor/src/store/computed/computeDiagramData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ export function computeDiagramData(
};

// requirements
ackRequirementEdges(definitions["@_namespace"], definitions["@_namespace"], definitions.drgElement, ackEdge);
ackRequirementEdges(
definitions,
definitions["@_namespace"],
definitions["@_namespace"],
definitions.drgElement,
ackEdge
);

// associations
(definitions.artifact ?? []).forEach((dmnObject, index) => {
Expand Down Expand Up @@ -284,6 +290,7 @@ export function computeDiagramData(
(acc, [namespace, externalDmn]) => {
// Taking advantage of the loop to add the edges here...
ackRequirementEdges(
definitions,
definitions["@_namespace"],
externalDmn.model.definitions["@_namespace"],
externalDmn.model.definitions.drgElement,
Expand Down Expand Up @@ -404,6 +411,7 @@ export function computeDiagramData(
}

function ackRequirementEdges(
definitions: State["dmn"]["model"]["definitions"],
thisDmnsNamespace: string,
drgElementsNamespace: string,
drgElements: Normalized<DMN15__tDefinitions>["drgElement"],
Expand All @@ -416,8 +424,17 @@ function ackRequirementEdges(
if (dmnObject.__$$element === "decision") {
(dmnObject.informationRequirement ?? []).forEach((ir, index) => {
const irHref = parseXmlHref((ir.requiredDecision ?? ir.requiredInput)!["@_href"]);
let finalIncludedIndex = -1;
let includedIndex = 0;
while (definitions[`@_xmlns:included${includedIndex}`]) {
if (definitions[`@_xmlns:included${includedIndex}`] === namespace) {
finalIncludedIndex = includedIndex;
break;
}
includedIndex++;
}
ackEdge({
id: ir["@_id"]!,
id: (finalIncludedIndex > -1 ? `included${finalIncludedIndex}:` : "") + ir["@_id"]!,
dmnObject: {
namespace: drgElementsNamespace,
type: dmnObject.__$$element,
Expand Down

0 comments on commit ba8b40d

Please sign in to comment.