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

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

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

Query.or介绍

[英]Creates a container to hold 'or' clauses
[中]创建一个容器来保存“or”子句

代码示例

代码示例来源:origin: org.actframework/act-morphia

public CriteriaContainer or(Criteria... criteria) {
  return mq.or(criteria);
}

代码示例来源: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: 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: BlackLabs/play-morphia

public <T extends Model> CriteriaContainer or(Criteria... criteria) {
  return q_.or(criteria);
}

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

query.or(
  query.criteria("name").containsIgnoreCase(filter.getFilter()),
  query.criteria("description").containsIgnoreCase(filter.getFilter())

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

@Override
public Long count(List<String> searchFields, String keywords,
         String where) {
  Query<?> q = ds().createQuery(clazz);
  if (keywords != null && !keywords.equals("")) {
    List<Criteria> cl = new ArrayList<Criteria>();
    String[] sa = keywords.split("[\\W]+");
    for (String f : fillSearchFieldsIfEmpty_(searchFields)) {
      for (String s : sa) {
        cl.add(q.criteria(f).containsIgnoreCase(keywords));
      }
    }
    q.or(cl.toArray(new Criteria[]{}));
  }
  processWhere(q, where);
  return q.countAll();
}

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

private Query<DynamicBuild> filterBranch(final Query<DynamicBuild> query) {
  final String branch = getBranch();
  if ("All".equals(branch)) {
    return query;
  }
  if ("Mine".equals(branch)) {
    query.or(
      query.criteria("actions.causes.user").equal(Jenkins.getAuthentication().getName()),
      query.criteria("actions.causes.pusher").equal(Jenkins.getAuthentication().getName())
    );
    return query;
  }
  return getDynamicBuildRepository().filterExpression(branch, query);
}

代码示例来源:origin: protegeproject/webprotege

private Query<RoleAssignment> withUserOrAnyUserAndTarget(Subject subject, Resource resource) {
  String userName = toUserName(subject);
  String projectId = toProjectId(resource);
  Query<RoleAssignment> query = datastore.createQuery(RoleAssignment.class)
                      .field(PROJECT_ID).equal(projectId);
  if (!subject.isGuest()) {
    query.or(
        query.criteria(USER_NAME).equal(userName),
        query.criteria(USER_NAME).equal(null)
    );
  }
  else {
    query.field(USER_NAME).equal(userName);
  }
  return query;
}

相关文章