Search in sources :

Example 81 with Entity

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)));
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 82 with Entity

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);
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 83 with Entity

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());
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 84 with Entity

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;
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity)

Example 85 with Entity

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();
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) WeakCollectionChangeListener(com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener)

Aggregations

Entity (com.haulmont.cuba.core.entity.Entity)203 MetaClass (com.haulmont.chile.core.model.MetaClass)51 MetaProperty (com.haulmont.chile.core.model.MetaProperty)44 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)40 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)18 Test (org.junit.Test)15 Inject (javax.inject.Inject)14 java.util (java.util)12 EntityManager (com.haulmont.cuba.core.EntityManager)11 ParseException (java.text.ParseException)11 Element (org.dom4j.Element)11 Logger (org.slf4j.Logger)11 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)10 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)9 LoggerFactory (org.slf4j.LoggerFactory)9 Query (com.haulmont.cuba.core.Query)8 Server (com.haulmont.cuba.core.entity.Server)8 Transaction (com.haulmont.cuba.core.Transaction)7 Datasource (com.haulmont.cuba.gui.data.Datasource)7 Collectors (java.util.stream.Collectors)7