本文整理汇总了Java中com.haulmont.cuba.core.global.LoadContext.setView方法的典型用法代码示例。如果您正苦于以下问题:Java LoadContext.setView方法的具体用法?Java LoadContext.setView怎么用?Java LoadContext.setView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.core.global.LoadContext
的用法示例。
在下文中一共展示了LoadContext.setView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
示例7: getActiveProjectsForUser
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
public List<Project> getActiveProjectsForUser(User user, @Nullable String viewName) {
LoadContext<Project> loadContext = new LoadContext<>(Project.class);
if (viewName != null) {
loadContext.setView(viewName);
}
LoadContext.Query query =
new LoadContext.Query("select pr from ts$Project pr, in(pr.participants) p " +
"where p.user.id = :userId and pr.status = 'open' order by pr.name")
.setParameter("userId", user.getId());
loadContext.setQuery(query);
return dataManager.loadList(loadContext);
}
示例8: getActiveManagedProjectsForUser
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
public List<Project> getActiveManagedProjectsForUser(User user, @Nullable String viewName) {
LoadContext<Project> loadContext = new LoadContext<>(Project.class);
if (viewName != null) {
loadContext.setView(viewName);
}
LoadContext.Query query =
new LoadContext.Query("select pr from ts$Project pr, in(pr.participants) p " +
"where p.user.id = :userId " +
"and (p.role.code = '" + MANAGER.getId() + "' or p.role.code = '" + APPROVER.getId() + "') " +
"and pr.status = 'open'")
.setParameter("userId", user.getId());
loadContext.setQuery(query);
return dataManager.loadList(loadContext);
}
示例9: getTagsForTheProject
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
public List<Tag> getTagsForTheProject(@Nullable Project project, @Nullable String viewName) {
LoadContext<Tag> loadContext = new LoadContext<>(Tag.class);
if (viewName != null) {
loadContext.setView(viewName);
}
LoadContext.Query query =
new LoadContext.Query("select e from ts$Tag e left join e.tagType.projects pr where pr.id is null" +
" or (pr.id = :project)")
.setParameter("project", project);
loadContext.setQuery(query);
return dataManager.loadList(loadContext);
}
示例10: getTagsWithTheTagType
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
@Override
public List<Tag> getTagsWithTheTagType(TagType type, @Nullable String viewName) {
LoadContext<Tag> loadContext = new LoadContext<>(Tag.class);
if (viewName != null) {
loadContext.setView(viewName);
}
LoadContext.Query query =
new LoadContext.Query("select e from ts$Tag e where e.tagType.id = :type")
.setParameter("type", type);
loadContext.setQuery(query);
return dataManager.loadList(loadContext);
}
示例11: getProjectParticipants
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
@Override
public List<ProjectParticipant> getProjectParticipants(Project project, @Nullable String viewName) {
LoadContext<ProjectParticipant> loadContext = new LoadContext<>(ProjectParticipant.class);
if (viewName != null) {
loadContext.setView(viewName);
}
loadContext.setQueryString("select e from ts$ProjectParticipant e where e.project.id = :projectId")
.setParameter("projectId", project.getId());
return dataManager.loadList(loadContext);
}
示例12: getProjectUsers
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
@Override
public List<User> getProjectUsers(Project project, @Nullable String viewName) {
LoadContext<User> loadContext = new LoadContext<>(User.class);
if (viewName != null) {
loadContext.setView(viewName);
}
loadContext.setQueryString("select u from sec$User u, ts$ProjectParticipant pp " +
"where pp.project.id = :projectId and pp.user.id = u.id")
.setParameter("projectId", project.getId());
return dataManager.loadList(loadContext);
}
示例13: getManagedUsers
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
@Override
public List<User> getManagedUsers(User manager, String viewName) {
LoadContext<User> loadContext = new LoadContext<>(User.class);
if (viewName != null) {
loadContext.setView(viewName);
}
loadContext.setQueryString("select distinct u from sec$User u, ts$ProjectParticipant pp " +
"join pp.project pr join pr.participants me " +
"where pp.user.id = u.id and me.user.id = :managerId " +
"and (me.role.code = '" + MANAGER.getId() + "' or me.role.code = '" + APPROVER.getId() + "')")
.setParameter("managerId", manager.getId());
return dataManager.loadList(loadContext);
}
示例14: getActivityTypesForProject
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
@Override
public List<ActivityType> getActivityTypesForProject(Project project, @Nullable String viewName) {
LoadContext<ActivityType> loadContext = new LoadContext<>(ActivityType.class);
if (viewName != null) {
loadContext.setView(viewName);
}
loadContext.setQueryString("select e from ts$ActivityType e left join e.projects pr " +
"where pr.id is null or (pr.id = :projectId)")
.setParameter("projectId", project.getId());
return dataManager.loadList(loadContext);
}
示例15: getInstances
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<JmxInstance> getInstances() {
LoadContext loadContext = new LoadContext(JmxInstance.class);
loadContext.setView("_local");
loadContext.setQueryString("select jmx from sys$JmxInstance jmx");
List<JmxInstance> jmxInstances = new ArrayList<>();
jmxInstances.add(getLocalInstance());
List<JmxInstance> clusterInstances = dataService.loadList(loadContext);
jmxInstances.addAll(clusterInstances);
return jmxInstances;
}