Search in sources :

Example 6 with SubProcess

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

the class ValuedDataObjectConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    // verify main process data objects
    List<ValuedDataObject> dataObjects = model.getMainProcess().getDataObjects();
    assertEquals(6, dataObjects.size());
    for (ValuedDataObject dObj : dataObjects) {
        if ("dObj1".equals(dObj.getId())) {
            assertEquals(StringDataObject.class, dObj.getClass());
            assertEquals("StringTest", dObj.getName());
            assertTrue(dObj.getValue() instanceof String);
            assertEquals("xsd:string", dObj.getItemSubjectRef().getStructureRef());
            assertEquals("Testing123", dObj.getValue());
        } else if ("dObj2".equals(dObj.getId())) {
            assertEquals(BooleanDataObject.class, dObj.getClass());
            assertEquals("BooleanTest", dObj.getName());
            assertEquals("xsd:boolean", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Boolean);
            assertEquals(new Boolean(true), dObj.getValue());
        } else if ("dObj3".equals(dObj.getId())) {
            assertEquals(DateDataObject.class, dObj.getClass());
            assertEquals("DateTest", dObj.getName());
            assertEquals("xsd:datetime", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Date);
            GregorianCalendar dateCal = new GregorianCalendar();
            dateCal.setTime((Date) dObj.getValue());
            assertEquals(2013, dateCal.get(Calendar.YEAR));
            assertEquals(8, dateCal.get(Calendar.MONTH));
            assertEquals(16, dateCal.get(Calendar.DAY_OF_MONTH));
            assertEquals(11, dateCal.get(Calendar.HOUR_OF_DAY));
            assertEquals(23, dateCal.get(Calendar.MINUTE));
        } else if ("dObj4".equals(dObj.getId())) {
            assertEquals(DoubleDataObject.class, dObj.getClass());
            assertEquals("DoubleTest", dObj.getName());
            assertEquals("xsd:double", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Double);
            assertEquals(new Double(123456789), dObj.getValue());
        } else if ("dObj5".equals(dObj.getId())) {
            assertEquals(IntegerDataObject.class, dObj.getClass());
            assertEquals("IntegerTest", dObj.getName());
            assertEquals("xsd:int", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Integer);
            assertEquals(new Integer(123), dObj.getValue());
        } else if ("dObj6".equals(dObj.getId())) {
            assertEquals(LongDataObject.class, dObj.getClass());
            assertEquals("LongTest", dObj.getName());
            assertEquals("xsd:long", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Long);
            assertEquals(new Long(-123456), dObj.getValue());
        }
    }
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertEquals(11, subProcess.getFlowElements().size());
    // verify subprocess data objects
    dataObjects = ((SubProcess) flowElement).getDataObjects();
    assertEquals(6, dataObjects.size());
    for (ValuedDataObject dObj : dataObjects) {
        if ("dObj1".equals(dObj.getId())) {
            assertEquals(StringDataObject.class, dObj.getClass());
            assertEquals("SubStringTest", dObj.getName());
            assertTrue(dObj.getValue() instanceof String);
            assertEquals("xsd:string", dObj.getItemSubjectRef().getStructureRef());
            assertEquals("Testing456", dObj.getValue());
        } else if ("dObj2".equals(dObj.getId())) {
            assertEquals(BooleanDataObject.class, dObj.getClass());
            assertEquals("SubBooleanTest", dObj.getName());
            assertEquals("xsd:boolean", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Boolean);
            assertEquals(new Boolean(false), dObj.getValue());
        } else if ("dObj3".equals(dObj.getId())) {
            assertEquals(DateDataObject.class, dObj.getClass());
            assertEquals("SubDateTest", dObj.getName());
            assertEquals("xsd:datetime", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Date);
            GregorianCalendar dateCal = new GregorianCalendar();
            dateCal.setTime((Date) dObj.getValue());
            assertEquals(2013, dateCal.get(Calendar.YEAR));
            assertEquals(10, dateCal.get(Calendar.MONTH));
            assertEquals(11, dateCal.get(Calendar.DAY_OF_MONTH));
        } else if ("dObj4".equals(dObj.getId())) {
            assertEquals(DoubleDataObject.class, dObj.getClass());
            assertEquals("SubDoubleTest", dObj.getName());
            assertEquals("xsd:double", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Double);
            assertEquals(new Double(678912345), dObj.getValue());
        } else if ("dObj5".equals(dObj.getId())) {
            assertEquals(IntegerDataObject.class, dObj.getClass());
            assertEquals("SubIntegerTest", dObj.getName());
            assertEquals("xsd:int", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Integer);
            assertEquals(new Integer(45), dObj.getValue());
        } else if ("dObj6".equals(dObj.getId())) {
            assertEquals(LongDataObject.class, dObj.getClass());
            assertEquals("SubLongTest", dObj.getName());
            assertEquals("xsd:long", dObj.getItemSubjectRef().getStructureRef());
            assertTrue(dObj.getValue() instanceof Long);
            assertEquals(new Long(456123), dObj.getValue());
            assertEquals(1, dObj.getExtensionElements().size());
        }
    }
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) GregorianCalendar(java.util.GregorianCalendar) BooleanDataObject(org.activiti.bpmn.model.BooleanDataObject) Date(java.util.Date) DoubleDataObject(org.activiti.bpmn.model.DoubleDataObject) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) LongDataObject(org.activiti.bpmn.model.LongDataObject)

Example 7 with SubProcess

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

the class SubProcessParser method parse.

public void parse(XMLStreamReader xtr, List<SubProcess> activeSubProcessList, Process activeProcess) {
    SubProcess subProcess = null;
    if (ELEMENT_TRANSACTION.equalsIgnoreCase(xtr.getLocalName())) {
        subProcess = new Transaction();
    } else if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(xtr.getAttributeValue(null, ATTRIBUTE_TRIGGERED_BY))) {
        subProcess = new EventSubProcess();
    } else {
        subProcess = new SubProcess();
    }
    BpmnXMLUtil.addXMLLocation(subProcess, xtr);
    activeSubProcessList.add(subProcess);
    subProcess.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
    subProcess.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
    boolean async = false;
    String asyncString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS);
    if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(asyncString)) {
        async = true;
    }
    boolean notExclusive = false;
    String exclusiveString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_EXCLUSIVE);
    if (ATTRIBUTE_VALUE_FALSE.equalsIgnoreCase(exclusiveString)) {
        notExclusive = true;
    }
    boolean forCompensation = false;
    String compensationString = xtr.getAttributeValue(null, ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION);
    if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(compensationString)) {
        forCompensation = true;
    }
    subProcess.setAsynchronous(async);
    subProcess.setNotExclusive(notExclusive);
    subProcess.setForCompensation(forCompensation);
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT))) {
        subProcess.setDefaultFlow(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT));
    }
    if (activeSubProcessList.size() > 1) {
        activeSubProcessList.get(activeSubProcessList.size() - 2).addFlowElement(subProcess);
    } else {
        activeProcess.addFlowElement(subProcess);
    }
}
Also used : EventSubProcess(org.activiti.bpmn.model.EventSubProcess) SubProcess(org.activiti.bpmn.model.SubProcess) Transaction(org.activiti.bpmn.model.Transaction) EventSubProcess(org.activiti.bpmn.model.EventSubProcess)

Example 8 with SubProcess

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

the class SubProcessConverterAutoLayoutTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertTrue(userTask.getCandidateUsers().size() == 1);
    assertTrue(userTask.getCandidateGroups().size() == 1);
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertTrue(subProcess.getFlowElements().size() == 6);
    List<ValuedDataObject> dataObjects = ((SubProcess) flowElement).getDataObjects();
    assertTrue(dataObjects.size() == 1);
    ValuedDataObject dataObj = dataObjects.get(0);
    assertEquals("SubTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    assertTrue(dataObj.getValue() instanceof String);
    assertEquals("Testing", dataObj.getValue());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask)

Example 9 with SubProcess

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

the class ValuedDataObjectWithExtensionsConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    // verify the main process data objects
    List<ValuedDataObject> dataObjects = model.getMainProcess().getDataObjects();
    assertEquals(1, dataObjects.size());
    Map<String, ValuedDataObject> objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }
    ValuedDataObject dataObj = objectMap.get("dObj1");
    assertEquals("dObj1", dataObj.getId());
    assertEquals("StringTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    assertTrue(dataObj.getValue() instanceof String);
    assertEquals("Testing123", dataObj.getValue());
    /*
     * Verify DataObject attributes extension
     */
    Map<String, String> attributes = getDataObjectAttributes(dataObj);
    assertEquals(2, attributes.size());
    for (String key : attributes.keySet()) {
        if (key.equals("Attr1")) {
            assertTrue("1".equals(attributes.get(key)));
        } else if (key.equals("Attr2")) {
            assertTrue("2".equals(attributes.get(key)));
        } else {
            fail("Unknown key value");
        }
    }
    /*
     * Verify DataObject localization extension
     */
    Localization localization = getLocalization(dataObj);
    assertEquals("rbkfn-1", localization.getResourceBundleKeyForName());
    assertEquals("rbkfd-1", localization.getResourceBundleKeyForDescription());
    assertEquals("leifn-1", localization.getLabeledEntityIdForName());
    assertEquals("leifd-1", localization.getLabeledEntityIdForDescription());
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertEquals(6, subProcess.getFlowElements().size());
    // verify the sub process data objects
    dataObjects = subProcess.getDataObjects();
    assertEquals(1, dataObjects.size());
    objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }
    dataObj = objectMap.get("dObj2");
    assertEquals("dObj2", dataObj.getId());
    assertEquals("BooleanTest", dataObj.getName());
    assertEquals("xsd:boolean", dataObj.getItemSubjectRef().getStructureRef());
    assertTrue(dataObj.getValue() instanceof Boolean);
    assertEquals(Boolean.TRUE, dataObj.getValue());
    /*
     * Verify DataObject attributes extension
     */
    attributes = getDataObjectAttributes(dataObj);
    assertEquals(2, attributes.size());
    for (String key : attributes.keySet()) {
        if (key.equals("Attr3")) {
            assertTrue("3".equals(attributes.get(key)));
        } else if (key.equals("Attr4")) {
            assertTrue("4".equals(attributes.get(key)));
        } else {
            fail("Unknown key value");
        }
    }
    /*
     * Verify DataObject localization extension
     */
    localization = getLocalization(dataObj);
    assertEquals("rbkfn-2", localization.getResourceBundleKeyForName());
    assertEquals("rbkfd-2", localization.getResourceBundleKeyForDescription());
    assertEquals("leifn-2", localization.getLabeledEntityIdForName());
    assertEquals("leifd-2", localization.getLabeledEntityIdForDescription());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) HashMap(java.util.HashMap) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent)

Example 10 with SubProcess

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

the class DataObjectConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    // verify the main process data objects
    List<ValuedDataObject> dataObjects = model.getMainProcess().getDataObjects();
    assertEquals(7, dataObjects.size());
    Map<String, ValuedDataObject> objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }
    ValuedDataObject dataObj = objectMap.get("dObj1");
    assertEquals("dObj1", dataObj.getId());
    assertEquals("StringTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj2");
    assertEquals("BooleanTest", dataObj.getName());
    assertEquals("xsd:boolean", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj3");
    assertEquals("DateTest", dataObj.getName());
    assertEquals("xsd:datetime", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj4");
    assertEquals("DoubleTest", dataObj.getName());
    assertEquals("xsd:double", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj5");
    assertEquals("IntegerTest", dataObj.getName());
    assertEquals("xsd:int", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj6");
    assertEquals("LongTest", dataObj.getName());
    assertEquals("xsd:long", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObjWithoutType");
    assertEquals("UnknownTypeTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("kermit", userTask.getAssignee());
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertEquals(11, subProcess.getFlowElements().size());
    // verify the sub process data objects
    dataObjects = subProcess.getDataObjects();
    assertEquals(6, dataObjects.size());
    objectMap = new HashMap<String, ValuedDataObject>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }
    dataObj = objectMap.get("dObj7");
    assertEquals("dObj7", dataObj.getId());
    assertEquals("StringSubTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj8");
    assertEquals("dObj8", dataObj.getId());
    assertEquals("BooleanSubTest", dataObj.getName());
    assertEquals("xsd:boolean", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj9");
    assertEquals("dObj9", dataObj.getId());
    assertEquals("DateSubTest", dataObj.getName());
    assertEquals("xsd:datetime", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj10");
    assertEquals("dObj10", dataObj.getId());
    assertEquals("DoubleSubTest", dataObj.getName());
    assertEquals("xsd:double", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj11");
    assertEquals("dObj11", dataObj.getId());
    assertEquals("IntegerSubTest", dataObj.getName());
    assertEquals("xsd:int", dataObj.getItemSubjectRef().getStructureRef());
    dataObj = objectMap.get("dObj12");
    assertEquals("dObj12", dataObj.getId());
    assertEquals("LongSubTest", dataObj.getName());
    assertEquals("xsd:long", dataObj.getItemSubjectRef().getStructureRef());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) HashMap(java.util.HashMap) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask)

Aggregations

SubProcess (org.activiti.bpmn.model.SubProcess)32 FlowElement (org.activiti.bpmn.model.FlowElement)24 UserTask (org.activiti.bpmn.model.UserTask)10 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)8 StartEvent (org.activiti.bpmn.model.StartEvent)8 ValuedDataObject (org.activiti.bpmn.model.ValuedDataObject)8 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)7 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)7 Gateway (org.activiti.bpmn.model.Gateway)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Activity (org.activiti.bpmn.model.Activity)4 Artifact (org.activiti.bpmn.model.Artifact)4 ExtensionElement (org.activiti.bpmn.model.ExtensionElement)4 FlowNode (org.activiti.bpmn.model.FlowNode)4 Transaction (org.activiti.bpmn.model.Transaction)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 DataObject (org.activiti.bpmn.model.DataObject)3