use of org.molgenis.api.model.Sort in project molgenis by molgenis.
the class EntityController method getReferencedEntities.
@Transactional(readOnly = true)
@GetMapping("/{entityTypeId}/{entityId}/{fieldId}")
public EntitiesResponse getReferencedEntities(@Valid ReadSubresourceRequest entitiesRequest) {
String entityTypeId = entitiesRequest.getEntityTypeId();
String entityId = entitiesRequest.getEntityId();
String fieldId = entitiesRequest.getFieldId();
Selection filter = entitiesRequest.getFilter();
Selection expand = entitiesRequest.getExpand();
int size = entitiesRequest.getSize();
int page = entitiesRequest.getPage();
Sort sort = entitiesRequest.getSort();
Entities entities = dataServiceV3.findSubresources(entityTypeId, entityId, fieldId, entitiesRequest.getQ().orElse(null), filter, expand, sort, size, page);
EntityCollection entityCollection = EntityCollection.builder().setEntityTypeId(entityTypeId).setEntities(entities.getEntities()).setPage(Page.builder().setOffset(size * page).setPageSize(size).setTotal(entities.getTotal()).build()).build();
return entityMapper.map(entityCollection, filter, expand, size, page, entities.getTotal());
}
use of org.molgenis.api.model.Sort in project molgenis by molgenis.
the class EntityController method getEntities.
@Transactional(readOnly = true)
@GetMapping("/{entityTypeId}")
public EntitiesResponse getEntities(@Valid ReadEntitiesRequest entitiesRequest) {
String entityTypeId = entitiesRequest.getEntityTypeId();
Selection filter = entitiesRequest.getFilter();
Selection expand = entitiesRequest.getExpand();
int size = entitiesRequest.getSize();
int page = entitiesRequest.getPage();
Sort sort = entitiesRequest.getSort();
Entities entities = dataServiceV3.findAll(entityTypeId, entitiesRequest.getQ().orElse(null), filter, expand, sort, size, page);
EntityCollection entityCollection = EntityCollection.builder().setEntityTypeId(entityTypeId).setEntities(entities.getEntities()).setPage(Page.builder().setOffset(size * page).setPageSize(size).setTotal(entities.getTotal()).build()).build();
return entityMapper.map(entityCollection, filter, expand, size, page, entities.getTotal());
}
use of org.molgenis.api.model.Sort in project molgenis by molgenis.
the class AttributeRequestMapperImpl method mapOrderBy.
@SuppressWarnings({ "unchecked", "UnstableApiUsage" })
private Optional<org.molgenis.data.Sort> mapOrderBy(Object value) {
List<Object> values = (List<Object>) value;
ImmutableList<Order> orders = values.stream().map(item -> mapOrderByItem((Map<String, String>) item)).collect(toImmutableList());
Sort sort = Sort.create(orders);
return Optional.of(sortMapper.map(sort, attributeFactory.getAttributeMetadata()));
}
use of org.molgenis.api.model.Sort in project molgenis by molgenis.
the class MetadataApiControllerTest method testGetAttributes.
@Test
void testGetAttributes() {
String entityTypeId = "MyEntityTypeId";
Query query = mock(Query.class);
Sort sort = mock(Sort.class);
int size = 1;
int page = 2;
ReadAttributesRequest readAttributesRequest = new ReadAttributesRequest();
readAttributesRequest.setQ(query);
readAttributesRequest.setSort(sort);
readAttributesRequest.setSize(size);
readAttributesRequest.setPage(page);
Attributes attributes = mock(Attributes.class);
when(metadataApiService.findAttributes(entityTypeId, query, sort, size, page)).thenReturn(attributes);
AttributesResponse attributesResponse = mock(AttributesResponse.class);
when(attributeResponseMapper.toAttributesResponse(attributes, size, page)).thenReturn(attributesResponse);
assertEquals(attributesResponse, metadataApiController.getAttributes(entityTypeId, readAttributesRequest));
}
use of org.molgenis.api.model.Sort in project molgenis by molgenis.
the class MetadataApiController method getEntityTypes.
@Transactional(readOnly = true)
@GetMapping
public EntityTypesResponse getEntityTypes(@Valid ReadEntityTypesRequest entitiesRequest) {
int size = entitiesRequest.getSize();
int page = entitiesRequest.getPage();
Sort sort = entitiesRequest.getSort();
EntityTypes entityTypes = metadataApiService.findEntityTypes(entitiesRequest.getQ().orElse(null), sort, size, page);
return entityTypeResponseMapper.toEntityTypesResponse(entityTypes, size, page);
}
Aggregations