use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
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)));
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
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 sys$Server s where s.name like :name").setParameter("name", "(?i)%localhost%");
List<Server> list = dataManager.loadList(loadContext);
assertTrue(list.size() > 0);
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class DataManagerTest method testLoad.
@Test
public void testLoad() {
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());
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class DesktopAbstractTable method getStylename.
protected String getStylename(JTable table, int row, int column) {
if (styleProviders == null) {
return null;
}
Entity item = tableModel.getItem(row);
int modelColumn = table.convertColumnIndexToModel(column);
Object property = columnsOrder.get(modelColumn).getId();
String joinedStyle = null;
for (StyleProvider styleProvider : styleProviders) {
// noinspection unchecked
String styleName = styleProvider.getStyleName(item, property.toString());
if (styleName != null) {
if (joinedStyle == null) {
joinedStyle = styleName;
} else {
joinedStyle += " " + styleName;
}
}
}
return joinedStyle;
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class DesktopOptionsGroup method setOptionsDatasource.
@Override
public void setOptionsDatasource(CollectionDatasource datasource) {
if (optionsInitialized)
return;
super.setOptionsDatasource(datasource);
if (optionsDatasource != null) {
if (!optionsDatasource.getState().equals(Datasource.State.VALID)) {
optionsDatasource.refresh();
}
for (Entity item : optionsDatasource.getItems()) {
addItem(new EntityWrapper(item));
}
collectionChangeListener = e -> {
Object value = getValue();
removeAllItems();
for (Object id : e.getDs().getItemIds()) {
addItem(new EntityWrapper(e.getDs().getItem(id)));
}
updateComponent(value);
fireChangeListeners(getValue());
impl.revalidate();
impl.repaint();
};
optionsDatasource.addCollectionChangeListener(new WeakCollectionChangeListener(optionsDatasource, collectionChangeListener));
if ((datasource != null) && (datasource.getState() == Datasource.State.VALID)) {
Entity newValue = datasource.getItem();
updateComponent(newValue);
fireChangeListeners(newValue);
}
optionsInitialized = true;
}
assignAutoDebugId();
}
Aggregations