Search in sources :

Example 1 with LockExceptionNameComparator

use of org.hisp.dhis.dataset.comparator.LockExceptionNameComparator in project dhis2-core by dhis2.

the class GetLockExceptionListAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    if (usePaging) {
        paging = createPaging(dataSetService.getLockExceptionCount());
        lockExceptions = new ArrayList<>(dataSetService.getLockExceptionsBetween(paging.getStartPos(), paging.getEndPos()));
    } else {
        lockExceptions = new ArrayList<>(dataSetService.getAllLockExceptions());
    }
    Collections.sort(lockExceptions, new LockExceptionNameComparator());
    for (LockException lockException : lockExceptions) {
        lockException.getPeriod().setName(format.formatPeriod(lockException.getPeriod()));
    }
    return SUCCESS;
}
Also used : LockExceptionNameComparator(org.hisp.dhis.dataset.comparator.LockExceptionNameComparator) LockException(org.hisp.dhis.dataset.LockException)

Example 2 with LockExceptionNameComparator

use of org.hisp.dhis.dataset.comparator.LockExceptionNameComparator in project dhis2-core by dhis2.

the class PrepareBatchRemovalAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    lockExceptions = new ArrayList<>(dataSetService.getLockExceptionCombinations());
    for (LockException lockException : lockExceptions) {
        lockException.getPeriod().setName(format.formatPeriod(lockException.getPeriod()));
    }
    Collections.sort(lockExceptions, new LockExceptionNameComparator());
    return SUCCESS;
}
Also used : LockExceptionNameComparator(org.hisp.dhis.dataset.comparator.LockExceptionNameComparator) LockException(org.hisp.dhis.dataset.LockException)

Example 3 with LockExceptionNameComparator

use of org.hisp.dhis.dataset.comparator.LockExceptionNameComparator 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;
}
Also used : RootNode(org.hisp.dhis.node.types.RootNode) LockExceptionNameComparator(org.hisp.dhis.dataset.comparator.LockExceptionNameComparator) LockException(org.hisp.dhis.dataset.LockException) FieldFilterParams(org.hisp.dhis.fieldfilter.FieldFilterParams) I18nFormat(org.hisp.dhis.i18n.I18nFormat) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

LockException (org.hisp.dhis.dataset.LockException)3 LockExceptionNameComparator (org.hisp.dhis.dataset.comparator.LockExceptionNameComparator)3 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)1 I18nFormat (org.hisp.dhis.i18n.I18nFormat)1 RootNode (org.hisp.dhis.node.types.RootNode)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1