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


Java Query.order方法代码示例

本文整理汇总了Java中org.mongodb.morphia.query.Query.order方法的典型用法代码示例。如果您正苦于以下问题:Java Query.order方法的具体用法?Java Query.order怎么用?Java Query.order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mongodb.morphia.query.Query的用法示例。


在下文中一共展示了Query.order方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJoinableServer

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public Server getJoinableServer(Filter filter, String uuid) {
    Query<Server> query = getFilterQuery(filter);
    query.and(getServerQuery().criteria("joinable").equal(true),
            getServerQuery().criteria("expiry").greaterThan(System.currentTimeMillis()),
            getServerQuery()
                    .or(new WhereCriteria("this.mpc > this.pc"),
                            getServerQuery().criteria("mpc").equal(0)));
    query.limit(1);
    query.order("pc");
    query.getSortObject().put("pc", -1);

    UpdateOperations<Server> updateOperations = datastore.createUpdateOperations(Server.class);
    updateOperations.inc("pc", 1);
    updateOperations.add("players", uuid);
    Server server = datastore.findAndModify(query, updateOperations, false, false);
    if (server == null)
        return null;
    return server;
}
 
开发者ID:Exorath,项目名称:ConnectorService,代码行数:21,代码来源:MongoDatabaseProvider.java

示例2: filter

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 *
 * @param queryCriteria - key is field and operator and value is RHS value
 * eg: "Location in" => "Delhi"
 * @param sortCriteria - comma separated field names. use - for descending
 * order eg: "location, -status"
 * @param pageInfo - contain limit and offset
 * @return
 */
public List<T> filter(Map<String, Object> queryCriteria, String sortCriteria, PageInfo pageInfo) {
    Query<T> query = datastore.createQuery(genericType);

    for (Map.Entry<String, Object> entry : queryCriteria.entrySet()) {
        query = query.filter(entry.getKey(), entry.getValue());
    }

    if (pageInfo == null) {
        pageInfo = new PageInfo(100000, 0);
    }

    if (sortCriteria == null) {
        sortCriteria = "_id";
    }

    query = query.limit(pageInfo.getLimit()).offset(pageInfo.getOffset());
    query = query.order(sortCriteria);

    return query.asList();
}
 
开发者ID:nimesh-mittal,项目名称:elastic-match,代码行数:30,代码来源:EntityDAO.java

示例3: pageSelect

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public PaginationRsp<JobPo> pageSelect(JobQueueReq request) {
    Query<JobPo> query = template.createQuery(getTargetTable(request.getTaskTrackerNodeGroup()), JobPo.class);
    addCondition(query, "jobId", request.getJobId());
    addCondition(query, "taskId", request.getTaskId());
    addCondition(query, "taskTrackerNodeGroup", request.getTaskTrackerNodeGroup());
    addCondition(query, "submitNodeGroup", request.getSubmitNodeGroup());
    addCondition(query, "needFeedback", request.getNeedFeedback());
    if (request.getStartGmtCreated() != null) {
        query.filter("gmtCreated >= ", request.getStartGmtCreated().getTime());
    }
    if (request.getEndGmtCreated() != null) {
        query.filter("gmtCreated <= ", request.getEndGmtCreated().getTime());
    }
    if (request.getStartGmtModified() != null) {
        query.filter("gmtModified <= ", request.getStartGmtModified().getTime());
    }
    if (request.getEndGmtModified() != null) {
        query.filter("gmtModified >= ", request.getEndGmtModified().getTime());
    }
    PaginationRsp<JobPo> response = new PaginationRsp<JobPo>();
    Long results = template.getCount(query);
    response.setResults(results.intValue());
    if (results == 0) {
        return response;
    }

    if (StringUtils.isNotEmpty(request.getField()) && StringUtils.isNotEmpty(request.getDirection())) {
        query.order(("ASC".equalsIgnoreCase(request.getDirection()) ? "" : "-") + request.getField());
    }
    query.offset(request.getStart()).limit(request.getLimit());
    response.setRows(query.asList());
    return response;
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:35,代码来源:AbstractMongoJobQueue.java

示例4: getMany

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 * @param ids
 * @param sortCriteria - comma separated field names. use - for descending
 * order eg: "location, -status"
 * @param pageInfo - contain limit and offset
 * @return
 */
public List<T> getMany(List<String> ids, String sortCriteria, PageInfo pageInfo) {
    Query<T> query = datastore.createQuery(genericType);
    query = query.field("_id").in(ids);
    query = query.limit(pageInfo.getLimit()).offset(pageInfo.getOffset());
    query = query.order(sortCriteria);

    return query.asList();
}
 
开发者ID:nimesh-mittal,项目名称:elastic-match,代码行数:16,代码来源:EntityDAO.java

示例5: applyQueryFilters

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private Query<DynamicBuild> applyQueryFilters(Query<DynamicBuild> query) {
    query = filterBranch(query);
    query = query.limit(getBuildCount());
    return query.order("number");
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:6,代码来源:JobMetric.java

示例6: fetch

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
protected Iterable<MongoActivity> fetch(Query<MongoActivity> q) {
    return super.fetch(q.order(reverse(MongoActivity.TIME)));
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:5,代码来源:MongoActivityDao.java

示例7: fetch

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
protected Iterable<MongoTrack> fetch(Query<MongoTrack> q) {
    return super.fetch(q.order(MongoTrack.RECENTLY_CREATED_ORDER));
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:5,代码来源:MongoTrackDao.java


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