List of usage examples for javax.xml.stream XMLStreamReader getElementText
public String getElementText() throws XMLStreamException;
From source file:org.activiti.bpmn.converter.child.DataAssociationParser.java
public static void parseDataAssociation(DataAssociation dataAssociation, String elementName, XMLStreamReader xtr) { boolean readyWithDataAssociation = false; Assignment assignment = null;/*from w ww .ja v a2 s. c om*/ try { while (readyWithDataAssociation == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_SOURCE_REF.equals(xtr.getLocalName())) { String sourceRef = xtr.getElementText(); if (StringUtils.isNotEmpty(sourceRef)) { dataAssociation.setSourceRef(sourceRef.trim()); } } else if (xtr.isStartElement() && ELEMENT_TARGET_REF.equals(xtr.getLocalName())) { String targetRef = xtr.getElementText(); if (StringUtils.isNotEmpty(targetRef)) { dataAssociation.setTargetRef(targetRef.trim()); } } else if (xtr.isStartElement() && ELEMENT_TRANSFORMATION.equals(xtr.getLocalName())) { String transformation = xtr.getElementText(); if (StringUtils.isNotEmpty(transformation)) { dataAssociation.setTransformation(transformation.trim()); } } else if (xtr.isStartElement() && ELEMENT_ASSIGNMENT.equals(xtr.getLocalName())) { assignment = new Assignment(); BpmnXMLUtil.addXMLLocation(assignment, xtr); } else if (xtr.isStartElement() && ELEMENT_FROM.equals(xtr.getLocalName())) { String from = xtr.getElementText(); if (assignment != null && StringUtils.isNotEmpty(from)) { assignment.setFrom(from.trim()); } } else if (xtr.isStartElement() && ELEMENT_TO.equals(xtr.getLocalName())) { String to = xtr.getElementText(); if (assignment != null && StringUtils.isNotEmpty(to)) { assignment.setTo(to.trim()); } } else if (xtr.isEndElement() && ELEMENT_ASSIGNMENT.equals(xtr.getLocalName())) { if (StringUtils.isNotEmpty(assignment.getFrom()) && StringUtils.isNotEmpty(assignment.getTo())) { dataAssociation.getAssignments().add(assignment); } } else if (xtr.isEndElement() && elementName.equals(xtr.getLocalName())) { readyWithDataAssociation = true; } } } catch (Exception e) { LOGGER.warn("Error parsing data association child elements", e); } }
From source file:org.activiti.bpmn.converter.child.DocumentationParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { String docText = xtr.getElementText(); if (StringUtils.isNotEmpty(docText)) { if (parentElement instanceof FlowElement) { ((FlowElement) parentElement).setDocumentation(docText.trim()); } else if (parentElement instanceof Process) { ((Process) parentElement).setDocumentation(docText.trim()); }/*from ww w. j a v a 2 s.c o m*/ } }
From source file:org.activiti.bpmn.converter.child.FieldExtensionParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof ActivitiListener == false && parentElement instanceof ServiceTask == false && parentElement instanceof SendTask == false) return;//w ww . j a v a 2s. co m FieldExtension extension = new FieldExtension(); BpmnXMLUtil.addXMLLocation(extension, xtr); extension.setFieldName(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_NAME)); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING))) { extension.setStringValue(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING)); } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION))) { extension.setExpression(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION)); } else { boolean readyWithFieldExtension = false; try { while (readyWithFieldExtension == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_FIELD_STRING.equalsIgnoreCase(xtr.getLocalName())) { extension.setStringValue(xtr.getElementText().trim()); } else if (xtr.isStartElement() && ATTRIBUTE_FIELD_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) { extension.setExpression(xtr.getElementText().trim()); } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithFieldExtension = true; } } } catch (Exception e) { LOGGER.warn("Error parsing field extension child elements", e); } } if (parentElement instanceof ActivitiListener) { ((ActivitiListener) parentElement).getFieldExtensions().add(extension); } else if (parentElement instanceof ServiceTask) { ((ServiceTask) parentElement).getFieldExtensions().add(extension); } else { ((SendTask) parentElement).getFieldExtensions().add(extension); } }
From source file:org.activiti.bpmn.converter.child.IOSpecificationParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof ServiceTask == false && parentElement instanceof SendTask == false && parentElement instanceof SubProcess == false && parentElement instanceof Process == false) return;/*from www . j a va 2 s. co m*/ IOSpecification ioSpecification = new IOSpecification(); BpmnXMLUtil.addXMLLocation(ioSpecification, xtr); boolean readyWithIOSpecification = false; try { while (readyWithIOSpecification == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) { DataSpec dataSpec = new DataSpec(); BpmnXMLUtil.addXMLLocation(dataSpec, xtr); dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); dataSpec.setItemSubjectRef( parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_DATA_SUBJECT_REF), model)); ioSpecification.getDataInputs().add(dataSpec); } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) { DataSpec dataSpec = new DataSpec(); BpmnXMLUtil.addXMLLocation(dataSpec, xtr); dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); dataSpec.setItemSubjectRef( parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_DATA_SUBJECT_REF), model)); ioSpecification.getDataOutputs().add(dataSpec); } else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) { String dataInputRefs = xtr.getElementText(); if (StringUtils.isNotEmpty(dataInputRefs)) { ioSpecification.getDataInputRefs().add(dataInputRefs.trim()); } } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) { String dataOutputRefs = xtr.getElementText(); if (StringUtils.isNotEmpty(dataOutputRefs)) { ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim()); } } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) { readyWithIOSpecification = true; } } } catch (Exception e) { LOGGER.warn("Error parsing ioSpecification child elements", e); } if (parentElement instanceof Process) { ((Process) parentElement).setIoSpecification(ioSpecification); } else { ((Activity) parentElement).setIoSpecification(ioSpecification); } }
From source file:org.activiti.bpmn.converter.child.TimeCycleParser.java
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (parentElement instanceof TimerEventDefinition == false) return;/*w w w. jav a2 s . c o m*/ TimerEventDefinition eventDefinition = (TimerEventDefinition) parentElement; if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_END_DATE))) { eventDefinition.setEndDate(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_END_DATE)); } eventDefinition.setTimeCycle(xtr.getElementText()); }
From source file:org.activiti.bpmn.converter.parser.InterfaceParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { Interface interfaceObject = new Interface(); BpmnXMLUtil.addXMLLocation(interfaceObject, xtr); interfaceObject.setId(model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID)); interfaceObject.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); interfaceObject.setImplementationRef( parseMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_IMPLEMENTATION_REF), model)); boolean readyWithInterface = false; Operation operation = null;/*ww w . ja va2s .co m*/ try { while (readyWithInterface == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_OPERATION.equals(xtr.getLocalName())) { operation = new Operation(); BpmnXMLUtil.addXMLLocation(operation, xtr); operation.setId(model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID)); operation.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); operation.setImplementationRef( parseMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_IMPLEMENTATION_REF), model)); } else if (xtr.isStartElement() && ELEMENT_IN_MESSAGE.equals(xtr.getLocalName())) { String inMessageRef = xtr.getElementText(); if (operation != null && StringUtils.isNotEmpty(inMessageRef)) { operation.setInMessageRef(parseMessageRef(inMessageRef.trim(), model)); } } else if (xtr.isStartElement() && ELEMENT_OUT_MESSAGE.equals(xtr.getLocalName())) { String outMessageRef = xtr.getElementText(); if (operation != null && StringUtils.isNotEmpty(outMessageRef)) { operation.setOutMessageRef(parseMessageRef(outMessageRef.trim(), model)); } } else if (xtr.isEndElement() && ELEMENT_OPERATION.equalsIgnoreCase(xtr.getLocalName())) { if (operation != null && StringUtils.isNotEmpty(operation.getImplementationRef())) { interfaceObject.getOperations().add(operation); } } else if (xtr.isEndElement() && ELEMENT_INTERFACE.equals(xtr.getLocalName())) { readyWithInterface = true; } } } catch (Exception e) { LOGGER.warn("Error parsing interface child elements", e); } model.getInterfaces().add(interfaceObject); }
From source file:org.activiti.bpmn.converter.parser.PotentialStarterParser.java
public void parse(XMLStreamReader xtr, Process activeProcess) throws Exception { String resourceElement = XMLStreamReaderUtil.moveDown(xtr); if (StringUtils.isNotEmpty(resourceElement) && "resourceAssignmentExpression".equals(resourceElement)) { String expression = XMLStreamReaderUtil.moveDown(xtr); if (StringUtils.isNotEmpty(expression) && "formalExpression".equals(expression)) { List<String> assignmentList = new ArrayList<String>(); String assignmentText = xtr.getElementText(); if (assignmentText.contains(",")) { String[] assignmentArray = assignmentText.split(","); assignmentList = Arrays.asList(assignmentArray); } else { assignmentList.add(assignmentText); }/* w ww. j ava 2 s. co m*/ for (String assignmentValue : assignmentList) { if (assignmentValue == null) continue; assignmentValue = assignmentValue.trim(); if (assignmentValue.length() == 0) continue; String userPrefix = "user("; String groupPrefix = "group("; if (assignmentValue.startsWith(userPrefix)) { assignmentValue = assignmentValue .substring(userPrefix.length(), assignmentValue.length() - 1).trim(); activeProcess.getCandidateStarterUsers().add(assignmentValue); } else if (assignmentValue.startsWith(groupPrefix)) { assignmentValue = assignmentValue .substring(groupPrefix.length(), assignmentValue.length() - 1).trim(); activeProcess.getCandidateStarterGroups().add(assignmentValue); } else { activeProcess.getCandidateStarterGroups().add(assignmentValue); } } } } }
From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java
public void parseBpmn(XMLStreamReader xtr, Bpmn2MemoryModel model) { try {//from w w w. j av a 2 s .com boolean processExtensionAvailable = false; Process activeProcess = null; List<SubProcess> activeSubProcessList = new ArrayList<SubProcess>(); while (xtr.hasNext()) { try { xtr.next(); } catch (Exception e) { return; } if (xtr.isEndElement() && "subProcess".equalsIgnoreCase(xtr.getLocalName())) { activeSubProcessList.remove(activeSubProcessList.size() - 1); } if (xtr.isStartElement() == false) continue; if (xtr.isStartElement() && "definitions".equalsIgnoreCase(xtr.getLocalName())) { model.setTargetNamespace(xtr.getAttributeValue(null, "targetNamespace")); } else if (xtr.isStartElement() && "signal".equalsIgnoreCase(xtr.getLocalName())) { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "id"))) { Signal signal = new Signal(); signal.setId(xtr.getAttributeValue(null, "id")); signal.setName(xtr.getAttributeValue(null, "name")); model.getSignals().add(signal); } } else if (xtr.isStartElement() && "participant".equalsIgnoreCase(xtr.getLocalName())) { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "id"))) { Pool pool = new Pool(); pool.setId(xtr.getAttributeValue(null, "id")); pool.setName(xtr.getAttributeValue(null, "name")); pool.setProcessRef(xtr.getAttributeValue(null, "processRef")); model.getPools().add(pool); } } else if (xtr.isStartElement() && "process".equalsIgnoreCase(xtr.getLocalName())) { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "id"))) { String processId = xtr.getAttributeValue(null, "id"); processExtensionAvailable = true; Process process = new Process(); process.setId(processId); process.setName(xtr.getAttributeValue(null, "name")); model.getProcesses().add(process); activeProcess = process; } } else if (xtr.isStartElement() && "lane".equalsIgnoreCase(xtr.getLocalName())) { Lane lane = new Lane(); lane.setId(xtr.getAttributeValue(null, "id")); lane.setName(xtr.getAttributeValue(null, "name")); lane.setParentProcess(activeProcess); activeProcess.getLanes().add(lane); while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && "flowNodeRef".equalsIgnoreCase(xtr.getLocalName())) { lane.getFlowReferences().add(xtr.getElementText()); } else if (xtr.isEndElement() && "lane".equalsIgnoreCase(xtr.getLocalName())) { break; } } } else if (xtr.isStartElement() && "documentation".equalsIgnoreCase(xtr.getLocalName())) { String docText = xtr.getElementText(); if (StringUtils.isNotEmpty(docText)) { if (activeSubProcessList.size() > 0) { activeSubProcessList.get(activeSubProcessList.size() - 1).setDocumentation(docText); } else if (activeProcess != null) { activeProcess.setDocumentation(docText); } } } else if (processExtensionAvailable == true && xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) { activeProcess.getExecutionListeners().addAll(parseListeners(xtr)); processExtensionAvailable = false; } else { Artifact currentArtifact = null; FlowNode currentActivity = null; String elementId = xtr.getAttributeValue(null, "id"); String elementName = xtr.getAttributeValue(null, "name"); boolean async = parseAsync(xtr); boolean notExclusive = parseNotExclusive(xtr); String defaultFlow = xtr.getAttributeValue(null, "default"); processExtensionAvailable = false; if (xtr.isStartElement() && "startEvent".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseStartEvent(xtr); } else if (xtr.isStartElement() && "subProcess".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseSubProcess(xtr); activeSubProcessList.add((SubProcess) currentActivity); } else if (activeSubProcessList.size() > 0 && xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) { activeSubProcessList.get(activeSubProcessList.size() - 1).getExecutionListeners() .addAll(parseListeners(xtr)); } else if (activeSubProcessList.size() > 0 && xtr.isStartElement() && "multiInstanceLoopCharacteristics".equalsIgnoreCase(xtr.getLocalName())) { activeSubProcessList.get(activeSubProcessList.size() - 1) .setLoopCharacteristics(parseMultiInstanceDef(xtr)); } else if (xtr.isStartElement() && "userTask".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseUserTask(xtr); } else if (xtr.isStartElement() && "serviceTask".equalsIgnoreCase(xtr.getLocalName())) { if ("mail".equalsIgnoreCase(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "type"))) { currentActivity = parseMailTask(xtr, "serviceTask"); } else if ("org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate" .equalsIgnoreCase(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "class"))) { currentActivity = parseAlfrescoScriptTask(xtr); } else { currentActivity = parseServiceTask(xtr); } } else if (xtr.isStartElement() && "sendTask".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseMailTask(xtr, "sendTask"); } else if (xtr.isStartElement() && "task".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseTask(xtr); } else if (xtr.isStartElement() && "scriptTask".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseScriptTask(xtr); } else if (xtr.isStartElement() && "manualTask".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseManualTask(xtr); } else if (xtr.isStartElement() && "receiveTask".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseReceiveTask(xtr); } else if (xtr.isStartElement() && "businessRuleTask".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseBusinessRuleTask(xtr); } else if (xtr.isStartElement() && "callActivity".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseCallActivity(xtr); } else if (xtr.isStartElement() && "endEvent".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseEndEvent(xtr); } else if (xtr.isStartElement() && "intermediateCatchEvent".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseIntermediateCatchEvent(xtr); } else if (xtr.isStartElement() && "intermediateThrowEvent".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseIntermediateThrowEvent(xtr); } else if (xtr.isStartElement() && "exclusiveGateway".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseExclusiveGateway(xtr); } else if (xtr.isStartElement() && "inclusiveGateway".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseInclusiveGateway(xtr); } else if (xtr.isStartElement() && "parallelGateway".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseParallelGateway(xtr); } else if (xtr.isStartElement() && "eventBasedGateway".equalsIgnoreCase(xtr.getLocalName())) { currentActivity = parseEventGateway(xtr); } else if (xtr.isStartElement() && "boundaryEvent".equalsIgnoreCase(xtr.getLocalName())) { String elementid = xtr.getAttributeValue(null, "id"); BoundaryEventModel event = parseBoundaryEvent(xtr); event.boundaryEvent.setId(elementid); event.parentProcess = activeProcess; boundaryList.add(event); } else if (xtr.isStartElement() && "sequenceFlow".equalsIgnoreCase(xtr.getLocalName())) { SequenceFlowModel sequenceFlow = parseSequenceFlow(xtr); sequenceFlow.parentProcess = activeProcess; sequenceFlowList.add(sequenceFlow); } else if (xtr.isStartElement() && "textAnnotation".equalsIgnoreCase(xtr.getLocalName())) { currentArtifact = parseTextAnnotation(xtr); } else if (xtr.isStartElement() && "association".equalsIgnoreCase(xtr.getLocalName())) { final AssociationModel associationModel = parseAssociation(xtr); associationModel.parentProcess = activeProcess; associationModels.add(associationModel); } else if (xtr.isStartElement() && "BPMNShape".equalsIgnoreCase(xtr.getLocalName())) { bpmdiInfoFound = true; String id = xtr.getAttributeValue(null, "bpmnElement"); while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && "Bounds".equalsIgnoreCase(xtr.getLocalName())) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.x = Double.valueOf(xtr.getAttributeValue(null, "x")).intValue(); graphicInfo.y = Double.valueOf(xtr.getAttributeValue(null, "y")).intValue(); graphicInfo.height = Double.valueOf(xtr.getAttributeValue(null, "height")) .intValue(); graphicInfo.width = Double.valueOf(xtr.getAttributeValue(null, "width")).intValue(); model.addGraphicInfo(id, graphicInfo); break; } } } else if (xtr.isStartElement() && "BPMNEdge".equalsIgnoreCase(xtr.getLocalName())) { String id = xtr.getAttributeValue(null, "bpmnElement"); List<GraphicInfo> wayPointList = new ArrayList<GraphicInfo>(); while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && "BPMNLabel".equalsIgnoreCase(xtr.getLocalName())) { while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && "Bounds".equalsIgnoreCase(xtr.getLocalName())) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.x = Double.valueOf(xtr.getAttributeValue(null, "x")).intValue(); graphicInfo.y = Double.valueOf(xtr.getAttributeValue(null, "y")).intValue(); labelLocationMap.put(id, graphicInfo); break; } else if (xtr.isEndElement() && "BPMNLabel".equalsIgnoreCase(xtr.getLocalName())) { break; } } } else if (xtr.isStartElement() && "waypoint".equalsIgnoreCase(xtr.getLocalName())) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.x = Double.valueOf(xtr.getAttributeValue(null, "x")).intValue(); graphicInfo.y = Double.valueOf(xtr.getAttributeValue(null, "y")).intValue(); wayPointList.add(graphicInfo); } else if (xtr.isEndElement() && "BPMNEdge".equalsIgnoreCase(xtr.getLocalName())) { break; } } flowLocationMap.put(id, wayPointList); } if (currentArtifact != null) { currentArtifact.setId(elementId); if (isInSubProcess(activeSubProcessList)) { final SubProcess currentSubProcess = activeSubProcessList .get(activeSubProcessList.size() - 2); currentSubProcess.getArtifacts().add(currentArtifact); } else { activeProcess.getArtifacts().add(currentArtifact); } } if (currentActivity != null) { currentActivity.setId(elementId); currentActivity.setName(elementName); if (currentActivity instanceof Activity) { Activity activity = (Activity) currentActivity; activity.setAsynchronous(async); activity.setNotExclusive(notExclusive); if (StringUtils.isNotEmpty(defaultFlow)) { activity.setDefaultFlow(defaultFlow); } } if (currentActivity instanceof Gateway) { if (StringUtils.isNotEmpty(defaultFlow)) { ((Gateway) currentActivity).setDefaultFlow(defaultFlow); } } if (currentActivity instanceof SubProcess) { if (isInSubProcess(activeSubProcessList)) { activeSubProcessList.get(activeSubProcessList.size() - 2).getFlowElements() .add(currentActivity); } else { activeProcess.getFlowElements().add(currentActivity); } } else if (activeSubProcessList.size() > 0) { activeSubProcessList.get(activeSubProcessList.size() - 1).getFlowElements() .add(currentActivity); } else { activeProcess.getFlowElements().add(currentActivity); } } } } for (BoundaryEventModel boundaryModel : boundaryList) { FlowNode flowNode = getFlowNode(boundaryModel.attachedRef, boundaryModel.parentProcess.getFlowElements()); if (flowNode != null) { boundaryModel.boundaryEvent.setAttachedToRef((Activity) flowNode); ((Activity) flowNode).getBoundaryEvents().add(boundaryModel.boundaryEvent); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java
private MultiInstanceLoopCharacteristics parseMultiInstanceDef(XMLStreamReader xtr) { MultiInstanceLoopCharacteristics multiInstanceDef = new MultiInstanceLoopCharacteristics(); if (xtr.getAttributeValue(null, "isSequential") != null) { multiInstanceDef.setSequential(Boolean.valueOf(xtr.getAttributeValue(null, "isSequential"))); }/*from ww w . j a va 2 s . c o m*/ if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "collection") != null) { multiInstanceDef.setInputDataItem(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "collection")); } if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "elementVariable") != null) { multiInstanceDef .setElementVariable(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "elementVariable")); } boolean readyWithMultiInstance = false; try { while (readyWithMultiInstance == false && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && "loopCardinality".equalsIgnoreCase(xtr.getLocalName())) { multiInstanceDef.setLoopCardinality(xtr.getElementText()); } else if (xtr.isStartElement() && "loopDataInputRef".equalsIgnoreCase(xtr.getLocalName())) { multiInstanceDef.setInputDataItem(xtr.getElementText()); } else if (xtr.isStartElement() && "inputDataItem".equalsIgnoreCase(xtr.getLocalName())) { if (xtr.getAttributeValue(null, "name") != null) { multiInstanceDef.setElementVariable(xtr.getAttributeValue(null, "name")); } } else if (xtr.isStartElement() && "completionCondition".equalsIgnoreCase(xtr.getLocalName())) { multiInstanceDef.setCompletionCondition(xtr.getElementText()); } else if (xtr.isEndElement() && "multiInstanceLoopCharacteristics".equalsIgnoreCase(xtr.getLocalName())) { readyWithMultiInstance = true; } } } catch (Exception e) { e.printStackTrace(); } return multiInstanceDef; }
From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java
private TextAnnotation parseTextAnnotation(XMLStreamReader xtr) throws XMLStreamException { final TextAnnotation ta = new TextAnnotation(); ta.setId(xtr.getAttributeValue(null, "id")); ta.setTextFormat(xtr.getAttributeValue(null, "textFormat")); while (xtr.hasNext()) { xtr.next();/*w w w . j av a2 s . com*/ if (xtr.isStartElement() && "text".equalsIgnoreCase(xtr.getLocalName())) { ta.setText(xtr.getElementText()); break; } } return ta; }