Search in sources :

Example 1 with XmlSchemaComplexContentExtension

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

the class ComponentBuilder method buileParameterFromTypes2.

private void buileParameterFromTypes2(String paraType, ParameterInfo parameter, int ioOrRecursion) {
    if (ioOrRecursion < 3) {
        parametersName.clear();
        parametersName.add(parameter.getName());
    } else if (ioOrRecursion == 3) {
        parametersName.add(parameter.getName());
    }
    for (int i = 0; i < allXmlSchemaType.size(); i++) {
        XmlSchemaType type = allXmlSchemaType.get(i);
        String typeName = type.getName();
        if (paraType.equals(typeName)) {
            if (type instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) type;
                XmlSchemaParticle xmlSchemaParticle = xmlSchemaComplexType.getParticle();
                XmlSchemaObjectCollection xmlSchemaObjectCollection = null;
                if (xmlSchemaParticle == null && xmlSchemaComplexType.getContentModel() != null) {
                    Object obj = xmlSchemaComplexType.getContentModel().getContent();
                    if (obj instanceof XmlSchemaComplexContentExtension) {
                        XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension) obj;
                        if (xscce != null) {
                            xmlSchemaParticle = xscce.getParticle();
                        }
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                        }
                    } else if (obj instanceof XmlSchemaComplexContentRestriction) {
                        XmlSchemaComplexContentRestriction xsccr = (XmlSchemaComplexContentRestriction) obj;
                        xmlSchemaObjectCollection = xsccr.getAttributes();
                    }
                } else if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                    XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                    xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                }
                if (xmlSchemaObjectCollection != null) {
                    buildParameterFromCollection2(xmlSchemaObjectCollection, parameter, 3);
                }
            } else if (type instanceof XmlSchemaSimpleType) {
            // Will TO DO if need.
            // System.out.println("XmlSchemaSimpleType");
            }
            break;
        }
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexContentRestriction(org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 2 with XmlSchemaComplexContentExtension

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

the class ComponentBuilder method buileParameterFromTypes.

/**
     * DOC gcui Comment method "buileParameterFromTypes".
     * 
     * @param paraType
     * @param parameter
     * @param operationInfo
     * @param i
     */
private void buileParameterFromTypes(String paraNamespace, String paraType, ParameterInfo parameter, int ioOrRecursion) {
    if (ioOrRecursion < 3) {
        parametersName.clear();
        parametersName.add(parameter.getName());
    } else if (ioOrRecursion == 3) {
        parametersName.add(parameter.getName());
    }
    for (int i = 0; i < allXmlSchemaType.size(); i++) {
        XmlSchemaType type = allXmlSchemaType.get(i);
        String typeName = type.getName();
        if (paraType.equals(typeName) && paraNamespace.equals(type.getQName().getNamespaceURI())) {
            if (type instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) type;
                XmlSchemaParticle xmlSchemaParticle = xmlSchemaComplexType.getParticle();
                XmlSchemaObjectCollection xmlSchemaObjectCollection = null;
                if (xmlSchemaParticle == null && xmlSchemaComplexType.getContentModel() != null) {
                    Object obj = xmlSchemaComplexType.getContentModel().getContent();
                    if (obj instanceof XmlSchemaComplexContentExtension) {
                        XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension) obj;
                        if (xscce.getBaseTypeName() != null) {
                            buileParameterFromTypes(xscce.getBaseTypeName().getNamespaceURI(), xscce.getBaseTypeName().getLocalPart(), parameter, ioOrRecursion);
                        }
                        if (xscce != null) {
                            xmlSchemaParticle = xscce.getParticle();
                        }
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                        }
                    } else if (obj instanceof XmlSchemaComplexContentRestriction) {
                        XmlSchemaComplexContentRestriction xsccr = (XmlSchemaComplexContentRestriction) obj;
                        xmlSchemaObjectCollection = xsccr.getAttributes();
                    }
                } else if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                    XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                    xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                }
                if (xmlSchemaObjectCollection != null && xmlSchemaObjectCollection.getCount() > 0) {
                    buildParameterFromCollection(xmlSchemaObjectCollection, parameter, 3);
                } else if (xmlSchemaObjectCollection != null && xmlSchemaObjectCollection.getCount() == 0 && xmlSchemaComplexType.isAbstract()) {
                    findExtendtion(xmlSchemaComplexType, parameter, 3);
                }
            } else if (type instanceof XmlSchemaSimpleType) {
            // Will TO DO if need.
            // System.out.println("XmlSchemaSimpleType");
            }
            break;
        }
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexContentRestriction(org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 3 with XmlSchemaComplexContentExtension

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

the class ComponentBuilder method findExtendtion.

private void findExtendtion(XmlSchemaType xmlSchemaType, ParameterInfo parameterSon, int ioOrRecursion) {
    for (int i = 0; i < allXmlSchemaType.size(); i++) {
        XmlSchemaType type = allXmlSchemaType.get(i);
        if (type != null) {
            if (type instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) type;
                if (xmlElementComplexType.getContentModel() != null) {
                    Object obj = xmlElementComplexType.getContentModel().getContent();
                    if (obj instanceof XmlSchemaComplexContentExtension) {
                        XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension) obj;
                        if (xscce.getBaseTypeName().getLocalPart() != null && xmlSchemaType.getName().equals(xscce.getBaseTypeName().getLocalPart())) {
                            if (xmlElementComplexType.isAbstract()) {
                                findExtendtion(type, parameterSon, ioOrRecursion);
                                break;
                            } else {
                                if (!alldExtendtion.contains(type.getName())) {
                                    alldExtendtion.add(type.getName());
                                    ParameterInfo parameterType = new ParameterInfo();
                                    parameterType.setName(parameterSon.getName() + ".@type");
                                    boolean flag = false;
                                    for (int x = 0; x < parameterSon.getParameterInfos().size(); x++) {
                                        ParameterInfo info = parameterSon.getParameterInfos().get(x);
                                        if (info.getName().equals(parameterType.getName())) {
                                            flag = true;
                                        }
                                    }
                                    if (!flag) {
                                        parameterType.setParent(parameterSon);
                                        parameterSon.getParameterInfos().add(parameterType);
                                    }
                                    ParameterInfo parameterSubSon = new ParameterInfo();
                                    parameterSubSon.setName(type.getName());
                                    parameterSubSon.setParent(parameterSon);
                                    parameterSon.getParameterInfos().add(parameterSubSon);
                                    buileParameterFromTypes2(type.getName(), parameterSubSon, ioOrRecursion);
                                    parametersName.clear();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 4 with XmlSchemaComplexContentExtension

use of org.apache.ws.commons.schema.XmlSchemaComplexContentExtension 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 5 with XmlSchemaComplexContentExtension

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

the class AllTypeDialog method buileParameterFromTypes.

private void buileParameterFromTypes(String paraType, ParameterInfo parameter) {
    for (int i = 0; i < allXmlSchemaType.size(); i++) {
        XmlSchemaType type = allXmlSchemaType.get(i);
        String typeName = type.getName();
        if (paraType.equals(typeName)) {
            if (type instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) type;
                XmlSchemaParticle xmlSchemaParticle = xmlSchemaComplexType.getParticle();
                XmlSchemaObjectCollection xmlSchemaObjectCollection = null;
                if (xmlSchemaParticle == null && xmlSchemaComplexType.getContentModel() != null) {
                    Object obj = xmlSchemaComplexType.getContentModel().getContent();
                    if (obj instanceof XmlSchemaComplexContentExtension) {
                        XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension) obj;
                        if (xscce.getBaseTypeName() != null) {
                            buileParameterFromTypes(xscce.getBaseTypeName().getLocalPart(), parameter);
                        }
                        if (xscce != null) {
                            xmlSchemaParticle = xscce.getParticle();
                        }
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                        }
                    } else if (obj instanceof XmlSchemaComplexContentRestriction) {
                        XmlSchemaComplexContentRestriction xsccr = (XmlSchemaComplexContentRestriction) obj;
                        xmlSchemaObjectCollection = xsccr.getAttributes();
                    }
                } else if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                    XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                    xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                }
                if (xmlSchemaObjectCollection != null && xmlSchemaObjectCollection.getCount() > 0) {
                    buildParameterFromCollection(xmlSchemaObjectCollection, parameter);
                }
            } else if (type instanceof XmlSchemaSimpleType) {
            }
            break;
        }
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexContentRestriction(org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Aggregations

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