PartitionUtils { public static List<AnalyticsTablePartition> getTablePartitions( List<AnalyticsTable> tables ) { final List<AnalyticsTablePartition> partitions = Lists.newArrayList(); for ( AnalyticsTable table : tables ) { if ( table.hasPartitionTables() ) { partitions.addAll( table.getTablePartitions() ); } else { partitions.add( new AnalyticsTablePartition( table, null, null, null, false ) ); } } return partitions; }  static Date getStartDate( Calendar calendar, Integer year ); static Date getEndDate( Calendar calendar, Integer year ); static String getTableName( String baseName, Program program ); static Partitions getPartitions( List<DimensionalItemObject> periods ); static Partitions getPartitions( Period period ); static Partitions getPartitions( Date startDate, Date endDate ); static Partitions getPartitions( DataQueryParams params, AnalyticsTableType tableType ); static ListMap<String, DimensionalItemObject> getPeriodTypePeriodMap( Collection<DimensionalItemObject> periods ); static List<AnalyticsTablePartition> getTablePartitions( List<AnalyticsTable> tables ); static AnalyticsTablePartition getLatestTablePartition( List<AnalyticsTable> tables ); static String getPartitionName( String tableName, Integer partition ); static final String SEP; }
@Test public void testGetTablePartitions() { List<AnalyticsTableColumn> dimensions = Lists.newArrayList( new AnalyticsTableColumn( "dx", TEXT, "dx" ) ); List<AnalyticsTableColumn> values = Lists.newArrayList( new AnalyticsTableColumn( "value", DOUBLE, "value" ) ); AnalyticsTable tA = new AnalyticsTable( AnalyticsTableType.DATA_VALUE, dimensions, values ); tA.addPartitionTable( 2010, new DateTime( 2010, 1, 1, 0, 0 ).toDate(), new DateTime( 2010, 12, 31, 0, 0 ).toDate() ); tA.addPartitionTable( 2011, new DateTime( 2011, 1, 1, 0, 0 ).toDate(), new DateTime( 2011, 12, 31, 0, 0 ).toDate() ); AnalyticsTable tB = new AnalyticsTable( AnalyticsTableType.ORG_UNIT_TARGET, dimensions, values ); List<AnalyticsTablePartition> partitions = PartitionUtils.getTablePartitions( Lists.newArrayList( tA, tB ) ); assertEquals( 3, partitions.size() ); }