use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class DataValidatorTest method setUp.
@BeforeEach
public void setUp() {
dataValidator = new DataValidator(categoryService, organisationUnitService, dataSetService, idObjectManager, dataValueService, inputUtils, fileResourceService, calendarService, accessManager);
periodJan = createPeriod("202001");
periodFeb = createPeriod("202002");
periodMar = createPeriod("202003");
dataSetA = new DataSet("dataSet", new MonthlyPeriodType());
dataElementA = new DataElement();
categoryOptionA = new CategoryOption();
optionComboA = new CategoryOptionCombo();
dataSetA.addDataSetElement(dataElementA);
dataElementA.getDataSetElements().addAll(dataSetA.getDataSetElements());
optionComboA.addCategoryOption(categoryOptionA);
jan15 = getDate(2020, 1, 15);
feb15 = getDate(2020, 2, 15);
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class GenerateDataSetReportAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
// ---------------------------------------------------------------------
// Configure response
// ---------------------------------------------------------------------
HttpServletResponse response = ServletActionContext.getResponse();
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false);
// ---------------------------------------------------------------------
// Assemble report
// ---------------------------------------------------------------------
selectedDataSet = dataSetService.getDataSetNoAcl(ds);
if (pe != null) {
selectedPeriod = PeriodType.getPeriodFromIsoString(pe);
selectedPeriod = periodService.reloadPeriod(selectedPeriod);
}
selectedOrgunit = organisationUnitService.getOrganisationUnit(ou);
FormType formType = selectedDataSet.getFormType();
CategoryOptionCombo attributeOptionCombo = categoryService.getDefaultCategoryOptionCombo();
registration = registrationService.getCompleteDataSetRegistration(selectedDataSet, selectedPeriod, selectedOrgunit, attributeOptionCombo);
if (formType.isCustom() && type == null) {
customDataEntryFormCode = dataSetReportService.getCustomDataSetReport(selectedDataSet, newArrayList(selectedPeriod), selectedOrgunit, dimension, selectedUnitOnly);
} else {
grids = dataSetReportService.getDataSetReportAsGrid(selectedDataSet, newArrayList(selectedPeriod), selectedOrgunit, dimension, selectedUnitOnly);
}
return type != null ? type : formType.toString();
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class HandleRelationshipsTrackedEntityInstanceServiceTest method setUpTest.
@Override
protected void setUpTest() throws Exception {
organisationUnitA = createOrganisationUnit('A');
trackedEntityType = createTrackedEntityType('A');
trackedEntityTypeService.addTrackedEntityType(trackedEntityType);
trackedEntityInstanceA = createTrackedEntityInstance(organisationUnitA);
trackedEntityInstanceA.setTrackedEntityType(trackedEntityType);
trackedEntityInstanceB = createTrackedEntityInstance(organisationUnitA);
trackedEntityInstanceB.setTrackedEntityType(trackedEntityType);
programA = createProgram('A', new HashSet<>(), organisationUnitA);
programA.setProgramType(ProgramType.WITH_REGISTRATION);
programStageA1 = createProgramStage('1', programA);
programStageA2 = createProgramStage('2', programA);
programA.setProgramStages(Stream.of(programStageA1, programStageA2).collect(Collectors.toCollection(HashSet::new)));
manager.save(organisationUnitA);
manager.save(trackedEntityInstanceA);
manager.save(trackedEntityInstanceB);
manager.save(programA);
manager.save(programStageA1);
manager.save(programStageA2);
ProgramInstance programInstanceA = programInstanceService.enrollTrackedEntityInstance(trackedEntityInstanceA, programA, null, null, organisationUnitA);
programStageInstanceA = new ProgramStageInstance(programInstanceA, programStageA1);
programStageInstanceA.setDueDate(null);
programStageInstanceA.setUid("UID-A");
CategoryCombo categoryComboA = createCategoryCombo('A');
CategoryOptionCombo categoryOptionComboA = createCategoryOptionCombo('A');
categoryOptionComboA.setCategoryCombo(categoryComboA);
manager.save(categoryComboA);
manager.save(categoryOptionComboA);
programStageInstanceA.setAttributeOptionCombo(categoryOptionComboA);
programStageInstanceService.addProgramStageInstance(programStageInstanceA);
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class AttributeOptionComboDateCheckTest method failOnCategoryOptionEndDateBeforeEventDate.
@Test
void failOnCategoryOptionEndDateBeforeEventDate() {
event.setEventDate("2019-05-01");
event.setDueDate("2019-05-10");
CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2019-04-01", false);
mockContext(categoryOptionCombo);
ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
assertHasError(importSummary, event, "Event date 2019-05-01 is after end date 2019-04-01 for attributeOption 'test' in program 'TestProgram'");
}
use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.
the class AttributeOptionComboDateCheckTest method succeedBeforeOpenDaysAfterCoEndDate.
@Test
void succeedBeforeOpenDaysAfterCoEndDate() {
event.setEventDate("2019-05-01");
event.setDueDate("2019-05-10");
program.setOpenDaysAfterCoEndDate(31);
CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2019-04-01", false);
mockContext(categoryOptionCombo);
ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
assertNoError(importSummary);
}
Aggregations