Search in sources :

Example 1 with MonthlyPeriodType

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

the class DhisConvenienceTest method createPeriod.

/**
     * @param startDate The start date.
     * @param endDate   The end date.
     */
public static Period createPeriod(Date startDate, Date endDate) {
    Period period = new Period();
    period.setAutoFields();
    period.setPeriodType(new MonthlyPeriodType());
    period.setStartDate(startDate);
    period.setEndDate(endDate);
    return period;
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) Period(org.hisp.dhis.period.Period)

Example 2 with MonthlyPeriodType

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

the class ResourceTableServiceTest method setUpTest.

@Override
public void setUpTest() {
    PeriodType pt = new MonthlyPeriodType();
    DataElement deA = createDataElement('A');
    DataElement deB = createDataElement('B');
    idObjectManager.save(deA);
    idObjectManager.save(deB);
    DataElementGroup degA = createDataElementGroup('A');
    DataElementGroup degB = createDataElementGroup('B');
    degA.addDataElement(deA);
    degB.addDataElement(deB);
    idObjectManager.save(degA);
    idObjectManager.save(degB);
    DataElementGroupSet degsA = createDataElementGroupSet('A');
    degsA.addDataElementGroup(degA);
    degsA.addDataElementGroup(degB);
    idObjectManager.save(degsA);
    OrganisationUnit ouA = createOrganisationUnit('A');
    OrganisationUnit ouB = createOrganisationUnit('B');
    OrganisationUnit ouC = createOrganisationUnit('C');
    ouB.setParent(ouA);
    ouC.setParent(ouA);
    ouA.getChildren().add(ouB);
    ouA.getChildren().add(ouC);
    idObjectManager.save(ouA);
    idObjectManager.save(ouB);
    idObjectManager.save(ouC);
    DataSet dsA = createDataSet('A', pt);
    DataSet dsB = createDataSet('B', pt);
    dsA.addDataSetElement(deA);
    dsB.addDataSetElement(deA);
    dsA.addOrganisationUnit(ouA);
    dsB.addOrganisationUnit(ouA);
    dataSetService.addDataSet(dsA);
    dataSetService.addDataSet(dsB);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) DataElement(org.hisp.dhis.dataelement.DataElement) DataElementGroupSet(org.hisp.dhis.dataelement.DataElementGroupSet) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) DataSet(org.hisp.dhis.dataset.DataSet) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup)

Example 3 with MonthlyPeriodType

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

the class PersianCalendarTest method testGenerateMonthlyPeriods.

@Test
public void testGenerateMonthlyPeriods() {
    Date startDate = new Cal(1997, 1, 1, true).time();
    Date endDate = new Cal(1998, 1, 1, true).time();
    List<Period> monthly = new MonthlyPeriodType().generatePeriods(calendar, startDate, endDate);
    assertEquals(13, 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)

Example 4 with MonthlyPeriodType

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

the class DataElementTest method testPeriodTypeIsValid.

@Test
public void testPeriodTypeIsValid() {
    DataElement de = new DataElement();
    DataSet dsA = new DataSet("A", new MonthlyPeriodType());
    DataSet dsB = new DataSet("B", new MonthlyPeriodType());
    DataSet dsC = new DataSet("C", new QuarterlyPeriodType());
    dsA.addDataSetElement(de);
    dsB.addDataSetElement(de);
    assertTrue(de.periodTypeIsValid());
    dsC.addDataSetElement(de);
    assertFalse(de.periodTypeIsValid());
}
Also used : DataSet(org.hisp.dhis.dataset.DataSet) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) Test(org.junit.Test)

Example 5 with MonthlyPeriodType

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

the class DataSetApprovalFrequencyComparatorTest method testC.

@Test
public 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.setWorkflow(workflow);
    dsD.setWorkflow(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.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