Search in sources :

Example 1 with List

use of org.eclipse.persistence.internal.oxm.schema.model.List in project eclipselink by eclipse-ee4j.

the class SDOTypesGenerator method processSimpleType.

private SDOType processSimpleType(String targetNamespace, String defaultNamespace, String sdoTypeName, SimpleType simpleType) {
    if (simpleType == null) {
        return null;
    }
    boolean addedNR = addNextNamespaceResolver(simpleType.getAttributesMap());
    String name = sdoTypeName;
    String originalName = name;
    String nameValue = simpleType.getAttributesMap().get(SDOConstants.SDOXML_NAME_QNAME);
    if (nameValue != null) {
        itemNameToSDOName.put(sdoTypeName, nameValue);
        name = nameValue;
    }
    SDOType newType = startSimpleType(targetNamespace, defaultNamespace, name, originalName, simpleType);
    if (newType != null) {
        Restriction restriction = simpleType.getRestriction();
        if (restriction != null) {
            processRestriction(targetNamespace, defaultNamespace, newType, restriction);
        }
        List list = simpleType.getList();
        if (list != null) {
            processList(targetNamespace, defaultNamespace, sdoTypeName, list, newType);
        }
        Union union = simpleType.getUnion();
        if (union != null) {
            processUnion(targetNamespace, defaultNamespace, sdoTypeName, union, newType);
        }
        finishSimpleType(targetNamespace, defaultNamespace, sdoTypeName, simpleType, newType);
    }
    if (addedNR) {
        namespaceResolvers.remove(namespaceResolvers.size() - 1);
    }
    return newType;
}
Also used : Restriction(org.eclipse.persistence.internal.oxm.schema.model.Restriction) SDOType(org.eclipse.persistence.sdo.SDOType) List(org.eclipse.persistence.internal.oxm.schema.model.List) ArrayList(java.util.ArrayList) Union(org.eclipse.persistence.internal.oxm.schema.model.Union)

Example 2 with List

use of org.eclipse.persistence.internal.oxm.schema.model.List in project eclipselink by eclipse-ee4j.

the class SDOTypesGenerator method define.

public java.util.List<Type> define(Schema schema, boolean includeAllTypes, boolean processImports) {
    // Initialize the List of Types before we process the schema
    java.util.List<Type> returnList = new ArrayList<Type>();
    setReturnAllTypes(includeAllTypes);
    setProcessImports(processImports);
    processSchema(schema);
    returnList.addAll(getGeneratedTypes().values());
    returnList.addAll(anonymousTypes);
    if (!this.isImportProcessor()) {
        java.util.List descriptorsToAdd = new ArrayList(returnList);
        Iterator<Type> iter = descriptorsToAdd.iterator();
        while (iter.hasNext()) {
            SDOType nextSDOType = (SDOType) iter.next();
            if (!nextSDOType.isFinalized()) {
                // Only throw this error if we're not processing an import.
                throw SDOException.typeReferencedButNotDefined(nextSDOType.getURI(), nextSDOType.getName());
            }
            Iterator<Property> propertiesIter = nextSDOType.getProperties().iterator();
            while (propertiesIter.hasNext()) {
                SDOProperty prop = (SDOProperty) propertiesIter.next();
                if (prop.getType().isDataType() && prop.isContainment()) {
                    // If isDataType is true, then isContainment has to be false.
                    // This property was likely created as a stub, and isContainment never got reset
                    // when the property was fully defined.
                    // This problem was uncovered in bug 6809767
                    prop.setContainment(false);
                }
            }
        }
        Iterator<Property> propertiesIter = getGeneratedGlobalElements().values().iterator();
        while (propertiesIter.hasNext()) {
            SDOProperty nextSDOProperty = (SDOProperty) propertiesIter.next();
            if (!nextSDOProperty.isFinalized()) {
                // Only throw this error if we're not processing an import.
                throw SDOException.referencedPropertyNotFound(nextSDOProperty.getUri(), nextSDOProperty.getName());
            }
        }
        propertiesIter = getGeneratedGlobalAttributes().values().iterator();
        while (propertiesIter.hasNext()) {
            SDOProperty nextSDOProperty = (SDOProperty) propertiesIter.next();
            if (!nextSDOProperty.isFinalized()) {
                // Only throw this error if we're not processing an import.
                throw SDOException.referencedPropertyNotFound(nextSDOProperty.getUri(), nextSDOProperty.getName());
            }
        }
        iter = getGeneratedTypes().values().iterator();
        // If we get here all types were finalized correctly
        while (iter.hasNext()) {
            SDOType nextSDOType = (SDOType) iter.next();
            ((SDOTypeHelper) aHelperContext.getTypeHelper()).addType(nextSDOType);
        }
        Iterator<SDOType> anonymousIterator = getAnonymousTypes().iterator();
        while (anonymousIterator.hasNext()) {
            SDOType nextSDOType = anonymousIterator.next();
            ((SDOTypeHelper) aHelperContext.getTypeHelper()).getAnonymousTypes().add(nextSDOType);
        }
        // add any base types to the list
        for (int i = 0; i < descriptorsToAdd.size(); i++) {
            SDOType nextSDOType = (SDOType) descriptorsToAdd.get(i);
            if (!nextSDOType.isDataType() && !nextSDOType.isSubType() && nextSDOType.isBaseType()) {
                nextSDOType.setupInheritance(null);
            } else if (!nextSDOType.isDataType() && nextSDOType.isSubType() && !getGeneratedTypes().values().contains(nextSDOType.getBaseTypes().get(0))) {
                SDOType baseType = (SDOType) nextSDOType.getBaseTypes().get(0);
                while (baseType != null) {
                    descriptorsToAdd.add(baseType);
                    if (baseType.getBaseTypes().size() == 0) {
                        // baseType should now be root of inheritance
                        baseType.setupInheritance(null);
                        baseType = null;
                    } else {
                        baseType = (SDOType) baseType.getBaseTypes().get(0);
                    }
                }
            }
        }
        ((SDOXMLHelper) aHelperContext.getXMLHelper()).addDescriptors(descriptorsToAdd);
        // go through generatedGlobalProperties and add to xsdhelper
        Iterator<QName> qNameIter = getGeneratedGlobalElements().keySet().iterator();
        while (qNameIter.hasNext()) {
            QName nextQName = qNameIter.next();
            SDOProperty nextSDOProperty = (SDOProperty) getGeneratedGlobalElements().get(nextQName);
            ((SDOXSDHelper) aHelperContext.getXSDHelper()).addGlobalProperty(nextQName, nextSDOProperty, true);
        }
        qNameIter = getGeneratedGlobalAttributes().keySet().iterator();
        while (qNameIter.hasNext()) {
            QName nextQName = qNameIter.next();
            SDOProperty nextSDOProperty = (SDOProperty) getGeneratedGlobalAttributes().get(nextQName);
            ((SDOXSDHelper) aHelperContext.getXSDHelper()).addGlobalProperty(nextQName, nextSDOProperty, false);
        }
        Iterator<java.util.List<GlobalRef>> globalRefsIter = getGlobalRefs().values().iterator();
        while (globalRefsIter.hasNext()) {
            java.util.List<GlobalRef> nextList = globalRefsIter.next();
            if (nextList.size() > 0) {
                GlobalRef ref = nextList.get(0);
                throw SDOException.referencedPropertyNotFound(((SDOProperty) ref.getProperty()).getUri(), ref.getProperty().getName());
            }
        }
    }
    return returnList;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) SDOType(org.eclipse.persistence.sdo.SDOType) ComplexType(org.eclipse.persistence.internal.oxm.schema.model.ComplexType) SimpleType(org.eclipse.persistence.internal.oxm.schema.model.SimpleType) SDOWrapperType(org.eclipse.persistence.sdo.types.SDOWrapperType) Type(commonj.sdo.Type) SDODataType(org.eclipse.persistence.sdo.types.SDODataType) SDOType(org.eclipse.persistence.sdo.SDOType) List(org.eclipse.persistence.internal.oxm.schema.model.List) ArrayList(java.util.ArrayList) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) Property(commonj.sdo.Property) SDOProperty(org.eclipse.persistence.sdo.SDOProperty)

Aggregations

ArrayList (java.util.ArrayList)2 List (org.eclipse.persistence.internal.oxm.schema.model.List)2 SDOType (org.eclipse.persistence.sdo.SDOType)2 Property (commonj.sdo.Property)1 Type (commonj.sdo.Type)1 QName (javax.xml.namespace.QName)1 ComplexType (org.eclipse.persistence.internal.oxm.schema.model.ComplexType)1 Restriction (org.eclipse.persistence.internal.oxm.schema.model.Restriction)1 SimpleType (org.eclipse.persistence.internal.oxm.schema.model.SimpleType)1 Union (org.eclipse.persistence.internal.oxm.schema.model.Union)1 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)1 SDODataType (org.eclipse.persistence.sdo.types.SDODataType)1 SDOWrapperType (org.eclipse.persistence.sdo.types.SDOWrapperType)1