use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.
the class ValueHolderDescriptorFactory method createToManyListProperty.
@Override
protected void createToManyListProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
String reverseName = relationship.getReverseRelationshipName();
Accessor accessor = createAccessor(descriptor, relationship.getName(), List.class);
descriptor.addDeclaredProperty(new ValueHolderListProperty(descriptor, targetDescriptor, accessor, reverseName));
}
use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.
the class ValueHolderDescriptorFactory method createToManyMapProperty.
@Override
protected void createToManyMapProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
String reverseName = relationship.getReverseRelationshipName();
Accessor accessor = createAccessor(descriptor, relationship.getName(), Map.class);
Accessor mapKeyAccessor = createMapKeyAccessor(relationship, targetDescriptor);
PropertyDescriptor property = new ValueHolderMapProperty(descriptor, targetDescriptor, accessor, reverseName, mapKeyAccessor);
descriptor.addDeclaredProperty(property);
}
use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.
the class ValueHolderDescriptorFactory method createToManyCollectionProperty.
@Override
protected void createToManyCollectionProperty(PersistentDescriptor descriptor, ObjRelationship relationship) {
ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship.getTargetEntityName());
String reverseName = relationship.getReverseRelationshipName();
Accessor accessor = createAccessor(descriptor, relationship.getName(), List.class);
descriptor.addDeclaredProperty(new ValueHolderListProperty(descriptor, targetDescriptor, accessor, reverseName));
}
use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.
the class ObjectContextGraphAction method handlePropertyChange.
/**
* Handles property change in a Persistent object, routing to either
* {@link #handleArcPropertyChange(Persistent, ArcProperty, Object, Object)} or
* {@link #handleSimplePropertyChange(Persistent, String, Object, Object)}.
*/
public void handlePropertyChange(Persistent object, String propertyName, Object oldValue, Object newValue) {
// translate ObjectContext generic property change callback to GraphManager terms
// (simple properties vs. relationships)
ClassDescriptor descriptor = context.getEntityResolver().getClassDescriptor(object.getObjectId().getEntityName());
PropertyDescriptor property = descriptor.getProperty(propertyName);
if (property instanceof ArcProperty) {
handleArcPropertyChange(object, (ArcProperty) property, oldValue, newValue);
} else {
handleSimplePropertyChange(object, propertyName, oldValue, newValue);
}
}
use of org.apache.cayenne.reflect.ClassDescriptor in project cayenne by apache.
the class DataObjectDescriptorFactoryIT method testVisitProperties_IterationOrder.
@Test
public void testVisitProperties_IterationOrder() {
DataObjectDescriptorFactory factory = new DataObjectDescriptorFactory(resolver.getClassDescriptorMap(), new SingletonFaultFactory());
for (ObjEntity e : resolver.getObjEntities()) {
ClassDescriptor descriptor = factory.getDescriptor(e.getName());
final PropertyDescriptor[] lastProcessed = new PropertyDescriptor[1];
PropertyVisitor visitor = new PropertyVisitor() {
public boolean visitToOne(ToOneProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitToMany(ToManyProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitAttribute(AttributeProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
};
descriptor.visitProperties(visitor);
}
}
Aggregations