use of org.molgenis.api.data.v3.model.EntitiesResponse.Builder in project molgenis by molgenis.
the class EntityMapperImpl method mapRecursive.
private EntityResponse mapRecursive(Entity entity, Selection filter, Selection expand, int depth) {
if (depth > MAX_DEPTH) {
throw new IllegalArgumentException("max_depth exceeded: " + depth);
}
EntityResponse.Builder builder = EntityResponse.builder();
if (filter.hasItems()) {
Map<String, Object> dataMap = new LinkedHashMap<>();
stream(entity.getEntityType().getAtomicAttributes()).filter(attribute -> filter.hasItem(attribute.getName())).forEach(attribute -> dataMap.put(attribute.getName(), mapRecursive(entity, attribute, filter, expand, depth)));
builder.setData(dataMap);
}
URI uri = createEntityResponseUri(entity);
return builder.setLinks(LinksResponse.create(null, uri, null)).build();
}
use of org.molgenis.api.data.v3.model.EntitiesResponse.Builder in project molgenis by molgenis.
the class EntityMapperImpl method map.
@Override
public EntitiesResponse map(EntityCollection entityCollection, Selection filter, Selection expand, int size, int number, int total) {
EntitiesResponse.Builder builder = mapRecursive(entityCollection, filter, expand, 0);
LinksResponse linksResponse = LinksUtils.createLinksResponse(number, size, total);
setPageResponse(entityCollection, builder);
return builder.setLinks(linksResponse).build();
}
use of org.molgenis.api.data.v3.model.EntitiesResponse.Builder in project molgenis by molgenis.
the class EntityMapperImpl method mapRecursive.
private EntitiesResponse.Builder mapRecursive(EntityCollection entityCollection, Selection filter, Selection expand, int depth) {
if (depth > MAX_DEPTH) {
throw new IllegalArgumentException("max_depth exceeded: " + depth);
}
EntitiesResponse.Builder builder = EntitiesResponse.builder();
if (filter.hasItems()) {
List<EntityResponse> entityResponses = entityCollection.getEntities().stream().map(entity -> mapRecursive(entity, filter, expand, depth)).collect(toList());
builder.setItems(entityResponses);
}
return builder;
}
Aggregations