use of io.jmix.core.FetchPlan in project jmix by jmix-framework.
the class CheckLoadedStateTest method testGetCurrentFetchPlan.
@Test
public void testGetCurrentFetchPlan() {
DataManager dataManager = AppBeans.get(DataManager.class);
EntityStates entityStates = AppBeans.get(EntityStates.class);
User user = dataManager.load(User.class).id(userId).fetchPlan("user.edit").one();
FetchPlan fetchPlan = entityStates.getCurrentFetchPlan(user);
User user1 = dataManager.load(User.class).id(userId).fetchPlan(fetchPlan).one();
entityStates.checkLoadedWithFetchPlan(user1, "user.edit");
}
use of io.jmix.core.FetchPlan in project jmix by jmix-framework.
the class DataManagerCommit2Test method testViewAfterCommitModified.
@Test
public void testViewAfterCommitModified() throws Exception {
Group group2 = dataManager.load(LoadContext.create(Group.class).setId(this.group2.getId()).setFetchPlan(FetchPlan.INSTANCE_NAME));
assertFalse(entityStates.isLoaded(group2, "createTs"));
LoadContext<User> loadContext = LoadContext.create(User.class).setId(userId).setView(view);
User user = dataManager.load(loadContext);
user.setName("testUser-changed");
user.setGroup(group2);
FetchPlan userView = new View(User.class, true).addProperty("login").addProperty("name").addProperty("group", new View(Group.class).addProperty("name").addProperty("createTs"));
User committedUser = dataManager.commit(user, userView);
assertTrue(entityStates.isLoaded(committedUser.getGroup(), "createTs"));
}
use of io.jmix.core.FetchPlan in project jmix by jmix-framework.
the class DataManagerCommit2Test method testViewAfterCommitNew.
@Test
public void testViewAfterCommitNew() throws Exception {
Group group = dataManager.load(LoadContext.create(Group.class).setId(group1.getId()).setFetchPlan(FetchPlan.INSTANCE_NAME));
assertFalse(entityStates.isLoaded(group, "createTs"));
User user = metadata.create(User.class);
try {
user.setName("testUser");
user.setLogin("login" + user.getId());
user.setGroup(group);
FetchPlan userView = new View(User.class, true).addProperty("login").addProperty("name").addProperty("group", new View(Group.class, false).addProperty("name").addProperty("createTs"));
User committedUser = dataManager.commit(user, userView);
assertTrue(entityStates.isLoaded(committedUser.getGroup(), "createTs"));
} finally {
testSupport.deleteRecord(user);
}
}
use of io.jmix.core.FetchPlan in project jmix by jmix-framework.
the class EclipseLinkQueriesTest method testJoinOnWithParentReference.
// join on, view contains parent attribute
@Test
public void testJoinOnWithParentReference() throws Exception {
try (Transaction tx = persistence.createTransaction()) {
EntityManager em = persistence.getEntityManager();
FetchPlan view = new View(Group.class).addProperty("parent");
TypedQuery<Group> query = em.createQuery("select g from test$Group g join test$QueryResult qr on qr.entityId = g.id where qr.queryKey = 1", Group.class);
query.setView(view);
List<Group> result = query.getResultList();
tx.commit();
}
}
use of io.jmix.core.FetchPlan in project jmix by jmix-framework.
the class FetchJoinTest method testLoadingJoinedInheritance.
@Test
public void testLoadingJoinedInheritance() throws Exception {
FetchPlan typeLocalView = new View(JoinType.class).addProperty("name");
FetchPlan classTypeView = new View(JoinClassType.class).addProperty("name").addProperty("types", typeLocalView);
FetchPlan typeView = new View(JoinType.class).addProperty("name").addProperty("classType", classTypeView);
FetchPlan userView = new View(JoinUser.class).addProperty("name").addProperty("type", typeView);
DataManager dataManager = AppBeans.get(DataManager.class);
JoinUser reloadedUser = dataManager.load(JoinUser.class).id(user.getId()).view(userView).one();
assertNotNull(reloadedUser);
assertEquals(type, reloadedUser.getType());
assertEquals(classType, reloadedUser.getType().getClassType());
}
Aggregations