dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20195
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9119: Impl new version of period resource table with null values for disaggregated period values
------------------------------------------------------------
revno: 9119
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-25 21:54:29 +0100
message:
Impl new version of period resource table with null values for disaggregated period values
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java 2012-11-25 20:18:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java 2012-11-25 20:54:29 +0000
@@ -74,6 +74,9 @@
/**
* Generates a resource table for all periods.
+ *
+ * @param noDisaggregation whether to include period types with higher
+ * frequency order than the period itself.
*/
- void generatePeriodTable();
+ void generatePeriodTable( boolean noDisaggregation );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java 2012-11-25 20:18:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java 2012-11-25 20:54:29 +0000
@@ -45,6 +45,7 @@
final String TABLE_NAME_ORGANISATION_UNIT_STRUCTURE = "_orgunitstructure";
final String TABLE_NAME_DATA_ELEMENT_STRUCTURE = "_dataelementstructure";
final String TABLE_NAME_PERIOD_STRUCTURE = "_periodstructure";
+ final String TABLE_NAME_PERIOD_NO_DISAGGREGATION_STRUCTURE = "_period_no_disaggregation_structure";
// -------------------------------------------------------------------------
// OrganisationUnitStructure
@@ -104,5 +105,5 @@
/**
* Creates table.
*/
- void createPeriodStructure();
+ void createPeriodStructure( boolean noDisaggregation );
}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java 2012-11-25 20:18:52 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java 2012-11-25 20:54:29 +0000
@@ -64,6 +64,8 @@
import org.hisp.dhis.resourcetable.statement.CreateIndicatorGroupSetTableStatement;
import org.hisp.dhis.resourcetable.statement.CreateOrganisationUnitGroupSetTableStatement;
+import static org.hisp.dhis.resourcetable.ResourceTableStore.*;
+
/**
* @author Lars Helge Overland
* @version $Id: DefaultResourceTableService.java 5459 2008-06-26 01:12:03Z
@@ -440,7 +442,7 @@
// PeriodTable
// -------------------------------------------------------------------------
- public void generatePeriodTable()
+ public void generatePeriodTable( boolean noDisaggregation )
{
// ---------------------------------------------------------------------
// Create table
@@ -448,18 +450,21 @@
Collection<Period> periods = periodService.getAllPeriods();
- resourceTableStore.createPeriodStructure();
+ resourceTableStore.createPeriodStructure( noDisaggregation );
// ---------------------------------------------------------------------
// Populate table
// ---------------------------------------------------------------------
+ String tableName = noDisaggregation ? TABLE_NAME_PERIOD_NO_DISAGGREGATION_STRUCTURE : TABLE_NAME_PERIOD_STRUCTURE;
+
BatchHandler<Object> batchHandler = batchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).
- setTableName( ResourceTableStore.TABLE_NAME_PERIOD_STRUCTURE ).init();
+ setTableName( tableName ).init();
for ( Period period : periods )
{
final Date startDate = period.getStartDate();
+ final PeriodType rowType = period.getPeriodType();
final List<String> values = new ArrayList<String>();
@@ -467,7 +472,14 @@
for ( PeriodType periodType : PeriodType.PERIOD_TYPES )
{
- values.add( periodType.createPeriod( startDate ).getIsoDate() );
+ if ( rowType.getFrequencyOrder() <= periodType.getFrequencyOrder() || !noDisaggregation )
+ {
+ values.add( periodType.createPeriod( startDate ).getIsoDate() );
+ }
+ else
+ {
+ values.add( null );
+ }
}
batchHandler.addObject( values );
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java 2012-11-25 20:18:52 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java 2012-11-25 20:54:29 +0000
@@ -228,18 +228,20 @@
// PeriodTable
// -------------------------------------------------------------------------
- public void createPeriodStructure()
+ public void createPeriodStructure( boolean noDisaggregation )
{
+ String tableName = noDisaggregation ? TABLE_NAME_PERIOD_NO_DISAGGREGATION_STRUCTURE : TABLE_NAME_PERIOD_STRUCTURE;
+
try
{
- jdbcTemplate.update( "DROP TABLE " + TABLE_NAME_PERIOD_STRUCTURE );
+ jdbcTemplate.update( "DROP TABLE " + tableName );
}
catch ( BadSqlGrammarException ex )
{
// Do nothing, table does not exist
}
- String sql = "CREATE TABLE " + TABLE_NAME_PERIOD_STRUCTURE + " (periodid INTEGER NOT NULL";
+ String sql = "CREATE TABLE " + tableName + " (periodid INTEGER NOT NULL";
for ( PeriodType periodType : PeriodType.PERIOD_TYPES )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2012-11-25 20:18:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2012-11-25 20:54:29 +0000
@@ -169,7 +169,8 @@
if ( periodStructure )
{
- resourceTableService.generatePeriodTable();
+ resourceTableService.generatePeriodTable( false );
+ resourceTableService.generatePeriodTable( true );
}
log.info( "Generated resource tables" );