Search in sources :

Example 6 with LoadContext

use of com.haulmont.cuba.core.global.LoadContext in project cuba by cuba-platform.

the class JmxControlBean method getInstances.

@SuppressWarnings("unchecked")
@Override
public List<JmxInstance> getInstances() {
    LoadContext loadContext = new LoadContext(JmxInstance.class);
    loadContext.setView(View.LOCAL);
    loadContext.setQueryString("select jmx from sys$JmxInstance jmx");
    List<JmxInstance> clusterInstances = dataService.loadList(loadContext);
    List<JmxInstance> jmxInstances = new ArrayList<>(clusterInstances.size() + 1);
    jmxInstances.add(getLocalInstance());
    jmxInstances.addAll(clusterInstances);
    return jmxInstances;
}
Also used : LoadContext(com.haulmont.cuba.core.global.LoadContext) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance)

Example 7 with LoadContext

use of com.haulmont.cuba.core.global.LoadContext in project cuba by cuba-platform.

the class EntityFactory method build.

@Override
public Object build(String string) {
    if (StringUtils.isBlank(string))
        return null;
    EntityLoadInfo info = EntityLoadInfo.parse(string);
    if (info == null)
        throw new IllegalArgumentException("Invalid entity info: " + string);
    LoadContext ctx = new LoadContext(info.getMetaClass()).setId(info.getId());
    if (info.getViewName() != null)
        ctx.setView(info.getViewName());
    return ds.load(ctx);
}
Also used : EntityLoadInfo(com.haulmont.cuba.core.global.EntityLoadInfo) LoadContext(com.haulmont.cuba.core.global.LoadContext)

Example 8 with LoadContext

use of com.haulmont.cuba.core.global.LoadContext in project cuba by cuba-platform.

the class DataManagerDistinctResultsTest method load.

private LinkedHashSet<User> load(int firstResult, int maxResults, String queryString) {
    DataManager ds = AppBeans.get(DataManager.NAME);
    LoadContext<User> lc = new LoadContext<>(User.class);
    LoadContext.Query q = lc.setQueryString(queryString);
    q.setParameter("groupId", groupId);
    q.setFirstResult(firstResult);
    q.setMaxResults(maxResults);
    List<User> list = ds.loadList(lc);
    return new LinkedHashSet<>(list);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) User(com.haulmont.cuba.security.entity.User) LoadContext(com.haulmont.cuba.core.global.LoadContext) DataManager(com.haulmont.cuba.core.global.DataManager)

Example 9 with LoadContext

use of com.haulmont.cuba.core.global.LoadContext in project cuba by cuba-platform.

the class HsqlLikeNullFailTest method setUp.

@Before
public void setUp() throws Exception {
    DataManager dataManager = AppBeans.get(DataManager.NAME);
    Group group = dataManager.load(new LoadContext<>(Group.class).setId(UUID.fromString("0fa2b1a5-1d68-4d69-9fbd-dff348347f93")));
    User user = new User();
    user.setGroup(group);
    user.setId(UUID.fromString("de0f39d2-e60a-11e1-9b55-3860770d7eaf"));
    user.setName("Test");
    user.setLogin("tEst");
    user.setLoginLowerCase("test");
    dataManager.commit(user);
}
Also used : Group(com.haulmont.cuba.security.entity.Group) User(com.haulmont.cuba.security.entity.User) LoadContext(com.haulmont.cuba.core.global.LoadContext) DataManager(com.haulmont.cuba.core.global.DataManager) Before(org.junit.Before)

Example 10 with LoadContext

use of com.haulmont.cuba.core.global.LoadContext in project cuba by cuba-platform.

the class QueryResultTest method testFirstQuery.

@Test
public void testFirstQuery() throws SQLException {
    DataService dataService = AppBeans.get(DataService.class);
    LoadContext context = new LoadContext(User.class).setView(View.LOCAL);
    context.setQueryString("select u from sec$User u where u.name like :name").setParameter("name", "A-%");
    List<Entity> entities = dataService.loadList(context);
    assertEquals(20, entities.size());
    List<Map<String, Object>> queryResults = getQueryResults();
    assertEquals(0, queryResults.size());
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) User(com.haulmont.cuba.security.entity.User) LoadContext(com.haulmont.cuba.core.global.LoadContext) DataService(com.haulmont.cuba.core.app.DataService) Test(org.junit.Test)

Aggregations

LoadContext (com.haulmont.cuba.core.global.LoadContext)14 User (com.haulmont.cuba.security.entity.User)5 DataService (com.haulmont.cuba.core.app.DataService)4 Entity (com.haulmont.cuba.core.entity.Entity)4 Test (org.junit.Test)3 FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)2 DataManager (com.haulmont.cuba.core.global.DataManager)2 IOException (java.io.IOException)2 UUID (java.util.UUID)2 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)1 JmxInstance (com.haulmont.cuba.core.entity.JmxInstance)1 EntityLoadInfo (com.haulmont.cuba.core.global.EntityLoadInfo)1 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)1 View (com.haulmont.cuba.core.global.View)1 SecurityContext (com.haulmont.cuba.core.sys.SecurityContext)1 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 DataSupplier (com.haulmont.cuba.gui.data.DataSupplier)1 Group (com.haulmont.cuba.security.entity.Group)1 NoUserSessionException (com.haulmont.cuba.security.global.NoUserSessionException)1 UserSession (com.haulmont.cuba.security.global.UserSession)1