Search in sources :

Example 1 with XmlSchemaComplexContent

use of org.apache.ws.commons.schema.XmlSchemaComplexContent in project ddf by codice.

the class FeatureMetacardTypeTest method testFeatureMetacardTypeComplexContentWithStringAndGmlProperties.

@Test
public void testFeatureMetacardTypeComplexContentWithStringAndGmlProperties() {
    XmlSchema schema = new XmlSchema();
    // Create the GML and String types
    XmlSchemaElement gmlElement = new XmlSchemaElement(schema, true);
    gmlElement.setSchemaType(new XmlSchemaComplexType(schema, false));
    gmlElement.setSchemaTypeName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, GML));
    gmlElement.setName(ELEMENT_NAME_1);
    XmlSchemaElement stringElement = new XmlSchemaElement(schema, true);
    stringElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
    stringElement.setSchemaTypeName(Constants.XSD_STRING);
    stringElement.setName(ELEMENT_NAME_2);
    // build the complex objects
    XmlSchemaElement complexElement = new XmlSchemaElement(schema, true);
    XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, false);
    XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent();
    XmlSchemaComplexContentExtension contentExtension = new XmlSchemaComplexContentExtension();
    XmlSchemaSequence particle = new XmlSchemaSequence();
    particle.getItems().add(stringElement);
    contentExtension.setParticle(particle);
    complexContent.setContent(contentExtension);
    complexType.setContentModel(complexContent);
    complexElement.setSchemaType(complexType);
    complexElement.setSchemaTypeName(new QName("Complex"));
    schema.getElements().put(new QName(ELEMENT_NAME_2), complexElement);
    FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
    assertTrue(featureMetacardType.getTextualProperties().size() == 1);
    assertTrue(featureMetacardType.getGmlProperties().size() == 1);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_2, BasicTypes.STRING_TYPE);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.GEO_TYPE);
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaComplexContent(org.apache.ws.commons.schema.XmlSchemaComplexContent) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Test(org.junit.Test)

Example 2 with XmlSchemaComplexContent

use of org.apache.ws.commons.schema.XmlSchemaComplexContent in project tdi-studio-se by Talend.

the class ComponentBuilderTest method testBuildParameterFromTypes.

@Test
public void testBuildParameterFromTypes() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, WSDLException {
    ParameterInfo parameter = new ParameterInfo();
    String name = "parameter";
    String nameSpace = "http://parameter";
    parameter.setName(name);
    parameter.setNameSpace(nameSpace);
    ComponentBuilder cb = new ComponentBuilder();
    Field field = cb.getClass().getDeclaredField("allXmlSchemaType");
    field.setAccessible(true);
    List<XmlSchemaType> allXmlSchemaType = (List<XmlSchemaType>) field.get(cb);
    XmlSchema first = new XmlSchema();
    first.setId("first");
    XmlSchemaSimpleType xsst = new XmlSchemaSimpleType(first);
    xsst.setId("first");
    xsst.setName("first");
    xsst.setSourceURI("http://first");
    XmlSchema two = new XmlSchema();
    two.setId("two");
    two.setTargetNamespace(nameSpace);
    String nameSpaceTwo = "http://parameter";
    XmlSchemaComplexType xsc = new XmlSchemaComplexType(two);
    XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
    xmlSchemaSequence.setId("sequence");
    XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
    xmlSchemaElement.setSourceURI(nameSpaceTwo);
    xmlSchemaElement.setQName(new QName(nameSpaceTwo, "parameter"));
    xmlSchemaElement.setName(name);
    xmlSchemaSequence.getItems().add(xmlSchemaElement);
    xsc.setParticle(xmlSchemaSequence);
    xsc.setId("two");
    xsc.setName("parameter");
    XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();
    XmlSchemaComplexContentExtension xmlSchemaContent = new XmlSchemaComplexContentExtension();
    xmlSchemaContent.setId("two");
    xmlSchemaContent.setBaseTypeName(new QName(nameSpace, "two"));
    xmlSchemaContent.setSourceURI(nameSpaceTwo);
    contentModel.setSourceURI(nameSpace);
    contentModel.setContent(xmlSchemaContent);
    xsc.setContentModel(contentModel);
    allXmlSchemaType.add(xsst);
    allXmlSchemaType.add(xsc);
    Method m = cb.getClass().getDeclaredMethod("buileParameterFromTypes", new Class[] { String.class, String.class, ParameterInfo.class, int.class });
    m.setAccessible(true);
    m.invoke(cb, nameSpace, name, parameter, 5);
    ParameterInfo parameterInfo = parameter.getParameterInfos().get(0);
    Assert.assertNotNull(parameterInfo);
    Assert.assertEquals(nameSpace, parameterInfo.getNameSpace());
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Method(java.lang.reflect.Method) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaComplexContent(org.apache.ws.commons.schema.XmlSchemaComplexContent) Field(java.lang.reflect.Field) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) List(java.util.List) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) ComponentBuilder(org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder) Test(org.junit.Test)

Example 3 with XmlSchemaComplexContent

use of org.apache.ws.commons.schema.XmlSchemaComplexContent in project ddf by codice.

the class FeatureMetacardTypeTest method testFeatureMetacardTypeComplexContentWithStringAndGmlProperties.

@Test
public void testFeatureMetacardTypeComplexContentWithStringAndGmlProperties() {
    XmlSchema schema = new XmlSchema();
    // Create the GML and String types
    XmlSchemaElement gmlElement = new XmlSchemaElement(schema, true);
    gmlElement.setSchemaType(new XmlSchemaComplexType(schema, false));
    gmlElement.setSchemaTypeName(new QName(Wfs10Constants.GML_NAMESPACE, GML));
    gmlElement.setName(ELEMENT_NAME_1);
    XmlSchemaElement stringElement = new XmlSchemaElement(schema, true);
    stringElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
    stringElement.setSchemaTypeName(Constants.XSD_STRING);
    stringElement.setName(ELEMENT_NAME_2);
    // build the complex objects
    XmlSchemaElement complexElement = new XmlSchemaElement(schema, true);
    XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, false);
    XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent();
    XmlSchemaComplexContentExtension contentExtension = new XmlSchemaComplexContentExtension();
    XmlSchemaSequence particle = new XmlSchemaSequence();
    particle.getItems().add(stringElement);
    contentExtension.setParticle(particle);
    complexContent.setContent(contentExtension);
    complexType.setContentModel(complexContent);
    complexElement.setSchemaType(complexType);
    complexElement.setSchemaTypeName(new QName("Complex"));
    schema.getElements().put(new QName(ELEMENT_NAME_2), complexElement);
    FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs10Constants.GML_NAMESPACE);
    assertTrue(featureMetacardType.getTextualProperties().size() == 1);
    assertTrue(featureMetacardType.getGmlProperties().size() == 1);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_2, BasicTypes.STRING_TYPE);
    assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.GEO_TYPE);
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaComplexContent(org.apache.ws.commons.schema.XmlSchemaComplexContent) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) Test(org.junit.Test)

Example 4 with XmlSchemaComplexContent

use of org.apache.ws.commons.schema.XmlSchemaComplexContent in project ddf by codice.

the class FeatureMetacardType method processComplexType.

private void processComplexType(XmlSchemaElement xmlSchemaElement) {
    if (!processGmlType(xmlSchemaElement)) {
        XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
        if ((schemaType != null) && (schemaType instanceof XmlSchemaComplexType)) {
            XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaType;
            if (complexType.getParticle() != null) {
                processXmlSchemaParticle(complexType.getParticle());
            } else {
                if (complexType.getContentModel() instanceof XmlSchemaComplexContent) {
                    XmlSchemaContent content = complexType.getContentModel().getContent();
                    if (content instanceof XmlSchemaComplexContentExtension) {
                        XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
                        processXmlSchemaParticle(extension.getParticle());
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaContent(org.apache.ws.commons.schema.XmlSchemaContent) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaComplexContent(org.apache.ws.commons.schema.XmlSchemaComplexContent)

Aggregations

XmlSchemaComplexContent (org.apache.ws.commons.schema.XmlSchemaComplexContent)4 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)4 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)4 QName (javax.xml.namespace.QName)3 XmlSchema (org.apache.ws.commons.schema.XmlSchema)3 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)3 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)3 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)3 Test (org.junit.Test)3 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)2 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 List (java.util.List)1 XmlSchemaContent (org.apache.ws.commons.schema.XmlSchemaContent)1 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)1 ComponentBuilder (org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder)1