danielzhe commented on code in PR #2508:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2508#discussion_r1704532541


##########
packages/dmn-editor/src/mutations/addDecisionToDecisionService.ts:
##########
@@ -25,25 +25,42 @@ import { SnapGrid } from "../store/Store";
 import { MIN_NODE_SIZES } from "../diagram/nodes/DefaultSizes";
 import { NODE_TYPES } from "../diagram/nodes/NodeTypes";
 import { Normalized } from "../normalization/normalize";
+import {
+  DMN15__tBusinessKnowledgeModel,
+  DMN15__tDecision,
+  DMN15__tDecisionService,
+  DMN15__tInputData,
+  DMN15__tKnowledgeSource,
+} from "@kie-tools/dmn-marshaller/src/schemas/dmn-1_5/ts-gen/types";
+
+export type DrgElement =
+  | Normalized<{ __$$element: "decision" } & DMN15__tDecision>
+  | Normalized<{ __$$element: "businessKnowledgeModel" } & 
DMN15__tBusinessKnowledgeModel>
+  | Normalized<{ __$$element: "decisionService" } & DMN15__tDecisionService>
+  | Normalized<{ __$$element: "inputData" } & DMN15__tInputData>
+  | Normalized<{ __$$element: "knowledgeSource" } & DMN15__tKnowledgeSource>;
 
 export function addDecisionToDecisionService({
   definitions,
-  decisionId,
+  drgElement,
   decisionServiceId,
   drdIndex,
   snapGrid,
+  decisionShape,
+  elementId,
 }: {
   definitions: Normalized<DMN15__tDefinitions>;
-  decisionId: string;
+  drgElement: DrgElement;
   decisionServiceId: string;
   drdIndex: number;
   snapGrid: SnapGrid;
+  decisionShape: Normalized<DMNDI15__DMNShape>;
+  elementId: string;
 }) {

Review Comment:
   In fact, we don't have DRG element always in the definitions: the external 
nodes do not have DRG element, only DMNDI. The DRG we have in 
`selectedNodes[i].data.dmnObject` is a loaded DRG from the external model, 
that's why its ID is different to the internal one, the one in href. 
   See below:
   
   ```
     <decisionService name="New Decision Service" 
id="_A0908B2B-DBE7-41C7-B055-0C0DAD17CE54">
       <variable name="New Decision Service" 
id="_145CD7A7-B14D-4D63-B9D3-85601FC915B1" />
       <outputDecision 
href="https://kie.apache.org/dmn/_D19B0015-2CBD-4BA8-84A9-5F554D84A9E1#_05621ED4-9236-47F1-B93A-164A4527B136";
 />
       <encapsulatedDecision 
href="https://kie.apache.org/dmn/_D19B0015-2CBD-4BA8-84A9-5F554D84A9E1#_1991FB34-1253-4A54-AD3D-89697938DDFA";
 />
       <encapsulatedDecision href="#_8E89DDF6-7ABC-4FBF-A1B6-B68BC32A52AE" />
     </decisionService>
     <decision name="New Decision" id="_8E89DDF6-7ABC-4FBF-A1B6-B68BC32A52AE">
       <variable name="New Decision" id="_BFB8A43B-5ADA-47D8-815E-8A0505814AA1" 
/>
     </decision>
   ```
   
   Notice only the `8E89DDF6-7ABC-4FBF-A1B6-B68BC32A52AE` is present in the 
file. 
   The other nodes are not, only as a `dmndi`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to