Search in sources :

Example 6 with QuarterlyPeriodType

use of org.hisp.dhis.period.QuarterlyPeriodType in project dhis2-core by dhis2.

the class DataSetApprovalFrequencyComparatorTest method testB.

@Test
void testB() {
    DataSet dsA = new DataSet("EA: Expenditures Site Level", new QuarterlyPeriodType());
    DataSet dsB = new DataSet("MER Results: Facility Based", new QuarterlyPeriodType());
    DataSet dsC = new DataSet("MER Results: Facility Based - DoD ONLY", new QuarterlyPeriodType());
    DataApprovalWorkflow workflow = new DataApprovalWorkflow("Workflow A", new QuarterlyPeriodType(), null);
    dsB.assignWorkflow(workflow);
    List<DataSet> list = Lists.newArrayList(dsB, dsC, dsA);
    Collections.sort(list, DataSetApprovalFrequencyComparator.INSTANCE);
    assertEquals(dsB, list.get(0));
    assertEquals(dsA, list.get(1));
    assertEquals(dsC, list.get(2));
}
Also used : DataSet(org.hisp.dhis.dataset.DataSet) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Test(org.junit.jupiter.api.Test)

Example 7 with QuarterlyPeriodType

use of org.hisp.dhis.period.QuarterlyPeriodType in project dhis2-core by dhis2.

the class DataSetApprovalFrequencyComparatorTest method testC.

@Test
void testC() {
    DataSet dsA = new DataSet("DataSetA", new YearlyPeriodType());
    DataSet dsB = new DataSet("DataSetB", new YearlyPeriodType());
    DataSet dsC = new DataSet("DataSetC", new MonthlyPeriodType());
    DataSet dsD = new DataSet("DataSetD", new QuarterlyPeriodType());
    DataApprovalWorkflow workflow = new DataApprovalWorkflow("Workflow A", new QuarterlyPeriodType(), null);
    dsA.assignWorkflow(workflow);
    dsD.assignWorkflow(workflow);
    DataElement deA = new DataElement();
    dsA.addDataSetElement(deA);
    dsB.addDataSetElement(deA);
    dsC.addDataSetElement(deA);
    dsD.addDataSetElement(deA);
    assertEquals(dsD, deA.getApprovalDataSet());
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataSet(org.hisp.dhis.dataset.DataSet) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) Test(org.junit.jupiter.api.Test)

Example 8 with QuarterlyPeriodType

use of org.hisp.dhis.period.QuarterlyPeriodType in project dhis2-core by dhis2.

the class QueryPlannerUtilsTest method testGetAggregationType.

@Test
void testGetAggregationType() {
    AnalyticsAggregationType typeA = new AnalyticsAggregationType(AggregationType.SUM, AggregationType.AVERAGE, DataType.NUMERIC, true);
    AnalyticsAggregationType typeB = new AnalyticsAggregationType(AggregationType.AVERAGE, AggregationType.AVERAGE, DataType.NUMERIC, true);
    assertEquals(typeA, QueryPlannerUtils.getAggregationType(new AnalyticsAggregationType(AggregationType.SUM, AggregationType.AVERAGE), ValueType.INTEGER, new QuarterlyPeriodType(), new YearlyPeriodType()));
    assertEquals(typeB, QueryPlannerUtils.getAggregationType(new AnalyticsAggregationType(AggregationType.AVERAGE, AggregationType.AVERAGE), ValueType.INTEGER, new QuarterlyPeriodType(), new YearlyPeriodType()));
}
Also used : QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) AnalyticsAggregationType(org.hisp.dhis.analytics.AnalyticsAggregationType) Test(org.junit.jupiter.api.Test)

Example 9 with QuarterlyPeriodType

use of org.hisp.dhis.period.QuarterlyPeriodType 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 10 with QuarterlyPeriodType

use of org.hisp.dhis.period.QuarterlyPeriodType 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)

Aggregations

QuarterlyPeriodType (org.hisp.dhis.period.QuarterlyPeriodType)18 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)12 Test (org.junit.jupiter.api.Test)12 YearlyPeriodType (org.hisp.dhis.period.YearlyPeriodType)10 DataSet (org.hisp.dhis.dataset.DataSet)8 WeeklyPeriodType (org.hisp.dhis.period.WeeklyPeriodType)6 DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)5 DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)5 Calendar (java.util.Calendar)3 Date (java.util.Date)3 Period (org.hisp.dhis.period.Period)3 DataElement (org.hisp.dhis.dataelement.DataElement)2 BiMonthlyPeriodType (org.hisp.dhis.period.BiMonthlyPeriodType)2 BiWeeklyPeriodType (org.hisp.dhis.period.BiWeeklyPeriodType)2 Cal (org.hisp.dhis.period.Cal)2 FinancialAprilPeriodType (org.hisp.dhis.period.FinancialAprilPeriodType)2 FinancialJulyPeriodType (org.hisp.dhis.period.FinancialJulyPeriodType)2 FinancialNovemberPeriodType (org.hisp.dhis.period.FinancialNovemberPeriodType)2 FinancialOctoberPeriodType (org.hisp.dhis.period.FinancialOctoberPeriodType)2 PeriodType (org.hisp.dhis.period.PeriodType)2