Example usage for javax.xml.stream XMLStreamReader getAttributeValue

List of usage examples for javax.xml.stream XMLStreamReader getAttributeValue

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamReader getAttributeValue.

Prototype

public String getAttributeValue(String namespaceURI, String localName);

Source Link

Document

Returns the normalized attribute value of the attribute with the namespace and localName If the namespaceURI is null the namespace is not checked for equality

Usage

From source file:org.activiti.bpmn.converter.SequenceFlowXMLConverter.java

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    SequenceFlow sequenceFlow = new SequenceFlow();
    BpmnXMLUtil.addXMLLocation(sequenceFlow, xtr);
    sequenceFlow.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF));
    sequenceFlow.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF));
    sequenceFlow.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));

    parseChildElements(getXMLElementName(), sequenceFlow, model, xtr);

    return sequenceFlow;
}

From source file:org.activiti.bpmn.converter.ServiceTaskXMLConverter.java

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    ServiceTask serviceTask = new ServiceTask();
    BpmnXMLUtil.addXMLLocation(serviceTask, xtr);
    if (StringUtils
            .isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS))) {
        serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
        serviceTask.setImplementation(/*  w  ww  .j a  v  a2s .c o m*/
                xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS));

    } else if (StringUtils.isNotEmpty(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION))) {
        serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
        serviceTask.setImplementation(
                xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION));

    } else if (StringUtils.isNotEmpty(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION))) {
        serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
        serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE,
                ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION));

    } else if ("##WebService".equals(xtr.getAttributeValue(null, ATTRIBUTE_TASK_IMPLEMENTATION))) {
        serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE);
        serviceTask.setOperationRef(
                parseOperationRef(xtr.getAttributeValue(null, ATTRIBUTE_TASK_OPERATION_REF), model));
    }

    serviceTask.setResultVariableName(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE));
    if (StringUtils.isEmpty(serviceTask.getResultVariableName())) {
        serviceTask
                .setResultVariableName(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariable"));
    }

    serviceTask.setType(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE));
    serviceTask.setExtensionId(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXTENSIONID));

    parseChildElements(getXMLElementName(), serviceTask, model, xtr);

    return serviceTask;
}

From source file:org.activiti.bpmn.converter.StartEventXMLConverter.java

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    String formKey = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_FORM_FORMKEY);
    StartEvent startEvent = null;/*from   ww  w  . ja v  a2  s .  c om*/
    if (StringUtils.isNotEmpty(formKey)) {
        if (model.getStartEventFormTypes() != null && model.getStartEventFormTypes().contains(formKey)) {
            startEvent = new AlfrescoStartEvent();
        }
    }
    if (startEvent == null) {
        startEvent = new StartEvent();
    }
    BpmnXMLUtil.addXMLLocation(startEvent, xtr);
    startEvent.setInitiator(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_EVENT_START_INITIATOR));
    startEvent.setFormKey(formKey);

    parseChildElements(getXMLElementName(), startEvent, model, xtr);

    return startEvent;
}

From source file:org.activiti.bpmn.converter.TextAnnotationXMLConverter.java

@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    TextAnnotation textAnnotation = new TextAnnotation();
    BpmnXMLUtil.addXMLLocation(textAnnotation, xtr);
    textAnnotation.setTextFormat(xtr.getAttributeValue(null, ATTRIBUTE_TEXTFORMAT));
    parseChildElements(getXMLElementName(), textAnnotation, childParserMap, model, xtr);
    return textAnnotation;
}

From source file:org.activiti.bpmn.converter.UserTaskXMLConverter.java

@Override
@SuppressWarnings("unchecked")
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    String formKey = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_FORM_FORMKEY);
    UserTask userTask = null;//from  ww  w .j av a2  s  . co  m
    if (StringUtils.isNotEmpty(formKey)) {
        if (model.getUserTaskFormTypes() != null && model.getUserTaskFormTypes().contains(formKey)) {
            userTask = new AlfrescoUserTask();
        }
    }
    if (userTask == null) {
        userTask = new UserTask();
    }
    BpmnXMLUtil.addXMLLocation(userTask, xtr);
    userTask.setDueDate(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_DUEDATE));
    userTask.setCategory(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CATEGORY));
    userTask.setFormKey(formKey);
    userTask.setAssignee(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_ASSIGNEE));
    userTask.setOwner(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_OWNER));
    userTask.setPriority(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_PRIORITY));

    if (StringUtils.isNotEmpty(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CANDIDATEUSERS))) {
        String expression = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE,
                ATTRIBUTE_TASK_USER_CANDIDATEUSERS);
        userTask.getCandidateUsers().addAll(parseDelimitedList(expression));
    }

    if (StringUtils.isNotEmpty(
            xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CANDIDATEGROUPS))) {
        String expression = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE,
                ATTRIBUTE_TASK_USER_CANDIDATEGROUPS);
        userTask.getCandidateGroups().addAll(parseDelimitedList(expression));
    }

    BpmnXMLUtil.addCustomAttributes(xtr, userTask, defaultElementAttributes, defaultActivityAttributes,
            defaultUserTaskAttributes);

    parseChildElements(getXMLElementName(), userTask, childParserMap, model, xtr);

    return userTask;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

public void parseBpmn(XMLStreamReader xtr, Bpmn2MemoryModel model) {
    try {// w  w w .jav a 2s  .  c  o m
        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 StartEvent parseStartEvent(XMLStreamReader xtr) {
    StartEvent startEvent = null;/*from w w w. j a v  a  2  s.c  o m*/
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"))) {
        String[] formTypes = PreferencesUtil.getStringArray(Preferences.ALFRESCO_FORMTYPES_STARTEVENT);
        for (String form : formTypes) {
            if (form.equals(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"))) {
                startEvent = new AlfrescoStartEvent();
            }
        }
    }
    if (startEvent == null) {
        startEvent = new StartEvent();
    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "initiator"))) {
        startEvent.setInitiator(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "initiator"));
    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"))) {
        startEvent.setFormKey(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"));
    }
    boolean readyWithStartEvent = false;
    try {
        while (readyWithStartEvent == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "formProperty".equalsIgnoreCase(xtr.getLocalName())) {
                FormProperty property = new FormProperty();
                startEvent.getFormProperties().add(property);
                parseFormProperty(property, xtr);

            } else if (xtr.isStartElement() && "errorEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                startEvent.getEventDefinitions().add(parseErrorEventDefinition(xtr));

            } else if (xtr.isStartElement() && "timerEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                startEvent.getEventDefinitions().add(parseTimerEventDefinition(xtr));

            } else if (xtr.isEndElement() && "startEvent".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithStartEvent = true;
            }
        }
    } catch (Exception e) {
    }
    return startEvent;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private void parseFormProperty(FormProperty property, XMLStreamReader xtr) {
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "id"))) {
        property.setId(xtr.getAttributeValue(null, "id"));
    }//from  ww w. j  a va 2  s .  c  om
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "name"))) {
        property.setName(xtr.getAttributeValue(null, "name"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "type"))) {
        property.setType(xtr.getAttributeValue(null, "type"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "value"))) {
        property.setValue(xtr.getAttributeValue(null, "value"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "variable"))) {
        property.setVariable(xtr.getAttributeValue(null, "variable"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "expression"))) {
        property.setExpression(xtr.getAttributeValue(null, "expression"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "default"))) {
        property.setDefaultExpression(xtr.getAttributeValue(null, "default"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "datePattern"))) {
        property.setDatePattern(xtr.getAttributeValue(null, "datePattern"));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "required"))) {
        property.setRequired(Boolean.valueOf(xtr.getAttributeValue(null, "required")));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "readable"))) {
        property.setReadable(Boolean.valueOf(xtr.getAttributeValue(null, "readable")));
    }
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "writable"))) {
        property.setWriteable(Boolean.valueOf(xtr.getAttributeValue(null, "writable")));
    }

    boolean readyWithFormProperty = false;
    try {
        while (readyWithFormProperty == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "value".equalsIgnoreCase(xtr.getLocalName())) {
                FormValue value = new FormValue();
                value.setId(xtr.getAttributeValue(null, "id"));
                value.setName(xtr.getAttributeValue(null, "name"));
                property.getFormValues().add(value);

            } else if (xtr.isEndElement() && "formProperty".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithFormProperty = true;
            }
        }
    } catch (Exception e) {
    }
}

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")));
    }/*www  .  j  a v  a 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 SubProcess parseSubProcess(XMLStreamReader xtr) {
    SubProcess subProcess = null;/*from  w ww  . j a v  a2s. co  m*/
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, "triggeredByEvent"))
            && "true".equalsIgnoreCase(xtr.getAttributeValue(null, "triggeredByEvent"))) {

        subProcess = new EventSubProcess();
    } else {
        subProcess = new SubProcess();
    }
    return subProcess;
}