gitgabrio commented on code in PR #6325:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6325#discussion_r2068208382


##########
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/ast/DMNConditionalEvaluator.java:
##########
@@ -101,8 +103,25 @@ static EvaluatorIdentifier 
getEvaluatorIdentifier(Map<EvaluatorType, EvaluatorId
                 .orElseThrow(() -> new RuntimeException("Missing " + type + " 
evaluator in evaluatorIdMap"));
     }
 
-    static String getDecisionName(DMNModelInstrumentedBase dmnElement) {
-        return dmnElement instanceof Decision decision ? decision.getName() : 
getDecisionName(dmnElement.getParentDRDElement());
+    /**
+     * Given a DMNModelInstrumentedBase element, it looks in the DMN hierarchy 
the element related Decision node name or
+     * BusinessKnowledgeModel node name
+     * @param dmnElement
+     * @return
+     */
+    static String getDecisionOrBkmName(DMNModelInstrumentedBase dmnElement) {
+        if (dmnElement instanceof Decision decision) {
+            return decision.getName();
+        }
+        if (dmnElement instanceof BusinessKnowledgeModel 
businessKnowledgeModel) {
+            return businessKnowledgeModel.getName();
+        }
+        if (dmnElement.getParentDRDElement() == null || dmnElement == 
dmnElement.getParentDRDElement()) {
+            logger.error("Root element id: {} reached. Can't find the related 
Decision or BKM node name", dmnElement.getIdentifierString());
+            throw new IllegalStateException("Root element id: " + 
dmnElement.getIdentifierString() + " reached. Can't find the related Decision 
or BKM node name.");

Review Comment:
   The `name` attribute of a decision is mandatory by specs, but I created that 
method to programmatically navigate the tree from a leaf element to identify 
the referring decision/bkm.
   But
   `if (dmnElement.getParentDRDElement() == null || dmnElement == 
dmnElement.getParentDRDElement()) {`
   actually is based on our implementation, and I'm not 100% sure that, 
somehow, we could have a situation where a Conditional (e.g.) does not have any 
- e.g.: what if it is defined inside an imported model, and referred by a 
decision that is in the importing model (just e.g. - I need to review the spec 
for this case).
   
   So, I think it would be safer - for the moment being - to simply return 
something like `(undefined)` - or similar.
   Wdyt ? Does this make sense ?
    



-- 
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