use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class ObjectDetachOperationIT method testDetachCommitted.
@Test
public void testDetachCommitted() {
EntityResolver serverResover = serverContext.getEntityResolver();
EntityResolver clientResolver = serverResover.getClientEntityResolver();
ObjectDetachOperation op = new ObjectDetachOperation(clientResolver);
ObjectId oid = new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 456);
MtTable1 so = new MtTable1();
so.setObjectId(oid);
so.setGlobalAttribute1("gx");
so.setPersistenceState(PersistenceState.COMMITTED);
so.setObjectContext(serverContext);
serverContext.getGraphManager().registerNode(oid, so);
Object detached = op.detach(so, serverResover.getClassDescriptor("MtTable1"), null);
assertNotNull(detached);
assertNotSame(so, detached);
assertTrue(detached instanceof ClientMtTable1);
ClientMtTable1 co = (ClientMtTable1) detached;
assertEquals(oid, co.getObjectId());
assertEquals("gx", co.getGlobalAttribute1());
assertEquals(PersistenceState.TRANSIENT, co.getPersistenceState());
assertNull(co.getObjectContext());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class PersistentObjectListTest method testResolvedHessianSerialization.
@Test
public void testResolvedHessianSerialization() throws Exception {
ClientMtTable1 owner = new ClientMtTable1();
owner.setPersistenceState(PersistenceState.COMMITTED);
owner.setGlobalAttribute1("a");
PersistentObjectList list = new PersistentObjectList(owner, "x");
List<Object> objects = new ArrayList<>();
objects.add("a");
objects.add("b");
list.setObjectList(objects);
assertFalse(list.isFault());
Object deserialized = HessianUtil.cloneViaServerClientSerialization(list, new EntityResolver());
assertNotNull(deserialized);
assertTrue("Invalid deserialized: " + deserialized.getClass().getName(), deserialized instanceof PersistentObjectList);
PersistentObjectList dlist = (PersistentObjectList) deserialized;
assertFalse(dlist.isFault());
assertNotNull(dlist.getRelationshipOwner());
assertEquals("x", dlist.getRelationshipName());
assertEquals(objects, dlist.objectList);
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class PersistentObjectListTest method testFaultHessianSerialization.
@Test
public void testFaultHessianSerialization() throws Exception {
ClientMtTable1 owner = new ClientMtTable1();
owner.setPersistenceState(PersistenceState.COMMITTED);
owner.setGlobalAttribute1("a");
PersistentObjectList list = new PersistentObjectList(owner, "x");
assertTrue(list.isFault());
Object deserialized = HessianUtil.cloneViaServerClientSerialization(list, new EntityResolver());
// faults are writtens as nulls
assertNull(deserialized);
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class DefaultDbImportAction method existingTargetMap.
protected DataMap existingTargetMap(DbImportConfiguration configuration) throws IOException {
File file = configuration.getTargetDataMap();
if (file != null && file.exists() && file.canRead()) {
URLResource configurationResource = new URLResource(file.toURI().toURL());
DataMap dataMap = mapLoader.load(configurationResource);
dataMap.setNamespace(new EntityResolver(Collections.singleton(dataMap)));
dataMap.setConfigurationSource(configurationResource);
return dataMap;
}
return null;
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class ProjectController method setProject.
public void setProject(Project currentProject) {
if (this.project != currentProject) {
this.project = currentProject;
this.projectControllerPreferences = null;
if (project == null) {
this.entityResolver = null;
if (fileChangeTracker != null) {
fileChangeTracker.interrupt();
fileChangeTracker = null;
}
} else {
if (fileChangeTracker == null) {
fileChangeTracker = new ProjectFileChangeTracker(this);
fileChangeTracker.setDaemon(true);
fileChangeTracker.start();
}
fileChangeTracker.reconfigure();
entityResolver = new EntityResolver(((DataChannelDescriptor) currentProject.getRootNode()).getDataMaps());
updateEntityResolver();
}
}
}
Aggregations