List of usage examples for javax.xml.stream XMLStreamReader getAttributeValue
public String getAttributeValue(String namespaceURI, String localName);
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;//from www. j ava 2 s.c om 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.ItemDefinitionParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { String itemDefinitionId = model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID); String structureRef = xtr.getAttributeValue(null, ATTRIBUTE_STRUCTURE_REF); if (StringUtils.isNotEmpty(structureRef)) { ItemDefinition item = new ItemDefinition(); item.setId(itemDefinitionId); BpmnXMLUtil.addXMLLocation(item, xtr); int indexOfP = structureRef.indexOf(':'); if (indexOfP != -1) { String prefix = structureRef.substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); structureRef = resolvedNamespace + ":" + structureRef.substring(indexOfP + 1); } else { structureRef = model.getTargetNamespace() + ":" + structureRef; }//from ww w. jav a 2 s .c o m item.setStructureRef(structureRef); item.setItemKind(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_KIND)); BpmnXMLUtil.parseChildElements(ELEMENT_ITEM_DEFINITION, item, xtr, model); model.addItemDefinition(itemDefinitionId, item); } } }
From source file:org.activiti.bpmn.converter.parser.MessageFlowParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String id = xtr.getAttributeValue(null, ATTRIBUTE_ID); if (StringUtils.isNotEmpty(id)) { MessageFlow messageFlow = new MessageFlow(); messageFlow.setId(id);//from w ww .j a v a 2s .co m String name = xtr.getAttributeValue(null, ATTRIBUTE_NAME); if (StringUtils.isNotEmpty(name)) { messageFlow.setName(name); } String sourceRef = xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF); if (StringUtils.isNotEmpty(sourceRef)) { messageFlow.setSourceRef(sourceRef); } String targetRef = xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF); if (StringUtils.isNotEmpty(targetRef)) { messageFlow.setTargetRef(targetRef); } String messageRef = xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF); if (StringUtils.isNotEmpty(messageRef)) { messageFlow.setMessageRef(messageRef); } model.addMessageFlow(messageFlow); } }
From source file:org.activiti.bpmn.converter.parser.MessageParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { String messageId = model.getTargetNamespace() + ":" + xtr.getAttributeValue(null, ATTRIBUTE_ID); String messageName = xtr.getAttributeValue(null, ATTRIBUTE_NAME); String itemRef = parseItemRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_REF), model); Message message = new Message(messageId, messageName, itemRef); BpmnXMLUtil.addXMLLocation(message, xtr); BpmnXMLUtil.parseChildElements(ELEMENT_MESSAGE, message, xtr, model); model.addMessage(message);/*from w w w . ja v a2s. co m*/ } }
From source file:org.activiti.bpmn.converter.parser.ParticipantParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { Pool pool = new Pool(); pool.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID)); pool.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); pool.setProcessRef(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_REF)); BpmnXMLUtil.parseChildElements(ELEMENT_PARTICIPANT, pool, xtr, model); model.getPools().add(pool);// w w w . j ava 2s . co m } }
From source file:org.activiti.bpmn.converter.parser.ProcessParser.java
public Process parse(XMLStreamReader xtr, BpmnModel model) throws Exception { Process process = null;/* w w w . j a va 2 s. c om*/ if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) { String processId = xtr.getAttributeValue(null, ATTRIBUTE_ID); process = new Process(); process.setId(processId); BpmnXMLUtil.addXMLLocation(process, xtr); process.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE))) { process.setExecutable( Boolean.parseBoolean(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE))); } String candidateUsersString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS); if (StringUtils.isNotEmpty(candidateUsersString)) { List<String> candidateUsers = BpmnXMLUtil.parseDelimitedList(candidateUsersString); process.setCandidateStarterUsers(candidateUsers); } String candidateGroupsString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_GROUPS); if (StringUtils.isNotEmpty(candidateGroupsString)) { List<String> candidateGroups = BpmnXMLUtil.parseDelimitedList(candidateGroupsString); process.setCandidateStarterGroups(candidateGroups); } BpmnXMLUtil.addCustomAttributes(xtr, process, ProcessExport.defaultProcessAttributes); model.getProcesses().add(process); } return process; }
From source file:org.activiti.bpmn.converter.parser.SignalParser.java
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String signalId = xtr.getAttributeValue(null, ATTRIBUTE_ID); String signalName = xtr.getAttributeValue(null, ATTRIBUTE_NAME); if (StringUtils.isEmpty(signalId)) { model.addProblem("signal must have an id", xtr); } else if (StringUtils.isEmpty(signalName)) { model.addProblem("signal with id '" + signalId + "' has no name", xtr); } else {//from w w w. ja va2 s . c om for (Signal signal : model.getSignals()) { if (signal.getName().equals(signalName)) { model.addProblem("duplicate signal name", xtr); } } Signal signal = new Signal(signalId, signalName); String scope = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_SCOPE); if (scope != null) { if (!scope.equals(Signal.SCOPE_GLOBAL) && !scope.equals(Signal.SCOPE_PROCESS_INSTANCE)) { model.addProblem( "Invalid value for 'scope'. Only 'global' and 'processInstance' is supported, but value is '" + scope + "'", signal); } signal.setScope(scope); } BpmnXMLUtil.addXMLLocation(signal, xtr); model.addSignal(signal); } }
From source file:org.activiti.bpmn.converter.parser.SubProcessParser.java
public void parse(XMLStreamReader xtr, List<SubProcess> activeSubProcessList, Process activeProcess) { SubProcess subProcess = null;//from w w w . j a v a2s . c o m 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; } subProcess.setAsynchronous(async); subProcess.setNotExclusive(notExclusive); 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); } }
From source file:org.activiti.bpmn.converter.ScriptTaskXMLConverter.java
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception { ScriptTask scriptTask = new ScriptTask(); BpmnXMLUtil.addXMLLocation(scriptTask, xtr); scriptTask.setScriptFormat(xtr.getAttributeValue(null, ATTRIBUTE_TASK_SCRIPT_FORMAT)); scriptTask.setResultVariable(/* w ww. j a va2 s. c o m*/ xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SCRIPT_RESULTVARIABLE)); if (StringUtils.isEmpty(scriptTask.getResultVariable())) { scriptTask.setResultVariable( xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE)); } String autoStoreVariables = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SCRIPT_AUTO_STORE_VARIABLE); if (StringUtils.isNotEmpty(autoStoreVariables)) { scriptTask.setAutoStoreVariables(Boolean.valueOf(autoStoreVariables)); } parseChildElements(getXMLElementName(), scriptTask, childParserMap, model, xtr); return scriptTask; }
From source file:org.activiti.bpmn.converter.SendTaskXMLConverter.java
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception { SendTask sendTask = new SendTask(); BpmnXMLUtil.addXMLLocation(sendTask, xtr); sendTask.setType(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE)); if ("##WebService".equals(xtr.getAttributeValue(null, ATTRIBUTE_TASK_IMPLEMENTATION))) { sendTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE); sendTask.setOperationRef(//from w w w . ja v a2s. c o m parseOperationRef(xtr.getAttributeValue(null, ATTRIBUTE_TASK_OPERATION_REF), model)); } parseChildElements(getXMLElementName(), sendTask, model, xtr); return sendTask; }