use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processLiteralArray.
private CorbaType processLiteralArray(XmlSchemaComplexType complex, QName defaultName, boolean anonymous) throws Exception {
// NEED TO DO
QName name;
QName typeName = null;
QName schematypeName = checkPrefix(complex.getQName());
if (schematypeName == null) {
schematypeName = defaultName;
name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
schematypeName = checkPrefix(schematypeName);
name = checkPrefix(name);
} else {
name = createQNameCorbaNamespace(schematypeName.getLocalPart());
name = checkPrefix(name);
}
CorbaType arrayType = null;
XmlSchemaElement arrayEl = null;
QName elName = null;
if (complex.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence) complex.getParticle();
Iterator<XmlSchemaSequenceMember> iterator = seq.getItems().iterator();
Iterator<XmlSchemaSequenceMember> iter = seq.getItems().iterator();
while (iterator.hasNext()) {
if (iter.next() instanceof XmlSchemaElement) {
arrayEl = (XmlSchemaElement) iterator.next();
elName = arrayEl.getQName();
XmlSchemaType atype = arrayEl.getSchemaType();
if (elName == null) {
elName = arrayEl.getRef().getTargetQName();
/*
* TODO: why are we looking up an element name with findSchemaType?
*/
atype = findSchemaType(elName);
}
String uri = defaultName.getNamespaceURI();
if (complex.getQName() != null) {
uri = complex.getQName().getNamespaceURI();
}
if (elName.getNamespaceURI().equals("")) {
elName = new QName(uri, elName.getLocalPart());
}
QName arrayTypeName = elName;
if (anonymous) {
arrayTypeName = new QName(elName.getNamespaceURI(), defaultName.getLocalPart() + "." + elName.getLocalPart());
}
arrayType = convertSchemaToCorbaType(atype, arrayTypeName, atype, null, true);
boolean isQualified = getElementQualification(arrayEl, uri);
if (isQualified) {
arrayType.setQualified(isQualified);
} else {
elName = new QName("", elName.getLocalPart());
}
typeName = arrayType.getQName();
}
}
}
Long maxOccurs = null;
Long minOccurs = null;
if (arrayEl != null) {
if (arrayEl.isNillable()) {
QName nilunionname = createQNameTargetNamespace(arrayType.getQName().getLocalPart() + "_nil");
boolean isQualified = arrayType.isSetQualified() && arrayType.isQualified();
arrayType = createNillableUnion(nilunionname, elName, arrayType.getQName(), isQualified);
typeName = createQNameCorbaNamespace(arrayType.getQName().getLocalPart());
if (arrayType != null && !isDuplicate(arrayType)) {
typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
}
}
maxOccurs = arrayEl.getMaxOccurs();
minOccurs = arrayEl.getMinOccurs();
}
return createArray(name, schematypeName, checkPrefix(typeName), elName, maxOccurs, minOccurs, anonymous);
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType 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.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processPrimitiveType.
private CorbaType processPrimitiveType(QName typeName) {
QName qName = createQNameXmlSchemaNamespace(typeName.getLocalPart());
CorbaType corbatype = (CorbaType) CORBAPRIMITIVEMAP.get(qName);
if (corbatype == null) {
// REVISIT, bravi, not an ideal way to add the fixed & octet type to the typemap.
CorbaType type = null;
if (typeName.equals(W3CConstants.NT_SCHEMA_DECIMAL)) {
QName name = new QName(idlNamespace, "fixed_1");
type = WSDLTypes.getFixedCorbaType(name, typeName, 31, 6);
corbatype = WSDLTypes.getFixedCorbaType(name, typeName, 31, 6);
} else if (typeName.equals(W3CConstants.NT_SCHEMA_BASE64) || typeName.equals(W3CConstants.NT_SCHEMA_HBIN)) {
QName name = new QName(idlNamespace, typeName.getLocalPart() + "Seq");
type = WSDLTypes.getOctetCorbaType(name, typeName, 0);
corbatype = WSDLTypes.getOctetCorbaType(name, typeName, 0);
}
if (type != null && !isDuplicate(type)) {
typeMappingType.getStructOrExceptionOrUnion().add(type);
}
}
return corbatype;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processLocalElement.
private CorbaType processLocalElement(QName containingTypeName, XmlSchemaElement element, String uri) throws Exception {
CorbaType membertype = new CorbaType();
XmlSchemaType schemaType = element.getSchemaType();
QName schemaName = element.getQName();
if (schemaType == null) {
if (element.getRef().getTarget() != null) {
schemaType = findSchemaType(element.getRef().getTarget().getSchemaTypeName());
schemaName = element.getRef().getTargetQName();
} else {
schemaType = findSchemaType(element.getSchemaTypeName());
}
}
if (schemaName.getNamespaceURI().equals("")) {
schemaName = new QName(uri, schemaName.getLocalPart());
}
QName elemName = schemaName;
boolean elementQualified = getElementQualification(element, uri);
if (!elementQualified) {
elemName = new QName("", elemName.getLocalPart());
}
QName memName = null;
if (element.isNillable()) {
CorbaType elemtype = convertSchemaToCorbaType(schemaType, elemName, schemaType, null, true);
QName name = createQNameTargetNamespace(elemtype.getQName().getLocalPart() + "_nil");
QName elName = checkPrefix(elemName);
if (elName == null) {
elName = createQNameTargetNamespace(elemName.getLocalPart());
}
CorbaType memtype = createNillableUnion(elName, name, elemtype.getQName(), elementQualified);
memName = createQNameCorbaNamespace(memtype.getQName().getLocalPart());
if (!isDuplicate(memtype)) {
typeMappingType.getStructOrExceptionOrUnion().add(memtype);
}
membertype.setQName(memName);
membertype.setName(memtype.getName());
membertype.setType(memtype.getType());
} else if (schemaType != null) {
XmlSchemaType st = schemaType;
boolean anonymous = WSDLTypes.isAnonymous(st.getName());
QName typeName = null;
if (anonymous) {
typeName = new QName(elemName.getNamespaceURI(), containingTypeName.getLocalPart() + "." + elemName.getLocalPart());
} else {
typeName = st.getQName();
}
membertype = convertSchemaToCorbaType(st, typeName, st, null, anonymous);
} else if (element.getSchemaTypeName() != null) {
QName name = checkPrefix(element.getSchemaTypeName());
membertype = getLocalType(name);
}
if (membertype == null) {
return null;
}
if (!(element.getMaxOccurs() == 1) || !(element.getMinOccurs() == 1)) {
QName name = createQNameCorbaNamespace(getModulePrefix(membertype) + elemName.getLocalPart() + "Array");
CorbaType arraytype = null;
if (memName != null) {
arraytype = createArray(name, /*schemaName*/
name, memName, elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
} else {
arraytype = createArray(name, /*schemaName*/
name, membertype.getQName(), elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
}
if (arraytype != null) {
if (arraytype instanceof Abstractsequence) {
((Abstractsequence) arraytype).setWrapped(false);
}
if (arraytype instanceof Abstractanonsequence) {
((Abstractanonsequence) arraytype).setWrapped(false);
}
if (!isDuplicate(arraytype)) {
typeMappingType.getStructOrExceptionOrUnion().add(arraytype);
}
// the local element with maxOccurs != 1 or minOccurs != 1 becomes the just created array
membertype = arraytype;
}
}
membertype.setQualified(elementQualified);
return membertype;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processSimpleRestrictionType.
private CorbaType processSimpleRestrictionType(XmlSchemaSimpleType stype, QName name, QName schematypeName, boolean anonymous) throws Exception {
CorbaType corbaTypeImpl = null;
// checks if enumeration
XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction) stype.getContent();
QName baseName = checkPrefix(restrictionType.getBaseTypeName());
String maxLength = null;
String length = null;
for (XmlSchemaFacet val : restrictionType.getFacets()) {
if (val instanceof XmlSchemaMaxLengthFacet) {
maxLength = val.getValue().toString();
}
if (val instanceof XmlSchemaLengthFacet) {
length = val.getValue().toString();
}
}
if (isEnumeration(restrictionType)) {
corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
} else {
if (restrictionType.getBaseType() != null) {
corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName, stype, null, false);
} else {
corbaTypeImpl = processPrimitiveType(baseName);
if (corbaTypeImpl == null) {
XmlSchemaType schematype = findSchemaType(baseName);
corbaTypeImpl = convertSchemaToCorbaType(schematype, schematypeName, schematype, null, false);
}
}
if (corbaTypeImpl != null) {
if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_STRING) || (baseName.equals(W3CConstants.NT_SCHEMA_STRING))) {
corbaTypeImpl = WSDLTypes.processStringType(corbaTypeImpl, name, maxLength, length);
} else if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_DECIMAL) || (baseName.equals(W3CConstants.NT_SCHEMA_DECIMAL))) {
corbaTypeImpl = WSDLTypes.processDecimalType(restrictionType, name, corbaTypeImpl, anonymous);
} else if ((corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_BASE64)) || (baseName.equals(W3CConstants.NT_SCHEMA_BASE64)) || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))) {
corbaTypeImpl = WSDLTypes.processBase64Type(corbaTypeImpl, name, maxLength, length);
}
}
}
return corbaTypeImpl;
}
Aggregations