本文整理汇总了Java中com.haulmont.cuba.core.global.LoadContext.setQuery方法的典型用法代码示例。如果您正苦于以下问题:Java LoadContext.setQuery方法的具体用法?Java LoadContext.setQuery怎么用?Java LoadContext.setQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.core.global.LoadContext
的用法示例。
在下文中一共展示了LoadContext.setQuery方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: createQueryLoadContext
import com.haulmont.cuba.core.global.LoadContext; //导入方法依赖的package包/类
protected LoadContext<Entity> createQueryLoadContext(String entityName,
String queryName,
@Nullable Integer limit,
@Nullable Integer offset,
Map<String, String> params) throws ClassNotFoundException, ParseException {
MetaClass metaClass = restControllerUtils.getMetaClass(entityName);
checkCanReadEntity(metaClass);
RestQueriesConfiguration.QueryInfo queryInfo = restQueriesConfiguration.getQuery(entityName, queryName);
if (queryInfo == null) {
throw new RestAPIException("Query not found",
String.format("Query with name %s for entity %s not found", queryName, entityName),
HttpStatus.NOT_FOUND);
}
LoadContext<Entity> ctx = new LoadContext<>(metaClass);
LoadContext.Query query = new LoadContext.Query(queryInfo.getJpql());
if (limit != null) {
query.setMaxResults(limit);
} else {
query.setMaxResults(persistenceManagerClient.getMaxFetchUI(entityName));
}
if (offset != null) {
query.setFirstResult(offset);
}
for (RestQueriesConfiguration.QueryParamInfo paramInfo : queryInfo.getParams()) {
String paramName = paramInfo.getName();
String requestParamValue = params.get(paramName);
if (requestParamValue == null) {
throw new RestAPIException("Query parameter not found",
String.format("Query parameter %s not found", paramName),
HttpStatus.BAD_REQUEST);
}
Class<?> clazz = ClassUtils.forName(paramInfo.getType(), getClass().getClassLoader());
Object objectParamValue = toObject(clazz, requestParamValue);
query.setParameter(paramName, objectParamValue);
}
ctx.setQuery(query);
ctx.setView(queryInfo.getViewName());
return ctx;
}