Search in sources :

Example 11 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processLiteralArray.

private CorbaType processLiteralArray(XmlSchemaComplexType complex, QName defaultName, boolean anonymous) throws Exception {
    // NEED TO DO
    QName name;
    QName typeName = null;
    QName schematypeName = checkPrefix(complex.getQName());
    if (schematypeName == null) {
        schematypeName = defaultName;
        name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
        schematypeName = checkPrefix(schematypeName);
        name = checkPrefix(name);
    } else {
        name = createQNameCorbaNamespace(schematypeName.getLocalPart());
        name = checkPrefix(name);
    }
    CorbaType arrayType = null;
    XmlSchemaElement arrayEl = null;
    QName elName = null;
    if (complex.getParticle() instanceof XmlSchemaSequence) {
        XmlSchemaSequence seq = (XmlSchemaSequence) complex.getParticle();
        Iterator<XmlSchemaSequenceMember> iterator = seq.getItems().iterator();
        Iterator<XmlSchemaSequenceMember> iter = seq.getItems().iterator();
        while (iterator.hasNext()) {
            if (iter.next() instanceof XmlSchemaElement) {
                arrayEl = (XmlSchemaElement) iterator.next();
                elName = arrayEl.getQName();
                XmlSchemaType atype = arrayEl.getSchemaType();
                if (elName == null) {
                    elName = arrayEl.getRef().getTargetQName();
                    /*
                         * TODO: why are we looking up an element name with findSchemaType?
                         */
                    atype = findSchemaType(elName);
                }
                String uri = defaultName.getNamespaceURI();
                if (complex.getQName() != null) {
                    uri = complex.getQName().getNamespaceURI();
                }
                if (elName.getNamespaceURI().equals("")) {
                    elName = new QName(uri, elName.getLocalPart());
                }
                QName arrayTypeName = elName;
                if (anonymous) {
                    arrayTypeName = new QName(elName.getNamespaceURI(), defaultName.getLocalPart() + "." + elName.getLocalPart());
                }
                arrayType = convertSchemaToCorbaType(atype, arrayTypeName, atype, null, true);
                boolean isQualified = getElementQualification(arrayEl, uri);
                if (isQualified) {
                    arrayType.setQualified(isQualified);
                } else {
                    elName = new QName("", elName.getLocalPart());
                }
                typeName = arrayType.getQName();
            }
        }
    }
    Long maxOccurs = null;
    Long minOccurs = null;
    if (arrayEl != null) {
        if (arrayEl.isNillable()) {
            QName nilunionname = createQNameTargetNamespace(arrayType.getQName().getLocalPart() + "_nil");
            boolean isQualified = arrayType.isSetQualified() && arrayType.isQualified();
            arrayType = createNillableUnion(nilunionname, elName, arrayType.getQName(), isQualified);
            typeName = createQNameCorbaNamespace(arrayType.getQName().getLocalPart());
            if (arrayType != null && !isDuplicate(arrayType)) {
                typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
            }
        }
        maxOccurs = arrayEl.getMaxOccurs();
        minOccurs = arrayEl.getMinOccurs();
    }
    return createArray(name, schematypeName, checkPrefix(typeName), elName, maxOccurs, minOccurs, anonymous);
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 12 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processComplexContentStructSequence.

private Struct processComplexContentStructSequence(Struct corbaStruct, XmlSchemaSequence seq, QName defaultName, QName schematypeName) throws Exception {
    CorbaType seqtype = processSequenceType(seq, defaultName, schematypeName);
    MemberType seqmem = new MemberType();
    seqmem.setName(seqtype.getQName().getLocalPart() + "_f");
    QName type = createQNameCorbaNamespace(seqtype.getQName().getLocalPart());
    seqmem.setIdltype(type);
    seqmem.setAnonschematype(true);
    if (seqtype.isSetQualified() && seqtype.isQualified()) {
        seqmem.setQualified(true);
    }
    corbaStruct.getMember().add(seqmem);
    if (!isDuplicate(seqtype)) {
        typeMappingType.getStructOrExceptionOrUnion().add(seqtype);
    }
    return corbaStruct;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName)

Example 13 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processPrimitiveType.

private CorbaType processPrimitiveType(QName typeName) {
    QName qName = createQNameXmlSchemaNamespace(typeName.getLocalPart());
    CorbaType corbatype = (CorbaType) CORBAPRIMITIVEMAP.get(qName);
    if (corbatype == null) {
        // REVISIT, bravi, not an ideal way to add the fixed & octet type to the typemap.
        CorbaType type = null;
        if (typeName.equals(W3CConstants.NT_SCHEMA_DECIMAL)) {
            QName name = new QName(idlNamespace, "fixed_1");
            type = WSDLTypes.getFixedCorbaType(name, typeName, 31, 6);
            corbatype = WSDLTypes.getFixedCorbaType(name, typeName, 31, 6);
        } else if (typeName.equals(W3CConstants.NT_SCHEMA_BASE64) || typeName.equals(W3CConstants.NT_SCHEMA_HBIN)) {
            QName name = new QName(idlNamespace, typeName.getLocalPart() + "Seq");
            type = WSDLTypes.getOctetCorbaType(name, typeName, 0);
            corbatype = WSDLTypes.getOctetCorbaType(name, typeName, 0);
        }
        if (type != null && !isDuplicate(type)) {
            typeMappingType.getStructOrExceptionOrUnion().add(type);
        }
    }
    return corbatype;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName)

Example 14 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processLocalElement.

private CorbaType processLocalElement(QName containingTypeName, XmlSchemaElement element, String uri) throws Exception {
    CorbaType membertype = new CorbaType();
    XmlSchemaType schemaType = element.getSchemaType();
    QName schemaName = element.getQName();
    if (schemaType == null) {
        if (element.getRef().getTarget() != null) {
            schemaType = findSchemaType(element.getRef().getTarget().getSchemaTypeName());
            schemaName = element.getRef().getTargetQName();
        } else {
            schemaType = findSchemaType(element.getSchemaTypeName());
        }
    }
    if (schemaName.getNamespaceURI().equals("")) {
        schemaName = new QName(uri, schemaName.getLocalPart());
    }
    QName elemName = schemaName;
    boolean elementQualified = getElementQualification(element, uri);
    if (!elementQualified) {
        elemName = new QName("", elemName.getLocalPart());
    }
    QName memName = null;
    if (element.isNillable()) {
        CorbaType elemtype = convertSchemaToCorbaType(schemaType, elemName, schemaType, null, true);
        QName name = createQNameTargetNamespace(elemtype.getQName().getLocalPart() + "_nil");
        QName elName = checkPrefix(elemName);
        if (elName == null) {
            elName = createQNameTargetNamespace(elemName.getLocalPart());
        }
        CorbaType memtype = createNillableUnion(elName, name, elemtype.getQName(), elementQualified);
        memName = createQNameCorbaNamespace(memtype.getQName().getLocalPart());
        if (!isDuplicate(memtype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(memtype);
        }
        membertype.setQName(memName);
        membertype.setName(memtype.getName());
        membertype.setType(memtype.getType());
    } else if (schemaType != null) {
        XmlSchemaType st = schemaType;
        boolean anonymous = WSDLTypes.isAnonymous(st.getName());
        QName typeName = null;
        if (anonymous) {
            typeName = new QName(elemName.getNamespaceURI(), containingTypeName.getLocalPart() + "." + elemName.getLocalPart());
        } else {
            typeName = st.getQName();
        }
        membertype = convertSchemaToCorbaType(st, typeName, st, null, anonymous);
    } else if (element.getSchemaTypeName() != null) {
        QName name = checkPrefix(element.getSchemaTypeName());
        membertype = getLocalType(name);
    }
    if (membertype == null) {
        return null;
    }
    if (!(element.getMaxOccurs() == 1) || !(element.getMinOccurs() == 1)) {
        QName name = createQNameCorbaNamespace(getModulePrefix(membertype) + elemName.getLocalPart() + "Array");
        CorbaType arraytype = null;
        if (memName != null) {
            arraytype = createArray(name, /*schemaName*/
            name, memName, elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
        } else {
            arraytype = createArray(name, /*schemaName*/
            name, membertype.getQName(), elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
        }
        if (arraytype != null) {
            if (arraytype instanceof Abstractsequence) {
                ((Abstractsequence) arraytype).setWrapped(false);
            }
            if (arraytype instanceof Abstractanonsequence) {
                ((Abstractanonsequence) arraytype).setWrapped(false);
            }
            if (!isDuplicate(arraytype)) {
                typeMappingType.getStructOrExceptionOrUnion().add(arraytype);
            }
            // the local element with maxOccurs != 1 or minOccurs != 1 becomes the just created array
            membertype = arraytype;
        }
    }
    membertype.setQualified(elementQualified);
    return membertype;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Abstractsequence(org.apache.cxf.binding.corba.wsdl.Abstractsequence) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Abstractanonsequence(org.apache.cxf.binding.corba.wsdl.Abstractanonsequence)

Example 15 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processSimpleRestrictionType.

private CorbaType processSimpleRestrictionType(XmlSchemaSimpleType stype, QName name, QName schematypeName, boolean anonymous) throws Exception {
    CorbaType corbaTypeImpl = null;
    // checks if enumeration
    XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction) stype.getContent();
    QName baseName = checkPrefix(restrictionType.getBaseTypeName());
    String maxLength = null;
    String length = null;
    for (XmlSchemaFacet val : restrictionType.getFacets()) {
        if (val instanceof XmlSchemaMaxLengthFacet) {
            maxLength = val.getValue().toString();
        }
        if (val instanceof XmlSchemaLengthFacet) {
            length = val.getValue().toString();
        }
    }
    if (isEnumeration(restrictionType)) {
        corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
    } else {
        if (restrictionType.getBaseType() != null) {
            corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName, stype, null, false);
        } else {
            corbaTypeImpl = processPrimitiveType(baseName);
            if (corbaTypeImpl == null) {
                XmlSchemaType schematype = findSchemaType(baseName);
                corbaTypeImpl = convertSchemaToCorbaType(schematype, schematypeName, schematype, null, false);
            }
        }
        if (corbaTypeImpl != null) {
            if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_STRING) || (baseName.equals(W3CConstants.NT_SCHEMA_STRING))) {
                corbaTypeImpl = WSDLTypes.processStringType(corbaTypeImpl, name, maxLength, length);
            } else if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_DECIMAL) || (baseName.equals(W3CConstants.NT_SCHEMA_DECIMAL))) {
                corbaTypeImpl = WSDLTypes.processDecimalType(restrictionType, name, corbaTypeImpl, anonymous);
            } else if ((corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_BASE64)) || (baseName.equals(W3CConstants.NT_SCHEMA_BASE64)) || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))) {
                corbaTypeImpl = WSDLTypes.processBase64Type(corbaTypeImpl, name, maxLength, length);
            }
        }
    }
    return corbaTypeImpl;
}
Also used : XmlSchemaFacet(org.apache.ws.commons.schema.XmlSchemaFacet) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaLengthFacet(org.apache.ws.commons.schema.XmlSchemaLengthFacet) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaMaxLengthFacet(org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet)

Aggregations

CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)71 QName (javax.xml.namespace.QName)44 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)22 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)13 AST (antlr.collections.AST)9 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)8 Test (org.junit.Test)8 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)7 Alias (org.apache.cxf.binding.corba.wsdl.Alias)6 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)6 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)6 Struct (org.apache.cxf.binding.corba.wsdl.Struct)6 Union (org.apache.cxf.binding.corba.wsdl.Union)6 File (java.io.File)5 Definition (javax.wsdl.Definition)5 ArrayList (java.util.ArrayList)4 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)4 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4