Search in sources :

Example 6 with Union

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

the class WSDLToCorbaBindingTypeTest method testNillableType.

@Test
public void testNillableType() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/nillable.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("NillablePortType");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(2, typemap.getElementsByTagName("corba:union").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:struct").getLength());
        TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("NillableCORBABinding");
        idlgen.setOutputFile("nillable.idl");
        idlgen.generateIDL(model);
        Union un = (Union) mapType.getStructOrExceptionOrUnion().get(2);
        assertEquals("Name is incorrect for Union Type", "long_nil", un.getName());
        assertEquals("Type is incorrect for Union Type", "PEl", un.getType().getLocalPart());
        Unionbranch unbranch = un.getUnionbranch().get(0);
        assertEquals("Name is incorrect for UnionBranch Type", "value", unbranch.getName());
        assertEquals("Type is incorrect for UnionBranch Type", "long", unbranch.getIdltype().getLocalPart());
        File f = new File("nillable.idl");
        assertTrue("nillable.idl should be generated", f.exists());
    } finally {
        new File("nillable.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) File(java.io.File) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch) Test(org.junit.Test)

Example 7 with Union

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

the class WSDLToCorbaHelper method processComplexContentStructChoice.

protected MemberType processComplexContentStructChoice(XmlSchemaChoice choice, QName schematypeName, QName defaultName) throws Exception {
    QName choicename = createQNameTargetNamespace(schematypeName.getLocalPart() + "ChoiceType");
    Union choiceunion = createUnion(choicename, choice, defaultName, schematypeName);
    MemberType choicemem = new MemberType();
    if (choiceunion != null) {
        String repoId = REPO_STRING + choiceunion.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
        choiceunion.setRepositoryID(repoId);
        choicemem.setName(choiceunion.getQName().getLocalPart() + "_f");
        choicemem.setIdltype(createQNameCorbaNamespace(choiceunion.getQName().getLocalPart()));
        if (!isDuplicate(choiceunion)) {
            typeMappingType.getStructOrExceptionOrUnion().add(choiceunion);
        }
    }
    return choicemem;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) Union(org.apache.cxf.binding.corba.wsdl.Union)

Example 8 with Union

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

the class WSDLToCorbaHelper method createNillableUnion.

protected CorbaType createNillableUnion(QName name, QName schemaType, QName membertype, boolean isQualified) {
    Union nilUnion = new Union();
    nilUnion.setName(name.getLocalPart());
    nilUnion.setType(schemaType);
    nilUnion.setQName(name);
    nilUnion.setDiscriminator(CorbaConstants.NT_CORBA_BOOLEAN);
    String id = REPO_STRING + nilUnion.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
    nilUnion.setRepositoryID(id);
    Unionbranch branch = new Unionbranch();
    branch.setName("value");
    branch.setIdltype(membertype);
    branch.setDefault(false);
    if (isQualified) {
        branch.setQualified(true);
    }
    CaseType caseType = new CaseType();
    caseType.setLabel("TRUE");
    branch.getCase().add(caseType);
    nilUnion.getUnionbranch().add(branch);
    nilUnion.setNillable(true);
    return nilUnion;
}
Also used : CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 9 with Union

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

the class WSDLToCorbaHelper method processChoice.

private CorbaType processChoice(XmlSchemaChoice choice, QName defaultName, QName schemaTypeName) throws Exception {
    QName choicename = null;
    if (schemaTypeName == null) {
        choicename = createQNameCorbaNamespace(defaultName.getLocalPart());
    } else {
        choicename = createQNameCorbaNamespace(schemaTypeName.getLocalPart());
    }
    choicename = checkPrefix(choicename);
    CorbaType corbatype = createUnion(choicename, choice, defaultName, schemaTypeName);
    String repoId = REPO_STRING + corbatype.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
    ((Union) corbatype).setRepositoryID(repoId);
    if (!(choice.getMaxOccurs() == 1) || !(choice.getMinOccurs() == 1)) {
        QName name = createQNameTargetNamespace(corbatype.getQName().getLocalPart() + "Array");
        CorbaType arrayType = createArray(name, corbatype.getQName(), corbatype.getQName(), choice.getMaxOccurs(), choice.getMinOccurs(), false);
        if (arrayType != null && !isDuplicate(arrayType)) {
            typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
        }
    }
    return corbatype;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Union(org.apache.cxf.binding.corba.wsdl.Union)

Example 10 with Union

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

the class WSDLToIDLAction method createType.

protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
    if (idlType.getLocalPart().equals("CORBA.Object")) {
        return IdlInterface.create(null, "Object");
    }
    CorbaType corbaTypeImpl = corbaType;
    if (corbaTypeImpl == null) {
        corbaTypeImpl = getCorbaType(idlType);
    }
    if (corbaTypeImpl == null) {
        String msgStr = "Type " + idlType.getLocalPart() + " not found.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    IdlScopeBase scope = root;
    StringBuilder dotScopedName = new StringBuilder("");
    for (int i = 0; i < name.length - 1; ++i) {
        dotScopedName.append(name[i]);
        // name array.
        if ("CORBA".equals(dotScopedName.toString()) && name.length == 2 && i == 0 && name[1].equals("Object")) {
            break;
        }
        IdlDefn idlDef = scope.lookup(name[i]);
        if (idlDef == null) {
            // Before creating module, check to see if a Corba type
            // represent this name aleady exists.
            // For example if type is a.b.c and we are about to create
            // module b, look to see if a.b
            // is an interface that needs to be processed
            QName qname = new QName(corbaTypeImpl.getType().getNamespaceURI(), dotScopedName.toString());
            // Check to see if CORBAType exists. If so, create type for it
            // otherwise
            // create module for this scope
            CorbaType possibleCorbaType = getCorbaType(qname);
            if (possibleCorbaType != null) {
                idlDef = findType(qname);
            }
            if (idlDef == null) {
                idlDef = IdlModule.create(scope, name[i]);
                scope.addToScope(idlDef);
            }
        }
        dotScopedName.append(".");
        scope = (IdlScopeBase) idlDef;
    }
    IdlType result = null;
    String local = name[name.length - 1];
    if (corbaTypeImpl instanceof Enum) {
        result = createEnum((Enum) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Sequence) {
        result = createSequence((Sequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonsequence) {
        result = createAnonSequence((Anonsequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Exception) {
        result = createIdlException((org.apache.cxf.binding.corba.wsdl.Exception) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Struct) {
        result = createStruct((Struct) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Union) {
        result = createUnion((Union) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Alias) {
        result = createTypedef((Alias) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Array) {
        result = createArray((Array) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonarray) {
        result = createAnonArray((Anonarray) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Fixed) {
        result = createFixed((Fixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonfixed) {
        result = createAnonFixed((Anonfixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Const) {
        result = createConst((Const) corbaTypeImpl, scope, local);
    } else {
        result = checkAnon(corbaTypeImpl, scope, local);
    }
    if (result == null && corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Object) {
        result = createInterface((org.apache.cxf.binding.corba.wsdl.Object) corbaTypeImpl, scope, local);
    }
    return result;
}
Also used : IdlEnum(org.apache.cxf.tools.corba.common.idltypes.IdlEnum) Enum(org.apache.cxf.binding.corba.wsdl.Enum) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) Union(org.apache.cxf.binding.corba.wsdl.Union) IdlUnion(org.apache.cxf.tools.corba.common.idltypes.IdlUnion) IdlStruct(org.apache.cxf.tools.corba.common.idltypes.IdlStruct) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) IdlFixed(org.apache.cxf.tools.corba.common.idltypes.IdlFixed) IdlAnonFixed(org.apache.cxf.tools.corba.common.idltypes.IdlAnonFixed) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed) QName(javax.xml.namespace.QName) IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) Const(org.apache.cxf.binding.corba.wsdl.Const) IdlConst(org.apache.cxf.tools.corba.common.idltypes.IdlConst) IdlScopeBase(org.apache.cxf.tools.corba.common.idltypes.IdlScopeBase) IdlAnonSequence(org.apache.cxf.tools.corba.common.idltypes.IdlAnonSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) IdlSequence(org.apache.cxf.tools.corba.common.idltypes.IdlSequence) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException) IdlAnonArray(org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray) Array(org.apache.cxf.binding.corba.wsdl.Array) IdlArray(org.apache.cxf.tools.corba.common.idltypes.IdlArray) Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Aggregations

Union (org.apache.cxf.binding.corba.wsdl.Union)16 QName (javax.xml.namespace.QName)8 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)6 Unionbranch (org.apache.cxf.binding.corba.wsdl.Unionbranch)6 Enum (org.apache.cxf.binding.corba.wsdl.Enum)4 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)4 File (java.io.File)3 Definition (javax.wsdl.Definition)3 CaseType (org.apache.cxf.binding.corba.wsdl.CaseType)3 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)3 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)3 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)2 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2 Array (org.apache.cxf.binding.corba.wsdl.Array)2 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)2