Search in sources :

Example 16 with PropertyDescriptor

use of org.apache.cayenne.reflect.PropertyDescriptor in project cayenne by apache.

the class DataContextMergeHandler method arcChanged.

// works the same for add and remove as long as we don't get too smart per TODO below.
private void arcChanged(Object nodeId, Object targetNodeId, Object arcId) {
    final Persistent source = (Persistent) context.getGraphManager().getNode(nodeId);
    if (source != null && source.getPersistenceState() != PersistenceState.HOLLOW) {
        final int state = source.getPersistenceState();
        PropertyDescriptor p = propertyForId(nodeId, arcId.toString());
        p.visit(new PropertyVisitor() {

            public boolean visitAttribute(AttributeProperty property) {
                return false;
            }

            public boolean visitToMany(ToManyProperty property) {
                if (state == PersistenceState.COMMITTED) {
                    property.invalidate(source);
                }
                return false;
            }

            public boolean visitToOne(ToOneProperty property) {
                if (state == PersistenceState.COMMITTED) {
                    property.invalidate(source);
                }
                // of dirty objects. See DataRowUtils for details.
                return false;
            }
        });
    }
}
Also used : PropertyDescriptor(org.apache.cayenne.reflect.PropertyDescriptor) ToManyProperty(org.apache.cayenne.reflect.ToManyProperty) Persistent(org.apache.cayenne.Persistent) AttributeProperty(org.apache.cayenne.reflect.AttributeProperty) PropertyVisitor(org.apache.cayenne.reflect.PropertyVisitor) ToOneProperty(org.apache.cayenne.reflect.ToOneProperty)

Aggregations

PropertyDescriptor (org.apache.cayenne.reflect.PropertyDescriptor)16 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)14 AttributeProperty (org.apache.cayenne.reflect.AttributeProperty)9 PropertyVisitor (org.apache.cayenne.reflect.PropertyVisitor)8 ToManyProperty (org.apache.cayenne.reflect.ToManyProperty)8 ToOneProperty (org.apache.cayenne.reflect.ToOneProperty)8 ArcProperty (org.apache.cayenne.reflect.ArcProperty)5 Persistent (org.apache.cayenne.Persistent)4 ObjEntity (org.apache.cayenne.map.ObjEntity)4 Test (org.junit.Test)4 SingletonFaultFactory (org.apache.cayenne.reflect.SingletonFaultFactory)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ObjectId (org.apache.cayenne.ObjectId)2 EJBQLException (org.apache.cayenne.ejbql.EJBQLException)2 EntityResolver (org.apache.cayenne.map.EntityResolver)2 ObjRelationship (org.apache.cayenne.map.ObjRelationship)2 PrefetchTreeNode (org.apache.cayenne.query.PrefetchTreeNode)2 Accessor (org.apache.cayenne.reflect.Accessor)2