use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class RelationshipFault method updateReverse.
// see if reverse relationship is to-one and we can connect source to
// results....
protected void updateReverse(List<E> resolved) {
EntityResolver resolver = relationshipOwner.getObjectContext().getEntityResolver();
ObjEntity sourceEntity = resolver.getObjEntity(relationshipOwner.getObjectId().getEntityName());
ObjRelationship relationship = sourceEntity.getRelationship(relationshipName);
ObjRelationship reverse = relationship.getReverseRelationship();
if (reverse != null && !reverse.isToMany()) {
PropertyDescriptor property = resolver.getClassDescriptor(reverse.getSourceEntity().getName()).getProperty(reverse.getName());
for (Object o : resolved) {
property.writePropertyDirectly(o, null, relationshipOwner);
}
}
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class DbEntityRelationshipPanel method createComboModel.
/**
* Creates a list of DbEntities.
*/
private ComboBoxModel<DbEntity> createComboModel() {
EntityResolver resolver = mediator.getEntityResolver();
DbEntity[] objects = resolver.getDbEntities().toArray(new DbEntity[0]);
return new DefaultComboBoxModel<>(objects);
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class CayenneContextGraphManager method remapTargets.
/**
* Remaps keys in to-many map relationships that contain dirty objects with
* potentially modified properties.
*/
private void remapTargets() {
Iterator<Object> it = stateLog.dirtyIds().iterator();
EntityResolver resolver = context.getEntityResolver();
while (it.hasNext()) {
ObjectId id = (ObjectId) it.next();
ClassDescriptor descriptor = resolver.getClassDescriptor(id.getEntityName());
Collection<ArcProperty> mapArcProperties = descriptor.getMapArcProperties();
if (!mapArcProperties.isEmpty()) {
Object object = getNode(id);
for (ArcProperty arc : mapArcProperties) {
ToManyMapProperty reverseArc = (ToManyMapProperty) arc.getComplimentaryReverseArc();
Object source = arc.readPropertyDirectly(object);
if (source != null && !reverseArc.isFault(source)) {
remapTarget(reverseArc, source, object);
}
}
}
}
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class CayenneContextQueryAction method invalidateLocally.
private void invalidateLocally(CayenneContextGraphManager graphManager, Iterator<?> it) {
if (!it.hasNext()) {
return;
}
EntityResolver resolver = actingContext.getEntityResolver();
while (it.hasNext()) {
final Persistent object = (Persistent) it.next();
// present
if (object.getPersistenceState() == PersistenceState.NEW) {
continue;
}
ObjectId id = object.getObjectId();
// per CAY-1082 ROP objects (unlike CayenneDataObject) require all
// relationship faults invalidation.
ClassDescriptor descriptor = resolver.getClassDescriptor(id.getEntityName());
PropertyVisitor arcInvalidator = new PropertyVisitor() {
public boolean visitAttribute(AttributeProperty property) {
return true;
}
public boolean visitToMany(ToManyProperty property) {
property.invalidate(object);
return true;
}
public boolean visitToOne(ToOneProperty property) {
property.invalidate(object);
return true;
}
};
descriptor.visitProperties(arcInvalidator);
object.setPersistenceState(PersistenceState.HOLLOW);
// remove cached changes
graphManager.changeLog.unregisterNode(id);
graphManager.stateLog.unregisterNode(id);
}
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class HessianConfigTest method testLoadFactoryInjection.
@Test
public void testLoadFactoryInjection() throws Exception {
EntityResolver resolver = new EntityResolver();
AbstractSerializerFactory factory = HessianConfig.loadFactory(MockAbstractSerializerFactory.class.getName(), resolver);
assertTrue(factory instanceof MockAbstractSerializerFactory);
assertSame(resolver, ((MockAbstractSerializerFactory) factory).getEntityResolver());
}
Aggregations