Search in sources :

Example 1 with Property

use of commonj.sdo.Property in project metro-jax-ws by eclipse-ee4j.

the class SDOWrapperAccessor method initBuilders.

protected void initBuilders() {
    HashMap<Object, PropertySetter> setByQName = new HashMap<>();
    HashMap<Object, PropertyGetter> getByQName = new HashMap<>();
    HashMap<Object, PropertySetter> setByLocalpart = new HashMap<>();
    HashMap<Object, PropertyGetter> getByLocalpart = new HashMap<>();
    HashSet<String> elementLocalNames = new HashSet<>();
    TypeHelper helper = contextWrapper.getHelperContext().getTypeHelper();
    Type type = helper.getType(contentClass);
    @SuppressWarnings("unchecked") List<Property> properties = (List<Property>) type.getDeclaredProperties();
    for (Property p : properties) {
        QName qname = SDOUtils.getPropertyElementName(contextWrapper.getHelperContext(), p);
        SDOPropertyBuilder pBuilder = new SDOPropertyBuilder(qname, p.getType().getInstanceClass());
        setByQName.put(qname, pBuilder);
        getByQName.put(qname, pBuilder);
        setByLocalpart.put(qname.getLocalPart(), pBuilder);
        getByLocalpart.put(qname.getLocalPart(), pBuilder);
        if (elementLocalNames.contains(qname.getLocalPart())) {
            elementLocalNameCollision = true;
        } else {
            elementLocalNames.add(qname.getLocalPart());
        }
    }
    if (elementLocalNameCollision) {
        propertySetters = setByQName;
        propertyGetters = getByQName;
    } else {
        propertySetters = setByLocalpart;
        propertyGetters = getByLocalpart;
    }
}
Also used : TypeHelper(commonj.sdo.helper.TypeHelper) HashMap(java.util.HashMap) PropertySetter(com.sun.xml.ws.spi.db.PropertySetter) QName(javax.xml.namespace.QName) Type(commonj.sdo.Type) PropertyGetter(com.sun.xml.ws.spi.db.PropertyGetter) DataObject(commonj.sdo.DataObject) List(java.util.List) Property(commonj.sdo.Property) HashSet(java.util.HashSet)

Example 2 with Property

use of commonj.sdo.Property in project metro-jax-ws by eclipse-ee4j.

the class Xsd2JavaSDOModel method getJavaTypeForElementName.

/**
 * return the java type used for the element, only Global elements can be located.
 * Containing types are not searched
 */
public String getJavaTypeForElementName(QName qname) {
    XSDHelper xsdHelper = context.getXSDHelper();
    Property globalProperty = xsdHelper.getGlobalProperty(qname.getNamespaceURI(), qname.getLocalPart(), true);
    if (globalProperty == null) {
        throw new RuntimeException("Given element with name: " + qname + "is not found.");
    }
    Type elementType = globalProperty.getType();
    if (elementType == null) {
        throw new RuntimeException("Given element with name: " + qname + "is not found.");
    }
    return ((SDOType) elementType).getInstanceClassName();
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) XSDHelper(commonj.sdo.helper.XSDHelper) Property(commonj.sdo.Property)

Example 3 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class SDODataObject method createDataObject.

@Override
public SDODataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) {
    Property aProperty = getInstanceProperty(propertyIndex);
    Type aType = aHelperContext.getTypeHelper().getType(namespaceURI, typeName);
    return createDataObject(aProperty, aType);
}
Also used : Type(commonj.sdo.Type) Property(commonj.sdo.Property)

Example 4 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class SDODataObject method _getOpenContentPropertiesAttributesMap.

public Map _getOpenContentPropertiesAttributesMap() {
    Map openContentPropertiesAttrs = new HashMap();
    for (int i = 0, size = _getOpenContentPropertiesAttributes().size(); i < size; i++) {
        Property next = (Property) _getOpenContentPropertiesAttributes().get(i);
        // if uri is null then attributes won't be prefix qualified
        QName qname = new QName(((SDOProperty) next).getUri(), next.getName());
        openContentPropertiesAttrs.put(qname, get(next));
    }
    return openContentPropertiesAttrs;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) HashMap(java.util.HashMap) Map(java.util.Map) Property(commonj.sdo.Property)

Example 5 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class SDODataObject method updateDataGraph.

/**
 * INTERNAL:
 * Recursively set this DataObject's DataGraph
 * This function serves as a copy of updateChangeSummaryAndDataGraph() to recursively walk and set the dataGraph.
 * that will be run when no recursion occurs in the case that an object (with a changeSummary)
 * is set internally to a tree (without a changeSummary).
 * Callers: Typically updateContainment (during a set) or delete/detach
 *   when the current object is internal with its own changeSummary property.
 * @param aDataGraph
 */
private void updateDataGraph(DataGraph aDataGraph) {
    Iterator iterProperties = getInstanceProperties().iterator();
    Property property;
    Object object;
    Object listContainedObject;
    // Add back pointer to containing DataGraph - in preOrder sequence before recursing
    setDataGraph(aDataGraph);
    // Recurse currentValueStore
    while (iterProperties.hasNext()) {
        property = (Property) iterProperties.next();
        // do not recurse bidirectional currentValueStore that are non-containment
        if (property.isContainment() || isContainedByDataGraph(property)) {
            object = get(property);
            if (object instanceof SDODataObject) {
                // DataObject child of this DataObject
                ((SDODataObject) object).updateDataGraph(aDataGraph);
            }
            if (object instanceof ListWrapper) {
                // ListWrapper child of this DataObject
                Iterator anIterator = ((ListWrapper) object).iterator();
                while (anIterator.hasNext()) {
                    listContainedObject = anIterator.next();
                    if (listContainedObject instanceof SDODataObject) {
                        ((SDODataObject) listContainedObject).updateDataGraph(aDataGraph);
                    }
                }
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) ListWrapper(org.eclipse.persistence.sdo.helper.ListWrapper) DataObject(commonj.sdo.DataObject) SequencedObject(org.eclipse.persistence.oxm.sequenced.SequencedObject) Property(commonj.sdo.Property)

Aggregations

Property (commonj.sdo.Property)354 DataObject (commonj.sdo.DataObject)204 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)194 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)124 List (java.util.List)99 Type (commonj.sdo.Type)87 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)76 ArrayList (java.util.ArrayList)73 ChangeSummary (commonj.sdo.ChangeSummary)56 SDOType (org.eclipse.persistence.sdo.SDOType)54 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)47 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)37 SDOException (org.eclipse.persistence.exceptions.SDOException)35 Iterator (java.util.Iterator)24 QName (javax.xml.namespace.QName)12 InputStream (java.io.InputStream)11 SDOSetting (org.eclipse.persistence.sdo.SDOSetting)11 Map (java.util.Map)5 XMLDocument (commonj.sdo.helper.XMLDocument)4 SequencedObject (org.eclipse.persistence.oxm.sequenced.SequencedObject)4