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;
}
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);
}
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());
}
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());
}
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());
}
Aggregations