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));
}
Aggregations