org.mongodb.morphia.query.Query.order()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(266)

本文整理了Java中org.mongodb.morphia.query.Query.order方法的一些代码示例,展示了Query.order的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.order方法的具体详情如下:
包路径:org.mongodb.morphia.query.Query
类名称:Query
方法名:order

Query.order介绍

[英]Sorts based on a property (defines return order). Examples:

  • order("age")
  • order("-age") (descending order)
  • order("age, date")
  • order("age,-date") (age ascending, date descending)
    [中]基于属性排序(定义退货顺序)。例如:
    *顺序(“年龄”)
    *顺序(“-age”)(降序)
    *订单(“年龄、日期”)
    *顺序(“年龄,-日期”)(年龄递增,日期递减)

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
  public List<JobFeedbackPo> fetchTop(String jobClientNodeGroup, int top) {
    Query<JobFeedbackPo> query = createQuery(jobClientNodeGroup);
    query.order("gmtCreated").limit(top);
    return query.asList();
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
  public List<JobFeedbackPo> fetchTop(String jobClientNodeGroup, int top) {
    Query<JobFeedbackPo> query = createQuery(jobClientNodeGroup);
    query.order("gmtCreated").limit(top);
    return query.asList();
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

protected List<JobPo> load(String loadTaskTrackerNodeGroup, int loadSize) {
  // load
  String tableName = JobQueueUtils.getExecutableQueueName(loadTaskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(false)
      .filter("triggerTime < ", SystemClock.now())
      .order(" priority, triggerTime , gmtCreated").offset(0).limit(loadSize);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

protected List<JobPo> load(String loadTaskTrackerNodeGroup, int loadSize) {
  // load
  String tableName = JobQueueUtils.getExecutableQueueName(loadTaskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(false)
      .filter("triggerTime < ", SystemClock.now())
      .order(" priority, triggerTime , gmtCreated").offset(0).limit(loadSize);
  return query.asList();
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
  public PaginationRsp<NodeGroupPo> getNodeGroup(NodeGroupGetReq request) {
    Query<NodeGroupPo> query = template.createQuery(NodeGroupPo.class);
    if (request.getNodeType() != null) {
      query.field("nodeType").equal(request.getNodeType());
    }
    if (StringUtils.isNotEmpty(request.getNodeGroup())) {
      query.field("name").equal(request.getNodeGroup());
    }
    PaginationRsp<NodeGroupPo> response = new PaginationRsp<NodeGroupPo>();
    Long results = template.getCount(query);
    response.setResults(results.intValue());
    if (results == 0) {
      return response;
    }
    query.order("-gmtCreated").offset(request.getStart()).limit(request.getLimit());

    response.setRows(query.asList());
    return response;
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
  public PaginationRsp<NodeGroupPo> getNodeGroup(NodeGroupGetReq request) {
    Query<NodeGroupPo> query = template.createQuery(NodeGroupPo.class);
    if (request.getNodeType() != null) {
      query.field("nodeType").equal(request.getNodeType());
    }
    if (StringUtils.isNotEmpty(request.getNodeGroup())) {
      query.field("name").equal(request.getNodeGroup());
    }
    PaginationRsp<NodeGroupPo> response = new PaginationRsp<NodeGroupPo>();
    Long results = template.getCount(query);
    response.setResults(results.intValue());
    if (results == 0) {
      return response;
    }
    query.order("-gmtCreated").offset(request.getStart()).limit(request.getLimit());

    response.setRows(query.asList());
    return response;
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

query.order(("ASC".equalsIgnoreCase(request.getDirection()) ? "" : "-") + request.getField());

代码示例来源:origin: ltsopensource/light-task-scheduler

query.order(("ASC".equalsIgnoreCase(request.getDirection()) ? "" : "-") + request.getField());

代码示例来源:origin: ltsopensource/light-task-scheduler

query.order("-logTime").offset(request.getStart()).limit(request.getLimit());

代码示例来源:origin: ltsopensource/light-task-scheduler

query.order("-logTime").offset(request.getStart()).limit(request.getLimit());

代码示例来源:origin: groupon/DotCi

private Query<DynamicBuild> applyQueryFilters(Query<DynamicBuild> query) {
  query = filterBranch(query);
  query = query.limit(getBuildCount());
  return query.order("number");
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> T getLastBuild(final DbBackedProject project, final String branch) {
  final Query<DbBackedBuild> query = getQuery(project);
  filterExpression(branch, query);
  final DbBackedBuild build = query
    .order("-number").get();
  associateProject(project, build);
  return (T) build;
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> T getLastBuild(final DbBackedProject project) {
  final DbBackedBuild build = getQuery(project).limit(1).order("-number").disableValidation().get();
  associateProject(project, build);
  return (T) build;
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> Iterable<T> getBuilds(final DbBackedProject project, final int offset) {
  final Query<DbBackedBuild> query = getQuery(project).order("-number")
    .offset(offset);
  final List<DbBackedBuild> builds = query.asList();
  for (final DbBackedBuild build : builds) {
    associateProject(project, build);
  }
  return (Iterable<T>) query.asList();
}

代码示例来源:origin: groupon/DotCi

public <B extends DbBackedBuild<P, B>, P extends DbBackedProject<P, B>> B getNextBuild(final DbBackedProject<P, B> project, final int number) {
    final DbBackedBuild build = getQuery(project).
      field("number").greaterThan(number).order("number").
      get();
    if (build != null) {
      associateProject(project, build);
    }
    return (B) build;
  }
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> T getFirstBuild(final DbBackedProject project) {
  final DbBackedBuild build = getQuery(project).disableValidation().
    limit(1).order("number").
    get();
  associateProject(project, build);
  return (T) build;
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> T getLastFailedBuild(final DbBackedProject project) {
  final DbBackedBuild build = getQuery(project).limit(1).order("-number").
    field("result").equal(Result.FAILURE.toString()).
    get();
  associateProject(project, build);
  return (T) build;
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> T getLastSuccessfulBuild(final DbBackedProject project, final String branch) {
  final DbBackedBuild build = getQuery(project).order("-number").
    field("result").equal(Result.SUCCESS.toString()).
    field("actions.causes.branch.branch").equal(branch).
    get();
  associateProject(project, build);
  return (T) build;
}

代码示例来源:origin: groupon/DotCi

public <T extends DbBackedBuild> Iterable<T> getCurrentUserBuildsGreaterThan(final DbBackedProject project, final int number) {
  final List<DbBackedBuild> builds = getQuery(project)
    .order("-number")
    .field("pusher").equal(Jenkins.getAuthentication().getName())
    .field("number").greaterThan(number)
    .asList();
  for (final DbBackedBuild build : builds) {
    associateProject(project, build);
  }
  return (Iterable<T>) builds;
}

代码示例来源:origin: groupon/DotCi

public DbBackedBuild getPreviousFinishedBuildOfSameBranch(final DbBackedBuild build, final String branch) {
  final DbBackedProject project = (DbBackedProject) build.getProject();
  final Query<DbBackedBuild> query = getQuery(project);
  if (branch != null) filterExpression(branch, query);
  final DbBackedBuild previousBuild = query.
    limit(1).
    order("-number").
    field("state").equal("COMPLETED").field("number").lessThan(build.getNumber()).
    get();
  associateProject(project, previousBuild);
  return previousBuild;
}

相关文章