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);
}
}
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations