private void validateModel(BpmnModel model) { assertEquals("simpleProcess", model.getMainProcess().getId()); assertEquals("Simple process", model.getMainProcess().getName()); FlowElement flowElement = model.getMainProcess().getFlowElement("flow1"); assertNotNull(flowElement); assertTrue(flowElement instanceof SequenceFlow); assertEquals("flow1", flowElement.getId()); flowElement = model.getMainProcess().getFlowElement("catchEvent"); assertNotNull(flowElement); assertTrue(flowElement instanceof IntermediateCatchEvent); assertEquals("catchEvent", flowElement.getId()); IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement; assertTrue(catchEvent.getEventDefinitions().size() == 1); EventDefinition eventDefinition = catchEvent.getEventDefinitions().get(0); assertTrue(eventDefinition instanceof TimerEventDefinition); TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition; assertEquals("PT5M", timerDefinition.getTimeDuration()); flowElement = model.getMainProcess().getFlowElement("flow1Condition"); assertNotNull(flowElement); assertTrue(flowElement instanceof SequenceFlow); assertEquals("flow1Condition", flowElement.getId()); SequenceFlow flow = (SequenceFlow) flowElement; assertEquals("${number <= 1}", flow.getConditionExpression()); }
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); assertTrue(userTask.getFormProperties().size() == 2); flowElement = model.getMainProcess().getFlowElement("subprocess1"); assertNotNull(flowElement); assertTrue(flowElement instanceof SubProcess); assertEquals("subprocess1", flowElement.getId()); SubProcess subProcess = (SubProcess) flowElement; assertTrue(subProcess.getFlowElements().size() == 5); flowElement = model.getMainProcess().getFlowElement("boundaryEvent1"); assertNotNull(flowElement); assertTrue(flowElement instanceof BoundaryEvent); assertEquals("boundaryEvent1", flowElement.getId()); BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; assertNotNull(boundaryEvent.getAttachedToRef()); assertEquals("subprocess1", boundaryEvent.getAttachedToRef().getId()); assertEquals(1, boundaryEvent.getEventDefinitions().size()); assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition); }
protected void convertElementToJson(ObjectNode propertiesNode, FlowElement flowElement) { propertiesNode.put("activitytype", "Sub-Process"); propertiesNode.put("subprocesstype", "Embedded"); ArrayNode subProcessshapesArrayNode = objectMapper.createArrayNode(); GraphicInfo graphicInfo = model.getGraphicInfo(flowElement.getId()); processor.processFlowElements( process, model, shapesArrayNode, graphicInfo.x + subProcessX, graphicInfo.y + subProcessY); flowElementNode.put("childShapes", subProcessshapesArrayNode); }
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getFlowElement("_5"); assertNotNull(flowElement); assertTrue(flowElement instanceof ScriptTask); assertEquals("_5", flowElement.getId()); ScriptTask scriptTask = (ScriptTask) flowElement; assertEquals("_5", scriptTask.getId()); assertEquals("Send Hello Message", scriptTask.getName()); }
public static List<FlowElement> findSucessorFlowElementsFor( Process process, FlowElement sourceFlowElement) { List<FlowElement> successors = new ArrayList<FlowElement>(); for (SequenceFlow sequenceFlow : findFlowElementsOfType(process, SequenceFlow.class)) { if (sequenceFlow.getSourceRef().equals(sourceFlowElement.getId())) { successors.add(process.getFlowElement(sequenceFlow.getTargetRef())); } } return successors; }
private void validateModel(BpmnModel model) { FlowElement flowElement = model.getMainProcess().getFlowElementMap().get("usertask"); assertNotNull(flowElement); assertTrue(flowElement instanceof UserTask); assertEquals("usertask", flowElement.getId()); UserTask userTask = (UserTask) flowElement; assertEquals("usertask", userTask.getId()); assertEquals("User task", userTask.getName()); assertEquals("testKey", userTask.getFormKey()); assertEquals("40", userTask.getPriority()); assertEquals("2012-11-01", userTask.getDueDate()); assertEquals("kermit", userTask.getAssignee()); assertEquals(2, userTask.getCandidateUsers().size()); assertTrue(userTask.getCandidateUsers().contains("kermit")); assertTrue(userTask.getCandidateUsers().contains("fozzie")); assertEquals(2, userTask.getCandidateGroups().size()); assertTrue(userTask.getCandidateGroups().contains("management")); assertTrue(userTask.getCandidateGroups().contains("sales")); List<FormProperty> formProperties = userTask.getFormProperties(); assertEquals(2, formProperties.size()); FormProperty formProperty = formProperties.get(0); assertEquals("formId", formProperty.getId()); assertEquals("formName", formProperty.getName()); assertEquals("string", formProperty.getType()); assertEquals("variable", formProperty.getVariable()); assertEquals("${expression}", formProperty.getExpression()); formProperty = formProperties.get(1); assertEquals("formId2", formProperty.getId()); assertEquals("anotherName", formProperty.getName()); assertEquals("long", formProperty.getType()); assertTrue(StringUtils.isEmpty(formProperty.getVariable())); assertTrue(StringUtils.isEmpty(formProperty.getExpression())); List<ActivitiListener> listeners = userTask.getTaskListeners(); assertEquals(3, listeners.size()); ActivitiListener listener = (ActivitiListener) listeners.get(0); assertTrue( ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType())); assertEquals("org.test.TestClass", listener.getImplementation()); assertEquals("create", listener.getEvent()); listener = (ActivitiListener) listeners.get(1); assertTrue( ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType())); assertEquals("${someExpression}", listener.getImplementation()); assertEquals("assignment", listener.getEvent()); listener = (ActivitiListener) listeners.get(2); assertTrue( ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals( listener.getImplementationType())); assertEquals("${someDelegateExpression}", listener.getImplementation()); assertEquals("complete", listener.getEvent()); }
public void processFlowElements(Collection<FlowElement> flowElements) { // Parsing the elements is done in a strict order of types, // as otherwise certain information might not be available when parsing a certain type. // Using lists as we want to keep the order in which they are defined List<SequenceFlow> sequenceFlowToParse = new ArrayList<SequenceFlow>(); List<BoundaryEvent> boundaryEventsToParse = new ArrayList<BoundaryEvent>(); // Activities are parsed first for (FlowElement flowElement : flowElements) { // Sequence flow are also flow elements, but are only parsed once every activity is found if (flowElement instanceof SequenceFlow) { sequenceFlowToParse.add((SequenceFlow) flowElement); } else if (flowElement instanceof BoundaryEvent) { boundaryEventsToParse.add((BoundaryEvent) flowElement); } else { bpmnParserHandlers.parse(this, flowElement); } } // Boundary events are parsed after all the regular activities are parsed for (BoundaryEvent boundaryEvent : boundaryEventsToParse) { bpmnParserHandlers.parse(this, boundaryEvent); } // sequence flows for (SequenceFlow sequenceFlow : sequenceFlowToParse) { bpmnParserHandlers.parse(this, sequenceFlow); } // validations after complete model for (FlowElement flowElement : flowElements) { if (flowElement instanceof ExclusiveGateway) { ActivityImpl gatewayActivity = getCurrentScope().findActivity(flowElement.getId()); validateExclusiveGateway(gatewayActivity, (ExclusiveGateway) flowElement); } } }
public void convertToBpmnModel( JsonNode elementNode, JsonNode modelNode, ActivityProcessor processor, BaseElement parentElement, Map<String, JsonNode> shapeMap, BpmnModel bpmnModel) { this.processor = processor; this.model = bpmnModel; BaseElement baseElement = convertJsonToElement(elementNode, modelNode, shapeMap); baseElement.setId(BpmnJsonConverterUtil.getElementId(elementNode)); if (baseElement instanceof FlowElement) { FlowElement flowElement = (FlowElement) baseElement; flowElement.setName(getPropertyValueAsString(PROPERTY_NAME, elementNode)); flowElement.setDocumentation(getPropertyValueAsString(PROPERTY_DOCUMENTATION, elementNode)); BpmnJsonConverterUtil.convertJsonToListeners(elementNode, flowElement); if (baseElement instanceof Activity) { Activity activity = (Activity) baseElement; activity.setAsynchronous(getPropertyValueAsBoolean(PROPERTY_ASYNCHRONOUS, elementNode)); activity.setNotExclusive(!getPropertyValueAsBoolean(PROPERTY_EXCLUSIVE, elementNode)); String multiInstanceType = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_TYPE, elementNode); String multiInstanceCardinality = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CARDINALITY, elementNode); String multiInstanceCollection = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_COLLECTION, elementNode); String multiInstanceCondition = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CONDITION, elementNode); if (StringUtils.isNotEmpty(multiInstanceType) && "none".equalsIgnoreCase(multiInstanceType) == false) { String multiInstanceVariable = getPropertyValueAsString(PROPERTY_MULTIINSTANCE_VARIABLE, elementNode); MultiInstanceLoopCharacteristics multiInstanceObject = new MultiInstanceLoopCharacteristics(); if ("sequential".equalsIgnoreCase(multiInstanceType)) { multiInstanceObject.setSequential(true); } else { multiInstanceObject.setSequential(false); } multiInstanceObject.setLoopCardinality(multiInstanceCardinality); multiInstanceObject.setInputDataItem(multiInstanceCollection); multiInstanceObject.setElementVariable(multiInstanceVariable); multiInstanceObject.setCompletionCondition(multiInstanceCondition); activity.setLoopCharacteristics(multiInstanceObject); } } else if (baseElement instanceof Gateway) { JsonNode flowOrderNode = getProperty(PROPERTY_SEQUENCEFLOW_ORDER, elementNode); if (flowOrderNode != null) { flowOrderNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(flowOrderNode); JsonNode orderArray = flowOrderNode.get("sequenceFlowOrder"); if (orderArray != null && orderArray.size() > 0) { for (JsonNode orderNode : orderArray) { ExtensionElement orderElement = new ExtensionElement(); orderElement.setName("EDITOR_FLOW_ORDER"); orderElement.setElementText(orderNode.asText()); flowElement.addExtensionElement(orderElement); } } } } } if (baseElement instanceof FlowElement) { FlowElement flowElement = (FlowElement) baseElement; if (flowElement instanceof SequenceFlow) { ExtensionElement idExtensionElement = new ExtensionElement(); idExtensionElement.setName("EDITOR_RESOURCEID"); idExtensionElement.setElementText(elementNode.get(EDITOR_SHAPE_ID).asText()); flowElement.addExtensionElement(idExtensionElement); } if (parentElement instanceof Process) { ((Process) parentElement).addFlowElement(flowElement); } else if (parentElement instanceof SubProcess) { ((SubProcess) parentElement).addFlowElement(flowElement); } else if (parentElement instanceof Lane) { Lane lane = (Lane) parentElement; lane.getFlowReferences().add(flowElement.getId()); lane.getParentProcess().addFlowElement(flowElement); } } else if (baseElement instanceof Artifact) { Artifact artifact = (Artifact) baseElement; if (parentElement instanceof Process) { ((Process) parentElement).addArtifact(artifact); } else if (parentElement instanceof SubProcess) { ((SubProcess) parentElement).addArtifact(artifact); } else if (parentElement instanceof Lane) { Lane lane = (Lane) parentElement; lane.getFlowReferences().add(artifact.getId()); lane.getParentProcess().addArtifact(artifact); } } }
private void drawFlowElements( Collection<FlowElement> elementList, Map<String, GraphicInfo> locationMap, ContainerShape parentShape, Process process) { final IFeatureProvider featureProvider = getDiagramTypeProvider().getFeatureProvider(); List<FlowElement> noDIList = new ArrayList<FlowElement>(); for (FlowElement flowElement : elementList) { if (flowElement instanceof SequenceFlow) { continue; } AddContext context = new AddContext(new AreaContext(), flowElement); IAddFeature addFeature = featureProvider.getAddFeature(context); if (addFeature == null) { System.out.println("Element not supported: " + flowElement); return; } GraphicInfo graphicInfo = locationMap.get(flowElement.getId()); if (graphicInfo == null) { noDIList.add(flowElement); } else { context.setNewObject(flowElement); context.setSize((int) graphicInfo.getWidth(), (int) graphicInfo.getHeight()); ContainerShape parentContainer = null; if (parentShape instanceof Diagram) { parentContainer = getParentContainer(flowElement.getId(), process, (Diagram) parentShape); } else { parentContainer = parentShape; } context.setTargetContainer(parentContainer); if (parentContainer instanceof Diagram == false) { Point location = getLocation(parentContainer); context.setLocation( (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y); } else { context.setLocation((int) graphicInfo.getX(), (int) graphicInfo.getY()); } if (flowElement instanceof ServiceTask) { ServiceTask serviceTask = (ServiceTask) flowElement; if (serviceTask.isExtended()) { CustomServiceTask targetTask = findCustomServiceTask(serviceTask); if (targetTask != null) { for (FieldExtension field : serviceTask.getFieldExtensions()) { CustomProperty customFieldProperty = new CustomProperty(); customFieldProperty.setName(field.getFieldName()); if (StringUtils.isNotEmpty(field.getExpression())) { customFieldProperty.setSimpleValue(field.getExpression()); } else { customFieldProperty.setSimpleValue(field.getStringValue()); } serviceTask.getCustomProperties().add(customFieldProperty); } serviceTask.getFieldExtensions().clear(); } } } if (flowElement instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; if (boundaryEvent.getAttachedToRef() != null) { ContainerShape container = (ContainerShape) featureProvider.getPictogramElementForBusinessObject( boundaryEvent.getAttachedToRef()); if (container != null) { AddContext boundaryContext = new AddContext(new AreaContext(), boundaryEvent); boundaryContext.setTargetContainer(container); Point location = getLocation(container); boundaryContext.setLocation( (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y); if (addFeature.canAdd(boundaryContext)) { PictogramElement newBoundaryContainer = addFeature.add(boundaryContext); // featureProvider.link(newBoundaryContainer, new Object[] { boundaryEvent }); } } } } else if (addFeature.canAdd(context)) { PictogramElement newContainer = addFeature.add(context); featureProvider.link(newContainer, new Object[] {flowElement}); if (flowElement instanceof SubProcess) { drawFlowElements( ((SubProcess) flowElement).getFlowElements(), locationMap, (ContainerShape) newContainer, process); } } } } for (FlowElement flowElement : noDIList) { if (flowElement instanceof BoundaryEvent) { ((BoundaryEvent) flowElement).getAttachedToRef().getBoundaryEvents().remove(flowElement); } else { elementList.remove(flowElement); } } }
protected void drawArtifacts( final FlowElementsContainer container, final Map<String, GraphicInfo> locationMap, final ContainerShape parent, final Process process) { final IFeatureProvider featureProvider = getDiagramTypeProvider().getFeatureProvider(); final List<Artifact> artifactsWithoutDI = new ArrayList<Artifact>(); for (final Artifact artifact : container.getArtifacts()) { if (artifact instanceof Association) { continue; } final AddContext context = new AddContext(new AreaContext(), artifact); final IAddFeature addFeature = featureProvider.getAddFeature(context); if (addFeature == null) { System.out.println("Element not supported: " + artifact); return; } final GraphicInfo gi = locationMap.get(artifact.getId()); if (gi == null) { artifactsWithoutDI.add(artifact); } else { context.setNewObject(artifact); context.setSize((int) gi.getWidth(), (int) gi.getHeight()); ContainerShape parentContainer = null; if (parent instanceof Diagram) { FlowElement connectingElement = null; for (final Artifact associationArtifact : container.getArtifacts()) { if (associationArtifact instanceof Association) { Association association = (Association) associationArtifact; if (association.getSourceRef().equals(artifact.getId())) { connectingElement = container.getFlowElement(association.getTargetRef()); } else if (association.getTargetRef().equals(artifact.getId())) { connectingElement = container.getFlowElement(association.getSourceRef()); } } } if (connectingElement != null) { parentContainer = getParentContainer(connectingElement.getId(), process, (Diagram) parent); } else { parentContainer = parent; } } else { parentContainer = parent; } context.setTargetContainer(parentContainer); if (parentContainer instanceof Diagram) { context.setLocation((int) gi.getX(), (int) gi.getY()); } else { final Point location = getLocation(parentContainer); context.setLocation((int) gi.getX() - location.x, (int) gi.getY() - location.y); } if (addFeature.canAdd(context)) { final PictogramElement newContainer = addFeature.add(context); featureProvider.link(newContainer, new Object[] {artifact}); } } } for (final Artifact artifact : artifactsWithoutDI) { container.getArtifacts().remove(artifact); } for (FlowElement flowElement : container.getFlowElements()) { if (flowElement instanceof SubProcess) { ContainerShape subProcessShape = (ContainerShape) featureProvider.getPictogramElementForBusinessObject(flowElement); drawArtifacts((SubProcess) flowElement, locationMap, subProcessShape, process); } } }
@SuppressWarnings({"rawtypes", "unchecked"}) protected void drawFlowElements( Collection<FlowElement> elementList, Map<String, GraphicInfo> locationMap, ContainerShape parentShape, Process process) { final IFeatureProvider featureProvider = getDiagramTypeProvider().getFeatureProvider(); List<FlowElement> noDIList = new ArrayList<FlowElement>(); for (FlowElement flowElement : elementList) { if (flowElement instanceof SequenceFlow) { continue; } AddContext context = new AddContext(new AreaContext(), flowElement); IAddFeature addFeature = featureProvider.getAddFeature(context); if (addFeature == null) { System.out.println("Element not supported: " + flowElement); return; } GraphicInfo graphicInfo = locationMap.get(flowElement.getId()); if (graphicInfo == null) { noDIList.add(flowElement); } else { context.setNewObject(flowElement); context.setSize((int) graphicInfo.getWidth(), (int) graphicInfo.getHeight()); ContainerShape parentContainer = null; if (parentShape instanceof Diagram) { parentContainer = getParentContainer(flowElement.getId(), process, (Diagram) parentShape); } else { parentContainer = parentShape; } context.setTargetContainer(parentContainer); if (parentContainer instanceof Diagram == false) { Point location = getLocation(parentContainer); context.setLocation( (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y); } else { context.setLocation((int) graphicInfo.getX(), (int) graphicInfo.getY()); } if (flowElement instanceof ServiceTask) { ServiceTask serviceTask = (ServiceTask) flowElement; if (serviceTask.isExtended()) { CustomServiceTask targetTask = findCustomServiceTask(serviceTask); if (targetTask != null) { for (FieldExtension field : serviceTask.getFieldExtensions()) { CustomProperty customFieldProperty = new CustomProperty(); customFieldProperty.setName(field.getFieldName()); if (StringUtils.isNotEmpty(field.getExpression())) { customFieldProperty.setSimpleValue(field.getExpression()); } else { customFieldProperty.setSimpleValue(field.getStringValue()); } serviceTask.getCustomProperties().add(customFieldProperty); } serviceTask.getFieldExtensions().clear(); } } } else if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; if (userTask.isExtended()) { CustomUserTask targetTask = findCustomUserTask(userTask); if (targetTask != null) { final List<Class<CustomUserTask>> classHierarchy = new ArrayList<Class<CustomUserTask>>(); final List<String> fieldInfoObjects = new ArrayList<String>(); Class clazz = targetTask.getClass(); classHierarchy.add(clazz); boolean hierarchyOpen = true; while (hierarchyOpen) { clazz = clazz.getSuperclass(); if (CustomUserTask.class.isAssignableFrom(clazz)) { classHierarchy.add(clazz); } else { hierarchyOpen = false; } } for (final Class<CustomUserTask> currentClass : classHierarchy) { for (final Field field : currentClass.getDeclaredFields()) { if (field.isAnnotationPresent(Property.class)) { fieldInfoObjects.add(field.getName()); } } } for (String fieldName : userTask.getExtensionElements().keySet()) { if (fieldInfoObjects.contains(fieldName)) { CustomProperty customFieldProperty = new CustomProperty(); customFieldProperty.setName(fieldName); customFieldProperty.setSimpleValue( userTask.getExtensionElements().get(fieldName).get(0).getElementText()); userTask.getCustomProperties().add(customFieldProperty); } } for (String fieldName : fieldInfoObjects) { userTask.getExtensionElements().remove(fieldName); } } } } if (flowElement instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; if (boundaryEvent.getAttachedToRef() != null) { ContainerShape container = (ContainerShape) featureProvider.getPictogramElementForBusinessObject( boundaryEvent.getAttachedToRef()); if (container != null) { AddContext boundaryContext = new AddContext(new AreaContext(), boundaryEvent); boundaryContext.setTargetContainer(container); Point location = getLocation(container); boundaryContext.setLocation( (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y); if (addFeature.canAdd(boundaryContext)) { addFeature.add(boundaryContext); } } } } else if (addFeature.canAdd(context)) { PictogramElement newContainer = addFeature.add(context); featureProvider.link(newContainer, new Object[] {flowElement}); if (flowElement instanceof SubProcess) { drawFlowElements( ((SubProcess) flowElement).getFlowElements(), locationMap, (ContainerShape) newContainer, process); } } } } for (FlowElement flowElement : noDIList) { if (flowElement instanceof BoundaryEvent) { ((BoundaryEvent) flowElement).getAttachedToRef().getBoundaryEvents().remove(flowElement); } else { // do not remove Data Objects if (flowElement instanceof DataObject == false) { elementList.remove(flowElement); } } } }
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()); }
public void convertToXML(XMLStreamWriter xtw, FlowElement flowElement) throws Exception { xtw.writeStartElement(getXMLElementName()); didWriteExtensionStartElement = false; writeDefaultAttribute(ATTRIBUTE_ID, flowElement.getId(), xtw); writeDefaultAttribute(ATTRIBUTE_NAME, flowElement.getName(), xtw); if (flowElement instanceof Activity) { Activity activity = (Activity) flowElement; if (activity.isAsynchronous()) { writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw); } if (activity.isNotExclusive()) { writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw); } writeDefaultAttribute(ATTRIBUTE_ACTIVITY_DEFAULT, activity.getDefaultFlow(), xtw); } writeAdditionalAttributes(flowElement, xtw); if (StringUtils.isNotEmpty(flowElement.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(flowElement.getDocumentation()); xtw.writeEndElement(); } writeAdditionalChildElements(flowElement, xtw); writeListeners(flowElement, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement(); } if (flowElement instanceof Activity) { Activity activity = (Activity) flowElement; if (activity.getLoopCharacteristics() != null) { MultiInstanceLoopCharacteristics multiInstanceObject = activity.getLoopCharacteristics(); if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality()) || StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem()) || StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE); writeDefaultAttribute( ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL, String.valueOf(multiInstanceObject.isSequential()).toLowerCase(), xtw); if (StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) { writeQualifiedAttribute( ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.getInputDataItem(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getElementVariable())) { writeQualifiedAttribute( ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.getElementVariable(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CARDINALITY); xtw.writeCharacters(multiInstanceObject.getLoopCardinality()); xtw.writeEndElement(); } if (StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CONDITION); xtw.writeCharacters(multiInstanceObject.getCompletionCondition()); xtw.writeEndElement(); } xtw.writeEndElement(); } } } xtw.writeEndElement(); }
protected boolean localizeFlowElements( Collection<FlowElement> flowElements, ObjectNode infoNode) { boolean localizationValuesChanged = false; if (flowElements == null) return localizationValuesChanged; CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService(); for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask || flowElement instanceof SubProcess) { List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals( localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String flowElementId = flowElement.getId(); if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue( locale, flowElementId, "description", documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription( locale, flowElementId, documentation, infoNode); localizationValuesChanged = true; } break; } } } if (flowElement instanceof SubProcess) { SubProcess subprocess = (SubProcess) flowElement; boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } } } } return localizationValuesChanged; }