Search in sources :

Example 6 with DataElementCategoryOptionCombo

use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.

the class UndoCompleteAction method execute.

@Override
public String execute() throws Exception {
    OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
    Period period = periodService.getPeriod(isoPeriod);
    DataSet dataSet = dataSetService.getDataSet(dataSetId);
    //TODO
    DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
    CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(dataSet, period, organisationUnit, optionCombo);
    if (registration != null) {
        registrationService.deleteCompleteDataSetRegistration(registration);
    }
    return SUCCESS;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataSet(org.hisp.dhis.dataset.DataSet) Period(org.hisp.dhis.period.Period) CompleteDataSetRegistration(org.hisp.dhis.dataset.CompleteDataSetRegistration) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 7 with DataElementCategoryOptionCombo

use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.

the class SaveMinMaxLimitsAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    minLimit = minLimit != null ? minLimit : 0;
    maxLimit = maxLimit != null ? maxLimit : 0;
    OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
    DataElement dataElement = dataElementService.getDataElement(dataElementId);
    DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptionComboId);
    MinMaxDataElement minMaxDataElement = minMaxDataElementService.getMinMaxDataElement(organisationUnit, dataElement, optionCombo);
    if (minMaxDataElement == null) {
        minMaxDataElement = new MinMaxDataElement(organisationUnit, dataElement, optionCombo, minLimit, maxLimit, false);
        minMaxDataElementService.addMinMaxDataElement(minMaxDataElement);
    } else {
        minMaxDataElement.setMin(minLimit);
        minMaxDataElement.setMax(maxLimit);
        minMaxDataElement.setGenerated(false);
        minMaxDataElementService.updateMinMaxDataElement(minMaxDataElement);
    }
    return SUCCESS;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataElement(org.hisp.dhis.dataelement.DataElement) MinMaxDataElement(org.hisp.dhis.minmax.MinMaxDataElement) MinMaxDataElement(org.hisp.dhis.minmax.MinMaxDataElement) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 8 with DataElementCategoryOptionCombo

use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.

the class GetDataSetOverviewAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    Validate.notNull(organisationUnitId);
    Validate.notNull(isoPeriod);
    Validate.notNull(dataSetId);
    organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
    period = periodService.getPeriod(isoPeriod);
    period.setName(format.formatPeriod(period));
    dataSet = dataSetService.getDataSet(dataSetId);
    DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
    if (registrationService.getCompleteDataSetRegistration(dataSet, period, organisationUnit, optionCombo) == null) {
        completed = false;
    } else {
        completed = true;
    }
    if (sectionId != null) {
        for (Section section : dataSet.getSections()) {
            if (section.getId() == sectionId) {
                sectionName = section.getName();
                break;
            }
        }
    } else {
        sectionName = "Default";
    }
    validationRuleViolations = formUtils.getValidationRuleViolations(organisationUnit, dataSet, period);
    return SUCCESS;
}
Also used : Section(org.hisp.dhis.dataset.Section) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 9 with DataElementCategoryOptionCombo

use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.

the class GetPeriodsAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    Validate.notNull(organisationUnitId);
    Validate.notNull(dataSetId);
    organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
    dataSet = dataSetService.getDataSet(dataSetId);
    periods = formUtils.getPeriodsForDataSet(dataSetId);
    markLockedDataSets(organisationUnit, dataSet, periods);
    //TODO
    DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
    for (Period period : periods) {
        period.setName(format.formatPeriod(period));
        CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(dataSet, period, organisationUnit, optionCombo);
        periodCompletedMap.put(period, registration != null);
    }
    return SUCCESS;
}
Also used : Period(org.hisp.dhis.period.Period) CompleteDataSetRegistration(org.hisp.dhis.dataset.CompleteDataSetRegistration) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 10 with DataElementCategoryOptionCombo

use of org.hisp.dhis.dataelement.DataElementCategoryOptionCombo in project dhis2-core by dhis2.

the class CategoryOptionComboNameResourceTable method getPopulateTempTableContent.

@Override
public Optional<List<Object[]>> getPopulateTempTableContent() {
    List<Object[]> batchArgs = new ArrayList<>();
    for (DataElementCategoryCombo combo : objects) {
        if (!combo.isValid()) {
            log.warn("Ignoring category combo, not valid: " + combo);
            continue;
        }
        for (DataElementCategoryOptionCombo coc : combo.getOptionCombos()) {
            List<Object> values = new ArrayList<>();
            values.add(coc.getId());
            values.add(coc.getName());
            values.add(coc.isIgnoreApproval() ? APPROVAL_LEVEL_HIGHEST : null);
            values.add(coc.getLatestStartDate());
            values.add(coc.getEarliestEndDate());
            batchArgs.add(values.toArray());
        }
    }
    return Optional.of(batchArgs);
}
Also used : DataElementCategoryCombo(org.hisp.dhis.dataelement.DataElementCategoryCombo) ArrayList(java.util.ArrayList) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Aggregations

DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)97 DataElement (org.hisp.dhis.dataelement.DataElement)43 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)36 Period (org.hisp.dhis.period.Period)31 DataValue (org.hisp.dhis.datavalue.DataValue)19 ArrayList (java.util.ArrayList)18 Date (java.util.Date)18 DataSet (org.hisp.dhis.dataset.DataSet)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)13 DataElementCategoryOption (org.hisp.dhis.dataelement.DataElementCategoryOption)12 CompleteDataSetRegistration (org.hisp.dhis.dataset.CompleteDataSetRegistration)12 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)10 DataElementCategoryCombo (org.hisp.dhis.dataelement.DataElementCategoryCombo)9 HashSet (java.util.HashSet)8 Test (org.junit.Test)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 Matcher (java.util.regex.Matcher)5 DataElementCategory (org.hisp.dhis.dataelement.DataElementCategory)5 HashMap (java.util.HashMap)4