Search in sources :

Example 51 with XmlSchemaSimpleType

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

the class WSDLToCorbaHelper method convertSchemaToCorbaType.

public CorbaType convertSchemaToCorbaType(XmlSchemaType stype, QName defaultName, XmlSchemaType parent, XmlSchemaAnnotation annotation, boolean anonymous) throws Exception {
    CorbaType corbaTypeImpl = null;
    if (!isAddressingNamespace(stype.getQName())) {
        // need to determine if its a primitive type.
        if (stype instanceof XmlSchemaComplexType) {
            corbaTypeImpl = processComplexType((XmlSchemaComplexType) stype, defaultName, annotation, anonymous);
        } else if (stype instanceof XmlSchemaSimpleType) {
            corbaTypeImpl = processSimpleType((XmlSchemaSimpleType) stype, defaultName, anonymous);
        } else if (xmlSchemaList.getElementByQName(stype.getQName()) != null) {
            XmlSchemaElement el = xmlSchemaList.getElementByQName(stype.getQName());
            // REVISIT, passing ns uri because of a bug in XmlSchema (Bug: WSCOMMONS-69)
            corbaTypeImpl = processElementType(el, defaultName, stype.getQName().getNamespaceURI());
        } else {
            throw new Exception("Couldn't convert schema " + stype.getQName() + " to corba type");
        }
    }
    if (corbaTypeImpl != null && !isDuplicate(corbaTypeImpl)) {
        typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
    }
    return corbaTypeImpl;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 52 with XmlSchemaSimpleType

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

the class DeclaratorVisitor method duplicateXmlSchemaSimpleType.

private XmlSchemaSimpleType duplicateXmlSchemaSimpleType(Scope newScope) {
    XmlSchemaSimpleType oldSimpleType = (XmlSchemaSimpleType) getSchemaType();
    XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, oldSimpleType.isTopLevel());
    simpleType.setContent(oldSimpleType.getContent());
    simpleType.setName(newScope.toString());
    return simpleType;
}
Also used : XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType)

Example 53 with XmlSchemaSimpleType

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

the class EnumVisitor method visit.

public void visit(AST enumNode) {
    // <enum_type> ::= "enum" <identifier> "{" <enumerator> {"," <enumerator>}* "}"
    // <enumerator> ::= <identifier>
    AST enumNameNode = enumNode.getFirstChild();
    Scope enumNameScope = new Scope(getScope(), enumNameNode);
    // xmlschema:enum
    XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema, true);
    enumSchemaSimpleType.setName(mapper.mapToQName(enumNameScope));
    XmlSchemaSimpleTypeRestriction enumSchemaSimpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
    enumSchemaSimpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
    // XmlSchemaSimpleTypeContent xmlSchemaSimpleTypeContent = enumSchemaSimpleTypeRestriction;
    enumSchemaSimpleType.setContent(enumSchemaSimpleTypeRestriction);
    // corba:enum
    Enum corbaEnum = new Enum();
    corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameScope.toString()));
    corbaEnum.setRepositoryID(enumNameScope.toIDLRepositoryID());
    corbaEnum.setType(enumSchemaSimpleType.getQName());
    AST node = enumNameNode.getNextSibling();
    while (node != null) {
        // xmlschema:enumeration
        XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
        enumeration.setValue(node.toString());
        enumSchemaSimpleTypeRestriction.getFacets().add(enumeration);
        // corba:enumerator
        Enumerator enumerator = new Enumerator();
        enumerator.setValue(node.toString());
        corbaEnum.getEnumerator().add(enumerator);
        node = node.getNextSibling();
    }
    // add corbaType
    typeMap.getStructOrExceptionOrUnion().add(corbaEnum);
    // REVISIT: are there assignments needed?
    setSchemaType(enumSchemaSimpleType);
    setCorbaType(corbaEnum);
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) AST(antlr.collections.AST) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaEnumerationFacet(org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)

Example 54 with XmlSchemaSimpleType

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

the class FixedVisitor method visit.

public void visit(AST fixedNode) {
    // "typedef" <type_declarator>
    // <type_declarator> ::= <type_spec> <declarators>
    // <type_spec> ::= <simple_type_spec>
    // | <constr_type_spec>
    // <simple_type_spec> ::= <base_type_spec>
    // | <template_type_spec>
    // | <scoped_name>
    // <base_type_spec> ::= ... omitted (integer, char, octect, etc)
    // <template_type_spec> ::= <sequence_type>
    // | <string_type>
    // | <wstring_type>
    // | <fixed_pt_type>
    // <constr_type_spec> ::= <struct_type>
    // | <union_type>
    // | <enum_type>
    // <declarators> ::= <declarator> {"," <declarator>}*
    // <declarator> ::= <simple_declarator>
    // | <complex_declarator>
    // <simple_declarator> ::= <identifier>
    // <complex_declarator> ::= <array_declarator>
    // <array_declarator> ::= <identifier> <fixed_array_size>+
    // <fixed_array_size> ::= "[" <positive_int_const> "]"
    AST digitsNode = fixedNode.getFirstChild();
    AST scaleNode = digitsNode.getNextSibling();
    Scope scopedName = null;
    if (identifierNode == null) {
        scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
    } else {
        scopedName = new Scope(getScope(), identifierNode);
    }
    // validate digits and scale
    Long digits = Long.valueOf(digitsNode.toString());
    Long scale = Long.valueOf(scaleNode.toString());
    if (digits < 1 || digits > 31) {
        // throw IllegalIDLException();
        System.out.println("Digits cannot be greater than 31");
        return;
    }
    if (scale.compareTo(digits) > 0) {
        // throw IllegalIDLException();
        System.out.println("Scale cannot be greater than digits");
        return;
    }
    // xmlschema:fixed
    XmlSchemaSimpleType fixedSimpleType = new XmlSchemaSimpleType(schema, true);
    XmlSchemaSimpleTypeRestriction fixedRestriction = new XmlSchemaSimpleTypeRestriction();
    fixedRestriction.setBaseTypeName(Constants.XSD_DECIMAL);
    XmlSchemaTotalDigitsFacet fixedTotalDigits = new XmlSchemaTotalDigitsFacet();
    fixedTotalDigits.setValue(digitsNode.toString());
    XmlSchemaFractionDigitsFacet fixedFractionDigits = new XmlSchemaFractionDigitsFacet();
    fixedFractionDigits.setValue(scaleNode.toString());
    fixedFractionDigits.setFixed(true);
    fixedRestriction.getFacets().add(fixedTotalDigits);
    fixedRestriction.getFacets().add(fixedFractionDigits);
    fixedSimpleType.setName(mapper.mapToQName(scopedName));
    fixedSimpleType.setContent(fixedRestriction);
    // add xmlschema:fixed
    setSchemaType(fixedSimpleType);
    CorbaType type = null;
    if (identifierNode != null) {
        // corba:fixed
        Fixed corbaFixed = new Fixed();
        corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
        corbaFixed.setDigits(digits);
        corbaFixed.setScale(scale);
        corbaFixed.setRepositoryID(scopedName.toIDLRepositoryID());
        // corbaFixed.setType(Constants.XSD_DECIMAL);
        corbaFixed.setType(fixedSimpleType.getQName());
        type = corbaFixed;
    } else {
        // corba:anonfixed
        Anonfixed corbaFixed = new Anonfixed();
        corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
        corbaFixed.setDigits(digits);
        corbaFixed.setScale(scale);
        // corbaFixed.setType(Constants.XSD_DECIMAL);
        corbaFixed.setType(fixedSimpleType.getQName());
        typeMap.getStructOrExceptionOrUnion().add(corbaFixed);
        type = corbaFixed;
    }
    // add corba:fixed
    setCorbaType(type);
}
Also used : Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) AST(antlr.collections.AST) XmlSchemaTotalDigitsFacet(org.apache.ws.commons.schema.XmlSchemaTotalDigitsFacet) XmlSchemaFractionDigitsFacet(org.apache.ws.commons.schema.XmlSchemaFractionDigitsFacet) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 55 with XmlSchemaSimpleType

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

the class ObjectReferenceVisitor method visitCustomTypeObjectReference.

private void visitCustomTypeObjectReference(AST node) {
    QName bindingName = null;
    QName referenceName = null;
    String repositoryID = null;
    Scope currentScope = getScope();
    Scope customScope = null;
    if ((node.getFirstChild() == null) || (node.getFirstChild() != null && node.getFirstChild().getType() != IDLTokenTypes.SCOPEOP)) {
        while (bindingName == null && currentScope != currentScope.getParent()) {
            if (ScopedNameVisitor.isFullyScopedName(node)) {
                customScope = ScopedNameVisitor.getFullyScopedName(currentScope, node);
            } else {
                customScope = new Scope(currentScope, node);
            }
            if (mapper.isDefaultMapping()) {
                referenceName = new QName(schema.getTargetNamespace(), customScope.toString() + "Ref");
            } else {
                String tns = mapper.map(customScope.getParent());
                referenceName = new QName(tns, customScope.tail() + "Ref");
            }
            repositoryID = customScope.toIDLRepositoryID();
            bindingName = getBindingQNameByID(definition, repositoryID, objRefWsdlVisitor);
            currentScope = currentScope.getParent();
        }
    }
    if (bindingName == null) {
        // Global scope is our last chance to resolve the node
        if (ScopedNameVisitor.isFullyScopedName(node)) {
            customScope = ScopedNameVisitor.getFullyScopedName(new Scope(), node);
            if (mapper.isDefaultMapping()) {
                referenceName = new QName(schema.getTargetNamespace(), customScope.toString() + "Ref");
            } else {
                String tns = mapper.map(customScope.getParent());
                referenceName = new QName(tns, customScope.tail() + "Ref");
            }
        } else {
            // customScope = currentScope;
            customScope = new Scope(new Scope(), node);
            if (mapper.isDefaultMapping()) {
                referenceName = new QName(schema.getTargetNamespace(), customScope.toString() + "Ref");
            } else {
                String tns = mapper.map(customScope.getParent());
                referenceName = new QName(tns, customScope.tail() + "Ref");
            }
        }
        repositoryID = customScope.toIDLRepositoryID();
        bindingName = getBindingQNameByID(definition, repositoryID, objRefWsdlVisitor);
        if (bindingName == null) {
            // check bindingName with prefix
            customScope.setPrefix(objRefWsdlVisitor.getPragmaPrefix());
            repositoryID = customScope.toIDLRepositoryID();
            bindingName = getBindingQNameByID(definition, repositoryID, objRefWsdlVisitor);
        }
    }
    if (bindingName == null) {
        // We need to have a binding for this kind of object reference to work
        throw new RuntimeException("[ObjectReferenceVisitor: No binding available for endpoint]");
    }
    // Create a schema namespace for WS addressing and use it to create an endpoint
    // reference type.  This will be used as the type for our endpoint reference.
    XmlSchema[] scs = schemas.getXmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE);
    XmlSchema wsaSchema = null;
    if (scs != null) {
        for (XmlSchema sc : scs) {
            if (ReferenceConstants.WSADDRESSING_NAMESPACE.equals(sc.getTargetNamespace())) {
                wsaSchema = sc;
                break;
            }
        }
    }
    if (wsaSchema == null) {
        wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
    }
    XmlSchemaType wsaType = new XmlSchemaSimpleType(wsaSchema, true);
    wsaType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
    // Check to see if we have already defined an element for this reference type.  If
    // we have, then there is no need to add it to the schema again.
    isDuplicateReference(referenceName, bindingName, customScope, wsaType, node);
    setSchemaType(wsaType);
    // Build and assign the corba:object to the visitor
    Object corbaObject = new Object();
    corbaObject.setBinding(bindingName);
    corbaObject.setQName(new QName(typeMap.getTargetNamespace(), customScope.toString()));
    corbaObject.setRepositoryID(repositoryID);
    corbaObject.setType(wsaType.getQName());
    setCorbaType(corbaObject);
    // type once.
    if (!isReferenceCORBATypeDefined(corbaObject.getQName())) {
        typeMap.getStructOrExceptionOrUnion().add(corbaObject);
    }
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Object(org.apache.cxf.binding.corba.wsdl.Object) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Aggregations

XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)60 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)44 QName (javax.xml.namespace.QName)38 XmlSchema (org.apache.ws.commons.schema.XmlSchema)31 Test (org.junit.Test)27 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)26 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)20 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)13 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)9 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)9 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)8 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)8 XmlSchemaSimpleTypeRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction)8 ArrayList (java.util.ArrayList)6 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)6 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)6 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)4 Iterator (java.util.Iterator)4 List (java.util.List)4 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)4