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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations