dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21532
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10205: Report table, now using foreign key to RelativePeriods entity instead of embedding relative perio...
------------------------------------------------------------
revno: 10205
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 11:12:47 +0100
message:
Report table, now using foreign key to RelativePeriods entity instead of embedding relative periods using component mapping.
added:
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/RelativePeriodsBatchHandler.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ReportTableBatchHandler.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/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2013-03-14 10:12:47 +0000
@@ -366,6 +366,11 @@
return userOrganisationUnit || userOrganisationUnitChildren;
}
+ public boolean hasRelativePeriods()
+ {
+ return relatives != null && !relatives.isEmpty();
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2013-03-14 10:12:47 +0000
@@ -285,6 +285,14 @@
return this;
}
+
+ /**
+ * Indicates whether this object contains at least one relative period.
+ */
+ public boolean isEmpty()
+ {
+ return getRelativePeriods().isEmpty();
+ }
/**
* Returns the period type for the option with the lowest frequency.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java 2013-03-14 10:12:47 +0000
@@ -126,7 +126,7 @@
*/
public boolean hasRelativePeriods()
{
- return relatives != null && !relatives.getRelativePeriods().isEmpty();
+ return relatives != null && !relatives.isEmpty();
}
/**
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2013-03-12 13:44:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2013-03-14 10:12:47 +0000
@@ -897,7 +897,7 @@
*/
public boolean hasRelativePeriods()
{
- return relatives != null && !relatives.getRelativePeriods().isEmpty();
+ return relatives != null && !relatives.isEmpty();
}
public boolean isDoIndicators()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-03-13 16:50:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-03-14 10:12:47 +0000
@@ -34,11 +34,17 @@
import java.util.List;
import java.util.Map;
+import org.amplecode.quick.BatchHandler;
+import org.amplecode.quick.BatchHandlerFactory;
import org.amplecode.quick.StatementHolder;
import org.amplecode.quick.StatementManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.jdbc.StatementBuilder;
+import org.hisp.dhis.jdbc.batchhandler.RelativePeriodsBatchHandler;
+import org.hisp.dhis.period.RelativePeriods;
import org.hisp.dhis.system.startup.AbstractStartupRoutine;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -53,12 +59,14 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
private StatementManager statementManager;
-
- public void setStatementManager( StatementManager statementManager )
- {
- this.statementManager = statementManager;
- }
+
+ @Autowired
+ private StatementBuilder statementBuilder;
+
+ @Autowired
+ private BatchHandlerFactory batchHandlerFactory;
// -------------------------------------------------------------------------
// Execute
@@ -528,6 +536,7 @@
executeSql( "ALTER TABLE datadictionary DROP CONSTRAINT datadictionary_name_key" );
upgradeReportTableColumns();
+ upgradeReportTableRelativePeriods();
// clear out sharing of de-group/de-group-set for now
executeSql( "UPDATE dataelementgroup SET userid=NULL WHERE userid IS NOT NULL" );
@@ -542,6 +551,83 @@
log.info( "Tables updated" );
}
+ private void upgradeReportTableRelativePeriods()
+ {
+ BatchHandler<RelativePeriods> batchHandler = batchHandlerFactory.createBatchHandler( RelativePeriodsBatchHandler.class ).init();
+
+ try
+ {
+ String sql = "select reportingmonth, * from reporttable";
+
+ ResultSet rs = statementManager.getHolder().getStatement().executeQuery( sql );
+
+ while ( rs.next() )
+ {
+ RelativePeriods r = new RelativePeriods(
+ rs.getBoolean( "reportingmonth" ),
+ rs.getBoolean( "reportingbimonth" ),
+ rs.getBoolean( "reportingquarter" ),
+ rs.getBoolean( "lastsixmonth" ),
+ rs.getBoolean( "monthsthisyear" ),
+ rs.getBoolean( "quartersthisyear" ),
+ rs.getBoolean( "thisyear" ),
+ rs.getBoolean( "monthslastyear" ),
+ rs.getBoolean( "quarterslastyear" ),
+ rs.getBoolean( "lastyear" ),
+ rs.getBoolean( "last5years" ),
+ rs.getBoolean( "last12months" ),
+ rs.getBoolean( "last3months" ),
+ false,
+ rs.getBoolean( "last4quarters" ),
+ rs.getBoolean( "last2sixmonths" ),
+ rs.getBoolean( "thisfinancialyear" ),
+ rs.getBoolean( "lastfinancialyear" ),
+ rs.getBoolean( "last5financialyears" ),
+ false, false, false );
+
+ int reportTableId = rs.getInt( "reporttableid" );
+
+ if ( !r.isEmpty() )
+ {
+ int relativePeriodsId = batchHandler.insertObject( r, true );
+
+ String update = "update reporttable set relativeperiodsid=" + relativePeriodsId + " where reporttableid=" + reportTableId;
+
+ executeSql( update );
+
+ log.info( "Updated relative periods for report table with id: " + reportTableId );
+ }
+ }
+
+ executeSql( "alter table reporttable drop column reportingmonth" );
+ executeSql( "alter table reporttable drop column reportingbimonth" );
+ executeSql( "alter table reporttable drop column reportingquarter" );
+ executeSql( "alter table reporttable drop column lastsixmonth" );
+ executeSql( "alter table reporttable drop column monthsthisyear" );
+ executeSql( "alter table reporttable drop column quartersthisyear" );
+ executeSql( "alter table reporttable drop column thisyear" );
+ executeSql( "alter table reporttable drop column monthslastyear" );
+ executeSql( "alter table reporttable drop column quarterslastyear" );
+ executeSql( "alter table reporttable drop column lastyear" );
+ executeSql( "alter table reporttable drop column last5years" );
+ executeSql( "alter table reporttable drop column last12months" );
+ executeSql( "alter table reporttable drop column last3months" );
+ executeSql( "alter table reporttable drop column last4quarters" );
+ executeSql( "alter table reporttable drop column last2sixmonths" );
+ executeSql( "alter table reporttable drop column thisfinancialyear" );
+ executeSql( "alter table reporttable drop column lastfinancialyear" );
+ executeSql( "alter table reporttable drop column last5financialyears" );
+ }
+ catch ( Exception ex )
+ {
+ log.warn( ex );
+ }
+ finally
+ {
+ batchHandler.flush();
+ }
+ }
+
private void upgradeReportTableColumns()
{
try
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-03-12 19:32:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-03-14 10:12:47 +0000
@@ -720,7 +720,6 @@
<!-- Startup routine definitions -->
<bean id="org.hisp.dhis.startup.TableAlteror" class="org.hisp.dhis.startup.TableAlteror">
- <property name="statementManager" ref="statementManager" />
<property name="name" value="TableAlteror" />
<property name="runlevel" value="1" />
<property name="skipInTests" value="true" />
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-02-06 14:45:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2013-03-14 10:12:47 +0000
@@ -181,7 +181,7 @@
public JFreeChart getJFreeChart( Chart chart, Date date, OrganisationUnit unit, I18nFormat format )
{
- if ( chart.getRelatives() != null )
+ if ( chart.hasRelativePeriods() )
{
List<Period> periods = chart.isRewindRelativePeriods() ?
chart.getRelatives().getRewindedRelativePeriods( 1, date, format, true ) :
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2013-02-08 07:18:39 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2013-03-14 10:12:47 +0000
@@ -234,7 +234,7 @@
* report table parameters.
*
* @param reportTable the report table.
- * @param reportingPeriod the reporting period number.
+ * @param reportingPeriod the reporting period start date.
* @param organisationUnitId the organisation unit identifier.
* @param format the I18n format.
* @return a report table.
@@ -248,7 +248,7 @@
log.info( "Running report table: " + reportTable.getName() );
- if ( reportTable.getReportParams() != null && reportTable.getReportParams().isParamReportingMonth() )
+ if ( reportTable.hasRelativePeriods() && reportTable.getReportParams() != null && reportTable.getReportParams().isParamReportingMonth() )
{
reportTable.setRelativePeriods( periodService.reloadPeriods( reportTable.getRelatives().getRelativePeriods(
reportingPeriod, format, !reportTable.isDoPeriods() ) ) );
@@ -257,7 +257,7 @@
log.info( "Reporting period date from report param: " + reportTable.getReportingPeriodName() );
}
- else
+ else if ( reportTable.hasRelativePeriods() )
{
reportTable.setRelativePeriods( periodService.reloadPeriods( reportTable.getRelatives().getRelativePeriods(
format, !reportTable.isDoPeriods() ) ) );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2013-03-12 13:44:27 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2013-03-14 10:12:47 +0000
@@ -102,26 +102,8 @@
<element type="string" column="dimension" />
</list>
- <component name="relatives">
- <property name="reportingMonth" />
- <property name="reportingBimonth" />
- <property name="reportingQuarter" />
- <property name="lastSixMonth" />
- <property name="monthsThisYear" />
- <property name="quartersThisYear" />
- <property name="thisYear" />
- <property name="monthsLastYear" />
- <property name="quartersLastYear" />
- <property name="lastYear" />
- <property name="last5Years" />
- <property name="last12Months" />
- <property name="last3Months" />
- <property name="last4Quarters" />
- <property name="last2SixMonths" />
- <property name="thisFinancialYear" />
- <property name="lastFinancialYear" />
- <property name="last5FinancialYears" />
- </component>
+ <many-to-one name="relatives" unique="true" class="org.hisp.dhis.period.RelativePeriods" column="relativeperiodsid"
+ cascade="all-delete-orphan" foreign-key="fk_report_relativeperiodsid" />
<component name="reportParams">
<property name="paramReportingMonth" />
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java 2013-02-26 17:45:20 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java 2013-03-14 10:12:47 +0000
@@ -93,7 +93,9 @@
private OrganisationUnit unitA;
private OrganisationUnit unitB;
- private RelativePeriods relatives;
+ private RelativePeriods relativesA;
+ private RelativePeriods relativesB;
+ private RelativePeriods relativesC;
private I18nFormat i18nFormat;
@@ -170,10 +172,17 @@
units.add( unitA );
units.add( unitB );
- relatives = new RelativePeriods();
-
- relatives.setReportingMonth( true );
- relatives.setThisYear( true );
+ relativesA = new RelativePeriods();
+ relativesA.setReportingMonth( true );
+ relativesA.setThisYear( true );
+
+ relativesB = new RelativePeriods();
+ relativesB.setReportingMonth( true );
+ relativesB.setThisYear( true );
+
+ relativesC = new RelativePeriods();
+ relativesC.setReportingMonth( true );
+ relativesC.setThisYear( true );
i18nFormat = new MockI18nFormat();
}
@@ -183,13 +192,13 @@
{
ReportTable reportTableA = new ReportTable( "Immunization",
new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relativesA, null, i18nFormat, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relativesB, null, i18nFormat, "january_2000" );
ReportTable reportTableC = new ReportTable( "Assualt",
new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relativesC, null, i18nFormat, "january_2000" );
int idA = reportTableStore.save( reportTableA );
int idB = reportTableStore.save( reportTableB );
@@ -207,7 +216,7 @@
assertEquals( true, reportTableA.isDoIndicators() );
assertEquals( true, reportTableA.isDoPeriods() );
assertEquals( false, reportTableA.isDoUnits() );
- assertEquals( relatives, reportTableA.getRelatives() );
+ assertEquals( relativesA, reportTableA.getRelatives() );
assertEquals( "Prescriptions", reportTableB.getName() );
assertEquals( dataElements, reportTableB.getDataElements() );
@@ -217,7 +226,7 @@
assertEquals( false, reportTableB.isDoIndicators() );
assertEquals( false, reportTableB.isDoPeriods() );
assertEquals( true, reportTableB.isDoUnits() );
- assertEquals( relatives, reportTableB.getRelatives() );
+ assertEquals( relativesB, reportTableB.getRelatives() );
assertEquals( "Assualt", reportTableC.getName() );
assertEquals( dataSets, reportTableC.getDataSets() );
@@ -227,7 +236,7 @@
assertEquals( false, reportTableC.isDoIndicators() );
assertEquals( false, reportTableC.isDoPeriods() );
assertEquals( true, reportTableC.isDoUnits() );
- assertEquals( relatives, reportTableC.getRelatives() );
+ assertEquals( relativesC, reportTableC.getRelatives() );
}
@Test
@@ -235,10 +244,10 @@
{
ReportTable reportTableA = new ReportTable( "Immunization",
new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relativesA, null, i18nFormat, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relativesB, null, i18nFormat, "january_2000" );
int idA = reportTableStore.save( reportTableA );
int idB = reportTableStore.save( reportTableB );
@@ -262,10 +271,10 @@
{
ReportTable reportTableA = new ReportTable( "Immunization",
new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relativesA, null, i18nFormat, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relativesB, null, i18nFormat, "january_2000" );
reportTableStore.save( reportTableA );
reportTableStore.save( reportTableB );
@@ -281,10 +290,10 @@
{
ReportTable reportTableA = new ReportTable( "Immunization",
new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relativesA, null, i18nFormat, "january_2000" );
ReportTable reportTableB = new ReportTable( "Prescriptions",
dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+ new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relativesB, null, i18nFormat, "january_2000" );
reportTableStore.save( reportTableA );
reportTableStore.save( reportTableB );
=== added file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/RelativePeriodsBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/RelativePeriodsBatchHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/RelativePeriodsBatchHandler.java 2013-03-14 10:12:47 +0000
@@ -0,0 +1,131 @@
+package org.hisp.dhis.jdbc.batchhandler;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.amplecode.quick.JdbcConfiguration;
+import org.amplecode.quick.batchhandler.AbstractBatchHandler;
+import org.hisp.dhis.period.RelativePeriods;
+
+public class RelativePeriodsBatchHandler
+ extends AbstractBatchHandler<RelativePeriods>
+{
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
+ public RelativePeriodsBatchHandler( JdbcConfiguration configuration )
+ {
+ super( configuration, false, false );
+ }
+ // -------------------------------------------------------------------------
+ // AbstractBatchHandler implementation
+ // -------------------------------------------------------------------------
+
+ protected void setTableName()
+ {
+ statementBuilder.setTableName( "relativeperiods" );
+ }
+
+ @Override
+ protected void setAutoIncrementColumn()
+ {
+ statementBuilder.setAutoIncrementColumn( "relativeperiodsid" );
+ }
+
+ @Override
+ protected void setIdentifierColumns()
+ {
+ statementBuilder.setIdentifierColumn( "relativeperiodsid" );
+ }
+
+ @Override
+ protected void setIdentifierValues( RelativePeriods relatives )
+ {
+ statementBuilder.setIdentifierValue( relatives.getId() );
+ }
+
+ @Override
+ protected void setUniqueColumns()
+ {
+ }
+
+ @Override
+ protected void setUniqueValues( RelativePeriods relatives )
+ {
+ }
+
+ @Override
+ protected void setColumns()
+ {
+ statementBuilder.setColumn( "reportingmonth" );
+ statementBuilder.setColumn( "reportingbimonth" );
+ statementBuilder.setColumn( "reportingquarter" );
+ statementBuilder.setColumn( "lastsixmonth" );
+ statementBuilder.setColumn( "monthsthisyear" );
+ statementBuilder.setColumn( "quartersthisyear" );
+ statementBuilder.setColumn( "thisyear" );
+ statementBuilder.setColumn( "monthslastyear" );
+ statementBuilder.setColumn( "quarterslastyear" );
+ statementBuilder.setColumn( "lastyear" );
+ statementBuilder.setColumn( "last5years" );
+ statementBuilder.setColumn( "last12months" );
+ statementBuilder.setColumn( "last3months" );
+ statementBuilder.setColumn( "last6bimonths" );
+ statementBuilder.setColumn( "last4quarters" );
+ statementBuilder.setColumn( "last2sixmonths" );
+ statementBuilder.setColumn( "thisfinancialyear" );
+ statementBuilder.setColumn( "lastfinancialyear" );
+ statementBuilder.setColumn( "last5financialyears" );
+ statementBuilder.setColumn( "last52weeks" );
+ }
+
+ @Override
+ protected void setValues( RelativePeriods relatives )
+ {
+ statementBuilder.setValue( relatives.isReportingMonth() );
+ statementBuilder.setValue( relatives.isReportingBimonth() );
+ statementBuilder.setValue( relatives.isReportingQuarter() );
+ statementBuilder.setValue( relatives.isLastSixMonth() );
+ statementBuilder.setValue( relatives.isMonthsThisYear() );
+ statementBuilder.setValue( relatives.isQuartersThisYear() );
+ statementBuilder.setValue( relatives.isThisYear() );
+ statementBuilder.setValue( relatives.isMonthsLastYear() );
+ statementBuilder.setValue( relatives.isQuartersLastYear() );
+ statementBuilder.setValue( relatives.isLastYear() );
+ statementBuilder.setValue( relatives.isLast5Years() );
+ statementBuilder.setValue( relatives.isLast12Months() );
+ statementBuilder.setValue( relatives.isLast3Months() );
+ statementBuilder.setValue( relatives.isLast6BiMonths() );
+ statementBuilder.setValue( relatives.isLast4Quarters() );
+ statementBuilder.setValue( relatives.isLast2SixMonths() );
+ statementBuilder.setValue( relatives.isThisFinancialYear() );
+ statementBuilder.setValue( relatives.isLastFinancialYear() );
+ statementBuilder.setValue( relatives.isLast5FinancialYears() );
+ statementBuilder.setValue( relatives.isLast52Weeks() );
+ }
+}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ReportTableBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ReportTableBatchHandler.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/ReportTableBatchHandler.java 2013-03-14 10:12:47 +0000
@@ -73,17 +73,20 @@
{
statementBuilder.setIdentifierValue( reportTable.getId() );
}
-
+
+ @Override
protected void setUniqueColumns()
{
statementBuilder.setUniqueColumn( "name" );
}
-
+
+ @Override
protected void setUniqueValues( ReportTable reportTable )
{
statementBuilder.setUniqueValue( reportTable.getName() );
}
-
+
+ @Override
protected void setColumns()
{
statementBuilder.setColumn( "uid" );
@@ -106,7 +109,8 @@
statementBuilder.setColumn( "paramparentorganisationunit" );
statementBuilder.setColumn( "paramorganisationunit" );
}
-
+
+ @Override
protected void setValues( ReportTable reportTable )
{
statementBuilder.setValue( reportTable.getUid() );