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

kie-issues#886: On the DMN Editor, adding waypoints to edges that don't have a corresponding DMNEdge associated with it should create the DMNEdge and add the waypoint normally #2546

Merged
merged 51 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
efa4577
kie-issues#886 On the DMN Editor, adding waypoints to edges that don'…
jomarko Aug 23, 2024
8eac192
Merge branch 'main' into kie-issues#886
jomarko Aug 26, 2024
7a79145
information requirement tests
jomarko Aug 26, 2024
de4b79f
add TODO tasks
jomarko Aug 26, 2024
5b1f21f
incorporate review feedback - @_href
jomarko Aug 26, 2024
05c48a2
drgNodes.toggle
jomarko Aug 26, 2024
dc80ddc
add tests
jomarko Aug 26, 2024
94db899
add missing test screenshots
jomarko Aug 28, 2024
8cfc2f5
cleanup spec.ts javadoc
jomarko Aug 28, 2024
eadc55e
Cleanup Diagram.tsx
jomarko Aug 28, 2024
b25ca85
addEdge in usePotentialWaypointControls
jomarko Aug 28, 2024
babe9a2
add logs
jomarko Aug 28, 2024
c2cbace
display waypoints on the edges targetting external nodes
jomarko Aug 30, 2024
632adeb
create DMNEdge targeting external node
jomarko Aug 30, 2024
f650d0a
Merge branch 'main' into kie-issues#886
jomarko Sep 9, 2024
d95740b
dmnElementRef in format [namespace]:[id]
jomarko Sep 9, 2024
ff2c7fc
documentation
jomarko Sep 9, 2024
77c96e5
Merge branch 'main' into kie-issues#886
jomarko Sep 10, 2024
fb13967
Merge branch 'main' into kie-issues#886
jomarko Sep 13, 2024
dda9611
allowExternalTarget refactoring
jomarko Sep 13, 2024
ba8b40d
remove target.qname.prefix usage
jomarko Sep 13, 2024
e3d0b79
remove non used code
jomarko Sep 13, 2024
4ea5a26
remove addEdgeTargetingExternal
jomarko Sep 13, 2024
8a2b8eb
Merge branch 'main' into kie-issues#886
jomarko Sep 16, 2024
411814d
fix onConnect
jomarko Sep 16, 2024
5bad3f8
fix deleteEdge
jomarko Sep 16, 2024
8b98787
Object.entries
jomarko Sep 17, 2024
3de7056
fix typo
jomarko Sep 18, 2024
b28961d
logs
jomarko Sep 18, 2024
1b7d807
simplified null checks
jomarko Sep 18, 2024
dd67a91
Merge branch 'main' into kie-issues#886
jomarko Sep 18, 2024
302ec19
review feedback
jomarko Sep 19, 2024
cb56865
review feedback
jomarko Sep 19, 2024
63c9187
remove extraArg
jomarko Sep 19, 2024
269d5a5
Merge branch 'main' into kie-issues#886
jomarko Sep 25, 2024
20ebd51
MUTATION -> DIAGRAM
jomarko Sep 25, 2024
e5eb1a0
Update packages/dmn-editor/src/diagram/edges/usePotentialWaypointCont…
jomarko Sep 25, 2024
f4207a8
Update packages/dmn-editor/src/diagram/edges/usePotentialWaypointCont…
jomarko Sep 25, 2024
bc8495e
targetsExternalNode
jomarko Sep 25, 2024
1da182f
throw error
jomarko Sep 25, 2024
4ac0a99
is valid connection
jomarko Sep 25, 2024
8eaa8b9
dmnEdgeIndex
jomarko Sep 25, 2024
6d6cc5b
incorporate review feedback
jomarko Sep 26, 2024
9be924f
Merge branch 'main' into kie-issues#886
jomarko Sep 26, 2024
a5044c8
fix != vs !==
jomarko Sep 26, 2024
d3fc589
Revert "incorporate review feedback"
jomarko Sep 26, 2024
79f64d2
incorporate review feedback - v2
jomarko Sep 26, 2024
38ce320
Merge branch 'main' into kie-issues#886
jomarko Sep 27, 2024
006000e
fix deleteEdge
jomarko Sep 27, 2024
3a77fd3
resolve conflicts with main
jomarko Oct 1, 2024
5ea16c2
Remove unnecessary Hook dependency
tiagobento Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions packages/dmn-editor/src/diagram/Diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,58 @@ export const Diagram = React.forwardRef<DiagramRef, { container: React.RefObject
},
},
});

const nodesById = state.computed(state).getDiagramData(externalModelsByNamespace).nodesById;
state
.computed(state)
.getDiagramData(externalModelsByNamespace)
.edgesById.forEach((edge, key) => {
const sourceData = nodesById.get(edge.source)?.data;
const sourceType = nodesById.get(edge.source)?.type;
const targetData = nodesById.get(edge.target)?.data;
const targetType = nodesById.get(edge.target)?.type;

// We want to add Edge only if both Source and Target are already present in DRD
if (
edge.data?.dmnShapeSource !== undefined &&
edge.data?.dmnShapeSource["dc:Bounds"] !== undefined &&
edge.data?.dmnShapeSource["@_id"] !== undefined &&
edge.data?.dmnShapeTarget &&
edge.data?.dmnShapeTarget["dc:Bounds"] !== undefined &&
edge.data?.dmnShapeTarget["@_id"] !== undefined &&
sourceData !== undefined &&
sourceType !== undefined &&
targetData !== undefined &&
targetType !== undefined
) {
addEdge({
definitions: state.dmn.model.definitions,
drdIndex: state.computed(state).getDrdIndex(),
edge: {
type: edge.type as EdgeType,
targetHandle: PositionalNodeHandleId.Center,
sourceHandle: PositionalNodeHandleId.Center,
autoPositionedEdgeMarker: undefined,
},
sourceNode: {
type: sourceType as NodeType,
data: sourceData,
href: edge.source.replace("#", ""),
bounds: edge.data?.dmnShapeSource["dc:Bounds"],
shapeId: edge.data?.dmnShapeSource["@_id"],
},
targetNode: {
type: targetType as NodeType,
href: edge.target.replace("#", ""),
data: targetData,
bounds: edge.data?.dmnShapeTarget["dc:Bounds"],
index: nodesById.get(edge.target)?.data.index ?? 0,
shapeId: edge.data?.dmnShapeTarget["@_id"],
},
keepWaypoints: false,
});
}
});
});
}
console.debug(`DMN DIAGRAM: Adding DRG node`, JSON.stringify(drgElement));
Expand Down
15 changes: 8 additions & 7 deletions packages/dmn-editor/src/mutations/addEdge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
DMN15__tInformationRequirement,
DMN15__tKnowledgeRequirement,
DMNDI15__DMNEdge,
DMNDI15__DMNShape,
} from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types";
import { PositionalNodeHandleId } from "../diagram/connections/PositionalNodeHandles";
import { EdgeType, NodeType } from "../diagram/connections/graphStructure";
Expand Down Expand Up @@ -195,20 +194,22 @@ export function addEdge({

function doesInformationRequirementsPointTo(a: Normalized<DMN15__tInformationRequirement>, nodeId: string) {
return (
a.requiredInput?.["@_href"] === `${nodeId}` || //
a.requiredDecision?.["@_href"] === `${nodeId}`
// use endsWith because @_href is sometimes prefixed with '#' and sometimes it is not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is in draft, but let me tell you already that using "endsWith" is not the way to go here. hrefs are structured strings, composed by a namespace and an id. They have this format:

  • #id; or
  • namespace#id; where namespace is an URL.

We have a special parsing method to treat those and separate namespace and id. See parseXmlHref.

a.requiredInput?.["@_href"].endsWith(`${nodeId}`) || a.requiredDecision?.["@_href"].endsWith(`${nodeId}`)
);
}

function doesKnowledgeRequirementsPointTo(a: Normalized<DMN15__tKnowledgeRequirement>, nodeId: string) {
return a.requiredKnowledge?.["@_href"] === `${nodeId}`;
// use endsWith because @_href is sometimes prefixed with '#' and sometimes it is not
return a.requiredKnowledge?.["@_href"].endsWith(`${nodeId}`);
}

function doesAuthorityRequirementsPointTo(a: Normalized<DMN15__tAuthorityRequirement>, nodeId: string) {
// use endsWith because @_href is sometimes prefixed with '#' and sometimes it is not
return (
a.requiredInput?.["@_href"] === `${nodeId}` ||
a.requiredDecision?.["@_href"] === `${nodeId}` ||
a.requiredAuthority?.["@_href"] === `${nodeId}`
a.requiredInput?.["@_href"].endsWith(`${nodeId}`) ||
a.requiredDecision?.["@_href"].endsWith(`${nodeId}`) ||
a.requiredAuthority?.["@_href"].endsWith(`${nodeId}`)
);
}

Expand Down
1 change: 0 additions & 1 deletion packages/dmn-editor/src/mutations/addShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import {
DC__Point,
DMN15__tDefinitions,
DMNDI15__DMNDecisionServiceDividerLine,
DMNDI15__DMNShape,
} from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types";
import { NodeType } from "../diagram/connections/graphStructure";
Expand Down
2 changes: 1 addition & 1 deletion packages/dmn-editor/src/mutations/addStandaloneNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { switchExpression } from "@kie-tools-core/switch-expression-ts";
import { DmnBuiltInDataType, generateUuid } from "@kie-tools/boxed-expression-component/dist/api";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been doing that kind of cleanup every time I see it. Nice!

import { generateUuid } from "@kie-tools/boxed-expression-component/dist/api";
import { DC__Bounds, DMN15__tDefinitions } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types";
import { NodeType } from "../diagram/connections/graphStructure";
import { NODE_TYPES } from "../diagram/nodes/NodeTypes";
Expand Down
Loading