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