fjtirado commented on code in PR #4146:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4146#discussion_r2758810258


##########
api/kogito-api/src/main/java/org/kie/kogito/process/ProcessInstances.java:
##########
@@ -56,4 +56,20 @@ default Stream<ProcessInstance<T>> 
waitingForEventType(String eventType) {
     }
 
     Stream<ProcessInstance<T>> waitingForEventType(String eventType, 
ProcessInstanceReadMode mode);
+
+    default Stream<ProcessInstance<T>> acceptingEventType(String signalName, 
String id) {
+        return findById(id, ProcessInstanceReadMode.MUTABLE)
+                .filter(pi -> {
+                    // Check if waiting for event (traditional signal event)
+                    boolean isWaitingForSignal = Stream.concat(
+                            waitingForEventType(signalName, 
ProcessInstanceReadMode.READ_ONLY),
+                            waitingForEventType("Message-" + signalName, 
ProcessInstanceReadMode.READ_ONLY)).anyMatch(p -> p.id().equals(id));
+
+                    boolean isAdHocNode = pi.adHocFragments().stream()
+                            .anyMatch(fragment -> 
fragment.getName().equals(signalName));
+
+                    return isWaitingForSignal || isAdHocNode;
+                })
+                .stream();
+    }

Review Comment:
    why we cannot rely on waitingForEventType and have to add the 
Message-prefix?
   Im not saying is wrong, Im wondering why we have to search for both. 



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