elguardian commented on code in PR #3490:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3490#discussion_r1590653317


##########
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractNodeVisitor.java:
##########
@@ -79,6 +88,64 @@ public void visitNode(T node, BlockStmt body, VariableScope 
variableScope, Proce
         if (isAdHocNode(node) && !(node instanceof HumanTaskNode)) {
             metadata.addSignal(node.getName(), null);
         }
+        if (isExtendedNode(node)) {
+            ExtendedNodeImpl extendedNodeImpl = (ExtendedNodeImpl) node;
+            addScript(extendedNodeImpl, body, ON_ACTION_SCRIPT_METHOD, 
ExtendedNodeImpl.EVENT_NODE_ENTER);
+            addScript(extendedNodeImpl, body, ON_ACTION_SCRIPT_METHOD, 
ExtendedNodeImpl.EVENT_NODE_EXIT);
+        }
+    }
+
+    private void addScript(ExtendedNodeImpl extendedNodeImpl, BlockStmt body, 
String factoryMethod, String actionType) {
+        if (!extendedNodeImpl.hasActions(actionType)) {
+            return;
+        }
+        List<DroolsConsequenceAction> scripts = 
extendedNodeImpl.getActions(actionType).stream()
+                .filter(Predicate.not(Objects::isNull))
+                .filter(DroolsConsequenceAction.class::isInstance)
+                .map(DroolsConsequenceAction.class::cast)
+                .filter(e -> e.getConsequence() != null && 
!e.getConsequence().isBlank())
+                .toList();
+
+        for (DroolsConsequenceAction script : scripts) {
+            body.addStatement(getFactoryMethod(getNodeId((T) 
extendedNodeImpl), factoryMethod,
+                    new StringLiteralExpr(actionType),
+                    new StringLiteralExpr(script.getDialect()),
+                    new 
StringLiteralExpr(sanitizeString(script.getConsequence())),
+                    buildDroolsConsequenceAction(extendedNodeImpl, 
script.getDialect(), script.getConsequence())));
+            ;
+        }
+    }
+
+    private Expression buildDroolsConsequenceAction(ExtendedNodeImpl 
extendedNodeImpl, String dialect, String script) {
+        BlockStmt newDroolsConsequenceActionExpression = new BlockStmt();
+        if (script != null) {
+            if (dialect.contains("java")) {

Review Comment:
   changed



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