Search in sources :

Example 1 with ParameterDefinition

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;
}
Also used : ArrayList(java.util.ArrayList) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition)

Example 2 with ParameterDefinition

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;
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) IntegerDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType) ArrayList(java.util.ArrayList) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ParameterDefinitionImpl(io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl) StringDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Work(io.automatiko.engine.workflow.base.core.Work) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Person(io.automatiko.engine.workflow.process.test.Person) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition) HashSet(java.util.HashSet)

Example 3 with ParameterDefinition

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);
    }
}
Also used : ArrayList(java.util.ArrayList) DataType(io.automatiko.engine.api.workflow.datatype.DataType) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition)

Example 4 with ParameterDefinition

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

Example 5 with ParameterDefinition

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;
}
Also used : ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition)

Aggregations

ParameterDefinition (io.automatiko.engine.workflow.base.core.ParameterDefinition)8 Work (io.automatiko.engine.workflow.base.core.Work)4 ParameterDefinitionImpl (io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl)4 WorkImpl (io.automatiko.engine.workflow.base.core.impl.WorkImpl)4 ArrayList (java.util.ArrayList)4 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)2 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)2 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 DataType (io.automatiko.engine.api.workflow.datatype.DataType)1 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)1 IntegerDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType)1 StringDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType)1 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)1 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)1 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)1 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1