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

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

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

Query.disableValidation介绍

[英]Turns off validation (for all calls made after)
[中]关闭验证(对于之后进行的所有调用)

代码示例

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

public MorphiaQuery disableValidation() {
  mq.disableValidation();
  return this;
}

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

public <T extends Model> MorphiaQuery disableValidation() {
  q_.disableValidation();
  return this;
}

代码示例来源:origin: acmeair/acmeair

@Override
public List<Booking> getBookingsByUser(String user) {
  try{
    Query<BookingImpl> q = datastore.find(BookingImpl.class).disableValidation().field("customerId").equal(user);
    List<BookingImpl> bookingImpls = q.asList();
    List<Booking> bookings = new ArrayList<Booking>();
    for(Booking b: bookingImpls){
      bookings.add(b);
    }
    return bookings;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源: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: org.actframework/act-morphia

public MorphiaQuery(MorphiaDaoBase<?, MODEL_TYPE> dao) {
  this.ds = dao.ds();
  this.modelType = dao.modelType();
  this.dao = dao;
  this.mq = ds.createQuery(modelType);
  if (dao.isAdaptive() || modelType.isAnnotationPresent(NoQueryValidation.class)) {
    this.mq = this.mq.disableValidation();
  }
}

代码示例来源:origin: org.mongodb.morphia/morphia

@Override
public <T, V> Query<T> get(final Class<T> clazz, final Iterable<V> ids) {
  return find(clazz).disableValidation().filter(Mapper.ID_KEY + " in", ids).enableValidation();
}

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

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

代码示例来源: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: 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 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 Iterable<DynamicProject> getProjectsForOrg(final OrganizationContainer organizationContainer) {
  return getDatastore().createQuery(DynamicProject.class).disableValidation()
    .field("containerName").equal(organizationContainer.getName())
    .asList();
}

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

protected Query<DynamicBuild> getQuery() {
  return getDynamicBuildRepository().getDatastore().createQuery(DynamicBuild.class).disableValidation().field("projectId").equal(this.project.getId());
}

代码示例来源:origin: org.mongodb.morphia/morphia

@Override
@SuppressWarnings("unchecked")
public <T> UpdateResults update(final Key<T> key, final UpdateOperations<T> operations) {
  Class<T> clazz = (Class<T>) key.getType();
  if (clazz == null) {
    clazz = (Class<T>) mapper.getClassFromCollection(key.getCollection());
  }
  return updateFirst(createQuery(clazz).disableValidation().filter(Mapper.ID_KEY, key.getId()), operations);
}

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

public Iterable<DynamicSubProject> getChildren(final DynamicProject parent) {
  final List<DynamicSubProject> children = getDatastore().createQuery(DynamicSubProject.class).
    disableValidation().
    field("parentId").exists().
    field("parentId").equal(parent.getId()).
    asList();
  for (final DynamicSubProject subProject : children) {
    try {
      subProject.onLoad(parent, subProject.getName());
    } catch (final IOException e) {
      throw new RuntimeException(e);
    }
  }
  return children;
}

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

public void updateInt(String taskId, String var, int value) {
  Query<LGTask> query = createQuery().field("_id").equal(taskId);
  UpdateOperations<LGTask> ops = getDatastore().createUpdateOperations(LGTask.class).set(var, value);
  getDatastore().update(query.disableValidation(), ops);
}

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

public DynamicSubProject getChild(final IdentifableItemGroup<DynamicSubProject> parent, final String name) {
  final DynamicSubProject subProject = getDatastore().createQuery(DynamicSubProject.class).
    disableValidation().
    field("name").equal(name).
    field("parentId").exists().
    field("parentId").equal(parent.getId()).
    get();
  if (subProject != null) {
    try {
      subProject.onLoad(parent, name);
    } catch (final IOException e) {
      throw new RuntimeException(e);
    }
  }
  return subProject;
}

代码示例来源:origin: org.mongodb.morphia/morphia

@Override
@SuppressWarnings("unchecked")
public <T> UpdateResults update(final T entity, final UpdateOperations<T> operations) {
  if (entity instanceof Query) {
    return update((Query<T>) entity, operations);
  }
  final MappedClass mc = mapper.getMappedClass(entity);
  Query<?> query = createQuery(mapper.getMappedClass(entity).getClazz())
    .disableValidation()
    .filter(Mapper.ID_KEY, mapper.getId(entity));
  if (!mc.getFieldsAnnotatedWith(Version.class).isEmpty()) {
    final MappedField field = mc.getFieldsAnnotatedWith(Version.class).get(0);
    query.field(field.getNameToStore()).equal(field.getFieldValue(entity));
  }
  return update((Query<T>) query, operations);
}

代码示例来源: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 void delete(final DynamicProject project) {
  // TODO do this in a query not iteratively in memory
  for (final DynamicSubProject subProject : getChildren(project)) {
    this.dynamicBuildRepository.delete(subProject);
    getDatastore().delete(subProject);
  }
  this.dynamicBuildRepository.delete(project);
  getDatastore().delete(project);
  final BuildNumberCounter seq = getDatastore().createQuery(BuildNumberCounter.class).disableValidation().field("key").equal(project.getFullName()).get();
  if (seq != null) {
    getDatastore().delete(seq);
  }
}

相关文章