use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class TableModelAdapter method setValueAt.
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
Table.Column column = columns.get(columnIndex);
if (!column.isEditable())
return;
if (generatedColumns.contains(column))
return;
Object id = getItemId(rowIndex);
Entity item = datasource.getItem(id);
if (column.getId() instanceof MetaPropertyPath) {
String property = column.getId().toString();
item.setValueEx(property, aValue);
}
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class TableModelAdapter method getRowIndex.
@Override
public int getRowIndex(Entity entity) {
int idx = 0;
if (entity != null) {
if (datasource instanceof CollectionDatasource.Ordered) {
Object id = ((CollectionDatasource.Ordered) datasource).firstItemId();
while (id != null) {
if (entity.equals(datasource.getItem(id)))
return idx;
id = ((CollectionDatasource.Ordered) datasource).nextItemId(id);
idx++;
}
} else {
for (Entity item : datasource.getItems()) {
if (entity.equals(item))
return idx;
idx++;
}
}
}
return -1;
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class TreeModelAdapter method isLeaf.
@Override
public boolean isLeaf(Object node) {
if (node == rootNode) {
return false;
} else {
Entity entity = ((Node) node).getEntity();
Collection<Object> childrenIds = datasource.getChildren(entity.getId());
return childrenIds.size() == 0;
}
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class TreeModelAdapter method getIndexOfChild.
@Override
public int getIndexOfChild(Object parent, Object child) {
if (parent == null || child == null)
return -1;
Collection<Object> childrenIds;
if (parent == rootNode) {
childrenIds = datasource.getRootItemIds();
} else {
Entity entity = ((Node) parent).getEntity();
childrenIds = datasource.getChildren(entity.getId());
}
final Entity childEntity = ((Node) child).getEntity();
return Iterables.indexOf(childrenIds, id -> childEntity.getId().equals(id));
}
use of com.haulmont.cuba.core.entity.Entity in project cuba by cuba-platform.
the class DataManagerTest method testLoadListById.
@Test
public void testLoadListById() {
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);
List<Server> list = dataManager.loadList(loadContext);
assertTrue(list.size() == 1);
}
Aggregations