Search in sources :

Example 1 with Work

use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.

the class ServerlessWorkflowFactory method humanTaskNode.

public HumanTaskNode humanTaskNode(long id, String name, FunctionDefinition function, ExecutableProcess process, NodeContainer nodeContainer) {
    // then the ht node
    HumanTaskNode humanTaskNode = new HumanTaskNode();
    humanTaskNode.setId(id);
    humanTaskNode.setName(name);
    Work work = new WorkImpl();
    work.setName("Human Task");
    humanTaskNode.setWork(work);
    work.setParameter("NodeName", name);
    humanTaskNode.addInMapping(DEFAULT_WORKFLOW_VAR, DEFAULT_WORKFLOW_VAR);
    nodeContainer.addNode(humanTaskNode);
    return humanTaskNode;
}
Also used : Work(io.automatiko.engine.workflow.base.core.Work) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode)

Example 2 with Work

use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.

the class ServerlessWorkflowFactory method serviceNode.

public WorkItemNode serviceNode(long id, Action action, FunctionDefinition function, NodeContainer nodeContainer) {
    String actionName = action.getName();
    String[] operationParts = function.getOperation().split("#");
    String interfaceStr = operationParts[0];
    String operationStr = operationParts[1];
    WorkItemNode workItemNode = new WorkItemNode();
    workItemNode.setId(id);
    workItemNode.setName(actionName);
    workItemNode.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
    workItemNode.setMetaData("Type", SERVICE_TASK_TYPE);
    workItemNode.setMetaData("Implementation", "##WebService");
    Work work = new WorkImpl();
    workItemNode.setWork(work);
    work.setName(SERVICE_TASK_TYPE);
    work.setParameter("Interface", interfaceStr);
    work.setParameter("Operation", operationStr);
    work.setParameter("interfaceImplementationRef", interfaceStr);
    work.setParameter("implementation", "##WebService");
    JsonNode params = action.getFunctionRef().getArguments();
    String inputFilter = null;
    String outputFilter = null;
    String scopeFilter = null;
    if (action.getActionDataFilter() != null) {
        inputFilter = unwrapExpression(action.getActionDataFilter().getFromStateData());
        outputFilter = unwrapExpression(action.getActionDataFilter().getResults());
        scopeFilter = unwrapExpression(action.getActionDataFilter().getToStateData());
    }
    Set<String> paramNames = new LinkedHashSet<>();
    if (params != null) {
        Iterator<String> it = params.fieldNames();
        while (it.hasNext()) {
            String name = it.next();
            String value = params.get(name).toString();
            work.setParameter(name, unwrapExpression(value));
            paramNames.add(name);
            work.addParameterDefinition(new ParameterDefinitionImpl(name, new JsonNodeDataType()));
        }
    } else {
        work.setParameter("ParameterType", JSON_NODE);
    }
    Assignment assignment = new Assignment("jq", null, null);
    assignment.setMetaData("Action", new TaskInputJqAssignmentAction(inputFilter, paramNames));
    workItemNode.addInAssociation(new DataAssociation(Collections.emptyList(), "", Arrays.asList(assignment), null));
    Assignment outAssignment = new Assignment("jq", null, null);
    outAssignment.setMetaData("Action", new TaskOutputJqAssignmentAction(outputFilter, scopeFilter));
    workItemNode.addOutAssociation(new DataAssociation(Collections.emptyList(), "", Arrays.asList(outAssignment), null));
    nodeContainer.addNode(workItemNode);
    return workItemNode;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) JsonNodeDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.JsonNodeDataType) TaskInputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.TaskInputJqAssignmentAction) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParameterDefinitionImpl(io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl) TaskOutputJqAssignmentAction(io.automatiko.engine.workflow.base.instance.impl.jq.TaskOutputJqAssignmentAction) Assignment(io.automatiko.engine.workflow.process.core.node.Assignment) 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)

Example 3 with Work

use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.

the class WorkItemNodeVisitor method visitNode.

@Override
public void visitNode(WorkflowProcess process, String factoryField, T node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    Work work = node.getWork();
    String workName = node.getWork().getName();
    if (workName.equals("Service Task")) {
        ServiceTaskDescriptor d = new ServiceTaskDescriptor(process, node, contextClassLoader);
        String mangledName = d.mangledName();
        metadata.getGeneratedHandlers().put(mangledName, d);
        workName = mangledName;
        if (d.openapi() != null) {
            metadata.addOpenAPI(d.openapi());
        }
    }
    body.addStatement(getAssignedFactoryMethod(factoryField, WorkItemNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId()))).addStatement(getNameMethod(node, work.getName())).addStatement(getFactoryMethod(getNodeId(node), METHOD_WORK_NAME, new StringLiteralExpr(workName)));
    addWorkItemParameters(work, body, getNodeId(node));
    addNodeMappings(process, node, body, getNodeId(node));
    body.addStatement(getDoneMethod(getNodeId(node)));
    visitMetaData(node.getMetaData(), body, getNodeId(node));
    metadata.getWorkItems().add(workName);
}
Also used : WorkItemNodeFactory(io.automatiko.engine.workflow.process.executable.core.factory.WorkItemNodeFactory) Work(io.automatiko.engine.workflow.base.core.Work) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) LongLiteralExpr(com.github.javaparser.ast.expr.LongLiteralExpr)

Example 4 with Work

use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.

the class WorkItemNodeFactory method workName.

public WorkItemNodeFactory workName(String name) {
    Work work = getWorkItemNode().getWork();
    if (work == null) {
        work = new WorkImpl();
        getWorkItemNode().setWork(work);
    }
    work.setName(name);
    return this;
}
Also used : Work(io.automatiko.engine.workflow.base.core.Work) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl)

Example 5 with Work

use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.

the class HumanTaskNodeFactory method skippable.

public HumanTaskNodeFactory skippable(boolean skippable) {
    Work work = getHumanTaskNode().getWork();
    if (work == null) {
        work = new WorkImpl();
        getHumanTaskNode().setWork(work);
    }
    work.setParameter(WORK_SKIPPABLE, Boolean.toString(skippable));
    return this;
}
Also used : Work(io.automatiko.engine.workflow.base.core.Work) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl)

Aggregations

Work (io.automatiko.engine.workflow.base.core.Work)25 WorkImpl (io.automatiko.engine.workflow.base.core.impl.WorkImpl)16 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)10 ParameterDefinitionImpl (io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl)5 ParameterDefinition (io.automatiko.engine.workflow.base.core.ParameterDefinition)4 ArrayList (java.util.ArrayList)4 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)3 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)3 HumanTaskNode (io.automatiko.engine.workflow.process.core.node.HumanTaskNode)3 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)3 LongLiteralExpr (com.github.javaparser.ast.expr.LongLiteralExpr)2 Node (io.automatiko.engine.api.definition.process.Node)2 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)2 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)2 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)2 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)2 DataAssociation (io.automatiko.engine.workflow.process.core.node.DataAssociation)2 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)2 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)2 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)2