private void fillReverseRelationship(Object destinationTarget, ArcProperty property) { ArcProperty clientProperty = (ArcProperty) targetDescriptor.getProperty(property.getName()); if (clientProperty != null) { ArcProperty clientReverse = clientProperty.getComplimentaryReverseArc(); if (clientReverse instanceof ToOneProperty) { clientReverse.writeProperty(destinationTarget, null, target); } } }
public boolean visitAttribute(AttributeProperty property) { // decorate super property to return an overridden attribute descriptor.addSuperProperty(new AttributePropertyDecorator(descriptor, property)); return true; }
/** * Creates an accessor for the property of the embeddable class. */ protected Accessor createEmbeddableAccessor(EmbeddableDescriptor descriptor, String propertyName, Class<?> propertyType) { return new FieldAccessor(descriptor.getObjectClass(), propertyName, propertyType); }
public boolean visitAttribute(AttributeProperty property) { PropertyDescriptor targetProperty = targetDescriptor .getProperty(property.getName()); targetProperty.writeProperty(target, null, property.readProperty(source)); return true; } });
/** * Returns object property using JavaBean-compatible introspection with one * addition - a property can be a dot-separated property name path. */ public static Object getProperty(Object object, String nestedPropertyName) throws CayenneRuntimeException { return accessor(nestedPropertyName).getValue(object); }
/** * Checks that an object's List field described by this property is set, injecting a * List if needed. */ protected ValueHolder ensureCollectionValueHolderSet(Object object) throws PropertyException { Object value = accessor.getValue(object); if (value == null || value instanceof Fault) { value = createCollectionValueHolder(object); accessor.setValue(object, value); } return (ValueHolder) value; }
/** * Sets object property using JavaBean-compatible introspection with one * addition - a property can be a dot-separated property name path. Before * setting a value attempts to convert it to a type compatible with the * object property. Automatic conversion is supported between strings and * basic types like numbers or primitives. */ public static void setProperty(Object object, String nestedPropertyName, Object value) throws CayenneRuntimeException { accessor(nestedPropertyName).setValue(object, value); }
void addListener(Class<?> entityClass, Object listener, Method method) { CallbackOnListener callback = new CallbackOnListener( listener, method, entityClass); addCallback(entityClass, callback); }
@Override public void writeProperty(Object object, Object oldValue, Object newValue) throws PropertyException { resolveFault(object); super.writeProperty(object, oldValue, newValue); }
/** * Registers a callback method to be invoked on a provided non-entity object when a * lifecycle event occurs on any entity that does not suppress default callbacks. */ void addDefaultListener(Object listener, String methodName) { CallbackOnListener callback = new CallbackOnListener(listener, methodName); addDefaultCallback(callback); }
@Override public Object readProperty(Object object) throws PropertyException { resolveFault(object); return super.readProperty(object); }
public boolean visitAllProperties(PropertyVisitor visitor) { checkDescriptorInitialized(); return descriptor.visitAllProperties(visitor); } }
/** * Recursively looks up property descriptor in this class descriptor and all * superclass descriptors. */ public PropertyDescriptor getProperty(String propertyName) { PropertyDescriptor property = getDeclaredProperty(propertyName); if (property == null && superclassDescriptor != null) { property = superclassDescriptor.getProperty(propertyName); } return property; }
/** * Registers a callback method to be invoked on an entity class instances when a * lifecycle event occurs. */ void addListener(Class<?> entityClass, String methodName) { addCallback(entityClass, new CallbackOnEntity(entityClass, methodName)); }
public PropertyDescriptor getDeclaredProperty(String propertyName) { checkDescriptorInitialized(); return descriptor.getDeclaredProperty(propertyName); }
public Collection<ObjAttribute> getDiscriminatorColumns() { checkDescriptorInitialized(); return descriptor.getDiscriminatorColumns(); }
public Expression getEntityQualifier() { checkDescriptorInitialized(); return descriptor.getEntityQualifier(); }
public PropertyDescriptor getProperty(String propertyName) { checkDescriptorInitialized(); return descriptor.getProperty(propertyName); }
public void shallowMerge(Object from, Object to) throws PropertyException { checkDescriptorInitialized(); descriptor.shallowMerge(from, to); }
/** * Creates a descriptor wrapper that will compile the underlying descriptor * on demand. Using proxy indirection is needed to compile relationships of * descriptors to other descriptors that are not compiled yet. */ protected ClassDescriptor createProxyDescriptor(String entityName) { ClassDescriptor descriptor = new LazyClassDescriptorDecorator(this, entityName); addDescriptor(entityName, descriptor); return descriptor; }