Search in sources :

Example 6 with MemberType

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

the class WSDLToCorbaHelper method processOMGUnion.

private CorbaType processOMGUnion(XmlSchemaComplexType complex, QName defaultName) throws Exception {
    QName name;
    Union corbaUnion = null;
    QName schematypeName = checkPrefix(complex.getQName());
    if (schematypeName == null) {
        schematypeName = defaultName;
        name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
    } else {
        name = createQNameCorbaNamespace(schematypeName.getLocalPart());
    }
    corbaUnion = new Union();
    corbaUnion.setName(name.getLocalPart());
    corbaUnion.setQName(name);
    String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
    corbaUnion.setRepositoryID(id);
    corbaUnion.setType(schematypeName);
    XmlSchemaSequence stype = (XmlSchemaSequence) complex.getParticle();
    Iterator<XmlSchemaSequenceMember> it = stype.getItems().iterator();
    XmlSchemaParticle st1 = (XmlSchemaParticle) it.next();
    XmlSchemaParticle st2 = (XmlSchemaParticle) it.next();
    XmlSchemaElement discEl = null;
    XmlSchemaChoice choice = null;
    if (st1 instanceof XmlSchemaElement) {
        discEl = (XmlSchemaElement) st1;
        choice = (XmlSchemaChoice) st2;
    } else {
        discEl = (XmlSchemaElement) st2;
        choice = (XmlSchemaChoice) st1;
    }
    CorbaType disctype = convertSchemaToCorbaType(discEl.getSchemaType(), discEl.getQName(), discEl.getSchemaType(), null, false);
    corbaUnion.setDiscriminator(disctype.getQName());
    List<MemberType> fields = processContainerAsMembers(choice, defaultName, schematypeName);
    List<String> caselist = new ArrayList<>();
    if (disctype instanceof Enum) {
        Enum corbaenum = (Enum) disctype;
        Iterator<Enumerator> iterator = corbaenum.getEnumerator().iterator();
        while (iterator.hasNext()) {
            Enumerator enumerator = iterator.next();
            caselist.add(enumerator.getValue());
        }
    } else if (SUPPORTEDDISTYPES.contains(disctype.getQName().getLocalPart())) {
        if (disctype.getQName().getLocalPart().equals("long") || disctype.getQName().getLocalPart().equals("short")) {
            for (int i = 0; i < fields.size(); i++) {
                caselist.add(Integer.toString(i));
            }
        } else if (disctype.getQName().getLocalPart().equals("char")) {
            for (int i = 0; i < fields.size(); i++) {
                caselist.add(Integer.toString(i));
            }
        } else if (disctype.getQName().getLocalPart().equals("char")) {
            for (int i = 0; i < fields.size(); i++) {
                caselist.add(Integer.toString(i));
            }
        } else if (disctype.getQName().getLocalPart().equals("boolean")) {
            if (fields.size() == 2) {
                caselist.add("TRUE");
                caselist.add("FALSE");
            } else if (fields.size() == 1) {
                caselist.add("TRUE");
            } else {
                String msg = "Discriminator Type doesnt match number of Choices in Union:" + name;
                LOG.log(Level.WARNING, msg);
            }
        }
    }
    WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
    return corbaUnion;
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) ArrayList(java.util.ArrayList) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) Union(org.apache.cxf.binding.corba.wsdl.Union) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice)

Example 7 with MemberType

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

the class WSDLToCorbaHelper method processChoiceMember.

private MemberType processChoiceMember(XmlSchemaChoice choice, QName defaultName, QName schemaTypeName) throws Exception {
    CorbaType corbatype = processChoice(choice, defaultName, schemaTypeName);
    MemberType member = new MemberType();
    member.setName(corbatype.getQName().getLocalPart());
    member.setIdltype(corbatype.getQName());
    if (corbatype.isSetQualified() && corbatype.isQualified()) {
        member.setQualified(true);
    }
    return member;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType)

Example 8 with MemberType

use of org.apache.cxf.binding.corba.wsdl.MemberType 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 9 with MemberType

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

the class WSDLToCorbaHelper method createUnion.

protected Union createUnion(QName name, XmlSchemaChoice choice, QName defaultName, QName schematypeName) throws Exception {
    Union corbaUnion = null;
    if (recursionMap.get(name) instanceof Union) {
        corbaUnion = (Union) recursionMap.get(name);
        if (corbaUnion != null) {
            return corbaUnion;
        }
    }
    corbaUnion = new Union();
    corbaUnion.setName(name.getLocalPart());
    corbaUnion.setQName(name);
    corbaUnion.setType(schematypeName);
    String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
    corbaUnion.setRepositoryID(id);
    // Set Integer as Discriminator
    corbaUnion.setDiscriminator(CorbaConstants.NT_CORBA_LONG);
    // add to the list of possible recursive types
    recursionMap.put(name, corbaUnion);
    List<MemberType> fields = processContainerAsMembers(choice, defaultName, schematypeName);
    // Choose an Integer as a Discriminator
    List<String> caselist = new ArrayList<>();
    for (int i = 0; i < fields.size(); i++) {
        caselist.add(Integer.toString(i));
    }
    corbaUnion = WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
    recursionMap.remove(name);
    if (!isDuplicate(corbaUnion)) {
        typeMappingType.getStructOrExceptionOrUnion().add(corbaUnion);
    }
    return corbaUnion;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) ArrayList(java.util.ArrayList) Union(org.apache.cxf.binding.corba.wsdl.Union)

Example 10 with MemberType

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

the class WSDLToCorbaHelper method processAllType.

protected CorbaType processAllType(XmlSchemaAll seq, QName defaultName, QName schematypeName) throws Exception {
    QName allName = null;
    Struct type = null;
    if (schematypeName == null) {
        allName = createQNameCorbaNamespace(defaultName.getLocalPart() + "AllStruct");
    } else {
        allName = createQNameCorbaNamespace(schematypeName.getLocalPart() + "AllStruct");
    }
    type = new Struct();
    type.setName(allName.getLocalPart());
    type.setQName(allName);
    type.setType(schematypeName);
    List<MemberType> members = processContainerAsMembers(seq, defaultName, schematypeName);
    for (MemberType memberType : members) {
        type.getMember().add(memberType);
    }
    String repoId = REPO_STRING + type.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
    type.setRepositoryID(repoId);
    return type;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Aggregations

MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)32 QName (javax.xml.namespace.QName)23 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)13 Struct (org.apache.cxf.binding.corba.wsdl.Struct)9 StructMember (org.omg.CORBA.StructMember)6 TypeCode (org.omg.CORBA.TypeCode)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)4 Exception (org.apache.cxf.binding.corba.wsdl.Exception)4 Union (org.apache.cxf.binding.corba.wsdl.Union)4 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)4 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)4 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 InputStream (org.omg.CORBA.portable.InputStream)4 OutputStream (org.omg.CORBA.portable.OutputStream)4 XmlSchemaChoice (org.apache.ws.commons.schema.XmlSchemaChoice)3 AST (antlr.collections.AST)2 IOException (java.io.IOException)2 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)2