Search in sources :

Example 91 with PeriodType

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

the class PeriodResourceTable method getCreateTempTableStatement.

@Override
public String getCreateTempTableStatement() {
    String sql = "create table " + getTempTableName() + " (periodid bigint not null primary key, iso varchar(15) not null, daysno integer not null, startdate date not null, enddate date not null, year integer not null";
    for (PeriodType periodType : PeriodType.PERIOD_TYPES) {
        sql += ", " + quote(periodType.getName().toLowerCase()) + " varchar(15)";
    }
    sql += ")";
    return sql;
}
Also used : WeeklyAbstractPeriodType(org.hisp.dhis.period.WeeklyAbstractPeriodType) PeriodType(org.hisp.dhis.period.PeriodType)

Example 92 with PeriodType

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

the class DataOrgUnitSplitHandlerTest method setUpTest.

@Override
public void setUpTest() {
    cocA = categoryService.getDefaultCategoryOptionCombo();
    deA = createDataElement('A');
    deB = createDataElement('B');
    idObjectManager.save(deA);
    idObjectManager.save(deB);
    PeriodType monthly = periodService.getPeriodTypeByClass(MonthlyPeriodType.class);
    peA = monthly.createPeriod("202101");
    peB = monthly.createPeriod("202102");
    periodService.addPeriod(peA);
    periodService.addPeriod(peB);
    ouA = createOrganisationUnit('A');
    ouB = createOrganisationUnit('B');
    ouC = createOrganisationUnit('C');
    idObjectManager.save(ouA);
    idObjectManager.save(ouB);
    idObjectManager.save(ouC);
    usA = createUser('A');
    userService.addUser(usA);
    dlA = new DataApprovalLevel("DataApprovalLevelA", 1);
    idObjectManager.save(dlA);
    dwA = new DataApprovalWorkflow("DataApprovalWorkflowA", monthly, Sets.newHashSet(dlA));
    idObjectManager.save(dwA);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow)

Example 93 with PeriodType

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

the class DataElementResourceTable method getPopulateTempTableContent.

@Override
public Optional<List<Object[]>> getPopulateTempTableContent() {
    List<Object[]> batchArgs = new ArrayList<>();
    for (DataElement dataElement : objects) {
        List<Object> values = new ArrayList<>();
        final DataSet dataSet = dataElement.getApprovalDataSet();
        final PeriodType periodType = dataElement.getPeriodType();
        // -----------------------------------------------------------------
        // Use highest approval level if data set does not require approval,
        // or null if approval is required.
        // -----------------------------------------------------------------
        values.add(dataElement.getId());
        values.add(dataElement.getUid());
        values.add(dataElement.getName());
        values.add(dataSet != null ? dataSet.getId() : null);
        values.add(dataSet != null ? dataSet.getUid() : null);
        values.add(dataSet != null ? dataSet.getName() : null);
        values.add(dataSet != null && dataSet.isApproveData() ? null : APPROVAL_LEVEL_HIGHEST);
        values.add(dataSet != null && dataSet.isApproveData() ? dataSet.getWorkflow().getId() : null);
        values.add(periodType != null ? periodType.getId() : null);
        values.add(periodType != null ? periodType.getName() : null);
        batchArgs.add(values.toArray());
    }
    return Optional.of(batchArgs);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) PeriodType(org.hisp.dhis.period.PeriodType) DataSet(org.hisp.dhis.dataset.DataSet) ArrayList(java.util.ArrayList)

Example 94 with PeriodType

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

the class DatePeriodResourceTable method getCreateTempTableStatement.

@Override
public String getCreateTempTableStatement() {
    String sql = "create table " + getTempTableName() + " (dateperiod date not null primary key, year integer not null";
    for (PeriodType periodType : PeriodType.PERIOD_TYPES) {
        sql += ", " + quote(periodType.getName().toLowerCase()) + " varchar(15)";
    }
    sql += ")";
    return sql;
}
Also used : DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType)

Example 95 with PeriodType

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

the class JdbcValidationResultTableManager method getDimensionColumns.

private List<AnalyticsTableColumn> getDimensionColumns() {
    List<AnalyticsTableColumn> columns = new ArrayList<>();
    List<OrganisationUnitGroupSet> orgUnitGroupSets = idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class);
    List<OrganisationUnitLevel> levels = organisationUnitService.getFilledOrganisationUnitLevels();
    List<Category> attributeCategories = categoryService.getAttributeDataDimensionCategoriesNoAcl();
    for (OrganisationUnitGroupSet groupSet : orgUnitGroupSets) {
        columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "ougs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
    }
    for (OrganisationUnitLevel level : levels) {
        String column = quote(PREFIX_ORGUNITLEVEL + level.getLevel());
        columns.add(new AnalyticsTableColumn(column, CHARACTER_11, "ous." + column).withCreated(level.getCreated()));
    }
    for (Category category : attributeCategories) {
        columns.add(new AnalyticsTableColumn(quote(category.getUid()), CHARACTER_11, "acs." + quote(category.getUid())).withCreated(category.getCreated()));
    }
    for (PeriodType periodType : PeriodType.getAvailablePeriodTypes()) {
        String column = quote(periodType.getName().toLowerCase());
        columns.add(new AnalyticsTableColumn(column, TEXT, "ps." + column));
    }
    columns.addAll(getFixedColumns());
    return filterDimensionColumns(columns);
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) Category(org.hisp.dhis.category.Category) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) ArrayList(java.util.ArrayList) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) DateUtils.getLongDateString(org.hisp.dhis.util.DateUtils.getLongDateString) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)

Aggregations

PeriodType (org.hisp.dhis.period.PeriodType)104 Period (org.hisp.dhis.period.Period)27 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)24 DataElement (org.hisp.dhis.dataelement.DataElement)17 DataSet (org.hisp.dhis.dataset.DataSet)17 ArrayList (java.util.ArrayList)15 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)13 Test (org.junit.jupiter.api.Test)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)11 Date (java.util.Date)10 DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)8 ProgramStage (org.hisp.dhis.program.ProgramStage)8 HashMap (java.util.HashMap)7 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)7 Expression (org.hisp.dhis.expression.Expression)7 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)7 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)6 Program (org.hisp.dhis.program.Program)6 Property (org.hisp.dhis.schema.Property)6 Schema (org.hisp.dhis.schema.Schema)6