use of org.eclipse.persistence.internal.oxm.schema.model.ComplexType in project eclipselink by eclipse-ee4j.
the class SDOTypesGenerator method processGlobalItem.
private void processGlobalItem(String targetNamespace, String defaultNamespace, String qualifiedName) {
if (rootSchema == null) {
return;
}
String localName = null;
int index = qualifiedName.indexOf(':');
if (index != -1) {
localName = qualifiedName.substring(index + 1, qualifiedName.length());
} else {
localName = qualifiedName;
}
SimpleType simpleType = rootSchema.getTopLevelSimpleTypes().get(localName);
if (simpleType == null) {
ComplexType complexType = rootSchema.getTopLevelComplexTypes().get(localName);
if (complexType == null) {
Element element = rootSchema.getTopLevelElements().get(localName);
if (element == null) {
Attribute attribute = rootSchema.getTopLevelAttributes().get(localName);
if (attribute != null) {
processGlobalAttribute(targetNamespace, defaultNamespace, attribute);
}
} else {
processGlobalElement(targetNamespace, defaultNamespace, element);
}
} else {
processGlobalComplexType(targetNamespace, defaultNamespace, complexType);
}
} else {
processGlobalSimpleType(targetNamespace, defaultNamespace, simpleType);
}
}
use of org.eclipse.persistence.internal.oxm.schema.model.ComplexType in project eclipselink by eclipse-ee4j.
the class SDOTypesGenerator method processElement.
private SDOType processElement(String targetNamespace, String defaultNamespace, SDOType owningType, TypeDefParticle typeDefParticle, Element element, boolean isGlobal, boolean isMany) {
SDOType type = null;
boolean addedNR = addNextNamespaceResolver(element.getAttributesMap());
ComplexType complexType = element.getComplexType();
boolean qualified = true;
if (!isGlobal) {
qualified = rootSchema.isElementFormDefault();
}
if (!isMany && maxOccursGreaterThanOne(element.getMaxOccurs())) {
isMany = true;
}
if (complexType != null) {
type = processComplexType(targetNamespace, defaultNamespace, element.getName(), complexType);
type.setXsdLocalName(element.getName());
type.setXsd(true);
processSimpleElement(targetNamespace, defaultNamespace, owningType, type, typeDefParticle, element, qualified, isGlobal, isMany);
} else if (element.getSimpleType() != null) {
type = processSimpleType(targetNamespace, defaultNamespace, element.getName(), element.getSimpleType());
type.setXsdLocalName(element.getName());
type.setXsd(true);
processSimpleElement(targetNamespace, defaultNamespace, owningType, type, typeDefParticle, element, qualified, isGlobal, isMany);
} else {
processSimpleElement(targetNamespace, defaultNamespace, owningType, null, typeDefParticle, element, qualified, isGlobal, isMany);
}
if (addedNR) {
namespaceResolvers.remove(namespaceResolvers.size() - 1);
}
return type;
}
use of org.eclipse.persistence.internal.oxm.schema.model.ComplexType in project eclipselink by eclipse-ee4j.
the class SDOTypesGenerator method processBaseType.
private Type processBaseType(String targetNamespace, String defaultNamespace, SDOType owningType, String qualifiedName, boolean simpleContentExtension, Restriction restriction) {
if (qualifiedName == null) {
return null;
}
SDOType baseType = getSDOTypeForName(targetNamespace, defaultNamespace, qualifiedName);
QName baseQName = getQNameForString(defaultNamespace, qualifiedName);
if (!baseType.isFinalized() && baseQName.getNamespaceURI().equals(targetNamespace)) {
if (baseType.isDataType()) {
SimpleType baseSimpleType = rootSchema.getTopLevelSimpleTypes().get(baseQName.getLocalPart());
processGlobalSimpleType(targetNamespace, defaultNamespace, baseSimpleType);
} else {
ComplexType baseComplexType = rootSchema.getTopLevelComplexTypes().get(baseQName.getLocalPart());
processGlobalComplexType(targetNamespace, defaultNamespace, baseComplexType);
}
}
// Java instance class is int
if (baseQName.equals(XMLConstants.INTEGER_QNAME) || baseQName.equals(SDOConstants.POSITIVEINTEGER_QNAME) || baseQName.equals(SDOConstants.NEGATIVEINTEGER_QNAME) || baseQName.equals(SDOConstants.NONPOSITIVEINTEGER_QNAME) || baseQName.equals(SDOConstants.NONNEGATIVEINTEGER_QNAME) || baseQName.equals(XMLConstants.LONG_QNAME) || baseQName.equals(SDOConstants.UNSIGNEDLONG_QNAME)) {
boolean alreadySet = false;
String value = restriction.getMaxInclusive();
if (value != null) {
if (Integer.parseInt(value) <= Integer.MAX_VALUE) {
baseType = getTypeForXSDQName(XMLConstants.INT_QNAME);
alreadySet = true;
}
}
// if maxInclusive was processed, no need to handle maxExclusive
if (!alreadySet) {
value = restriction.getMaxExclusive();
if (value != null) {
if (Integer.parseInt(value) < Integer.MAX_VALUE) {
baseType = getTypeForXSDQName(XMLConstants.INT_QNAME);
}
}
}
}
processBaseType(baseType, targetNamespace, defaultNamespace, owningType, qualifiedName, simpleContentExtension);
return baseType;
}
use of org.eclipse.persistence.internal.oxm.schema.model.ComplexType in project eclipselink by eclipse-ee4j.
the class BaseDBWSBuilderHelper method buildSchema.
/**
* Build the schema
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void buildSchema(NamingConventionTransformer nct) {
Project oxProject = dbwsBuilder.getOxProject();
Schema schema = null;
List<Descriptor> descriptorsToProcess = new ArrayList<Descriptor>();
for (Descriptor desc : (List<Descriptor>) (List) oxProject.getOrderedDescriptors()) {
String alias = desc.getAlias();
if (!DEFAULT_SIMPLE_XML_FORMAT_TAG.equals(alias)) {
descriptorsToProcess.add(desc);
}
}
if (descriptorsToProcess.size() > 0) {
// need a deep-copy clone of oxProject; simplest way is to marshall/unmarshall to a stream
StringWriter sw = new StringWriter();
XMLProjectWriter.write(oxProject, sw);
XRDynamicClassLoader specialLoader = new XRDynamicClassLoader(this.getClass().getClassLoader());
Project oxProjectClone = XMLProjectReader.read(new StringReader(sw.toString()), specialLoader);
ProjectHelper.fixOROXAccessors(oxProjectClone, null);
XMLLogin xmlLogin = new XMLLogin();
DOMPlatform domPlatform = new DOMPlatform();
domPlatform.getConversionManager().setLoader(specialLoader);
xmlLogin.setPlatform(domPlatform);
oxProjectClone.setLogin(xmlLogin);
// initialize reference descriptors
oxProjectClone.createDatabaseSession();
SchemaModelGenerator schemaGenerator = new SchemaModelGenerator(XMLConversionManager.getDefaultXMLManager(), true);
SchemaModelGeneratorProperties sgProperties = new SchemaModelGeneratorProperties();
// set element form default to qualified for target namespace
sgProperties.addProperty(dbwsBuilder.getTargetNamespace(), ELEMENT_FORM_QUALIFIED_KEY, true);
Map<String, Schema> schemaMap = schemaGenerator.generateSchemas(descriptorsToProcess, sgProperties);
Schema s = schemaMap.get(dbwsBuilder.getTargetNamespace());
// check existing schema for any top-level ComplexTypes
if (dbwsBuilder.getSchema() != null && s != null) {
Map<String, ComplexType> topLevelComplexTypes = dbwsBuilder.getSchema().getTopLevelComplexTypes();
for (Map.Entry<String, ComplexType> me : topLevelComplexTypes.entrySet()) {
s.addTopLevelComplexTypes(me.getValue());
}
// add any additional namespaces
NamespaceResolver snr = s.getNamespaceResolver();
NamespaceResolver nr = dbwsBuilder.getSchema().getNamespaceResolver();
// we only want to add prefix/uri pairs for prefixes that don't already exist
for (String prefix : nr.getPrefixesToNamespaces().keySet()) {
if (snr.resolveNamespacePrefix(prefix) == null) {
snr.put(prefix, nr.resolveNamespacePrefix(prefix));
}
}
// switch
schema = s;
schema.setNamespaceResolver(snr);
}
} else {
schema = new Schema();
addSimpleXMLFormat(schema);
schema.setTargetNamespace(dbwsBuilder.getTargetNamespace());
}
dbwsBuilder.setSchema(schema);
}
Aggregations