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