当前位置: 首页>>代码示例>>Java>>正文


Java LoadContext类代码示例

本文整理汇总了Java中com.haulmont.cuba.core.global.LoadContext的典型用法代码示例。如果您正苦于以下问题:Java LoadContext类的具体用法?Java LoadContext怎么用?Java LoadContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LoadContext类属于com.haulmont.cuba.core.global包,在下文中一共展示了LoadContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initNewItem

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Override
protected void initNewItem(Request item) {
    super.initNewItem(item);

    User user = userSessionSource.getUserSession().getUser();

    LoadContext<ExtUser> loadContext = LoadContext.create(ExtUser.class)
            .setId(user.getId())
            .setView("user.edit");
    ExtUser extUser = dataManager.load(loadContext);

    if (extUser != null) {
        item.setUser(extUser);
        item.setDepartment(extUser.getDepartment());
    }

    LoadContext<RequestTag> tagLoadContext =  LoadContext.create(RequestTag.class)
            .setQuery(LoadContext.createQuery("select e from extuser$RequestTag e"));
    List<RequestTag> tags = dataManager.loadList(tagLoadContext);
    item.setTags(tags);

}
 
开发者ID:aleksey-stukalov,项目名称:ext-user,代码行数:23,代码来源:RequestEdit.java

示例2: getTimeEntriesForPeriod

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Override
public List<TimeEntry> getTimeEntriesForPeriod(Date start, Date end, User user, @Nullable TimeEntryStatus status, @Nullable String viewName) {
    LoadContext<TimeEntry> loadContext = new LoadContext<>(TimeEntry.class);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    String queryStr = "select e from ts$TimeEntry e where e.user.id = :userId and (e.date between :start and :end)";
    if (status != null) {
        queryStr += " and e.status = :status";
    }
    LoadContext.Query query = loadContext.setQueryString(queryStr)
            .setParameter("start", start)
            .setParameter("end", end)
            .setParameter("userId", user.getId());
    if (status != null) {
        query.setParameter("status", status.getId());
    }
    return dataManager.loadList(loadContext);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:20,代码来源:ProjectsServiceBean.java

示例3: getApprovableTimeEntriesForPeriod

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Override
public List<TimeEntry> getApprovableTimeEntriesForPeriod(
        Date start, Date end, User approver, User user, @Nullable TimeEntryStatus status, @Nullable String viewName
) {
    LoadContext<TimeEntry> loadContext = new LoadContext<>(TimeEntry.class);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    String queryStr = "select e from ts$TimeEntry e join e.task t join t.project pr join pr.participants p " +
            "where p.user.id = :approverId and (p.role.code = '" + MANAGER.getId() + "' or p.role.code = '" + APPROVER.getId() + "') " +
            "and e.user.id = :userId and (e.date between :start and :end)";
    if (status != null) {
        queryStr += " and e.status = :status";
    }
    LoadContext.Query query = loadContext.setQueryString(queryStr)
            .setParameter("start", start)
            .setParameter("end", end)
            .setParameter("approverId", approver.getId())
            .setParameter("userId", user.getId());
    if (status != null) {
        query.setParameter("status", status.getId());
    }
    return dataManager.loadList(loadContext);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:25,代码来源:ProjectsServiceBean.java

示例4: getActiveTasksForUser

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Override
public List<Task> getActiveTasksForUser(User user, @Nullable String viewName) {
    LoadContext<Task> loadContext = new LoadContext<>(Task.class);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    loadContext.setQueryString("select e from ts$Task e join e.exclusiveParticipants p " +
            "where p.user.id = :userId and e.status = 'active' order by e.project")
            .setParameter("userId", user.getId());
    List<Task> assignedTasks = dataManager.loadList(loadContext);
    loadContext.setQueryString("select e from ts$Task e join e.project pr join pr.participants p " +
            "where p.user.id = :userId and e.exclusiveParticipants is empty and e.status = 'active' order by e.project")
            .setParameter("userId", user.getId());
    List<Task> commonTasks = dataManager.loadList(loadContext);
    if (assignedTasks.isEmpty() && commonTasks.isEmpty()) {
        return Collections.emptyList();
    }
    List<Task> allTasks = new ArrayList<>(assignedTasks.size() + commonTasks.size());
    allTasks.addAll(assignedTasks);
    allTasks.addAll(commonTasks);
    return allTasks;
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:23,代码来源:ProjectsServiceBean.java

示例5: findLocalizedConstraintMessage

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Nullable
@Override
public LocalizedConstraintMessage findLocalizedConstraintMessage(String entityName,
                                                                 ConstraintOperationType operationType) {
    Preconditions.checkNotNullArgument(entityName);
    Preconditions.checkNotNullArgument(operationType);

    LoadContext<LocalizedConstraintMessage> loadContext = new LoadContext<>(LocalizedConstraintMessage.class);
    loadContext.setQueryString("select e from sec$LocalizedConstraintMessage e " +
            "where e.entityName = :name and e.operationType = :type")
            .setParameter("name", entityName)
            .setParameter("type", operationType);

    List<LocalizedConstraintMessage> localizations = dataManager.loadList(loadContext);

    if (CollectionUtils.isEmpty(localizations)) {
        return null;
    } else if (localizations.size() == 1) {
        return localizations.get(0);
    } else {
        throw new IllegalStateException("Several entities with the same 'entity name/operation type' combination");
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:ConstraintLocalizationServiceBean.java

示例6: testLoadDeletedObject

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Test
public void testLoadDeletedObject() {
    View taskView_Message = new View(SoftDelete_Task.class).addProperty("message");
    View taskView_Service = new View(SoftDelete_Task.class)
            .addProperty("service", new View(SoftDelete_Service.class).addProperty("code"));
    View taskValueView = new View(SoftDelete_TaskValue.class)
            .addProperty("task", taskView_Message);

    View projectView = new View(SoftDelete_Project.class)
            .addProperty("name")
            .addProperty("aValue", taskValueView)
            .addProperty("task", taskView_Service);

    LoadContext<SoftDelete_Project> loadContext = new LoadContext<>(SoftDelete_Project.class)
            .setView(projectView).setId(projectId);
    SoftDelete_Project project = dataManager.load(loadContext);

    Assert.assertNotNull(project);
    Assert.assertNotNull(project.getTask());
    Assert.assertTrue(project.getTask().isDeleted());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:SoftDeleteNotFoundDeletedTest.java

示例7: testSecondQuery

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Test
public void testSecondQuery() 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.email like :email").setParameter("email", "%aaa.com");

    LoadContext.Query prevQuery = new LoadContext.Query("select u from sec$User u where u.name like :name")
            .setParameter("name", "A-%");
    context.getPrevQueries().add(prevQuery);          context.setQueryKey(111);

    List<Entity> entities = dataService.loadList(context);
    assertEquals(10, entities.size());

    List<Map<String, Object>> queryResults = getQueryResults();
    assertEquals(20, queryResults.size());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:QueryResultTest.java

示例8: setUp

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@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);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:HsqlLikeNullFailTest.java

示例9: isScheduledTaskLoaded

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
protected boolean isScheduledTaskLoaded(String code) {
    SchedulerLoaderLog loaderLog =
        dataManager.load(LoadContext.create(SchedulerLoaderLog.class)
                .setQuery(LoadContext.createQuery("select e from scheduler$SchedulerLoaderLog e where e.code = :code")
                        .setParameter("code", code)));

    return loaderLog != null;
}
 
开发者ID:aleksey-stukalov,项目名称:cuba-scheduler-annotation,代码行数:9,代码来源:ScheduledTaskLoader.java

示例10: getEntityByCode

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
public <T extends Entity> T getEntityByCode(Class<T> clazz, String code, @Nullable String viewName) {
    LoadContext<T> loadContext = new LoadContext<>(clazz);
    MetaClass metaClass = metadata.getSession().getClassNN(clazz);
    loadContext.setQueryString("select e from " + metaClass.getName() + " e where e.code = :code")
            .setParameter("code", code);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    return dataManager.load(loadContext);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:11,代码来源:SystemDataManager.java

示例11: getEntitiesByCodes

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
public <T extends Entity> List<T> getEntitiesByCodes(Class<T> clazz, List<String> codes, @Nullable String viewName) {
    if (codes.isEmpty()) {
        return Collections.emptyList();
    }
    LoadContext<T> loadContext = new LoadContext<>(clazz);
    MetaClass metaClass = metadata.getSession().getClassNN(clazz);
    loadContext.setQueryString("select e from " + metaClass.getName() + " e where e.code in :codes")
            .setParameter("codes", codes);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    return dataManager.loadList(loadContext);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:14,代码来源:SystemDataManager.java

示例12: getStatisticsByTasks

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
public Map<Task, BigDecimal> getStatisticsByTasks(Date start, Date end, @Nullable Project project) {
    LoadContext.Query query = LoadContext.createQuery(
            "select t from ts$TimeEntry t where t.date >= :start and t.date <= :end")
            .setParameter("start", start)
            .setParameter("end", end);
    if (project != null) {
        query.setQueryString(query.getQueryString() + " and t.task.project.id = :project");
        query.setParameter("project", project);
    }
    LoadContext<TimeEntry> loadContext = LoadContext.create(TimeEntry.class)
            .setQuery(query)
            .setView(new View(TimeEntry.class)
                            .addProperty("task",
                                    new View(Task.class)
                                            .addProperty("name")
                                            .addProperty("project", viewRepository.getView(Project.class, View.MINIMAL)))
                            .addProperty("timeInMinutes")
            );
    List<TimeEntry> timeEntries = dataManager.loadList(loadContext);
    Map<Task, BigDecimal> result = new HashMap<>();
    for (TimeEntry timeEntry : timeEntries) {
        BigDecimal sum = result.get(timeEntry.getTask());
        if (sum == null) {
            sum = BigDecimal.ZERO;
        }

        sum = sum.add(HoursAndMinutes.fromTimeEntry(timeEntry).toBigDecimal());
        result.put(timeEntry.getTask(), sum);
    }

    return result;
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:33,代码来源:StatisticServiceBean.java

示例13: getAllProjects

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
protected List<Project> getAllProjects() {
    LoadContext<Project> loadContext = new LoadContext<>(Project.class)
            .setView("project-full");
    loadContext.setQueryString("select e from ts$Project e");

    return dataManager.loadList(loadContext);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:8,代码来源:ProjectsServiceBean.java

示例14: getUserProjectRole

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Nullable
@Override
public ProjectRole getUserProjectRole(Project project, User user) {
    LoadContext<ProjectParticipant> loadContext = new LoadContext<>(ProjectParticipant.class)
            .setView("projectParticipant-full");
    loadContext.setQueryString("select e from ts$ProjectParticipant e " +
            "where e.user.id = :userId and e.project.id = :projectId")
            .setParameter("userId", user.getId())
            .setParameter("projectId", project.getId());
    ProjectParticipant participant = dataManager.load(loadContext);
    return participant != null ? participant.getRole() : null;
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:13,代码来源:ProjectsServiceBean.java

示例15: getActiveTasksForUserAndProject

import com.haulmont.cuba.core.global.LoadContext; //导入依赖的package包/类
@Override
public Map<String, Task> getActiveTasksForUserAndProject(User user, Project project, @Nullable String viewName) {
    LoadContext<Task> loadContext = new LoadContext<>(Task.class);
    if (viewName != null) {
        loadContext.setView(viewName);
    }
    loadContext.setQueryString("select e from ts$Task e join e.exclusiveParticipants p " +
            "where p.user.id = :userId and e.project.id = :projectId and e.status = 'active' order by e.project")
            .setParameter("projectId", project.getId())
            .setParameter("userId", user.getId());
    List<Task> assignedTasks = dataManager.loadList(loadContext);
    loadContext.setQueryString("select e from ts$Task e join e.project pr join pr.participants p " +
            "where p.user.id = :userId and e.project.id = :projectId and e.exclusiveParticipants is empty " +
            "and e.status = 'active' order by e.project")
            .setParameter("projectId", project.getId())
            .setParameter("userId", user.getId());
    List<Task> commonTasks = dataManager.loadList(loadContext);
    if (assignedTasks.isEmpty() && commonTasks.isEmpty()) {
        return Collections.emptyMap();
    }
    List<Task> allTasks = new ArrayList<>(assignedTasks.size() + commonTasks.size());
    allTasks.addAll(assignedTasks);
    allTasks.addAll(commonTasks);
    Map<String, Task> tasksMap = new TreeMap<>();
    for (Task task : allTasks) {
        tasksMap.put(task.getName(), task);
    }
    return tasksMap;
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:30,代码来源:ProjectsServiceBean.java


注:本文中的com.haulmont.cuba.core.global.LoadContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。