org.mongodb.morphia.query.Query类的使用及代码示例

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

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

Query介绍

暂无

代码示例

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

@Override
  public List<JobPo> getNeedGenerateJobPos(Long checkTime, int topSize) {
    Query<JobPo> query = template.createQuery(JobPo.class);
    query.field("relyOnPrevCycle").equal(false);
    query.field("lastGenerateTriggerTime").equal(checkTime);
    query.offset(0).limit(topSize);
    return query.asList();
  }
}

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

@Override
public JobPo getJob(String jobId) {
  Query<JobPo> query = template.createQuery(JobPo.class);
  query.field("jobId").equal(jobId);
  return query.get();
}

代码示例来源: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<JobPo> getDeadJobs(long deadline) {
  Query<JobPo> query = template.createQuery(JobPo.class);
  query.filter("gmtModified < ", deadline);
  return query.asList();
}

代码示例来源: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: protegeproject/webprotege

public int getOpenCommentsCount(@Nonnull ProjectId projectId,
                @Nonnull OWLEntity entity) {
  return datastore.createQuery(EntityDiscussionThread.class)
          .disableValidation()
          .field(PROJECT_ID).equal(projectId)
          .field(ENTITY).equal(entity)
          .field(STATUS).equal(Status.OPEN)
          .asList()
          .stream().map(thread -> thread.getComments().size())
          .reduce((left, right) -> left + right)
          .orElse(0);
}

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

@Override
public List<NodeGroupPo> getNodeGroup(NodeType nodeType) {
  Query<NodeGroupPo> query = template.createQuery(NodeGroupPo.class);
  query.field("nodeType").equal(nodeType);
  return query.asList();
}

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

public DynamicProject getProjectForOrg(OrganizationContainer organizationContainer, String name) {
  return getDatastore().createQuery(DynamicProject.class).disableValidation()
    .field("containerName").equal(organizationContainer.getName())
    .field("name").equal(name)
    .get();
}

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

public <T extends DbBackedBuild> Iterable<T> getCurrentUserBuilds(final DbBackedProject project, final int i, final Result result) {
  Query<DbBackedBuild> query = getQuery(project)
    .limit(i)
    .order("-number");
  query.or(
    query.criteria("actions.causes.user").equal(Jenkins.getAuthentication().getName()),
    query.criteria("actions.causes.pusher").equal(Jenkins.getAuthentication().getName())
  );
  if (result != null) {
    query = query.filter("result", result.toString());
  }
  final List<DbBackedBuild> builds = query.asList();
  for (final DbBackedBuild build : builds) {
    associateProject(project, build);
  }
  return (Iterable<T>) builds;
}

代码示例来源:origin: BlackLabs/play-morphia

@Override
public List<play.db.Model> fetch(int offset, int size, String orderBy,
                 String order, List<String> searchFields, String keywords,
                 String where) {
  if (orderBy == null)
    orderBy = keyName();
  if ("DESC".equalsIgnoreCase(order))
    orderBy = null == orderBy ? null : "-" + orderBy;
  Query<? extends Model> q = ds().createQuery(clazz).offset(offset)
      .limit(size);
  if (null != orderBy)
    q = q.order(orderBy);
  if (keywords != null && !keywords.equals("")) {
    List<Criteria> cl = new ArrayList<Criteria>();
    String[] sa = keywords.split("[\\W]+");
    for (String f : fillSearchFieldsIfEmpty_(searchFields)) {
      List<Criteria> cl0 = new ArrayList<Criteria>();
      for (String s : sa) {
        cl0.add(q.criteria(f).containsIgnoreCase(s));
      }
      cl.add(q.and(cl0.toArray(new Criteria[]{})));
    }
    q.or(cl.toArray(new Criteria[]{}));
  }
  processWhere(q, where);
  List<play.db.Model> l = new ArrayList<play.db.Model>();
  l.addAll(q.asList());
  return l;
}

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

@Override
public List<JobPo> getDeadJob(String taskTrackerNodeGroup, long deadline) {
  String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
  Query<JobPo> query = template.createQuery(tableName, JobPo.class);
  query.field("isRunning").equal(true).
      filter("gmtCreated < ", deadline);
  return query.asList();
}

代码示例来源: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

private Query<DynamicBuild> getDynamicBuildsForUser(final String user, final int numberOfBuilds) {
  final Query<DynamicBuild> query = getDatastore().createQuery(DynamicBuild.class)
    .limit(numberOfBuilds)
    .disableValidation()
    .order("-timestamp")
    .field("className").equal("com.groupon.jenkins.dynamic.build.DynamicBuild");
  query.or(
    query.criteria("actions.causes.user").equal(user),
    query.criteria("actions.causes.pusher").equal(user)
  );
  return query;
}

代码示例来源: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: protegeproject/webprotege

public List<EntityDiscussionThread> findThreads(@Nonnull ProjectId projectId,
                        @Nonnull OWLEntity entity) {
  datastore.createQuery(EntityDiscussionThread.class);
  return datastore.find(EntityDiscussionThread.class)
          .disableValidation()
          .field(PROJECT_ID).equal(projectId)
          .field(ENTITY).equal(entity)
          .order("-comments.0.createdAt")
          .asList();
}

代码示例来源:origin: RentTheRunway/alchemy

query.or(
    query.criteria("name").containsIgnoreCase(filter.getFilter()),
    query.criteria("description").containsIgnoreCase(filter.getFilter())
  );
  query.order(orderingString.toString());
  query.offset(filter.getOffset());
  query.limit(filter.getLimit());
return new ExperimentIterable(query.iterator(), factory);

代码示例来源: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

private Query<DbBackedBuild> getQuery(final DbBackedProject project) {
  return getDatastore().createQuery(DbBackedBuild.class).disableValidation().field("projectId").equal(project.getId());
}

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

public <T extends DbBackedBuild> T getBuildBySha(final DbBackedProject<?, ?> project, final String sha, final Result result) {
  Query<DbBackedBuild> query = getQuery(project).
    field("actions.causes.sha").equal(sha);
  if (result != null) {
    query = query.filter("result", result.toString());
  }
  final DbBackedBuild build = query.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();
}

相关文章