List of usage examples for org.w3c.dom Element getAttributeNode
public Attr getAttributeNode(String name);
From source file:org.jbpm.bpel.xml.BpelReader.java
private VariableType getVariableType(Element variableElem, ImportDefinition importDefinition) { VariableType type;//from w w w .j av a2 s.c om Attr schemaType = variableElem.getAttributeNode(BpelConstants.ATTR_TYPE); Attr elementName = variableElem.getAttributeNode(BpelConstants.ATTR_ELEMENT); Attr messageType = variableElem.getAttributeNode(BpelConstants.ATTR_MESSAGE_TYPE); if (messageType != null) { if (schemaType != null || elementName != null) problemHandler.add(new ParseProblem("more than one type specifier present", variableElem)); type = getMessageType(variableElem, messageType, importDefinition); } else if (schemaType != null) { if (elementName != null) problemHandler.add(new ParseProblem("more than one type specifier present", variableElem)); type = getSchemaType(variableElem, schemaType, importDefinition); } else if (elementName != null) { type = getElementType(variableElem, elementName, importDefinition); } else { problemHandler.add(new ParseProblem("no type specifier present", variableElem)); type = null; } return type; }
From source file:org.jbpm.bpel.xml.BpelReader.java
protected PartnerLinkDefinition readPartnerLink(Element partnerLinkElem, CompositeActivity parent) { PartnerLinkDefinition partnerLink = new PartnerLinkDefinition(); partnerLink.setName(partnerLinkElem.getAttribute(BpelConstants.ATTR_NAME)); // partner link type QName typeName = XmlUtil//from w w w. j a v a 2s. c o m .getQNameValue(partnerLinkElem.getAttributeNode(BpelConstants.ATTR_PARTNER_LINK_TYPE)); PartnerLinkType type = parent.getBpelProcessDefinition().getImportDefinition().getPartnerLinkType(typeName); if (type == null) { problemHandler.add(new ParseProblem("partner link type not found", partnerLinkElem)); return partnerLink; } partnerLink.setPartnerLinkType(type); String myRoleName = XmlUtil.getAttribute(partnerLinkElem, BpelConstants.ATTR_MY_ROLE); String partnerRoleName = XmlUtil.getAttribute(partnerLinkElem, BpelConstants.ATTR_PARTNER_ROLE); boolean partnerFirst = false; // first role Role role = type.getFirstRole(); String roleName = role.getName(); if (roleName.equals(myRoleName)) { partnerLink.setMyRole(role); } else if (roleName.equals(partnerRoleName)) { partnerLink.setPartnerRole(role); partnerFirst = true; } else { problemHandler.add(new ParseProblem( "neither my role nor partner role match the first partner link type role", partnerLinkElem)); return partnerLink; } PortType portType = role.getPortType(); if (portType.isUndefined()) { problemHandler.add(new ParseProblem("port type not found: " + portType.getQName(), partnerLinkElem)); } // second role role = type.getSecondRole(); if (role != null) { roleName = role.getName(); if (partnerFirst) { if (!roleName.equals(myRoleName)) { problemHandler.add(new ParseProblem("my role does not match the second partner link type role", partnerLinkElem)); } partnerLink.setMyRole(role); } else { if (!roleName.equals(partnerRoleName)) { problemHandler.add(new ParseProblem( "partner role does not match the second partner link type role", partnerLinkElem)); } partnerLink.setPartnerRole(role); } portType = role.getPortType(); if (portType.isUndefined()) { problemHandler .add(new ParseProblem("port type not found: " + portType.getQName(), partnerLinkElem)); } } else if (partnerFirst ? myRoleName != null : partnerRoleName != null) problemHandler.add(new ParseProblem("partner link type has one role only", partnerLinkElem)); return partnerLink; }
From source file:org.jbpm.bpel.xml.BpelReader.java
PortType getMessageActivityPortType(Element serviceElem, Role role) { PortType effectivePortType = role.getPortType(); // validate port type attribute, if present Attr portTypeAttr = serviceElem.getAttributeNode(BpelConstants.ATTR_PORT_TYPE); if (portTypeAttr != null) { QName portTypeName = XmlUtil.getQNameValue(portTypeAttr); if (!effectivePortType.getQName().equals(portTypeName)) { problemHandler.add(new ParseProblem("port type mismatch between message activity and partner link", serviceElem));/*from w w w . j a v a 2 s . c o m*/ } } return effectivePortType; }
From source file:org.jbpm.bpel.xml.DeploymentDescriptorReader.java
protected MyRoleDescriptor readMyRole(Element myRoleElem) { MyRoleDescriptor myRole = new MyRoleDescriptor(); // partner link handle String handle = XmlUtil.getAttribute(myRoleElem, BpelConstants.ATTR_HANDLE); if (handle != null) myRole.setHandle(handle);/*from w w w.j a v a2 s .c o m*/ // service and port Attr service = myRoleElem.getAttributeNode(BpelConstants.ATTR_SERVICE); String port = XmlUtil.getAttribute(myRoleElem, BpelConstants.ATTR_PORT); if (service != null) { myRole.setService(XmlUtil.getQNameValue(service)); if (port != null) myRole.setPort(port); } else if (port != null) problemHandler.add(new ParseProblem("port is not combined with service", myRoleElem)); return myRole; }
From source file:org.jbpm.designer.server.service.DefaultDesignerAssetServiceTest.java
@Test public void testCreateProcessWithMultiLevelPackage() throws Exception { final Path pathSource = mock(Path.class); when(pathSource.toURI()).thenReturn("default://p0/Evaluation/src/main/resources/org/jbpm/test/process"); when(pathSource.getFileName()).thenReturn("MyProcess.bpmn2"); DefaultDesignerAssetService assetService = new DefaultDesignerAssetService(); assetService.setRepository(repository); final ArgumentCaptor<Asset> assetArgumentCaptor = ArgumentCaptor.forClass(Asset.class); assetService.createProcess(pathSource, "MyProcess.bpmn2"); verify(repository, times(1)).createAsset(assetArgumentCaptor.capture()); Asset<String> asset = assetArgumentCaptor.getValue(); assertNotNull(asset);//from ww w . j a v a 2 s.c o m assertNotNull(asset.getAssetContent()); Element element = getProcessElementFromXml(asset.getAssetContent()); assertNotNull(element); String processId = element.getAttribute("id"); assertNotNull(processId); assertEquals("Evaluation.org.jbpm.test.process.MyProcess", processId); String packageName = element.getAttribute("drools:packageName"); assertNotNull(packageName); assertEquals("org.jbpm.test.process", packageName); Element definitionsElement = getDefinitionsElementFromXml(asset.getAssetContent()); assertNotNull(definitionsElement); String exporter = definitionsElement.getAttributeNode("exporter").getValue(); assertNotNull(exporter); assertEquals("jBPM Designer", exporter); String exporterVersion = definitionsElement.getAttributeNode("exporterVersion").getValue(); assertNotNull(exporterVersion); assertEquals("1.0", exporterVersion); }
From source file:org.jbpm.designer.server.service.DefaultDesignerAssetServiceTest.java
@Test public void testCreateCaseDefinitionWithDefaultPackage() throws Exception { final Path pathSource = mock(Path.class); when(pathSource.toURI()).thenReturn("default://p0/Evaluation/src/main/resources/org/jbpm/test/cases"); when(pathSource.getFileName()).thenReturn("MyCase.bpmn2"); DefaultDesignerAssetService assetService = new DefaultDesignerAssetService(); assetService.setRepository(repository); final ArgumentCaptor<Asset> assetArgumentCaptor = ArgumentCaptor.forClass(Asset.class); assetService.createCaseDefinition(pathSource, "MyCase.bpmn2", "HR"); verify(repository, times(1)).createAsset(assetArgumentCaptor.capture()); Asset<String> asset = assetArgumentCaptor.getValue(); assertNotNull(asset);//from w w w .j a v a 2s . c o m assertNotNull(asset.getAssetContent()); Element element = getProcessElementFromXml(asset.getAssetContent()); assertNotNull(element); String processId = element.getAttribute("id"); assertNotNull(processId); assertEquals("Evaluation.org.jbpm.test.cases.MyCase", processId); String packageName = element.getAttribute("drools:packageName"); assertNotNull(packageName); assertEquals("org.jbpm.test.cases", packageName); String adHoc = element.getAttribute("drools:adHoc"); assertNotNull(adHoc); assertEquals("true", adHoc); Element metadataElement = getMetaDataElementFromXml(asset.getAssetContent()); String caseIdPrefix = metadataElement.getAttribute("name"); assertNotNull(caseIdPrefix); assertEquals("customCaseIdPrefix", caseIdPrefix); String caseIdPrefixValue = metadataElement.getFirstChild().getNextSibling().getTextContent(); assertNotNull(caseIdPrefixValue); assertEquals("HR", caseIdPrefixValue); Element definitionsElement = getDefinitionsElementFromXml(asset.getAssetContent()); assertNotNull(definitionsElement); String exporter = definitionsElement.getAttributeNode("exporter").getValue(); assertNotNull(exporter); assertEquals("jBPM Designer", exporter); String exporterVersion = definitionsElement.getAttributeNode("exporterVersion").getValue(); assertNotNull(exporterVersion); assertEquals("1.0", exporterVersion); }
From source file:org.kepler.sms.util.OntologyConfiguration.java
/** * Get the file path names for the ontologies *//*w w w. j av a 2 s . c om*/ public Iterator getFilePathNames() { Vector result = new Vector(); if (_document == null) return result.iterator(); // get the root Element root = _document.getDocumentElement(); if (root == null) return result.iterator(); // iterate through root, get each ontology element and its // filename NodeList lst = root.getElementsByTagName("ontology"); for (int i = 0; i < lst.getLength(); i++) { Element elem = (Element) lst.item(i); Attr att = elem.getAttributeNode("filename"); if (att != null) { String filename = att.getValue(); if (filename != null) result.addElement(getAbsoluteOntologyPath(filename)); } } return result.iterator(); }
From source file:org.kepler.sms.util.OntologyConfiguration.java
public Color getLibraryColor(String filepath) { if (_document == null || filepath == null) return null; // get the root Element root = _document.getDocumentElement(); if (root == null) return null; filepath = new File(filepath).getAbsolutePath(); // iterate to find the ontology with filepath NodeList lst = root.getElementsByTagName("ontology"); for (int i = 0; i < lst.getLength(); i++) { Element elem = (Element) lst.item(i); Attr att = elem.getAttributeNode("filename"); if (att != null) { String filename = att.getValue(); if (filepath.equals(getAbsoluteOntologyPath(filename))) { Attr libatt = elem.getAttributeNode("color"); if (libatt != null) { String colorString = libatt.getValue(); return new Color(colorString); }/*from w w w. ja va2s. c o m*/ } } } if (!defaultSetColors.containsKey(filepath)) { if (defaultColors.isEmpty()) { return Color.getDefaultColor(); } defaultSetColors.put(filepath, defaultColors.remove(defaultColors.size() - 1)); } return defaultSetColors.get(filepath); }
From source file:org.kepler.sms.util.OntologyConfiguration.java
public Boolean isLibraryLocal(String filepath) { if (_document == null || filepath == null) return null; // get the root Element root = _document.getDocumentElement(); if (root == null) return null; // iterate to find the ontology with filepath NodeList lst = root.getElementsByTagName("ontology"); for (int i = 0; i < lst.getLength(); i++) { Element elem = (Element) lst.item(i); Attr att = elem.getAttributeNode("filename"); if (att != null) { String filename = att.getValue(); if (filepath.equals(getAbsoluteOntologyPath(filename))) { Attr libatt = elem.getAttributeNode("local"); if (libatt != null) { String localityString = libatt.getValue(); return "true".equals(localityString); } else { // Default to not editable return false; }//from w w w .j a va 2 s. c om } } } return false; }
From source file:org.kepler.sms.util.OntologyConfiguration.java
/** * @return True if the filepath is suitable as a library categorization. *///from www. ja v a2s . com public boolean isLibraryOntology(String filepath) { if (_document == null || filepath == null) return false; // get the root Element root = _document.getDocumentElement(); if (root == null) return false; // iterate to find the ontology with filepath NodeList lst = root.getElementsByTagName("ontology"); for (int i = 0; i < lst.getLength(); i++) { Element elem = (Element) lst.item(i); Attr att = elem.getAttributeNode("filename"); if (att != null) { String filename = att.getValue(); if (filepath.equals(getAbsoluteOntologyPath(filename))) { Attr libatt = elem.getAttributeNode("library"); if (libatt != null) { String library = libatt.getValue(); if (library != null && library.equals("true")) return true; } } } } return false; }