Search in sources :

Example 1 with HumanTaskDeadlineEvent

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

the class KogitoProcessEventSupportImpl method fireTaskNotification.

private void fireTaskNotification(KogitoProcessInstance instance, HumanTaskWorkItem workItem, Map<String, Object> notification, DeadlineType type, KieRuntime kruntime) {
    final HumanTaskDeadlineEvent event = new HumanTaskDeadlineEventImpl(instance, workItem, notification, type, kruntime);
    unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> notifyAllListeners(event, KogitoProcessEventListener::onHumanTaskDeadline)));
}
Also used : ProcessStartedEventImpl(org.drools.core.event.ProcessStartedEventImpl) ProcessCompletedEvent(org.kie.api.event.process.ProcessCompletedEvent) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) WorkUnit(org.kie.kogito.uow.WorkUnit) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) AbstractEventSupport(org.drools.core.event.AbstractEventSupport) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) DeadlineType(org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent.DeadlineType) KogitoProcessEventListener(org.kie.kogito.internal.process.event.KogitoProcessEventListener) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) Map(java.util.Map) UnitOfWorkManager(org.kie.kogito.uow.UnitOfWorkManager) SLAViolatedEventImpl(org.drools.core.event.SLAViolatedEventImpl) SignalEvent(org.kie.api.event.process.SignalEvent) ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) SignalEventImpl(org.drools.core.event.SignalEventImpl) ProcessCompletedEventImpl(org.drools.core.event.ProcessCompletedEventImpl) MessageEvent(org.kie.api.event.process.MessageEvent) KogitoNodeInstance(org.kie.kogito.internal.process.runtime.KogitoNodeInstance) MessageEventImpl(org.drools.core.event.MessageEventImpl) List(java.util.List) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) Transition(org.kie.kogito.process.workitem.Transition) KieRuntime(org.kie.api.runtime.KieRuntime) KogitoProcessEventSupport(org.kie.kogito.internal.process.event.KogitoProcessEventSupport) HumanTaskDeadlineEvent(org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent) SLAViolatedEvent(org.kie.api.event.process.SLAViolatedEvent) HumanTaskWorkItem(org.kie.kogito.process.workitem.HumanTaskWorkItem) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) ProcessWorkItemTransitionEvent(org.kie.kogito.internal.process.event.ProcessWorkItemTransitionEvent) HumanTaskDeadlineEvent(org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent) KogitoProcessEventListener(org.kie.kogito.internal.process.event.KogitoProcessEventListener)

Example 2 with HumanTaskDeadlineEvent

use of org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent 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

List (java.util.List)2 Map (java.util.Map)2 ProcessCompletedEvent (org.kie.api.event.process.ProcessCompletedEvent)2 ProcessNodeLeftEvent (org.kie.api.event.process.ProcessNodeLeftEvent)2 ProcessNodeTriggeredEvent (org.kie.api.event.process.ProcessNodeTriggeredEvent)2 ProcessVariableChangedEvent (org.kie.api.event.process.ProcessVariableChangedEvent)2 HumanTaskDeadlineEvent (org.kie.kogito.internal.process.event.HumanTaskDeadlineEvent)2 ProcessWorkItemTransitionEvent (org.kie.kogito.internal.process.event.ProcessWorkItemTransitionEvent)2 KogitoNodeInstance (org.kie.kogito.internal.process.runtime.KogitoNodeInstance)2 KogitoProcessInstance (org.kie.kogito.internal.process.runtime.KogitoProcessInstance)2 KogitoWorkItem (org.kie.kogito.internal.process.runtime.KogitoWorkItem)2 HumanTaskWorkItem (org.kie.kogito.process.workitem.HumanTaskWorkItem)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AbstractEventSupport (org.drools.core.event.AbstractEventSupport)1 MessageEventImpl (org.drools.core.event.MessageEventImpl)1