Search in sources :

Example 26 with MonthlyPeriodType

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);
}
Also used : MockBatchHandlerFactory(org.hisp.dhis.mock.batchhandler.MockBatchHandlerFactory) Attribute(org.hisp.dhis.attribute.Attribute) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) MockCurrentUserService(org.hisp.dhis.mock.MockCurrentUserService) MockCurrentUserService(org.hisp.dhis.mock.MockCurrentUserService) CurrentUserService(org.hisp.dhis.user.CurrentUserService) Option(org.hisp.dhis.option.Option) OptionSet(org.hisp.dhis.option.OptionSet)

Example 27 with MonthlyPeriodType

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);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) IndicatorType(org.hisp.dhis.indicator.IndicatorType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) Indicator(org.hisp.dhis.indicator.Indicator)

Example 28 with MonthlyPeriodType

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);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType)

Example 29 with MonthlyPeriodType

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);
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType)

Example 30 with MonthlyPeriodType

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());
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) Period(org.hisp.dhis.period.Period) Date(java.util.Date) Cal(org.hisp.dhis.period.Cal) Test(org.junit.Test)

Aggregations

MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)33 QuarterlyPeriodType (org.hisp.dhis.period.QuarterlyPeriodType)12 Test (org.junit.Test)12 Period (org.hisp.dhis.period.Period)11 PeriodType (org.hisp.dhis.period.PeriodType)11 YearlyPeriodType (org.hisp.dhis.period.YearlyPeriodType)10 DataSet (org.hisp.dhis.dataset.DataSet)8 ArrayList (java.util.ArrayList)7 WeeklyPeriodType (org.hisp.dhis.period.WeeklyPeriodType)6 DateTime (org.joda.time.DateTime)5 DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)4 Calendar (java.util.Calendar)3 Date (java.util.Date)3 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)3 DataElement (org.hisp.dhis.dataelement.DataElement)3 MockCurrentUserService (org.hisp.dhis.mock.MockCurrentUserService)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)2 DataElementCategoryOption (org.hisp.dhis.dataelement.DataElementCategoryOption)2 Indicator (org.hisp.dhis.indicator.Indicator)2