Search in sources :

Example 6 with MonthlyPeriodType

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

the class DataEntryFormServiceTest method setUpTest.

// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() throws Exception {
    periodType = new MonthlyPeriodType();
    dataElement = createDataElement('A');
    dataElementService.addDataElement(dataElement);
    categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
    dataElementUid = dataElement.getUid();
    categoryOptionComboUid = categoryOptionCombo.getUid();
    i18n = new MockI18n();
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) MockI18n(org.hisp.dhis.mock.MockI18n)

Example 7 with MonthlyPeriodType

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

the class SectionStoreTest method setUpTest.

@Override
public void setUpTest() {
    dataSet = createDataSet('A', new MonthlyPeriodType());
    dataSetService.addDataSet(dataSet);
    DataElement dataElementA = createDataElement('A');
    DataElement dataElementB = createDataElement('B');
    dataElementService.addDataElement(dataElementA);
    dataElementService.addDataElement(dataElementB);
    List<DataElement> dataElements = new ArrayList<>();
    dataElements.add(dataElementA);
    dataElements.add(dataElementB);
    sectionA = new Section("SectionA", dataSet, dataElements, null);
    sectionB = new Section("SectionB", dataSet, dataElements, null);
    sectionC = new Section("SectionC", dataSet, dataElements, null);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) ArrayList(java.util.ArrayList)

Example 8 with MonthlyPeriodType

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

the class DataApprovalAuditStoreTest method setUpTest.

// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@Override
public void setUpTest() throws Exception {
    // ---------------------------------------------------------------------
    // Add supporting data
    // ---------------------------------------------------------------------
    level1 = new DataApprovalLevel("01", 1, null);
    level2 = new DataApprovalLevel("02", 2, null);
    dataApprovalLevelService.addDataApprovalLevel(level1);
    dataApprovalLevelService.addDataApprovalLevel(level2);
    PeriodType periodType = PeriodType.getPeriodTypeByName("Monthly");
    workflowA = new DataApprovalWorkflow("workflowA", periodType, newHashSet(level1));
    workflowB = new DataApprovalWorkflow("workflowB", periodType, newHashSet(level1, level2));
    dataApprovalService.addWorkflow(workflowA);
    dataApprovalService.addWorkflow(workflowB);
    periodA = createPeriod(new MonthlyPeriodType(), getDate(2017, 1, 1), getDate(2017, 1, 31));
    periodB = createPeriod(new MonthlyPeriodType(), getDate(2018, 1, 1), getDate(2018, 1, 31));
    periodService.addPeriod(periodA);
    periodService.addPeriod(periodB);
    sourceA = createOrganisationUnit('A');
    sourceB = createOrganisationUnit('B', sourceA);
    organisationUnitService.addOrganisationUnit(sourceA);
    organisationUnitService.addOrganisationUnit(sourceB);
    userA = createUser('A');
    userService.addUser(userA);
    optionA = new DataElementCategoryOption("CategoryOptionA");
    optionB = new DataElementCategoryOption("CategoryOptionB");
    categoryService.addDataElementCategoryOption(optionA);
    categoryService.addDataElementCategoryOption(optionB);
    categoryA = createDataElementCategory('A', optionA, optionB);
    categoryService.addDataElementCategory(categoryA);
    categoryComboA = createCategoryCombo('A', categoryA);
    categoryService.addDataElementCategoryCombo(categoryComboA);
    optionComboA = createCategoryOptionCombo('A', categoryComboA, optionA);
    optionComboB = createCategoryOptionCombo('B', categoryComboA, optionA, optionB);
    categoryService.addDataElementCategoryOptionCombo(optionComboA);
    categoryService.addDataElementCategoryOptionCombo(optionComboB);
    dateA = getDate(2017, 1, 1);
    dateB = getDate(2018, 1, 1);
    DataApproval approvalA = new DataApproval(level1, workflowA, periodA, sourceA, optionComboA, false, dateA, userA);
    DataApproval approvalB = new DataApproval(level2, workflowB, periodB, sourceB, optionComboB, false, dateB, userA);
    auditA = new DataApprovalAudit(approvalA, APPROVE);
    auditB = new DataApprovalAudit(approvalB, UNAPPROVE);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption)

Example 9 with MonthlyPeriodType

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

the class DataValueSetServiceIntegrationTest method setUpTest.

@Override
public void setUpTest() {
    deA = createDataElement('A');
    deB = createDataElement('B');
    deC = createDataElement('C');
    deA.setUid("f7n9E0hX8qk");
    deB.setUid("Ix2HsbDMLea");
    deC.setUid("eY5ehpbEsB7");
    idObjectManager.save(deA);
    idObjectManager.save(deB);
    idObjectManager.save(deC);
    ptA = new MonthlyPeriodType();
    dsA = createDataSet('A', ptA);
    dsA.setUid("pBOMPrpg1QX");
    dataSetService.addDataSet(dsA);
    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));
    periodService.addPeriod(peA);
    periodService.addPeriod(peB);
    periodService.addPeriod(peC);
    ouA = createOrganisationUnit('A');
    ouB = createOrganisationUnit('B');
    ouC = createOrganisationUnit('C');
    ouA.setUid("DiszpKrYNg8");
    ouB.setUid("BdfsJfj87js");
    ouC.setUid("j7Hg26FpoIa");
    idObjectManager.save(ouA);
    idObjectManager.save(ouB);
    idObjectManager.save(ouC);
    user = createUser('A');
    user.setOrganisationUnits(Sets.newHashSet(ouA, ouB, ouC));
    CurrentUserService currentUserService = new MockCurrentUserService(user);
    setDependency(dataValueSetService, "currentUserService", currentUserService);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) MockCurrentUserService(org.hisp.dhis.mock.MockCurrentUserService) MockCurrentUserService(org.hisp.dhis.mock.MockCurrentUserService) CurrentUserService(org.hisp.dhis.user.CurrentUserService)

Example 10 with MonthlyPeriodType

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

the class FacilityReportingServiceImpl method getMobileDataSetsForUnit.

// -------------------------------------------------------------------------
// Service methods
// -------------------------------------------------------------------------
@Override
public List<DataSet> getMobileDataSetsForUnit(OrganisationUnit unit, String localeString) {
    List<DataSet> datasets = new ArrayList<>();
    Locale locale = LocaleUtil.getLocale(localeString);
    if (DEBUG)
        log.debug("Getting data sets for unit " + unit.getName());
    for (org.hisp.dhis.dataset.DataSet dataSet : dataSetService.getDataSetsForMobile(unit)) {
        PeriodType periodType = dataSet.getPeriodType();
        if (periodType instanceof DailyPeriodType || periodType instanceof WeeklyPeriodType || periodType instanceof MonthlyPeriodType || periodType instanceof YearlyPeriodType || periodType instanceof QuarterlyPeriodType) {
            if (DEBUG)
                log.debug("Found data set " + dataSet.getName());
            datasets.add(getDataSetForLocale(dataSet.getId(), locale));
        } else {
            log.warn("Dataset '" + dataSet.getName() + "' set to be reported from mobile, but not of a supported period type: " + periodType.getName());
        }
    }
    return datasets;
}
Also used : Locale(java.util.Locale) DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) WeeklyPeriodType(org.hisp.dhis.period.WeeklyPeriodType) DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) DataSet(org.hisp.dhis.api.mobile.model.DataSet) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) ArrayList(java.util.ArrayList) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) WeeklyPeriodType(org.hisp.dhis.period.WeeklyPeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType)

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