danielzhe commented on code in PR #2508:
URL:
https://github.com/apache/incubator-kie-tools/pull/2508#discussion_r1750711962
##########
packages/dmn-editor/src/mutations/repopulateInputDataAndDecisionsOnDecisionService.ts:
##########
@@ -76,6 +85,44 @@ export function
repopulateInputDataAndDecisionsOnDecisionService({
});
}
+ for (const hrefString of hrefsToDecisionsInsideDecisionService) {
+ const href = parseXmlHref(hrefString);
+ const externalModel = externalModelsByNamespace?.[href.namespace ?? ""];
+ if (externalModel) {
+ const externalDecision = (externalModel?.model as
Normalized<DmnLatestModel>).definitions.drgElement?.find(
+ (drgElement) => drgElement["@_id"] === href.id
+ ) as Normalized<DMN15__tDecision>;
+
+ if (externalDecision) {
+ (externalDecision.informationRequirement ?? []).flatMap((ir) => {
+ if (ir.requiredDecision) {
+ const externalHref = parseXmlHref(ir.requiredDecision["@_href"]);
+ // If the requiredDecision has namespace, it means that it is
pointing to a node in a 3rd model,
+ // not this one (the local model) neither the model in the
`href.namespace`.
+ if (externalHref.namespace) {
+ requirements.set(`${ir.requiredDecision["@_href"]}`,
"decisionIr");
+ } else {
+
requirements.set(`${href.namespace}${ir.requiredDecision["@_href"]}`,
"decisionIr");
+ }
+ } else if (ir.requiredInput) {
+ // If the requiredInput has namespace, it means that it is
pointing to a node in a 3rd model,
+ // not this one (the local model) neither the model in the
`href.namespace`.
+ const externalHref = parseXmlHref(ir.requiredInput["@_href"]);
+ if (externalHref.namespace) {
+ requirements.set(`${ir.requiredInput["@_href"]}`, "inputDataIr");
+ } else {
+
requirements.set(`${href.namespace}${ir.requiredInput["@_href"]}`,
"inputDataIr");
+ }
+ } else {
+ throw new Error(
+ `DMN MUTATION: Invalid information requirement referenced by
external DecisionService: '${externalDecision["@_id"]}'`
+ );
+ }
+ });
+ }
+ }
+ }
Review Comment:
Good point (the nesting)!
--
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]