Search in sources :

Example 6 with CorbaType

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

the class UnionVisitor method visitDeclaredUnion.

public void visitDeclaredUnion(AST identifierNode) {
    Scope unionScope = new Scope(getScope(), identifierNode);
    AST discriminatorNode = identifierNode.getNextSibling();
    AST caseNode = discriminatorNode.getNextSibling();
    // xmlschema:union
    XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema, true);
    unionSchemaComplexType.setName(mapper.mapToQName(unionScope));
    // REVISIT
    // TEMPORARILY
    // using TypesVisitor to visit <const_type>
    // it should be visited by a SwitchTypeSpecVisitor
    TypesVisitor visitor = new TypesVisitor(getScope(), definition, schema, wsdlVisitor, null);
    visitor.visit(discriminatorNode);
    CorbaType ctype = visitor.getCorbaType();
    Scope fullyQualifiedName = visitor.getFullyQualifiedName();
    XmlSchemaChoice choice = new XmlSchemaChoice();
    choice.setMinOccurs(1);
    choice.setMaxOccurs(1);
    unionSchemaComplexType.setParticle(choice);
    // corba:union
    Union corbaUnion = new Union();
    corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
    corbaUnion.setRepositoryID(unionScope.toIDLRepositoryID());
    corbaUnion.setType(unionSchemaComplexType.getQName());
    if (ctype != null) {
        corbaUnion.setDiscriminator(ctype.getQName());
    } else {
        // Discriminator type is forward declared.
        UnionDeferredAction unionDiscriminatorAction = new UnionDeferredAction(corbaUnion);
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionDiscriminatorAction);
    }
    boolean recursiveAdd = addRecursiveScopedName(identifierNode);
    processCaseNodes(caseNode, unionScope, choice, corbaUnion);
    if (recursiveAdd) {
        removeRecursiveScopedName(identifierNode);
    }
    // add corbaType
    typeMap.getStructOrExceptionOrUnion().add(corbaUnion);
    // REVISIT: are these assignments needed?
    setSchemaType(unionSchemaComplexType);
    setCorbaType(corbaUnion);
    // Need to check if the union was forward declared
    processForwardUnionActions(unionScope);
    // Once we've finished declaring the union, we should make sure it has been removed from
    // the list of scopedNames so that we indicate that is no longer simply forward declared.
    scopedNames.remove(unionScope);
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) Union(org.apache.cxf.binding.corba.wsdl.Union)

Example 7 with CorbaType

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

the class UnionVisitor method processForwardUnionActions.

// Process any actions that were defered for a forward declared union
private void processForwardUnionActions(Scope unionScope) {
    if (wsdlVisitor.getDeferredActions() != null) {
        DeferredActionCollection deferredActions = wsdlVisitor.getDeferredActions();
        List<DeferredAction> list = deferredActions.getActions(unionScope);
        if ((list != null) && !list.isEmpty()) {
            XmlSchemaType stype = getSchemaType();
            CorbaType ctype = getCorbaType();
            Iterator<DeferredAction> iterator = list.iterator();
            while (iterator.hasNext()) {
                SchemaDeferredAction action = (SchemaDeferredAction) iterator.next();
                action.execute(stype, ctype);
            }
            iterator = list.iterator();
            while (iterator.hasNext()) {
                iterator.next();
                iterator.remove();
            }
        }
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 8 with CorbaType

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

the class WSDLToCorbaBinding method cleanUpTypeMap.

public void cleanUpTypeMap(TypeMappingType typeMap) {
    List<CorbaType> types = typeMap.getStructOrExceptionOrUnion();
    if (types != null) {
        for (int i = 0; i < types.size(); i++) {
            CorbaType type = types.get(i);
            if (type.getQName() != null) {
                type.setName(type.getQName().getLocalPart());
                type.setQName(null);
            }
        }
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType)

Example 9 with CorbaType

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

use of org.apache.cxf.binding.corba.wsdl.CorbaType 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)

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