Search in sources :

Example 1 with Unionbranch

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

the class CorbaObjectWriter method writeUnion.

public void writeUnion(CorbaObjectHandler obj) throws CorbaBindingException {
    Union unionType = (Union) obj.getType();
    List<Unionbranch> branches = unionType.getUnionbranch();
    if (!branches.isEmpty()) {
        CorbaObjectHandler discriminator = ((CorbaUnionHandler) obj).getDiscriminator();
        this.write(discriminator);
        CorbaObjectHandler unionValue = ((CorbaUnionHandler) obj).getValue();
        if (unionValue != null) {
            this.write(unionValue);
        }
    }
}
Also used : CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) CorbaUnionHandler(org.apache.cxf.binding.corba.types.CorbaUnionHandler) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 2 with Unionbranch

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

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

the class WSDLTypes method processUnionBranches.

public static Union processUnionBranches(Union corbaUnion, List<MemberType> fields, List<String> caselist) {
    int caseIndex = 0;
    for (int i = 0; i < fields.size(); i++) {
        MemberType field = fields.get(i);
        Unionbranch branch = new Unionbranch();
        branch.setName(field.getName());
        branch.setIdltype(field.getIdltype());
        if (field.isSetQualified() && field.isQualified()) {
            branch.setQualified(true);
        }
        branch.setDefault(false);
        CaseType c = new CaseType();
        c.setLabel(caselist.get(caseIndex));
        caseIndex++;
        branch.getCase().add(c);
        corbaUnion.getUnionbranch().add(branch);
    }
    return corbaUnion;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 4 with Unionbranch

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

the class WSDLToIDLAction method createUnion.

private IdlType createUnion(Union u, IdlScopeBase scope, String local) throws Exception {
    boolean undefinedCircular = false;
    IdlType disc = findType(u.getDiscriminator());
    IdlUnion union = IdlUnion.create(scope, local, disc);
    scope.holdForScope(union);
    for (Unionbranch ub : u.getUnionbranch()) {
        QName qname = ub.getIdltype();
        IdlType bt = findType(qname);
        boolean isDefault = false;
        if (ub.isSetDefault()) {
            isDefault = ub.isDefault();
        }
        IdlUnionBranch b = IdlUnionBranch.create(union, ub.getName(), bt, isDefault);
        for (CaseType cs : ub.getCase()) {
            b.addCase(cs.getLabel());
        }
        if (!undefinedCircular && !(bt instanceof IdlSequence)) {
            String mlocal = qname.getLocalPart();
            String[] mname = unscopeName(mlocal);
            undefinedCircular = null != root.lookup(mname, true);
        }
        union.addBranch(b);
    }
    if (undefinedCircular) {
        scope.parkHeld();
    } else {
        scope.promoteHeldToScope();
        if (union.isCircular()) {
            // resolving this union closed a recursion
            scope.flush();
        }
    }
    return union;
}
Also used : IdlUnionBranch(org.apache.cxf.tools.corba.common.idltypes.IdlUnionBranch) IdlSequence(org.apache.cxf.tools.corba.common.idltypes.IdlSequence) CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) QName(javax.xml.namespace.QName) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) IdlUnion(org.apache.cxf.tools.corba.common.idltypes.IdlUnion) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 5 with Unionbranch

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

Aggregations

Unionbranch (org.apache.cxf.binding.corba.wsdl.Unionbranch)11 Union (org.apache.cxf.binding.corba.wsdl.Union)6 QName (javax.xml.namespace.QName)5 CaseType (org.apache.cxf.binding.corba.wsdl.CaseType)5 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)2 AST (antlr.collections.AST)1 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 Definition (javax.wsdl.Definition)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1 CorbaEnumHandler (org.apache.cxf.binding.corba.types.CorbaEnumHandler)1 CorbaUnionHandler (org.apache.cxf.binding.corba.types.CorbaUnionHandler)1 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)1 Enum (org.apache.cxf.binding.corba.wsdl.Enum)1 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)1 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)1 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)1 IdlSequence (org.apache.cxf.tools.corba.common.idltypes.IdlSequence)1 IdlString (org.apache.cxf.tools.corba.common.idltypes.IdlString)1 IdlType (org.apache.cxf.tools.corba.common.idltypes.IdlType)1