Search in sources :

Example 1 with IOEventDescription

use of io.automatiko.engine.api.workflow.IOEventDescription in project automatiko-engine by automatiko-io.

the class WorkItemNodeInstance method getEventDescriptions.

@SuppressWarnings("unchecked")
@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<>();
    Map<String, Object> dataOutputs = (Map<String, Object>) getWorkItemNode().getMetaData().getOrDefault("DataOutputs", Collections.emptyMap());
    for (Entry<String, Object> dOut : dataOutputs.entrySet()) {
        outputs.add(new NamedDataType(dOut.getKey(), dOut.getValue()));
    }
    GroupedNamedDataType dataTypes = new GroupedNamedDataType();
    dataTypes.add("Input", inputs);
    dataTypes.add("Output", outputs);
    Map<String, String> properties = new HashMap<>();
    if (getWorkItem() instanceof HumanTaskWorkItem) {
        properties.put("ActualOwner", ((HumanTaskWorkItem) getWorkItem()).getActualOwner());
        properties.put("PotentialUsers", ((HumanTaskWorkItem) getWorkItem()).getPotentialUsers().stream().collect(Collectors.joining(",")));
        properties.put("PotentialGroups", ((HumanTaskWorkItem) getWorkItem()).getPotentialGroups().stream().collect(Collectors.joining(",")));
    }
    // return just the main completion type of an event
    return Collections.singleton(new IOEventDescription("workItemCompleted", getNodeDefinitionId(), getNodeName(), "workItem", getWorkItemId(), getProcessInstance().getId(), dataTypes, properties));
}
Also used : HashMap(java.util.HashMap) GroupedNamedDataType(io.automatiko.engine.api.workflow.GroupedNamedDataType) ArrayList(java.util.ArrayList) IOEventDescription(io.automatiko.engine.api.workflow.IOEventDescription) HumanTaskWorkItem(io.automatiko.engine.api.runtime.process.HumanTaskWorkItem) NamedDataType(io.automatiko.engine.api.workflow.NamedDataType) GroupedNamedDataType(io.automatiko.engine.api.workflow.GroupedNamedDataType) Map(java.util.Map) HashMap(java.util.HashMap) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition)

Aggregations

HumanTaskWorkItem (io.automatiko.engine.api.runtime.process.HumanTaskWorkItem)1 GroupedNamedDataType (io.automatiko.engine.api.workflow.GroupedNamedDataType)1 IOEventDescription (io.automatiko.engine.api.workflow.IOEventDescription)1 NamedDataType (io.automatiko.engine.api.workflow.NamedDataType)1 ParameterDefinition (io.automatiko.engine.workflow.base.core.ParameterDefinition)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1