Search in sources :

Example 1 with GroupedNamedDataType

use of org.kie.kogito.process.GroupedNamedDataType in project kogito-runtimes by kiegroup.

the class WorkItemNodeInstance method getEventDescriptions.

@Override
public Set<EventDescription<?>> getEventDescriptions() {
    List<NamedDataType> inputs = new ArrayList<>();
    for (ParameterDefinition paramDef : getWorkItemNode().getWork().getParameterDefinitions()) {
        inputs.add(new NamedDataType(paramDef.getName(), paramDef.getType()));
    }
    List<NamedDataType> outputs = new ArrayList<>();
    VariableScope variableScope = (VariableScope) getProcessInstance().getContextContainer().getDefaultContext(VARIABLE_SCOPE);
    getWorkItemNode().getOutAssociations().forEach(da -> da.getSources().forEach(s -> outputs.add(new NamedDataType(s.getLabel(), variableScope.findVariable(da.getTarget().getLabel()).getType()))));
    GroupedNamedDataType dataTypes = new GroupedNamedDataType();
    dataTypes.add("Input", inputs);
    dataTypes.add("Output", outputs);
    // return just the main completion type of an event
    return Collections.singleton(new IOEventDescription("workItemCompleted", getNodeDefinitionId(), getNodeName(), "workItem", getWorkItemId(), getProcessInstance().getStringId(), dataTypes));
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) NamedDataType(org.kie.kogito.process.NamedDataType) WorkflowProcessInstance(org.jbpm.workflow.instance.WorkflowProcessInstance) GroupedNamedDataType(org.kie.kogito.process.GroupedNamedDataType) STATE_COMPLETED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED) ProcessInstance(org.jbpm.process.instance.ProcessInstance) Context(org.jbpm.process.core.Context) ContextInstance(org.jbpm.process.instance.ContextInstance) Map(java.util.Map) WorkItemExecutionException(org.kie.kogito.process.workitem.WorkItemExecutionException) KogitoWorkItemNodeInstance(org.kie.kogito.internal.process.runtime.KogitoWorkItemNodeInstance) ABORTED(org.kie.api.runtime.process.WorkItem.ABORTED) Collection(java.util.Collection) Set(java.util.Set) VARIABLE_SCOPE(org.jbpm.process.core.context.variable.VariableScope.VARIABLE_SCOPE) KogitoProcessContextImpl(org.jbpm.process.instance.KogitoProcessContextImpl) KogitoNodeInstance(org.kie.kogito.internal.process.runtime.KogitoNodeInstance) VariableScope(org.jbpm.process.core.context.variable.VariableScope) List(java.util.List) ContextContainer(org.jbpm.process.core.ContextContainer) Node(org.jbpm.workflow.core.Node) KieRuntime(org.kie.api.runtime.KieRuntime) Model(org.kie.kogito.Model) ExceptionScopeInstance(org.jbpm.process.instance.context.exception.ExceptionScopeInstance) Entry(java.util.Map.Entry) Work(org.jbpm.process.core.Work) ParameterDefinition(org.jbpm.process.core.ParameterDefinition) InternalKogitoWorkItem(org.kie.kogito.process.workitems.InternalKogitoWorkItem) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) WorkflowRuntimeException(org.jbpm.workflow.instance.WorkflowRuntimeException) AbstractProcessInstance(org.kie.kogito.process.impl.AbstractProcessInstance) ProcessWorkItemHandlerException(org.kie.api.runtime.process.ProcessWorkItemHandlerException) HashMap(java.util.HashMap) KogitoProcessRuntime(org.kie.kogito.internal.process.runtime.KogitoProcessRuntime) Function(java.util.function.Function) ArrayList(java.util.ArrayList) EventListener(org.kie.api.runtime.process.EventListener) NodeIoHelper(org.jbpm.workflow.core.impl.NodeIoHelper) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) ContextInstanceFactoryRegistry(org.jbpm.process.instance.impl.ContextInstanceFactoryRegistry) ContextInstanceContainer(org.jbpm.process.instance.ContextInstanceContainer) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Logger(org.slf4j.Logger) STATE_ABORTED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ABORTED) EnvironmentName(org.kie.api.runtime.EnvironmentName) VariableScopeInstance(org.jbpm.process.instance.context.variable.VariableScopeInstance) IOEventDescription(org.kie.kogito.process.IOEventDescription) COMPLETED(org.kie.api.runtime.process.WorkItem.COMPLETED) KogitoWorkItemImpl(org.kie.kogito.process.workitems.impl.KogitoWorkItemImpl) InternalProcessRuntime(org.jbpm.process.instance.InternalProcessRuntime) WorkItemHandlerNotFoundException(org.drools.core.WorkItemHandlerNotFoundException) ContextInstanceFactory(org.jbpm.process.instance.impl.ContextInstanceFactory) EventDescription(org.kie.kogito.process.EventDescription) InternalKogitoWorkItemManager(org.kie.kogito.process.workitems.InternalKogitoWorkItemManager) Processes(org.kie.kogito.process.Processes) Collections(java.util.Collections) NamedDataType(org.kie.kogito.process.NamedDataType) GroupedNamedDataType(org.kie.kogito.process.GroupedNamedDataType) GroupedNamedDataType(org.kie.kogito.process.GroupedNamedDataType) ArrayList(java.util.ArrayList) IOEventDescription(org.kie.kogito.process.IOEventDescription) VariableScope(org.jbpm.process.core.context.variable.VariableScope) ParameterDefinition(org.jbpm.process.core.ParameterDefinition)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Function (java.util.function.Function)1 WorkItemHandlerNotFoundException (org.drools.core.WorkItemHandlerNotFoundException)1 Context (org.jbpm.process.core.Context)1 ContextContainer (org.jbpm.process.core.ContextContainer)1 ParameterDefinition (org.jbpm.process.core.ParameterDefinition)1 Work (org.jbpm.process.core.Work)1 ExceptionScope (org.jbpm.process.core.context.exception.ExceptionScope)1 VariableScope (org.jbpm.process.core.context.variable.VariableScope)1 VARIABLE_SCOPE (org.jbpm.process.core.context.variable.VariableScope.VARIABLE_SCOPE)1 ContextInstance (org.jbpm.process.instance.ContextInstance)1