Search in sources :

Example 1 with AnalyticsTable

use of org.hisp.dhis.analytics.AnalyticsTable in project dhis2-core by dhis2.

the class AnalyticsTableTest method testGetTableName.

@Test
public void testGetTableName() {
    Program program = new Program("ProgramA", "DescriptionA");
    program.setUid("UIDA");
    Period period = new YearlyPeriodType().createPeriod(new DateTime(2014, 1, 1, 0, 0).toDate());
    AnalyticsTable tableA = new AnalyticsTable("analytics_event", null, period, program);
    assertEquals("analytics_event_2014_uida", tableA.getTableName());
}
Also used : Program(org.hisp.dhis.program.Program) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) Period(org.hisp.dhis.period.Period) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 2 with AnalyticsTable

use of org.hisp.dhis.analytics.AnalyticsTable in project dhis2-core by dhis2.

the class AnalyticsTableTest method testEquals.

@Test
public void testEquals() {
    Period periodA = new YearlyPeriodType().createPeriod(new DateTime(2014, 1, 1, 0, 0).toDate());
    Period periodB = new YearlyPeriodType().createPeriod(new DateTime(2015, 1, 1, 0, 0).toDate());
    AnalyticsTable tableA = new AnalyticsTable("analytics", null, periodA);
    AnalyticsTable tableB = new AnalyticsTable("analytics", null, periodA);
    AnalyticsTable tableC = new AnalyticsTable("analytics", null, periodB);
    List<AnalyticsTable> uniqueList = new UniqueArrayList<>();
    uniqueList.add(tableA);
    uniqueList.add(tableB);
    uniqueList.add(tableC);
    assertEquals(2, uniqueList.size());
}
Also used : AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) Period(org.hisp.dhis.period.Period) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) UniqueArrayList(org.hisp.dhis.commons.collection.UniqueArrayList) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 3 with AnalyticsTable

use of org.hisp.dhis.analytics.AnalyticsTable in project dhis2-core by dhis2.

the class JdbcEventAnalyticsTableManager method getTables.

@Override
@Transactional
public List<AnalyticsTable> getTables(Date earliest) {
    log.info(String.format("Get tables using earliest: %s, spatial support: %b", earliest, databaseInfo.isSpatialSupport()));
    List<AnalyticsTable> tables = new UniqueArrayList<>();
    Calendar calendar = PeriodType.getCalendar();
    String baseName = getTableName();
    List<Program> programs = idObjectManager.getAllNoAcl(Program.class);
    for (Program program : programs) {
        List<Integer> dataYears = getDataYears(program, earliest);
        Collections.sort(dataYears);
        for (Integer year : dataYears) {
            Period period = PartitionUtils.getPeriod(calendar, year);
            AnalyticsTable table = new AnalyticsTable(baseName, null, period, program);
            List<AnalyticsTableColumn> dimensionColumns = getDimensionColumns(table);
            table.setDimensionColumns(dimensionColumns);
            tables.add(table);
        }
    }
    return tables;
}
Also used : Program(org.hisp.dhis.program.Program) AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) Calendar(org.hisp.dhis.calendar.Calendar) Period(org.hisp.dhis.period.Period) UniqueArrayList(org.hisp.dhis.commons.collection.UniqueArrayList) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with AnalyticsTable

use of org.hisp.dhis.analytics.AnalyticsTable in project dhis2-core by dhis2.

the class JdbcOrgUnitTargetTableManager method getTables.

@Override
@Transactional
public List<AnalyticsTable> getTables(Date earliest) {
    List<AnalyticsTable> tables = new ArrayList<>();
    tables.add(new AnalyticsTable(getTableName(), getDimensionColumns(null)));
    return tables;
}
Also used : AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with AnalyticsTable

use of org.hisp.dhis.analytics.AnalyticsTable in project dhis2-core by dhis2.

the class JdbcCompletenessTargetTableManager method getTables.

@Override
@Transactional
public List<AnalyticsTable> getTables(Date earliest) {
    List<AnalyticsTable> tables = new ArrayList<>();
    tables.add(new AnalyticsTable(getTableName(), getDimensionColumns(null)));
    return tables;
}
Also used : AnalyticsTable(org.hisp.dhis.analytics.AnalyticsTable) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AnalyticsTable (org.hisp.dhis.analytics.AnalyticsTable)7 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)4 Period (org.hisp.dhis.period.Period)4 Program (org.hisp.dhis.program.Program)3 Transactional (org.springframework.transaction.annotation.Transactional)3 ArrayList (java.util.ArrayList)2 AnalyticsTableColumn (org.hisp.dhis.analytics.AnalyticsTableColumn)2 Calendar (org.hisp.dhis.calendar.Calendar)2 YearlyPeriodType (org.hisp.dhis.period.YearlyPeriodType)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.Test)2