use of org.hisp.dhis.fieldfilter.FieldFilterParams in project dhis2-core by dhis2.
the class DeletedObjectController method getDeletedObjects.
@GetMapping
@PreAuthorize("hasRole('ALL')")
public RootNode getDeletedObjects(DeletedObjectQuery query) {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
int totalDeletedObjects = deletedObjectService.countDeletedObjects(query);
query.setTotal(totalDeletedObjects);
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
List<DeletedObject> deletedObjects = deletedObjectService.getDeletedObjects(query);
RootNode rootNode = NodeUtils.createMetadata();
if (!query.isSkipPaging()) {
query.setTotal(totalDeletedObjects);
rootNode.addChild(NodeUtils.createPager(query.getPager()));
}
rootNode.addChild(fieldFilterService.toCollectionNode(DeletedObject.class, new FieldFilterParams(deletedObjects, fields)));
return rootNode;
}
use of org.hisp.dhis.fieldfilter.FieldFilterParams in project dhis2-core by dhis2.
the class LockExceptionController method getLockExceptions.
// -------------------------------------------------------------------------
// Resources
// -------------------------------------------------------------------------
@GetMapping(produces = ContextUtils.CONTENT_TYPE_JSON)
@ResponseBody
public RootNode getLockExceptions(@RequestParam(required = false) String key, @RequestParam Map<String, String> rpParameters, HttpServletRequest request, HttpServletResponse response) throws WebMessageException {
List<String> filters = Lists.newArrayList(contextService.getParameterValues("filter"));
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
List<LockException> lockExceptions = new ArrayList<>();
if (key != null) {
LockException lockException = dataSetService.getLockException(MathUtils.parseInt(key));
if (lockException == null) {
throw new WebMessageException(notFound("Cannot find LockException with key: " + key));
}
lockExceptions.add(lockException);
} else if (!filters.isEmpty()) {
lockExceptions = dataSetService.filterLockExceptions(filters);
} else {
lockExceptions = dataSetService.getAllLockExceptions();
}
WebOptions options = new WebOptions(rpParameters);
WebMetadata metadata = new WebMetadata();
Pager pager = metadata.getPager();
if (options.hasPaging() && pager == null) {
pager = new Pager(options.getPage(), lockExceptions.size(), options.getPageSize());
lockExceptions = PagerUtils.pageCollection(lockExceptions, pager);
}
RootNode rootNode = NodeUtils.createMetadata();
if (pager != null) {
rootNode.addChild(NodeUtils.createPager(pager));
}
I18nFormat format = this.i18nManager.getI18nFormat();
for (LockException lockException : lockExceptions) {
lockException.getPeriod().setName(format.formatPeriod(lockException.getPeriod()));
}
rootNode.addChild(fieldFilterService.toCollectionNode(LockException.class, new FieldFilterParams(lockExceptions, fields)));
return rootNode;
}
use of org.hisp.dhis.fieldfilter.FieldFilterParams in project dhis2-core by dhis2.
the class LockExceptionController method getLockExceptionCombinations.
@GetMapping(value = "/combinations", produces = ContextUtils.CONTENT_TYPE_JSON)
@ResponseBody
public RootNode getLockExceptionCombinations() {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
List<LockException> lockExceptions = this.dataSetService.getLockExceptionCombinations();
I18nFormat format = this.i18nManager.getI18nFormat();
for (LockException lockException : lockExceptions) {
lockException.getPeriod().setName(format.formatPeriod(lockException.getPeriod()));
}
Collections.sort(lockExceptions, new LockExceptionNameComparator());
RootNode rootNode = NodeUtils.createMetadata();
rootNode.addChild(fieldFilterService.toCollectionNode(LockException.class, new FieldFilterParams(lockExceptions, fields)));
return rootNode;
}
use of org.hisp.dhis.fieldfilter.FieldFilterParams in project dhis2-core by dhis2.
the class MinMaxDataElementController method getObjectList.
// --------------------------------------------------------------------------
// GET
// --------------------------------------------------------------------------
@GetMapping
@ResponseBody
public RootNode getObjectList(MinMaxDataElementQueryParams query) throws QueryParserException {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
List<String> filters = Lists.newArrayList(contextService.getParameterValues("filter"));
query.setFilters(filters);
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
List<MinMaxDataElement> minMaxDataElements = minMaxService.getMinMaxDataElements(query);
RootNode rootNode = NodeUtils.createMetadata();
if (!query.isSkipPaging()) {
query.setTotal(minMaxService.countMinMaxDataElements(query));
rootNode.addChild(NodeUtils.createPager(query.getPager()));
}
rootNode.addChild(fieldFilterService.toCollectionNode(MinMaxDataElement.class, new FieldFilterParams(minMaxDataElements, fields)));
return rootNode;
}
use of org.hisp.dhis.fieldfilter.FieldFilterParams in project dhis2-core by dhis2.
the class DeduplicationController method getAllByQuery.
@GetMapping
public Node getAllByQuery(PotentialDuplicateQuery query, HttpServletResponse response) throws BadRequestException {
checkDeduplicationStatusRequestParam(Optional.ofNullable(query.getStatus()).map(Enum::name).orElse(null));
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
List<PotentialDuplicate> potentialDuplicates = deduplicationService.getAllPotentialDuplicatesBy(query);
RootNode rootNode = NodeUtils.createMetadata();
if (!query.isSkipPaging()) {
query.setTotal(deduplicationService.countPotentialDuplicates(query));
rootNode.addChild(NodeUtils.createPager(query.getPager()));
}
rootNode.addChild(fieldFilterService.toCollectionNode(PotentialDuplicate.class, new FieldFilterParams(potentialDuplicates, fields)));
setNoStore(response);
return rootNode;
}
Aggregations