use of io.jmix.core.Entity in project jmix by jmix-framework.
the class CollectionPropertyDatasourceImpl method modifyItem.
@Override
public void modifyItem(T item) {
checkNotNullArgument(item, "item is null");
Collection<T> collection = getCollection();
if (collection != null) {
for (T t : collection) {
if (t.equals(item)) {
EntityCopyUtils.copyCompositionsBack(item, t);
modified = true;
if (cascadeProperty) {
final Entity parentItem = masterDs.getItem();
// noinspection unchecked
((DatasourceImplementation) masterDs).modified(parentItem);
} else {
modified(t);
}
}
}
fireCollectionChanged(Operation.UPDATE, Collections.singletonList(item));
}
}
use of io.jmix.core.Entity in project jmix by jmix-framework.
the class DataManagerTest method testLoadListCaseInsensitiveLower.
@Test
public void testLoadListCaseInsensitiveLower() {
Server server = new Server();
server.setName("LocalHost");
server.setRunning(true);
DataManager dataManager = AppBeans.get(DataManager.NAME);
dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
LoadContext<Server> loadContext = LoadContext.create(Server.class);
loadContext.setQueryString("select s from test$Server s where s.name like :name").setParameter("name", "(?i)%localhost%");
List<Server> list = dataManager.loadList(loadContext);
assertTrue(list.size() > 0);
}
use of io.jmix.core.Entity in project jmix by jmix-framework.
the class DataManagerTest method testLoadList.
@Test
public void testLoadList() {
Server server = new Server();
server.setName("localhost");
server.setRunning(true);
dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
LoadContext<Server> loadContext = LoadContext.create(Server.class);
loadContext.setQueryString("select s from " + metadata.getClass(Server.class).getName() + " s");
List<Server> list = dataManager.loadList(loadContext);
assertTrue(list.size() > 0);
}
use of io.jmix.core.Entity in project jmix by jmix-framework.
the class DataManagerTest method testDiscardCommitted.
@Test
public void testDiscardCommitted() throws Exception {
Server server = new Server();
server.setName("localhost");
CommitContext commitContext = new CommitContext(server);
commitContext.setDiscardCommitted(true);
Set<Entity> committed = dataManager.commit(commitContext);
assertTrue(committed.isEmpty());
Server saved = dataManager.load(LoadContext.create(Server.class).setId(server.getId()));
assertNotNull(saved);
}
use of io.jmix.core.Entity in project jmix by jmix-framework.
the class DataManagerTest method test.
@Test
public void test() {
Server server = new Server();
UUID id = server.getId();
server.setName("localhost");
server.setRunning(true);
dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
LoadContext<Server> loadContext = LoadContext.create(Server.class).setId(id);
server = dataManager.load(loadContext);
assertEquals("localhost", server.getName());
server.setName("krivopustov");
dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
}
Aggregations