use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.
the class DataValueSetServiceTest method setUpTest.
@Override
public void setUpTest() {
mockDataValueBatchHandler = new MockBatchHandler<>();
mockDataValueAuditBatchHandler = new MockBatchHandler<>();
mockBatchHandlerFactory = new MockBatchHandlerFactory();
mockBatchHandlerFactory.registerBatchHandler(DataValueBatchHandler.class, mockDataValueBatchHandler);
mockBatchHandlerFactory.registerBatchHandler(DataValueAuditBatchHandler.class, mockDataValueAuditBatchHandler);
setDependency(dataValueSetService, "batchHandlerFactory", mockBatchHandlerFactory);
attribute = new Attribute("CUSTOM_ID", ValueType.TEXT);
attribute.setUid(ATTRIBUTE_UID);
attribute.setUnique(true);
attribute.setOrganisationUnitAttribute(true);
attribute.setDataElementAttribute(true);
idObjectManager.save(attribute);
categoryOptionA = createCategoryOption('A');
categoryOptionB = createCategoryOption('B');
categoryA = createDataElementCategory('A', categoryOptionA, categoryOptionB);
categoryComboA = createCategoryCombo('A', categoryA);
categoryComboDef = categoryService.getDefaultDataElementCategoryCombo();
ocDef = categoryService.getDefaultDataElementCategoryOptionCombo();
ocDef.setCode("OC_DEF_CODE");
categoryService.updateDataElementCategoryOptionCombo(ocDef);
osA = new OptionSet("OptionSetA", ValueType.INTEGER);
osA.getOptions().add(new Option("Blue", "1"));
osA.getOptions().add(new Option("Green", "2"));
osA.getOptions().add(new Option("Yellow", "3"));
ocA = createCategoryOptionCombo(categoryComboA, categoryOptionA);
ocB = createCategoryOptionCombo(categoryComboA, categoryOptionB);
deA = createDataElement('A', categoryComboDef);
deB = createDataElement('B', categoryComboDef);
deC = createDataElement('C', categoryComboDef);
deD = createDataElement('D', categoryComboDef);
deE = createDataElement('E');
deE.setOptionSet(osA);
deF = createDataElement('F', categoryComboDef);
deF.setValueType(ValueType.BOOLEAN);
deG = createDataElement('G', categoryComboDef);
deG.setValueType(ValueType.TRUE_ONLY);
dsA = createDataSet('A', new MonthlyPeriodType());
dsA.setCategoryCombo(categoryComboDef);
ouA = createOrganisationUnit('A');
ouB = createOrganisationUnit('B');
ouC = createOrganisationUnit('C');
peA = createPeriod(PeriodType.getByNameIgnoreCase(MonthlyPeriodType.NAME), getDate(2012, 1, 1), getDate(2012, 1, 31));
peB = createPeriod(PeriodType.getByNameIgnoreCase(MonthlyPeriodType.NAME), getDate(2012, 2, 1), getDate(2012, 2, 29));
peC = createPeriod(PeriodType.getByNameIgnoreCase(MonthlyPeriodType.NAME), getDate(2012, 3, 1), getDate(2012, 3, 31));
ocA.setUid("kjuiHgy67hg");
ocB.setUid("Gad33qy67g5");
deA.setUid("f7n9E0hX8qk");
deB.setUid("Ix2HsbDMLea");
deC.setUid("eY5ehpbEsB7");
deE.setUid("jH26dja2f28");
deF.setUid("jH26dja2f30");
deG.setUid("jH26dja2f31");
dsA.setUid("pBOMPrpg1QX");
ouA.setUid("DiszpKrYNg8");
ouB.setUid("BdfsJfj87js");
ouC.setUid("j7Hg26FpoIa");
ocA.setCode("OC_A");
ocB.setCode("OC_B");
deA.setCode("DE_A");
deB.setCode("DE_B");
deC.setCode("DE_C");
deD.setCode("DE_D");
dsA.setCode("DS_A");
ouA.setCode("OU_A");
ouB.setCode("OU_B");
ouC.setCode("OU_C");
categoryService.addDataElementCategoryOption(categoryOptionA);
categoryService.addDataElementCategoryOption(categoryOptionB);
categoryService.addDataElementCategory(categoryA);
categoryService.addDataElementCategoryCombo(categoryComboA);
categoryService.addDataElementCategoryOptionCombo(ocA);
categoryService.addDataElementCategoryOptionCombo(ocB);
attributeService.addAttributeValue(deA, createAttributeValue(attribute, "DE1"));
dataElementService.addDataElement(deA);
attributeService.addAttributeValue(deB, createAttributeValue(attribute, "DE2"));
dataElementService.addDataElement(deB);
attributeService.addAttributeValue(deC, createAttributeValue(attribute, "DE3"));
dataElementService.addDataElement(deC);
attributeService.addAttributeValue(deD, createAttributeValue(attribute, "DE4"));
dataElementService.addDataElement(deD);
dataElementService.addDataElement(deF);
dataElementService.addDataElement(deG);
idObjectManager.save(osA);
dsA.addDataSetElement(deA);
dsA.addDataSetElement(deB);
dsA.addDataSetElement(deC);
dsA.addDataSetElement(deD);
attributeService.addAttributeValue(ouA, createAttributeValue(attribute, "OU1"));
organisationUnitService.addOrganisationUnit(ouA);
attributeService.addAttributeValue(ouB, createAttributeValue(attribute, "OU2"));
organisationUnitService.addOrganisationUnit(ouB);
attributeService.addAttributeValue(ouC, createAttributeValue(attribute, "OU3"));
organisationUnitService.addOrganisationUnit(ouC);
dsA.addOrganisationUnit(ouA);
dsA.addOrganisationUnit(ouC);
dataSetService.addDataSet(dsA);
periodService.addPeriod(peA);
periodService.addPeriod(peB);
periodService.addPeriod(peC);
user = createUser('A');
user.setOrganisationUnits(Sets.newHashSet(ouA, ouB));
CurrentUserService currentUserService = new MockCurrentUserService(user);
setDependency(dataValueSetService, "currentUserService", currentUserService);
}
use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.
the class ChartStoreTest method setUpTest.
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() {
// ---------------------------------------------------------------------
// Indicator
// ---------------------------------------------------------------------
IndicatorType indicatorType = createIndicatorType('A');
indicatorA = createIndicator('A', indicatorType);
indicatorB = createIndicator('B', indicatorType);
indicatorC = createIndicator('C', indicatorType);
indicatorService.addIndicatorType(indicatorType);
indicatorService.addIndicator(indicatorA);
indicatorService.addIndicator(indicatorB);
indicatorService.addIndicator(indicatorC);
List<Indicator> indicators = new ArrayList<>();
indicators.add(indicatorA);
indicators.add(indicatorB);
indicators.add(indicatorC);
// ---------------------------------------------------------------------
// Period
// ---------------------------------------------------------------------
PeriodType periodType = new MonthlyPeriodType();
periodA = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 1, 2));
periodB = createPeriod(periodType, getDate(2000, 1, 3), getDate(2000, 1, 4));
periodC = createPeriod(periodType, getDate(2000, 1, 5), getDate(2000, 1, 6));
periodService.addPeriod(periodA);
periodService.addPeriod(periodB);
periodService.addPeriod(periodC);
List<Period> periods = new ArrayList<>();
periods.add(periodA);
periods.add(periodB);
periods.add(periodC);
// ---------------------------------------------------------------------
// OrganisationUnit
// ---------------------------------------------------------------------
unitA = createOrganisationUnit('A');
unitB = createOrganisationUnit('B');
organisationUnitService.addOrganisationUnit(unitA);
organisationUnitService.addOrganisationUnit(unitB);
List<OrganisationUnit> units = new ArrayList<>();
units.add(unitA);
units.add(unitB);
// units.add( unitC );
chartA = createChart('A', indicators, periods, units);
chartB = createChart('B', indicators, periods, units);
chartC = createChart('C', indicators, periods, units);
}
use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.
the class DataSetCompletenessServiceExportTest method setUpTest.
@Override
public void setUpTest() {
dataSets = new ArrayList<>();
periods = new ArrayList<>();
units = new ArrayList<>();
monthly = new MonthlyPeriodType();
quarterly = new QuarterlyPeriodType();
periodA = createPeriod(monthly, getDate(2000, 1, 1), getDate(2000, 1, 31));
periodB = createPeriod(monthly, getDate(2000, 2, 1), getDate(2000, 2, 28));
periodC = createPeriod(monthly, getDate(2000, 3, 1), getDate(2000, 3, 31));
periodD = createPeriod(quarterly, getDate(2000, 1, 1), getDate(2000, 3, 31));
periodService.addPeriod(periodA);
periodService.addPeriod(periodB);
periodService.addPeriod(periodC);
periodService.addPeriod(periodD);
periods.add(periodA);
periods.add(periodB);
periods.add(periodC);
periods.add(periodD);
unitA = createOrganisationUnit('A');
unitB = createOrganisationUnit('B');
unitC = createOrganisationUnit('C');
unitB.setParent(unitA);
unitC.setParent(unitA);
unitA.getChildren().add(unitB);
unitA.getChildren().add(unitC);
organisationUnitService.addOrganisationUnit(unitA);
organisationUnitService.addOrganisationUnit(unitB);
organisationUnitService.addOrganisationUnit(unitC);
units.add(unitA);
units.add(unitB);
units.add(unitC);
dataSetA = createDataSet('A', monthly);
dataSetA.getSources().add(unitA);
dataSetA.getSources().add(unitB);
dataSetA.getSources().add(unitC);
dataSetService.addDataSet(dataSetA);
dataSets.add(dataSetA);
}
use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.
the class DataSetCompletenessServiceTest method setUpTest.
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() {
setExternalTestDir(locationManager);
categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
periodType = new MonthlyPeriodType();
periodA = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 1, 31));
periodB = createPeriod(periodType, getDate(2000, 2, 1), getDate(2000, 2, 28));
periodC = createPeriod(new QuarterlyPeriodType(), getDate(2000, 1, 1), getDate(2000, 3, 31));
periodIdA = periodService.addPeriod(periodA);
periodService.addPeriod(periodB);
periodIdC = periodService.addPeriod(periodC);
unitA = createOrganisationUnit('A');
unitB = createOrganisationUnit('B');
unitC = createOrganisationUnit('C');
unitD = createOrganisationUnit('D');
unitE = createOrganisationUnit('E');
unitF = createOrganisationUnit('F');
unitG = createOrganisationUnit('G');
unitH = createOrganisationUnit('H');
unitB.setParent(unitA);
unitC.setParent(unitA);
unitE.setParent(unitB);
unitF.setParent(unitB);
unitG.setParent(unitC);
unitH.setParent(unitC);
unitA.getChildren().add(unitB);
unitA.getChildren().add(unitC);
unitB.getChildren().add(unitE);
unitB.getChildren().add(unitF);
unitC.getChildren().add(unitG);
unitC.getChildren().add(unitH);
unitIdA = organisationUnitService.addOrganisationUnit(unitA);
unitIdB = organisationUnitService.addOrganisationUnit(unitB);
unitIdC = organisationUnitService.addOrganisationUnit(unitC);
organisationUnitService.addOrganisationUnit(unitD);
organisationUnitService.addOrganisationUnit(unitE);
organisationUnitService.addOrganisationUnit(unitF);
organisationUnitService.addOrganisationUnit(unitG);
organisationUnitService.addOrganisationUnit(unitH);
unitIdsA = new HashSet<>();
unitIdsA.add(unitIdA);
unitIdsA.add(unitIdB);
unitIdsA.add(unitIdC);
groupA = createOrganisationUnitGroup('A');
groupB = createOrganisationUnitGroup('B');
groupC = createOrganisationUnitGroup('C');
groupA.addOrganisationUnit(unitA);
groupB.addOrganisationUnit(unitA);
groupB.addOrganisationUnit(unitB);
groupC.addOrganisationUnit(unitE);
groupC.addOrganisationUnit(unitF);
organisationUnitGroupService.addOrganisationUnitGroup(groupA);
organisationUnitGroupService.addOrganisationUnitGroup(groupB);
organisationUnitGroupService.addOrganisationUnitGroup(groupC);
dataSetA = createDataSet('A', periodType);
dataSetB = createDataSet('B', periodType);
dataSetC = createDataSet('C', periodType);
dataElementA = createDataElement('A');
dataElementB = createDataElement('B');
dataElementService.addDataElement(dataElementA);
dataElementService.addDataElement(dataElementB);
dataSetA.getCompulsoryDataElementOperands().add(new DataElementOperand(dataElementA, categoryOptionCombo));
dataSetA.getCompulsoryDataElementOperands().add(new DataElementOperand(dataElementB, categoryOptionCombo));
dataSetB.getCompulsoryDataElementOperands().add(new DataElementOperand(dataElementA, categoryOptionCombo));
onTimeA = getDate(2000, 2, 10);
tooLateA = getDate(2000, 2, 25);
onTimeB = getDate(2000, 3, 10);
tooLateB = getDate(2000, 3, 25);
}
use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.
the class EthiopianCalendarTest method testGenerateMonthlyPeriods.
@Test
public void testGenerateMonthlyPeriods() {
Date startDate = new Cal(1975, 1, 1, true).time();
Date endDate = new Cal(2025, 1, 2, true).time();
List<Period> monthly = new MonthlyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(601, monthly.size());
}
Aggregations