public static Map<String, TypeDescriptor> filterDescriptors( Map<String, TypeDescriptor> descriptors) { Map<String, TypeDescriptor> filtered = new HashMap<String, TypeDescriptor>(); for (Entry<String, TypeDescriptor> entry : descriptors.entrySet()) { TypeDescriptor descriptor = entry.getValue(); if (descriptor.getMimeType().contains("'text/xml'")) { filtered.put(entry.getKey(), descriptor); } } return filtered; }
private void defineFromTypeDescriptor() { if (typeDescriptor instanceof ComplexTypeDescriptor) { List elements = ((ComplexTypeDescriptor) typeDescriptor) .getElements(); outputNames = new String[elements.size()]; outputTypes = new String[elements.size()]; Class[] types = new Class[elements.size()]; TypeDescriptor.retrieveSignature(elements, outputNames, types); for (int i = 0; i < types.length; i++) { outputTypes[i] = TypeDescriptor.translateJavaType(types[i]); } } else if (typeDescriptor instanceof ArrayTypeDescriptor) { outputNames = new String[] { typeDescriptor.getName() }; if (((ArrayTypeDescriptor) typeDescriptor).getElementType() instanceof BaseTypeDescriptor) { outputTypes = new String[] { "l('text/plain')" }; } else { outputTypes = new String[] { "l('text/xml')" }; } } }
private String describePort(Port port, TypeDescriptor descriptor) { String html = "<tr><td>"+port.getName()+"</td><td>"; if (descriptor!=null && descriptor.isOptional()) { html += "<em>optional</em><br>"; } html+="Depth:"+port.getDepth()+"<br>"; if (descriptor != null ) { html+="<code>"+descriptor.getQname().toString()+"</code><br>"; if (descriptor.getDocumentation() != null && !descriptor.getDocumentation().isEmpty()){ html += "<p>"+descriptor.getDocumentation()+"</p>"; } } html+="</td></tr>"; return html; }
private String describePort(Port port, TypeDescriptor descriptor) { String html = "<tr><tr>"+port.getName()+"</td></td>"; if (descriptor!=null && descriptor.isOptional()) { html += "<em>optional</em><br>"; } html+="Depth:"+port.getDepth()+"<br>"; if (descriptor != null )html+="<code>"+descriptor.getQname().toString()+"</code><br>"; html+="</td></tr>"; return html; }
private void defineFromTypeDescriptor() { if (typeDescriptor instanceof ComplexTypeDescriptor) { List elements = ((ComplexTypeDescriptor) typeDescriptor) .getElements(); inputNames = new String[elements.size()]; inputTypes = new String[elements.size()]; Class[] types = new Class[elements.size()]; TypeDescriptor.retrieveSignature(elements, inputNames, types); for (int i = 0; i < types.length; i++) { inputTypes[i] = TypeDescriptor.translateJavaType(types[i]); } } else if (typeDescriptor instanceof ArrayTypeDescriptor) { inputNames = new String[] { typeDescriptor.getType() }; if (((ArrayTypeDescriptor) typeDescriptor).getElementType() instanceof BaseTypeDescriptor) { inputTypes = new String[] { "l('text/plain')" }; } else { inputTypes = new String[] { "l('text/xml')" }; } } }
.getElements().get(0); assertEquals("wrong name", "db", typeDesc.getName()); assertEquals("wrong type", "string", typeDesc.getType()); assertTrue("db should be optional", typeDesc.isOptional()); assertFalse("db should not be unbounded", typeDesc.isUnbounded()); assertEquals("wrong name", "tool", typeDesc.getName()); assertEquals("wrong type", "string", typeDesc.getType()); assertTrue("tool should be optional", typeDesc.isOptional()); assertFalse("tool should not be unbounded", typeDesc.isUnbounded()); assertEquals("wrong name", "email", typeDesc.getName()); assertEquals("wrong type", "string", typeDesc.getType()); assertTrue("email should be optional", typeDesc.isOptional()); assertFalse("email should not be unbounded", typeDesc.isUnbounded());
public TypeDescriptor getTypeDescriptorForOutputPort(String portName) { TypeDescriptor result = null; if (typeDescriptor instanceof ComplexTypeDescriptor) { for (TypeDescriptor desc : ((ComplexTypeDescriptor) typeDescriptor) .getElements()) { if (desc.getName().equals(portName)) { result = desc; break; } } } else if (typeDescriptor instanceof ArrayTypeDescriptor) { TypeDescriptor desc = ((ArrayTypeDescriptor)typeDescriptor).getElementType(); if (typeDescriptor.getName().equals(portName)) { result = desc; } } return result; }
public void testBaseTypeUnrecognisedSigniture() { TypeDescriptor date=new BaseTypeDescriptor(); date.setName("adate"); date.setType("date"); List<TypeDescriptor> params=new ArrayList<TypeDescriptor>(); String [] names=new String[1]; Class<?> [] types=new Class[1]; params.add(date); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("should only be 1 type",1,types.length); assertEquals("should only be 1 name",1,names.length); assertEquals("name should be adecimal","adate",names[0]); assertEquals("type should be string",String.class,types[0]); }
.iterator(); inputIterator.hasNext();) { TypeDescriptor elementType = (TypeDescriptor) inputIterator.next(); String key = elementType.getName(); DataThing thing = (DataThing) inputMap.get(key); if (thing != null) { .getElementType(); if (!wrapped) { itemkey = elementType.getName(); } else { if (arrayElementType.getName() != null && arrayElementType.getName().length() > 0) { itemkey = arrayElementType.getName(); } else { itemkey = arrayElementType.getType(); itemObject); dataElement.setNamespace(Namespace .getNamespace(elementType.getNamespaceURI())); if (!wrapped) { dataElement.setName(itemkey); .getNamespaceURI())); XMLOutputter outputter = new XMLOutputter(); String xmlText = outputter.outputString(outputElement);
outTypes = new Class[outputs.size()]; TypeDescriptor.retrieveSignature(inputs, inNames, inTypes); TypeDescriptor.retrieveSignature(outputs, outNames, outTypes); inNames[i]); inputPort.setSyntacticType(TypeDescriptor .translateJavaType(inTypes[i])); addPort(inputPort); outNames[i]); outputPort.setSyntacticType(TypeDescriptor .translateJavaType(outTypes[i])); addPort(outputPort);
public void testRetrieveSignitureForArrayDescriptor() { ArrayTypeDescriptor desc = new ArrayTypeDescriptor(); desc.setName("AnArray"); desc.setType("arrayofstring"); BaseTypeDescriptor base = new BaseTypeDescriptor(); base.setName(""); base.setType("string"); desc.setElementType(base); String[] names = new String[1]; Class<?>[] types = new Class[1]; List<TypeDescriptor> params = new ArrayList<TypeDescriptor>(); params.add(desc); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("AnArray", names[0]); assertEquals(String[].class, types[0]); }
private void configurePorts() throws UnknownOperationException, IOException { List<TypeDescriptor> inputDescriptors = parser .getOperationInputParameters(configurationBean.getOperation().getOperationName()); List<TypeDescriptor> outputDescriptors = parser .getOperationOutputParameters(configurationBean.getOperation().getOperationName()); for (TypeDescriptor descriptor : inputDescriptors) { addInput(descriptor.getName(), descriptor.getDepth(), true, null, String.class); } isWsrfService = parser.isWsrfService(); if (isWsrfService) { // Make sure the port name is unique endpointReferenceInputPortName = ENDPOINT_REFERENCE; int counter = 0; while (Tools.getActivityInputPort(this, endpointReferenceInputPortName) != null) { endpointReferenceInputPortName = ENDPOINT_REFERENCE + counter++; } addInput(endpointReferenceInputPortName, 0, true, null, String.class); } for (TypeDescriptor descriptor : outputDescriptors) { addOutput(descriptor.getName(), descriptor.getDepth()); outputDepth.put(descriptor.getName(), Integer.valueOf(descriptor .getDepth())); } // add output for attachment list addOutput("attachmentList", 1); outputDepth.put("attachmentList", Integer.valueOf(1)); }
@Test public void testCyclicFromElement() throws Exception { String xml = "<s:extensions xmlns:s=\"http://org.embl.ebi.escience/xscufl/0.1alpha\"><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" qname=\"{namespace}typename\"><s:elements><s:complextype id=\"{namespace}typename\" /></s:elements></s:complextype></s:extensions>"; Element el = new SAXBuilder().build(new StringReader(xml)) .getRootElement(); TypeDescriptor a = XMLSplitterSerialisationHelper .extensionXMLToTypeDescriptor(el); assertTrue("wrong type", a instanceof ComplexTypeDescriptor); assertEquals("wrong name", "a", a.getName()); List<TypeDescriptor> a_elements = ((ComplexTypeDescriptor) a).getElements(); assertEquals("should be only 1 element", 1, a_elements.size()); TypeDescriptor b = a_elements.get(0); assertTrue("wrong type", b instanceof ComplexTypeDescriptor); List<TypeDescriptor> b_elements = ((ComplexTypeDescriptor) b).getElements(); assertEquals("should be only 1 element", 1, b_elements.size()); assertEquals("b should contain a reference to a", a.toString(), b_elements.get(0).toString()); }
/** * Returns true if the given port maps to a complex type whose data * structure contains cyclic references * * @param port * @return */ public boolean doesTypeContainCyclicReferences(OutputPort port) { TypeDescriptor td = getTypeDescriptor(port); return TypeDescriptor.isCyclic(td); }
/** * Tests the QName is constructed with the correct URI and LocalPart * * @throws Exception */ @Test public void testCorrectQName() throws Exception { TypeDescriptor desc = XMLSplitterSerialisationHelper .extensionXMLToTypeDescriptor(new SAXBuilder().build( new StringReader(eInfoXML())).getRootElement()); assertEquals("NamespaceURI is incorrect", "http://www.ncbi.nlm.nih.gov/soap/eutils/espell", desc .getQname().getNamespaceURI()); assertEquals("Localpart is incorrect", "eSpellRequest", desc.getQname() .getLocalPart()); }
@Test public void testArrayType() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("bind.wsdl")); List<TypeDescriptor> inputs = parser .getOperationInputParameters("BIVGetRecords"); List<TypeDescriptor> outputs = parser .getOperationOutputParameters("BIVGetRecords"); assertEquals("wrong number of inputs", 1, inputs.size()); assertTrue("input should be of AArrayTypeDescriptor", inputs.get(0) instanceof ArrayTypeDescriptor); ArrayTypeDescriptor arrayTypeDesc = (ArrayTypeDescriptor) inputs.get(0); assertEquals("wrong name", "ids", arrayTypeDesc.getName()); assertEquals("wrong type", "ArrayOf_xsd_int", arrayTypeDesc.getType()); TypeDescriptor typeDesc = arrayTypeDesc.getElementType(); assertTrue("element should be of type BaseTypeDescriptor", typeDesc instanceof BaseTypeDescriptor); assertEquals("wrong type", "int", typeDesc.getType()); assertEquals("wrong number of outputs", 1, outputs.size()); assertTrue("output should be of ArrayTypeDescriptor", outputs.get(0) instanceof ArrayTypeDescriptor); arrayTypeDesc = (ArrayTypeDescriptor) outputs.get(0); assertEquals("wrong name", "BIVRecords", arrayTypeDesc.getName()); assertEquals("wrong type", "ArrayOfBIVRecord", arrayTypeDesc.getType()); typeDesc = arrayTypeDesc.getElementType(); assertEquals("wrong type", "BIVRecord", typeDesc.getType()); }
@Test public void testBaseTypes() throws Exception { WSDLParser parser = new WSDLParser(wsdlResourcePath("bind.wsdl")); List<TypeDescriptor> inputs = parser .getOperationInputParameters("BIVGetRecord"); assertEquals("wrong number of inputs", 1, inputs.size()); assertTrue("should not be base type", inputs.get(0) instanceof BaseTypeDescriptor); assertEquals("wrong name", "bid", (inputs.get(0)) .getName()); assertEquals("wrong type", "int", (inputs.get(0)) .getType()); }
/** * {@inheritDoc} * */ public Map<String, TypeDescriptor> getTypeDescriptorsForInputPorts() throws UnknownOperationException, IOException { Map<String, TypeDescriptor> descriptors = new HashMap<String, TypeDescriptor>(); if (typeDescriptor instanceof ComplexTypeDescriptor) { for (TypeDescriptor desc : ((ComplexTypeDescriptor)typeDescriptor).getElements()) { descriptors.put(desc.getName(), desc); } } else if (typeDescriptor instanceof ArrayTypeDescriptor) { TypeDescriptor desc = ((ArrayTypeDescriptor)typeDescriptor).getElementType(); descriptors.put(typeDescriptor.getName(), desc); } return descriptors; } }
public void testComplex() { TypeDescriptor complex=new ComplexTypeDescriptor(); complex.setName("acomplex"); complex.setType("complextype"); List<TypeDescriptor> params=new ArrayList<TypeDescriptor>(); String [] names=new String[1]; Class<?> [] types=new Class[1]; params.add(complex); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("should only be 1 type",1,types.length); assertEquals("should only be 1 name",1,names.length); assertEquals("name should be adecimal","acomplex",names[0]); assertEquals("type should be string",org.w3c.dom.Element.class,types[0]); }