Search in sources :

Example 81 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class SequenceVisitor method generateSchemaType.

private XmlSchemaType generateSchemaType(XmlSchemaType stype, Scope scopedName, long bound, Scope fullyQualifiedName) {
    XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, true);
    ct.setName(mapper.mapToQName(scopedName));
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    XmlSchemaElement el = new XmlSchemaElement(schema, false);
    el.setName(ELEMENT_NAME);
    el.setMinOccurs(0);
    if (bound != -1) {
        el.setMaxOccurs(bound);
    } else {
        el.setMaxOccurs(Long.MAX_VALUE);
    }
    if (stype != null) {
        el.setSchemaTypeName(stype.getQName());
        if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            el.setNillable(true);
        }
    } else {
        SequenceDeferredAction elementAction = new SequenceDeferredAction(el);
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
    }
    sequence.getItems().add(el);
    ct.setParticle(sequence);
    return ct;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 82 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class StructVisitor method createXmlSchemaElement.

private XmlSchemaElement createXmlSchemaElement(AST memberNode, XmlSchemaType schemaType, Scope fqName) {
    // xmlschema:member
    XmlSchemaElement member = new XmlSchemaElement(schema, false);
    String memberName = memberNode.toString();
    member.setName(memberName);
    member.setSchemaType(schemaType);
    if (schemaType != null) {
        member.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            member.setNillable(true);
        }
    } else {
        wsdlVisitor.getDeferredActions().add(fqName, new StructDeferredAction(member));
    }
    return member;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 83 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class StructVisitor method visitStructMembers.

private void visitStructMembers(AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
        AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
        final XmlSchemaType schemaType;
        final CorbaType corbaType;
        Scope fqName;
        try {
            TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
            visitor.visit(memberTypeNode);
            schemaType = visitor.getSchemaType();
            corbaType = visitor.getCorbaType();
            fqName = visitor.getFullyQualifiedName();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        // (hence the ScopedNameVisitor.accept() call).
        while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor, true)) {
            XmlSchemaType memberSchemaType = schemaType;
            CorbaType memberCorbaType = corbaType;
            // needed for anonymous arrays in structs
            if (ArrayVisitor.accept(memberNode)) {
                Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
                arrayVisitor.setSchemaType(schemaType);
                arrayVisitor.setCorbaType(corbaType);
                arrayVisitor.visit(memberNode);
                memberSchemaType = arrayVisitor.getSchemaType();
                memberCorbaType = arrayVisitor.getCorbaType();
                fqName = arrayVisitor.getFullyQualifiedName();
            }
            XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
            sequence.getItems().add(member);
            MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
            struct.getMember().add(memberType);
            memberNode = memberNode.getNextSibling();
        }
        memberTypeNode = memberNode;
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 84 with XmlSchemaElement

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

the class ComponentBuilder method buildParameterFromElements.

private void buildParameterFromElements(String partElement, ParameterInfo parameterRoot, int ioOrRecursion) {
    // XmlSchemaObjectTable elements = xmlSchema.getElements();
    if (ioOrRecursion < 3) {
        parametersName.clear();
        parametersName.add(parameterRoot.getName());
    } else if (ioOrRecursion == 3) {
        parametersName.add(parameterRoot.getName());
    }
    Iterator elementsItr = allXmlSchemaElement.iterator();
    if (partElement != null) {
        while (elementsItr.hasNext()) {
            XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) elementsItr.next();
            if (partElement.equals(xmlSchemaElement.getName())) {
                // parameter.setName(partName);
                if (xmlSchemaElement.getSchemaType() != null) {
                    if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaComplexType) {
                        XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaElement.getSchemaType();
                        XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            XmlSchemaObjectCollection xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                            if (xmlSchemaObjectCollection != null) {
                                buildParameterFromCollection(xmlSchemaObjectCollection, parameterRoot, ioOrRecursion);
                            }
                        } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                            String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                            String paraTypeNamespace = xmlSchemaElement.getSchemaTypeName().getNamespaceURI();
                            if (paraTypeName != null) {
                                parameterRoot.setType(paraTypeName);
                                buileParameterFromTypes(paraTypeNamespace, paraTypeName, parameterRoot, ioOrRecursion);
                            }
                        }
                    } else if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaSimpleType) {
                        XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) xmlSchemaElement.getSchemaType();
                        String typeName = xmlSchemaSimpleType.getName();
                        if (typeName != null && typeName.equals("anyType")) {
                            ParameterInfo parameterSon = new ParameterInfo();
                            parameterSon.setName("anyType");
                            parameterSon.setParent(parameterRoot);
                            parameterRoot.getParameterInfos().add(parameterSon);
                        }
                        parameterRoot.setType(typeName);
                    }
                } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                    String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                    String paraTypeNamespace = xmlSchemaElement.getSchemaTypeName().getNamespaceURI();
                    if (paraTypeName != null) {
                        parameterRoot.setType(paraTypeName);
                        buileParameterFromTypes(paraTypeNamespace, paraTypeName, parameterRoot, ioOrRecursion);
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Iterator(java.util.Iterator) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 85 with XmlSchemaElement

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

the class ComponentBuilder method buildParameterFromCollection2.

private void buildParameterFromCollection2(XmlSchemaObjectCollection xmlSchemaObjectCollection, ParameterInfo parameter, int ioOrRecursion) {
    // XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) xmlSchemaParticle;
    // XmlSchemaObjectCollection xmlSchemaObjectCollection = xmlSchemaSequence.getItems();
    int count = xmlSchemaObjectCollection.getCount();
    for (int j = 0; j < count; j++) {
        XmlSchemaObject xmlSchemaObject = xmlSchemaObjectCollection.getItem(j);
        if (xmlSchemaObject instanceof XmlSchemaGroupBase) {
            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaObject;
            XmlSchemaObjectCollection items = xmlSchemaGroupBase.getItems();
            if (items != null) {
                buildParameterFromCollection(items, parameter, ioOrRecursion);
            }
        } else if (xmlSchemaObject instanceof XmlSchemaAny) {
            ParameterInfo parameterSon = new ParameterInfo();
            parameterSon.setName("_content_");
            parameterSon.setParent(parameter);
            parameter.getParameterInfos().add(parameterSon);
        } else if (xmlSchemaObject instanceof XmlSchemaElement) {
            XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) xmlSchemaObject;
            String elementName = xmlSchemaElement.getName();
            ParameterInfo parameterSon = new ParameterInfo();
            parameterSon.setName(elementName);
            parameterSon.setParent(parameter);
            Long min = xmlSchemaElement.getMinOccurs();
            Long max = xmlSchemaElement.getMaxOccurs();
            if (max - min > 1) {
                parameterSon.setArraySize(-1);
                parameterSon.setIndex("*");
            }
            parameter.getParameterInfos().add(parameterSon);
            Boolean isHave = false;
            if (!parametersName.isEmpty() && parameterSon.getName() != null) {
                for (int p = 0; p < parametersName.size(); p++) {
                    if (parameterSon.getName().equals(parametersName.get(p))) {
                        isHave = true;
                    }
                }
            }
            // }
            if (xmlSchemaElement.getSchemaTypeName() != null) {
                String elementTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                parameterSon.setType(elementTypeName);
                if (!isHave && !WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
                    buileParameterFromTypes2(elementTypeName, parameterSon, ioOrRecursion);
                }
            } else if (xmlSchemaElement.getSchemaType() != null) {
                if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaComplexType) {
                    XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaElement.getSchemaType();
                    XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
                    if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                        XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                        XmlSchemaObjectCollection childCollection = xmlSchemaGroupBase.getItems();
                        if (childCollection != null && !isHave) {
                            buildParameterFromCollection(childCollection, parameterSon, ioOrRecursion);
                        }
                    } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                        String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                        String paraTypeNamespace = xmlSchemaElement.getSchemaTypeName().getNamespaceURI();
                        if (paraTypeName != null && !isHave) {
                            parameter.setType(paraTypeName);
                            buileParameterFromTypes(paraTypeNamespace, paraTypeName, parameterSon, ioOrRecursion);
                        }
                    }
                } else if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaSimpleType) {
                    XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) xmlSchemaElement.getSchemaType();
                    String typeName = xmlSchemaSimpleType.getName();
                    parameter.setType(typeName);
                }
            } else if (xmlSchemaElement.getRefName() != null) {
                String elementTypeName = xmlSchemaElement.getRefName().getLocalPart();
                if (!isHave && !WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
                    buildParameterFromElements(elementTypeName, parameterSon, ioOrRecursion);
                }
            }
        } else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
            XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute) xmlSchemaObject;
            String elementName = xmlSchemaAttribute.getName();
            ParameterInfo parameterSon = new ParameterInfo();
            parameterSon.setName(elementName);
            parameterSon.setParent(parameter);
            parameter.getParameterInfos().add(parameterSon);
            Boolean isHave = false;
            if (!parametersName.isEmpty() && parameterSon.getName() != null) {
                for (int p = 0; p < parametersName.size(); p++) {
                    if (parameterSon.getName().equals(parametersName.get(p))) {
                        isHave = true;
                    }
                }
            }
            if (xmlSchemaAttribute.getSchemaTypeName() != null) {
                String elementTypeName = xmlSchemaAttribute.getSchemaTypeName().getLocalPart();
                String elementTypeNamespace = xmlSchemaAttribute.getSchemaTypeName().getNamespaceURI();
                parameterSon.setType(elementTypeName);
                if (!isHave && !WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
                    buileParameterFromTypes(elementTypeNamespace, elementTypeName, parameterSon, ioOrRecursion);
                }
            } else if (xmlSchemaAttribute.getRefName() != null) {
                String refName = xmlSchemaAttribute.getRefName().getLocalPart();
                parameterSon.setType(refName);
                if (!isHave) {
                    buildParameterFromElements(refName, parameterSon, ioOrRecursion);
                }
            }
        }
    }
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaAny(org.apache.ws.commons.schema.XmlSchemaAny) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Aggregations

XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)164 QName (javax.xml.namespace.QName)100 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)59 XmlSchema (org.apache.ws.commons.schema.XmlSchema)54 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)51 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)42 Test (org.junit.Test)42 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)39 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)32 Message (org.apache.cxf.common.i18n.Message)15 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)15 XmlSchemaSequenceMember (org.apache.ws.commons.schema.XmlSchemaSequenceMember)14 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)13 ArrayList (java.util.ArrayList)12 JAXBBeanInfo (org.apache.cxf.common.jaxb.JAXBBeanInfo)12 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)12 Method (java.lang.reflect.Method)11 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)11 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)10 Iterator (java.util.Iterator)9