use of org.apache.cxf.binding.corba.wsdl.MemberType 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.MemberType 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;
}
use of org.apache.cxf.binding.corba.wsdl.MemberType in project cxf by apache.
the class WSDLToCorbaHelper method processComplexContentStructSequence.
private Struct processComplexContentStructSequence(Struct corbaStruct, XmlSchemaSequence seq, QName defaultName, QName schematypeName) throws Exception {
CorbaType seqtype = processSequenceType(seq, defaultName, schematypeName);
MemberType seqmem = new MemberType();
seqmem.setName(seqtype.getQName().getLocalPart() + "_f");
QName type = createQNameCorbaNamespace(seqtype.getQName().getLocalPart());
seqmem.setIdltype(type);
seqmem.setAnonschematype(true);
if (seqtype.isSetQualified() && seqtype.isQualified()) {
seqmem.setQualified(true);
}
corbaStruct.getMember().add(seqmem);
if (!isDuplicate(seqtype)) {
typeMappingType.getStructOrExceptionOrUnion().add(seqtype);
}
return corbaStruct;
}
use of org.apache.cxf.binding.corba.wsdl.MemberType in project cxf by apache.
the class WSDLToCorbaHelper method createUnion.
protected Union createUnion(QName name, XmlSchemaChoice choice, QName defaultName, QName schematypeName) throws Exception {
Union corbaUnion = null;
if (recursionMap.get(name) instanceof Union) {
corbaUnion = (Union) recursionMap.get(name);
if (corbaUnion != null) {
return corbaUnion;
}
}
corbaUnion = new Union();
corbaUnion.setName(name.getLocalPart());
corbaUnion.setQName(name);
corbaUnion.setType(schematypeName);
String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
corbaUnion.setRepositoryID(id);
// Set Integer as Discriminator
corbaUnion.setDiscriminator(CorbaConstants.NT_CORBA_LONG);
// add to the list of possible recursive types
recursionMap.put(name, corbaUnion);
List<MemberType> fields = processContainerAsMembers(choice, defaultName, schematypeName);
// Choose an Integer as a Discriminator
List<String> caselist = new ArrayList<>();
for (int i = 0; i < fields.size(); i++) {
caselist.add(Integer.toString(i));
}
corbaUnion = WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
recursionMap.remove(name);
if (!isDuplicate(corbaUnion)) {
typeMappingType.getStructOrExceptionOrUnion().add(corbaUnion);
}
return corbaUnion;
}
use of org.apache.cxf.binding.corba.wsdl.MemberType in project cxf by apache.
the class WSDLToCorbaHelper method processAllType.
protected CorbaType processAllType(XmlSchemaAll seq, QName defaultName, QName schematypeName) throws Exception {
QName allName = null;
Struct type = null;
if (schematypeName == null) {
allName = createQNameCorbaNamespace(defaultName.getLocalPart() + "AllStruct");
} else {
allName = createQNameCorbaNamespace(schematypeName.getLocalPart() + "AllStruct");
}
type = new Struct();
type.setName(allName.getLocalPart());
type.setQName(allName);
type.setType(schematypeName);
List<MemberType> members = processContainerAsMembers(seq, defaultName, schematypeName);
for (MemberType memberType : members) {
type.getMember().add(memberType);
}
String repoId = REPO_STRING + type.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
type.setRepositoryID(repoId);
return type;
}
Aggregations