Search in sources :

Example 31 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class CompleteConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("catchsignal");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof IntermediateCatchEvent);
    assertEquals("catchsignal", flowElement.getId());
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertEquals(1, catchEvent.getEventDefinitions().size());
    assertTrue(catchEvent.getEventDefinitions().get(0) instanceof SignalEventDefinition);
    SignalEventDefinition signalEvent = (SignalEventDefinition) catchEvent.getEventDefinitions().get(0);
    assertEquals("testSignal", signalEvent.getSignalRef());
    flowElement = model.getMainProcess().getFlowElement("subprocess");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    flowElement = subProcess.getFlowElement("receiveTask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ReceiveTask);
    assertEquals("receiveTask", flowElement.getId());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ReceiveTask(org.activiti.bpmn.model.ReceiveTask) FlowElement(org.activiti.bpmn.model.FlowElement) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition)

Example 32 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class EncodingConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("writeReportTask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("writeReportTask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("writeReportTask", userTask.getId());
    assertEquals("Fazer relatório", userTask.getName());
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask)

Example 33 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class TestProcessUtil method createOneTaskProcess.

public static org.activiti.bpmn.model.Process createOneTaskProcess() {
    org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
    process.setId("oneTaskProcess");
    process.setName("The one task process");
    StartEvent startEvent = new StartEvent();
    startEvent.setId("start");
    process.addFlowElement(startEvent);
    UserTask userTask = new UserTask();
    userTask.setName("The Task");
    userTask.setId("theTask");
    userTask.setAssignee("kermit");
    process.addFlowElement(userTask);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("theEnd");
    process.addFlowElement(endEvent);
    process.addFlowElement(new SequenceFlow("start", "theTask"));
    process.addFlowElement(new SequenceFlow("theTask", "theEnd"));
    return process;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent)

Example 34 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class BaseBpmnJsonConverter method convertToJson.

public void convertToJson(BaseElement baseElement, ActivityProcessor processor, BpmnModel model, FlowElementsContainer container, ArrayNode shapesArrayNode, double subProcessX, double subProcessY) {
    this.model = model;
    this.processor = processor;
    this.subProcessX = subProcessX;
    this.subProcessY = subProcessY;
    this.shapesArrayNode = shapesArrayNode;
    GraphicInfo graphicInfo = model.getGraphicInfo(baseElement.getId());
    String stencilId = null;
    if (baseElement instanceof ServiceTask) {
        ServiceTask serviceTask = (ServiceTask) baseElement;
        if ("mail".equalsIgnoreCase(serviceTask.getType())) {
            stencilId = STENCIL_TASK_MAIL;
        } else if ("camel".equalsIgnoreCase(serviceTask.getType())) {
            stencilId = STENCIL_TASK_CAMEL;
        } else if ("mule".equalsIgnoreCase(serviceTask.getType())) {
            stencilId = STENCIL_TASK_MULE;
        } else {
            stencilId = getStencilId(baseElement);
        }
    } else {
        stencilId = getStencilId(baseElement);
    }
    flowElementNode = BpmnJsonConverterUtil.createChildShape(baseElement.getId(), stencilId, graphicInfo.getX() - subProcessX + graphicInfo.getWidth(), graphicInfo.getY() - subProcessY + graphicInfo.getHeight(), graphicInfo.getX() - subProcessX, graphicInfo.getY() - subProcessY);
    shapesArrayNode.add(flowElementNode);
    ObjectNode propertiesNode = objectMapper.createObjectNode();
    propertiesNode.put(PROPERTY_OVERRIDE_ID, baseElement.getId());
    if (baseElement instanceof FlowElement) {
        FlowElement flowElement = (FlowElement) baseElement;
        if (StringUtils.isNotEmpty(flowElement.getName())) {
            propertiesNode.put(PROPERTY_NAME, flowElement.getName());
        }
        if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
            propertiesNode.put(PROPERTY_DOCUMENTATION, flowElement.getDocumentation());
        }
    }
    convertElementToJson(propertiesNode, baseElement);
    flowElementNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
    ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
    if (baseElement instanceof FlowNode) {
        FlowNode flowNode = (FlowNode) baseElement;
        for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
            outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getId()));
        }
        for (MessageFlow messageFlow : model.getMessageFlows().values()) {
            if (messageFlow.getSourceRef().equals(flowNode.getId())) {
                outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId()));
            }
        }
    }
    if (baseElement instanceof Activity) {
        Activity activity = (Activity) baseElement;
        for (BoundaryEvent boundaryEvent : activity.getBoundaryEvents()) {
            outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(boundaryEvent.getId()));
        }
        propertiesNode.put(PROPERTY_ASYNCHRONOUS, activity.isAsynchronous());
        propertiesNode.put(PROPERTY_EXCLUSIVE, !activity.isNotExclusive());
        if (activity.getLoopCharacteristics() != null) {
            MultiInstanceLoopCharacteristics loopDef = activity.getLoopCharacteristics();
            if (StringUtils.isNotEmpty(loopDef.getLoopCardinality()) || StringUtils.isNotEmpty(loopDef.getInputDataItem()) || StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
                if (loopDef.isSequential() == false) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Parallel");
                } else {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Sequential");
                }
                if (StringUtils.isNotEmpty(loopDef.getLoopCardinality())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_CARDINALITY, loopDef.getLoopCardinality());
                }
                if (StringUtils.isNotEmpty(loopDef.getInputDataItem())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_COLLECTION, loopDef.getInputDataItem());
                }
                if (StringUtils.isNotEmpty(loopDef.getElementVariable())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_VARIABLE, loopDef.getElementVariable());
                }
                if (StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
                    propertiesNode.put(PROPERTY_MULTIINSTANCE_CONDITION, loopDef.getCompletionCondition());
                }
            }
        }
        if (activity instanceof UserTask) {
            BpmnJsonConverterUtil.convertListenersToJson(((UserTask) activity).getTaskListeners(), false, propertiesNode);
        }
        BpmnJsonConverterUtil.convertListenersToJson(activity.getExecutionListeners(), true, propertiesNode);
        if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) {
            for (DataAssociation dataAssociation : activity.getDataInputAssociations()) {
                if (model.getFlowElement(dataAssociation.getSourceRef()) != null) {
                    createDataAssociation(dataAssociation, true, activity);
                }
            }
        }
        if (CollectionUtils.isNotEmpty(activity.getDataOutputAssociations())) {
            for (DataAssociation dataAssociation : activity.getDataOutputAssociations()) {
                if (model.getFlowElement(dataAssociation.getTargetRef()) != null) {
                    createDataAssociation(dataAssociation, false, activity);
                    outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId()));
                }
            }
        }
    }
    for (Artifact artifact : container.getArtifacts()) {
        if (artifact instanceof Association) {
            Association association = (Association) artifact;
            if (StringUtils.isNotEmpty(association.getSourceRef()) && association.getSourceRef().equals(baseElement.getId())) {
                outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getId()));
            }
        }
    }
    if (baseElement instanceof DataStoreReference) {
        for (Process process : model.getProcesses()) {
            processDataStoreReferences(process, baseElement.getId(), outgoingArrayNode);
        }
    }
    flowElementNode.put("outgoing", outgoingArrayNode);
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) DataAssociation(org.activiti.bpmn.model.DataAssociation) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) UserTask(org.activiti.bpmn.model.UserTask) Activity(org.activiti.bpmn.model.Activity) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) MessageFlow(org.activiti.bpmn.model.MessageFlow) Artifact(org.activiti.bpmn.model.Artifact) DataStoreReference(org.activiti.bpmn.model.DataStoreReference) DataAssociation(org.activiti.bpmn.model.DataAssociation) Association(org.activiti.bpmn.model.Association) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 35 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class BpmnJsonConverterUtil method convertJsonToListeners.

public static void convertJsonToListeners(JsonNode objectNode, BaseElement element) {
    JsonNode executionListenersNode = getProperty(PROPERTY_EXECUTION_LISTENERS, objectNode);
    if (executionListenersNode != null) {
        executionListenersNode = validateIfNodeIsTextual(executionListenersNode);
        JsonNode listenersNode = executionListenersNode.get("executionListeners");
        parseListeners(listenersNode, element, false);
    }
    if (element instanceof UserTask) {
        JsonNode taskListenersNode = getProperty(PROPERTY_TASK_LISTENERS, objectNode);
        if (taskListenersNode != null) {
            taskListenersNode = validateIfNodeIsTextual(taskListenersNode);
            JsonNode listenersNode = taskListenersNode.get("taskListeners");
            parseListeners(listenersNode, element, true);
        }
    }
}
Also used : UserTask(org.activiti.bpmn.model.UserTask) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

UserTask (org.activiti.bpmn.model.UserTask)49 FlowElement (org.activiti.bpmn.model.FlowElement)26 StartEvent (org.activiti.bpmn.model.StartEvent)18 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)11 SubProcess (org.activiti.bpmn.model.SubProcess)11 FormProperty (org.activiti.bpmn.model.FormProperty)7 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)6 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 BpmnModel (org.activiti.bpmn.model.BpmnModel)6 EndEvent (org.activiti.bpmn.model.EndEvent)6 HashMap (java.util.HashMap)5 Process (org.activiti.bpmn.model.Process)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ArrayList (java.util.ArrayList)4 FormValue (org.activiti.bpmn.model.FormValue)4 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 AlfrescoUserTask (org.activiti.bpmn.model.alfresco.AlfrescoUserTask)4 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)4 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)4