Search in sources :

Example 1 with KogitoProcessVariableChangedEvent

use of org.kie.kogito.internal.process.event.KogitoProcessVariableChangedEvent in project kogito-runtimes by kiegroup.

the class ProcessInstanceEventBatch method events.

@Override
public Collection<DataEvent<?>> events() {
    Map<String, ProcessInstanceEventBody> processInstances = new LinkedHashMap<>();
    Map<String, UserTaskInstanceEventBody> userTaskInstances = new LinkedHashMap<>();
    Set<VariableInstanceEventBody> variables = new LinkedHashSet<>();
    Collection<DataEvent<?>> processedEvents = new ArrayList<>();
    for (ProcessEvent event : rawEvents) {
        ProcessInstanceEventBody body = processInstances.computeIfAbsent(((KogitoProcessInstance) event.getProcessInstance()).getStringId(), key -> create(event));
        if (event instanceof ProcessNodeTriggeredEvent) {
            handleProcessNodeTriggeredEvent((ProcessNodeTriggeredEvent) event, body);
        } else if (event instanceof ProcessNodeLeftEvent) {
            handleProcessNodeLeftEvent((ProcessNodeLeftEvent) event, body);
        } else if (event instanceof ProcessCompletedEvent) {
            handleProcessCompletedEvent((ProcessCompletedEvent) event, body);
        } else if (event instanceof ProcessWorkItemTransitionEvent) {
            handleProcessWorkItemTransitionEvent((ProcessWorkItemTransitionEvent) event, userTaskInstances);
        } else if (event instanceof ProcessVariableChangedEvent) {
            handleProcessVariableChangedEvent((KogitoProcessVariableChangedEvent) event, variables);
        } else if (event instanceof HumanTaskDeadlineEvent) {
            processedEvents.add(buildUserTaskDeadlineEvent((HumanTaskDeadlineEvent) event));
        }
    }
    processInstances.values().stream().map(pi -> new ProcessInstanceDataEvent(extractRuntimeSource(pi.metaData()), addons.toString(), pi.metaData(), pi)).forEach(processedEvents::add);
    userTaskInstances.values().stream().map(pi -> new UserTaskInstanceDataEvent(extractRuntimeSource(pi.metaData()), addons.toString(), pi.metaData(), pi)).forEach(processedEvents::add);
    variables.stream().map(pi -> new VariableInstanceDataEvent(extractRuntimeSource(pi.metaData()), addons.toString(), pi.metaData(), pi)).forEach(processedEvents::add);
    return processedEvents;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) KogitoProcessVariableChangedEvent(org.kie.kogito.internal.process.event.KogitoProcessVariableChangedEvent) ProcessCompletedEvent(org.kie.api.event.process.ProcessCompletedEvent) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) Map(java.util.Map) KogitoWorkflowProcessInstance(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance) UserTaskInstanceDataEvent(org.kie.kogito.services.event.UserTaskInstanceDataEvent) ProcessInstanceDataEvent(org.kie.kogito.services.event.ProcessInstanceDataEvent) Addons(org.kie.kogito.Addons) LinkedHashSet(java.util.LinkedHashSet) ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) EventBatch(org.kie.kogito.event.EventBatch) KogitoProcessVariableChangedEvent(org.kie.kogito.internal.process.event.KogitoProcessVariableChangedEvent) Collection(java.util.Collection) Set(java.util.Set) KogitoNodeInstance(org.kie.kogito.internal.process.runtime.KogitoNodeInstance) Collectors(java.util.stream.Collectors) List(java.util.List) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) ProcessNodeEvent(org.kie.api.event.process.ProcessNodeEvent) UserTaskDeadlineDataEvent(org.kie.kogito.services.event.UserTaskDeadlineDataEvent) HumanTaskDeadlineEvent(org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent) DataEvent(org.kie.kogito.event.DataEvent) ProcessEvent(org.kie.api.event.process.ProcessEvent) HumanTaskWorkItem(org.kie.kogito.process.workitem.HumanTaskWorkItem) VariableInstanceDataEvent(org.kie.kogito.services.event.VariableInstanceDataEvent) ProcessWorkItemTransitionEvent(org.kie.kogito.internal.process.event.ProcessWorkItemTransitionEvent) HumanTaskDeadlineEvent(org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent) ProcessEvent(org.kie.api.event.process.ProcessEvent) ProcessWorkItemTransitionEvent(org.kie.kogito.internal.process.event.ProcessWorkItemTransitionEvent) ArrayList(java.util.ArrayList) UserTaskInstanceDataEvent(org.kie.kogito.services.event.UserTaskInstanceDataEvent) ProcessInstanceDataEvent(org.kie.kogito.services.event.ProcessInstanceDataEvent) UserTaskDeadlineDataEvent(org.kie.kogito.services.event.UserTaskDeadlineDataEvent) DataEvent(org.kie.kogito.event.DataEvent) VariableInstanceDataEvent(org.kie.kogito.services.event.VariableInstanceDataEvent) ProcessCompletedEvent(org.kie.api.event.process.ProcessCompletedEvent) LinkedHashMap(java.util.LinkedHashMap) VariableInstanceDataEvent(org.kie.kogito.services.event.VariableInstanceDataEvent) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) UserTaskInstanceDataEvent(org.kie.kogito.services.event.UserTaskInstanceDataEvent) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) ProcessInstanceDataEvent(org.kie.kogito.services.event.ProcessInstanceDataEvent)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ProcessCompletedEvent (org.kie.api.event.process.ProcessCompletedEvent)1 ProcessEvent (org.kie.api.event.process.ProcessEvent)1 ProcessNodeEvent (org.kie.api.event.process.ProcessNodeEvent)1 ProcessNodeLeftEvent (org.kie.api.event.process.ProcessNodeLeftEvent)1 ProcessNodeTriggeredEvent (org.kie.api.event.process.ProcessNodeTriggeredEvent)1 ProcessVariableChangedEvent (org.kie.api.event.process.ProcessVariableChangedEvent)1 Addons (org.kie.kogito.Addons)1 DataEvent (org.kie.kogito.event.DataEvent)1 EventBatch (org.kie.kogito.event.EventBatch)1 HumanTaskDeadlineEvent (org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent)1 KogitoProcessVariableChangedEvent (org.kie.kogito.internal.process.event.KogitoProcessVariableChangedEvent)1 ProcessWorkItemTransitionEvent (org.kie.kogito.internal.process.event.ProcessWorkItemTransitionEvent)1