use of io.automatiko.engine.workflow.base.core.ParameterDefinition in project automatiko-engine by automatiko-io.
the class WorkItemNode method adjustInMapping.
public List<DataAssociation> adjustInMapping(String forEachInVariable) {
List<DataAssociation> result = new ArrayList<DataAssociation>();
if (forEachInVariable == null) {
return result;
}
Iterator<DataAssociation> it = inMapping.iterator();
while (it.hasNext()) {
DataAssociation association = it.next();
if (association.getTarget().equals(forEachInVariable)) {
it.remove();
Set<ParameterDefinition> params = work.getParameterDefinitions();
Iterator<ParameterDefinition> itp = params.iterator();
while (itp.hasNext()) {
ParameterDefinition param = (ParameterDefinition) itp.next();
if (param.getName().equals(association.getTarget())) {
((WorkImpl) work).removeParameterDefinition(param.getName());
}
}
result.add(association);
}
}
return result;
}
use of io.automatiko.engine.workflow.base.core.ParameterDefinition in project automatiko-engine by automatiko-io.
the class WorkItemTest method getWorkItemProcess.
private ExecutableProcess getWorkItemProcess(String processId, String workName) {
ExecutableProcess process = new ExecutableProcess();
process.setId(processId);
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("UserName");
variable.setType(new StringDataType());
variables.add(variable);
variable = new Variable();
variable.setName("Person");
variable.setType(new ObjectDataType(Person.class));
variables.add(variable);
variable = new Variable();
variable.setName("MyObject");
variable.setType(new ObjectDataType());
variables.add(variable);
variable = new Variable();
variable.setName("Number");
variable.setType(new IntegerDataType());
variables.add(variable);
process.getVariableScope().setVariables(variables);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
WorkItemNode workItemNode = new WorkItemNode();
workItemNode.setName("workItemNode");
workItemNode.setId(2);
workItemNode.addInMapping("Comment", "Person.name");
workItemNode.addInMapping("Attachment", "MyObject");
workItemNode.addOutMapping("Result", "MyObject");
workItemNode.addOutMapping("Result.length()", "Number");
Work work = new WorkImpl();
work.setName(workName);
Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
ParameterDefinition parameterDefinition = new ParameterDefinitionImpl("ActorId", new StringDataType());
parameterDefinitions.add(parameterDefinition);
parameterDefinition = new ParameterDefinitionImpl("Content", new StringDataType());
parameterDefinitions.add(parameterDefinition);
parameterDefinition = new ParameterDefinitionImpl("Comment", new StringDataType());
parameterDefinitions.add(parameterDefinition);
work.setParameterDefinitions(parameterDefinitions);
work.setParameter("ActorId", "#{UserName}");
work.setParameter("Content", "#{Person.name}");
workItemNode.setWork(work);
EndNode endNode = new EndNode();
endNode.setName("End");
endNode.setId(3);
connect(startNode, workItemNode);
connect(workItemNode, endNode);
process.addNode(startNode);
process.addNode(workItemNode);
process.addNode(endNode);
return process;
}
use of io.automatiko.engine.workflow.base.core.ParameterDefinition in project automatiko-engine by automatiko-io.
the class WorkItemNodeHandler method visitWork.
protected void visitWork(Work work, StringBuilder xmlDump, boolean includeMeta) {
if (work != null) {
xmlDump.append(" <work name=\"" + work.getName() + "\" >" + EOL);
List<ParameterDefinition> parameterDefinitions = new ArrayList<ParameterDefinition>(work.getParameterDefinitions());
Collections.sort(parameterDefinitions, new Comparator<ParameterDefinition>() {
public int compare(ParameterDefinition o1, ParameterDefinition o2) {
return o1.getName().compareTo(o2.getName());
}
});
for (ParameterDefinition paramDefinition : parameterDefinitions) {
DataType dataType = paramDefinition.getType();
xmlDump.append(" <parameter name=\"" + paramDefinition.getName() + "\" >" + EOL + " ");
XmlWorkflowProcessDumper.visitDataType(dataType, xmlDump);
Object value = work.getParameter(paramDefinition.getName());
if (value != null) {
xmlDump.append(" ");
XmlWorkflowProcessDumper.visitValue(value, dataType, xmlDump);
}
xmlDump.append(" </parameter>" + EOL);
}
xmlDump.append(" </work>" + EOL);
}
}
use of io.automatiko.engine.workflow.base.core.ParameterDefinition 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));
}
use of io.automatiko.engine.workflow.base.core.ParameterDefinition in project automatiko-engine by automatiko-io.
the class ServiceTaskDescriptor method serviceTaskParameters.
private Map<String, String> serviceTaskParameters() {
String type = (String) workItemNode.getWork().getParameter("ParameterType");
Map<String, String> parameters = null;
if (type != null) {
if (isDefaultParameterType(type)) {
type = inferParameterType();
}
parameters = Collections.singletonMap("Parameter", type);
} else {
parameters = new LinkedHashMap<>();
for (ParameterDefinition def : workItemNode.getWork().getParameterDefinitions()) {
parameters.put(def.getName(), def.getType().getStringType());
}
}
return parameters;
}
Aggregations