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


Java LoadContext.setQuery方法代码示例

本文整理汇总了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);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:13,代码来源:ProjectsServiceBean.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:15,代码来源:ProjectsServiceBean.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:13,代码来源:ProjectsServiceBean.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:13,代码来源:ProjectsServiceBean.java

示例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;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:46,代码来源:QueriesControllerManager.java


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