org.molgenis.data.Query.findAll()方法的使用及代码示例

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

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

Query.findAll介绍

暂无

代码示例

代码示例来源:origin: org.molgenis/molgenis-data-postgresql

public void populate() {
  dataService
    .query(ENTITY_TYPE_META_DATA, EntityType.class)
    .eq(BACKEND, POSTGRESQL)
    .findAll()
    .forEach(entityTypeRegistry::registerEntityType);
 }
}

代码示例来源:origin: org.molgenis/molgenis-apps

@Override
public void deleteAll()
{
  query().findAll().forEach(this::deleteApp);
  super.deleteAll();
}

代码示例来源:origin: org.molgenis/molgenis-navigator

@Transactional(readOnly = true)
@Override
public List<Resource> getResources(@Nullable String folderId) {
 try (Stream<Resource> packageResources =
   dataService
     .query(PackageMetadata.PACKAGE, Package.class)
     .eq(PackageMetadata.PARENT, folderId)
     .findAll()
     .map(this::toResource)) {
  Stream<Resource> entityTypeResources =
    dataService
      .query(ENTITY_TYPE_META_DATA, EntityType.class)
      .eq(EntityTypeMetadata.PACKAGE, folderId)
      .findAll()
      .map(this::toResource);
  return Streams.concat(packageResources, entityTypeResources).collect(toList());
 }
}

代码示例来源:origin: org.molgenis/molgenis-security

@RunAsSystem
 public Collection<? extends GrantedAuthority> getAuthorities(User user) {
  Set<GrantedAuthority> authorities = new LinkedHashSet<>();

  if (user.isSuperuser() != null && user.isSuperuser()) {
   authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_SU));
  }
  if (user.getUsername().equals(SecurityUtils.ANONYMOUS_USERNAME)) {
   authorities.add(new SimpleGrantedAuthority(SecurityUtils.AUTHORITY_ANONYMOUS));
  } else {
   authorities.add(new SimpleGrantedAuthority(AUTHORITY_USER));
  }

  dataService
    .query(ROLE_MEMBERSHIP, RoleMembership.class)
    .eq(USER, user)
    .findAll()
    .filter(RoleMembership::isCurrent)
    .map(RoleMembership::getRole)
    .map(Role::getName)
    .map(SidUtils::createRoleAuthority)
    .map(SimpleGrantedAuthority::new)
    .forEach(authorities::add);

  return grantedAuthoritiesMapper.mapAuthorities(authorities);
 }
}

代码示例来源:origin: org.molgenis/molgenis-data-postgresql

@Override
public Iterable<String> getEntityTypeIds() {
 return dataService
     .query(ENTITY_TYPE_META_DATA, EntityType.class)
     .eq(BACKEND, POSTGRESQL)
     .fetch(getEntityTypeFetch())
     .findAll()
     .map(EntityType::getId)
   ::iterator;
}

代码示例来源:origin: org.molgenis/molgenis-apps

private Stream<App> getApps()
{
  Query<App> query = dataService.query(APP, App.class);
  query.sort().on(AppMetaData.NAME);
  Stream<App> apps = query.findAll();
  if (!permissionService.hasPermissionOnEntityType(APP, Permission.WRITE))
  {
    apps = apps.filter(App::isActive);
  }
  return apps;
}

代码示例来源:origin: org.molgenis/molgenis-navigator

/**
 * Checks if there's a Package in the target location with the same label. If so, keeps adding a
 * postfix until the label is unique.
 */
private void assignUniqueLabel(Package pack, Package targetPackage) {
 Set<String> existingLabels;
 if (targetPackage != null) {
  existingLabels = stream(targetPackage.getChildren()).map(Package::getLabel).collect(toSet());
 } else {
  existingLabels =
    dataService
      .query(PACKAGE, Package.class)
      .eq(PackageMetadata.PARENT, null)
      .findAll()
      .map(Package::getLabel)
      .collect(toSet());
 }
 pack.setLabel(generateUniqueLabel(pack.getLabel(), existingLabels));
}

代码示例来源:origin: org.molgenis/molgenis-data-postgresql

@Override
public Iterator<Repository<Entity>> iterator() {
 return dataService
   .query(ENTITY_TYPE_META_DATA, EntityType.class)
   .eq(BACKEND, POSTGRESQL)
   .and()
   .eq(IS_ABSTRACT, false)
   .fetch(getEntityTypeFetch())
   .findAll()
   .map(this::getRepository)
   .iterator();
}

代码示例来源:origin: org.molgenis/molgenis-navigator

@Transactional(readOnly = true)
@Override
public List<Resource> findResources(String query) {
 Stream<Resource> packageResources =
   dataService
     .query(PackageMetadata.PACKAGE, Package.class)
     .search(PackageMetadata.LABEL, query)
     .or()
     .search(PackageMetadata.DESCRIPTION, query)
     .findAll()
     .map(this::toResource);
 Stream<Resource> entityTypeResources =
   dataService
     .query(ENTITY_TYPE_META_DATA, EntityType.class)
     .search(EntityTypeMetadata.LABEL, query)
     .or()
     .search(EntityTypeMetadata.DESCRIPTION, query)
     .findAll()
     .map(this::toResource);
 return Streams.concat(packageResources, entityTypeResources).collect(toList());
}

代码示例来源:origin: org.molgenis/molgenis-jobs

private void bootstrap(SystemEntityType systemEntityType) {
 dataService
   .query(systemEntityType.getId())
   .eq(STATUS, RUNNING)
   .or()
   .eq(STATUS, PENDING)
   .findAll()
   .forEach(this::setFailed);
}

代码示例来源:origin: org.molgenis/molgenis-ontology-core

/**
 * Retrieve all descendant ontology terms
 *
 * @return a list of {@link OntologyTerm}
 */
public List<OntologyTerm> getChildren(OntologyTerm ontologyTerm) {
 Iterable<org.molgenis.ontology.core.meta.OntologyTerm> ontologyTermEntities =
   () ->
     dataService
       .query(ONTOLOGY_TERM, org.molgenis.ontology.core.meta.OntologyTerm.class)
       .eq(ONTOLOGY_TERM_IRI, ontologyTerm.getIRI())
       .findAll()
       .iterator();
 List<OntologyTerm> children = new ArrayList<>();
 for (Entity ontologyTermEntity : ontologyTermEntities) {
  Entity ontologyEntity = ontologyTermEntity.getEntity(OntologyTermMetaData.ONTOLOGY);
  ontologyTermEntity
    .getEntities(OntologyTermMetaData.ONTOLOGY_TERM_NODE_PATH)
    .forEach(
      ontologyTermNodePathEntity ->
        children.addAll(
          getChildOntologyTermsByNodePath(ontologyEntity, ontologyTermNodePathEntity)));
 }
 return children;
}

代码示例来源:origin: org.molgenis/molgenis-security

private void deleteOldRecoveryCodes(String userId) {
 runAsSystem(
   () -> {
    Stream<RecoveryCode> recoveryCodes =
      dataService.query(RECOVERY_CODE, RecoveryCode.class).eq(USER_ID, userId).findAll();
    dataService.delete(RECOVERY_CODE, recoveryCodes);
   });
}

代码示例来源:origin: org.molgenis/molgenis-navigator

/**
 * Checks if there's an EntityType in the target location with the same label. If so, keeps adding
 * a postfix until the label is unique.
 */
private EntityType assignUniqueLabel(EntityType entityType, CopyState state) {
 Set<String> existingLabels;
 if (state.targetPackage() != null) {
  //noinspection ConstantConditions
  existingLabels =
    stream(state.targetPackage().getEntityTypes()).map(EntityType::getLabel).collect(toSet());
 } else {
  existingLabels =
    dataService
      .query(ENTITY_TYPE_META_DATA, EntityType.class)
      .eq(EntityTypeMetadata.PACKAGE, null)
      .findAll()
      .map(EntityType::getLabel)
      .collect(toSet());
 }
 entityType.setLabel(LabelGenerator.generateUniqueLabel(entityType.getLabel(), existingLabels));
 return entityType;
}

代码示例来源:origin: org.molgenis/molgenis-security

@Override
public Stream<RecoveryCode> getRecoveryCodes() {
 String userId = getUser().getId();
 return runAsSystem(
   () -> dataService.query(RECOVERY_CODE, RecoveryCode.class).eq(USER_ID, userId).findAll());
}

代码示例来源:origin: org.molgenis/molgenis-data-validation

private Multimap<String, Attribute> getDefaultValueMap(EntityType entityType) {
 Multimap<String, Attribute> defaultValueMultiMap = LinkedHashMultimap.create();
 dataService
   .query(ATTRIBUTE_META_DATA, Attribute.class)
   .eq(REF_ENTITY_TYPE, entityType.getIdValue())
   .and()
   .not()
   .eq(DEFAULT_VALUE, null)
   .findAll()
   .forEach(
     attribute -> {
      if (EntityTypeUtils.isSingleReferenceType(attribute)) {
       Entity defaultEntityValue = (Entity) getDefaultTypedValue(attribute);
       defaultValueMultiMap.put(defaultEntityValue.getIdValue().toString(), attribute);
      } else if (EntityTypeUtils.isMultipleReferenceType(attribute)) {
       @SuppressWarnings("unchecked")
       Iterable<Entity> defaultEntitiesValue =
         (Iterable<Entity>) getDefaultTypedValue(attribute);
       defaultEntitiesValue.forEach(
         defaultEntityValue ->
           defaultValueMultiMap.put(
             defaultEntityValue.getIdValue().toString(), attribute));
      }
     });
 return defaultValueMultiMap;
}

代码示例来源:origin: org.molgenis/molgenis-questionnaires

@Override
public Stream<EntityType> getQuestionnaires() {
 return dataService
   .query(ENTITY_TYPE_META_DATA, EntityType.class)
   .eq(EntityTypeMetadata.EXTENDS, QUESTIONNAIRE)
   .findAll()
   .filter(
     entityType ->
       userPermissionEvaluator.hasPermission(
         new EntityTypeIdentity(entityType.getId()), EntityTypePermission.ADD_DATA))
   .filter(
     entityType ->
       userPermissionEvaluator.hasPermission(
         new EntityTypeIdentity(entityType.getId()), EntityTypePermission.UPDATE_DATA));
}

代码示例来源:origin: org.molgenis/molgenis-ontology

private List<SortaJobExecution> getJobsForCurrentUser() {
 final List<SortaJobExecution> jobs = new ArrayList<>();
 User currentUser = userAccountService.getCurrentUser();
 Query<SortaJobExecution> query =
   dataService
     .query(SORTA_JOB_EXECUTION, SortaJobExecution.class)
     .eq(JobExecutionMetaData.USER, currentUser.getUsername());
 query.sort().on(JobExecutionMetaData.START_DATE, DESC);
 RunAsSystemAspect.runAsSystem(
   () ->
     query
       .findAll()
       .forEach(
         job -> {
          // TODO: fetch the user as well
          job.set(JobExecutionMetaData.USER, currentUser.getUsername());
          jobs.add(job);
         }));
 return jobs;
}

代码示例来源:origin: org.molgenis/molgenis-data-index

/**
  * Cleans up successful IndexJobExecutions that finished longer than five minutes ago. delay for a
  * minute to allow the transaction manager to become available
  */
 @Scheduled(initialDelay = 1 * 60 * 1000, fixedRate = 5 * 60 * 1000)
 public void cleanupJobExecutions() {
  runAsSystem(
    () -> {
     LOG.trace("Clean up Index job executions...");
     Instant fiveMinutesAgo = Instant.now().minus(5, ChronoUnit.MINUTES);
     boolean indexJobExecutionExists =
       dataService.hasRepository(IndexJobExecutionMeta.INDEX_JOB_EXECUTION);
     if (indexJobExecutionExists) {
      Stream<Entity> executions =
        dataService
          .getRepository(IndexJobExecutionMeta.INDEX_JOB_EXECUTION)
          .query()
          .lt(END_DATE, fiveMinutesAgo)
          .and()
          .eq(STATUS, SUCCESS.toString())
          .findAll();
      dataService.delete(IndexJobExecutionMeta.INDEX_JOB_EXECUTION, executions);
      LOG.debug("Cleaned up Index job executions.");
     } else {
      LOG.warn("{} does not exist", IndexJobExecutionMeta.INDEX_JOB_EXECUTION);
     }
    });
 }
}

代码示例来源:origin: org.molgenis/molgenis-security

@Override
public void resetSecretForUser() {
 User user = getUser();
 Stream<UserSecret> userSecrets =
   runAsSystem(
     () ->
       dataService
         .query(USER_SECRET, UserSecret.class)
         .eq(USER_ID, user.getId())
         .findAll());
 //noinspection RedundantCast
 runAsSystem((Runnable) () -> dataService.delete(USER_SECRET, userSecrets));
}

相关文章