@Test void testFindAttributesUnknownEntityType() { String entityTypeId = "UnknownEntityType"; assertThrows( UnknownEntityTypeException.class, () -> metadataApiService.findAttributes( entityTypeId, mock(Query.class), mock(Sort.class), 1, 1)); }
@Override public Attributes findAttributes( String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number) { if (!metadataService.hasEntityType(entityTypeId)) { throw new UnknownEntityTypeException(entityTypeId); } Repository<Attribute> repository = getAttributeRepository(); org.molgenis.data.Query<Attribute> repositoryQuery = toAttributeRepositoryQuery(entityTypeId, query, repository); org.molgenis.data.Query<Attribute> findQuery = new QueryImpl<>(repositoryQuery); findQuery.offset(number * size); findQuery.pageSize(size); findQuery.sort(sortMapper.map(sort, repository.getEntityType())); List<Attribute> attributes = repository.findAll(findQuery).collect(toList()); org.molgenis.data.Query<Attribute> countQuery = new QueryImpl<>(repositoryQuery); countQuery.offset(0); countQuery.pageSize(Integer.MAX_VALUE); int count = Math.toIntExact(repository.count(countQuery)); return Attributes.builder().setAttributes(attributes).setTotal(count).build(); }
MetadataApiServiceImpl implements MetadataApiService { @Override public Attributes findAttributes( String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number) { if (!metadataService.hasEntityType(entityTypeId)) { throw new UnknownEntityTypeException(entityTypeId); } Repository<Attribute> repository = getAttributeRepository(); org.molgenis.data.Query<Attribute> repositoryQuery = toAttributeRepositoryQuery(entityTypeId, query, repository); org.molgenis.data.Query<Attribute> findQuery = new QueryImpl<>(repositoryQuery); findQuery.offset(number * size); findQuery.pageSize(size); findQuery.sort(sortMapper.map(sort, repository.getEntityType())); List<Attribute> attributes = repository.findAll(findQuery).collect(toList()); org.molgenis.data.Query<Attribute> countQuery = new QueryImpl<>(repositoryQuery); countQuery.offset(0); countQuery.pageSize(Integer.MAX_VALUE); int count = Math.toIntExact(repository.count(countQuery)); return Attributes.builder().setAttributes(attributes).setTotal(count).build(); } }
MetadataApiServiceImpl implements MetadataApiService { @Override public Attributes findAttributes( String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number) { if (!metadataService.hasEntityType(entityTypeId)) { throw new UnknownEntityTypeException(entityTypeId); } Repository<Attribute> repository = getAttributeRepository(); org.molgenis.data.Query<Attribute> repositoryQuery = toAttributeRepositoryQuery(entityTypeId, query, repository); org.molgenis.data.Query<Attribute> findQuery = new QueryImpl<>(repositoryQuery); findQuery.offset(number * size); findQuery.pageSize(size); findQuery.sort(sortMapper.map(sort, repository.getEntityType())); List<Attribute> attributes = repository.findAll(findQuery).collect(toList()); org.molgenis.data.Query<Attribute> countQuery = new QueryImpl<>(repositoryQuery); countQuery.offset(0); countQuery.pageSize(Integer.MAX_VALUE); int count = Math.toIntExact(repository.count(countQuery)); return Attributes.builder().setAttributes(attributes).setTotal(count).build(); } MetadataApiServiceImpl(
      MetaDataService metadataService,
      QueryMapper queryMapperV3,
      SortMapper sortMapper,
      MetadataApiJobService metadataApiJobService); }
MetadataApiServiceImpl implements MetadataApiService { @Override public Attributes findAttributes( String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number) { if (!metadataService.hasEntityType(entityTypeId)) { throw new UnknownEntityTypeException(entityTypeId); } Repository<Attribute> repository = getAttributeRepository(); org.molgenis.data.Query<Attribute> repositoryQuery = toAttributeRepositoryQuery(entityTypeId, query, repository); org.molgenis.data.Query<Attribute> findQuery = new QueryImpl<>(repositoryQuery); findQuery.offset(number * size); findQuery.pageSize(size); findQuery.sort(sortMapper.map(sort, repository.getEntityType())); List<Attribute> attributes = repository.findAll(findQuery).collect(toList()); org.molgenis.data.Query<Attribute> countQuery = new QueryImpl<>(repositoryQuery); countQuery.offset(0); countQuery.pageSize(Integer.MAX_VALUE); int count = Math.toIntExact(repository.count(countQuery)); return Attributes.builder().setAttributes(attributes).setTotal(count).build(); } MetadataApiServiceImpl(
      MetaDataService metadataService,
      QueryMapper queryMapperV3,
      SortMapper sortMapper,
      MetadataApiJobService metadataApiJobService); EntityTypes findEntityTypes(
      @Nullable @CheckForNull Query query, Sort sort, int size, int number); @Override EntityType findEntityType(String identifier); @Override Attributes findAttributes(
      String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number); @Override Attribute findAttribute(String entityTypeId, String attributeId); @Override MetadataUpsertJobExecution deleteAttributeAsync(String entityTypeId, String attributeId); @Override MetadataUpsertJobExecution deleteAttributesAsync(String entityTypeId, Query query); @Override void createEntityType(EntityType entityType); @Override MetadataUpsertJobExecution updateEntityTypeAsync(EntityType entityType); @Override MetadataDeleteJobExecution deleteEntityTypeAsync(String entityTypeId); @Override MetadataDeleteJobExecution deleteEntityTypesAsync(Query query); }
MetadataApiServiceImpl implements MetadataApiService { @Override public Attributes findAttributes( String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number) { if (!metadataService.hasEntityType(entityTypeId)) { throw new UnknownEntityTypeException(entityTypeId); } Repository<Attribute> repository = getAttributeRepository(); org.molgenis.data.Query<Attribute> repositoryQuery = toAttributeRepositoryQuery(entityTypeId, query, repository); org.molgenis.data.Query<Attribute> findQuery = new QueryImpl<>(repositoryQuery); findQuery.offset(number * size); findQuery.pageSize(size); findQuery.sort(sortMapper.map(sort, repository.getEntityType())); List<Attribute> attributes = repository.findAll(findQuery).collect(toList()); org.molgenis.data.Query<Attribute> countQuery = new QueryImpl<>(repositoryQuery); countQuery.offset(0); countQuery.pageSize(Integer.MAX_VALUE); int count = Math.toIntExact(repository.count(countQuery)); return Attributes.builder().setAttributes(attributes).setTotal(count).build(); } MetadataApiServiceImpl(
      MetaDataService metadataService,
      QueryMapper queryMapperV3,
      SortMapper sortMapper,
      MetadataApiJobService metadataApiJobService); EntityTypes findEntityTypes(
      @Nullable @CheckForNull Query query, Sort sort, int size, int number); @Override EntityType findEntityType(String identifier); @Override Attributes findAttributes(
      String entityTypeId, @Nullable @CheckForNull Query query, Sort sort, int size, int number); @Override Attribute findAttribute(String entityTypeId, String attributeId); @Override MetadataUpsertJobExecution deleteAttributeAsync(String entityTypeId, String attributeId); @Override MetadataUpsertJobExecution deleteAttributesAsync(String entityTypeId, Query query); @Override void createEntityType(EntityType entityType); @Override MetadataUpsertJobExecution updateEntityTypeAsync(EntityType entityType); @Override MetadataDeleteJobExecution deleteEntityTypeAsync(String entityTypeId); @Override MetadataDeleteJobExecution deleteEntityTypesAsync(Query query);  }