=== removed directory 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dialect' === removed file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dialect/IdentityDerbyDialect.java' --- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dialect/IdentityDerbyDialect.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dialect/IdentityDerbyDialect.java 1970-01-01 00:00:00 +0000 @@ -1,50 +0,0 @@ -package org.hisp.dhis.dialect; - -/* - * 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.hibernate.dialect.DerbyDialect; -import org.hibernate.id.IdentityGenerator; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class IdentityDerbyDialect - extends DerbyDialect -{ - public IdentityDerbyDialect() - { - super(); - } - - @Override - public Class getNativeIdentifierGeneratorClass() - { - return IdentityGenerator.class; - } -} === removed file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java' --- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java 2012-07-10 07:16:10 +0000 +++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java 1970-01-01 00:00:00 +0000 @@ -1,313 +0,0 @@ -package org.hisp.dhis.jdbc.statementbuilder; - -/* - * 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 static org.hisp.dhis.system.util.DateUtils.getSqlDateString; - -import java.util.List; - -import org.hisp.dhis.period.Period; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DerbyStatementBuilder - extends AbstractStatementBuilder -{ - public String getDoubleColumnType() - { - return "DOUBLE"; - } - - public String getPeriodIdentifierStatement( Period period ) - { - return - "SELECT periodid FROM period WHERE periodtypeid=" + period.getPeriodType().getId() + " " + - "AND startdate='" + getSqlDateString( period.getStartDate() ) + "' " + - "AND enddate='" + getSqlDateString( period.getEndDate() ) + "'"; - } - - public String getDeleteZeroDataValues() - { - return - "DELETE FROM datavalue " + - "USING datavalue, dataelement " + - "WHERE datavalue.dataelementid = dataelement.dataelementid " + - "AND dataelement.aggregationtype = 'sum' " + - "AND datavalue.value = '0'"; - } - - public int getMaximumNumberOfColumns() - { - return 1200; //TODO verify - } - - public String getDropDatasetForeignKeyForDataEntryFormTable() - { - return "ALTER TABLE dataentryform DROP FOREIGN KEY fk_dataentryform_datasetid;" ; - } - - @Override - public String getMoveDataValueToDestination( int sourceId, int destinationId ) - { - return "UPDATE datavalue AS d1 SET sourceid=" + destinationId + " " + "WHERE sourceid=" + sourceId + " " - + "AND NOT EXISTS ( " + "SELECT * from datavalue AS d2 " + "WHERE d2.sourceid=" + destinationId + " " - + "AND d1.dataelementid=d2.dataelementid " + "AND d1.periodid=d2.periodid " - + "AND d1.categoryoptioncomboid=d2.categoryoptioncomboid );"; - } - - @Override - public String getSummarizeDestinationAndSourceWhereMatching( int sourceId, int destId ) - { - return "UPDATE datavalue AS d1 SET value=( " + "SELECT SUM( CAST( value AS " - + getDoubleColumnType() + " ) ) " + "FROM datavalue as d2 " - + "WHERE d1.dataelementid=d2.dataelementid " + "AND d1.periodid=d2.periodid " - + "AND d1.categoryoptioncomboid=d2.categoryoptioncomboid " + "AND d2.sourceid IN ( " + destId + ", " - + sourceId + " ) ) " + "FROM dataelement AS de " + "WHERE d1.sourceid=" + destId + " " - + "AND d1.dataelementid=de.dataelementid " + "AND de.valuetype='int';"; - } - - @Override - public String getUpdateDestination( int destDataElementId, int destCategoryOptionComboId, - int sourceDataElementId, int sourceCategoryOptionComboId ) - { - return "UPDATE datavalue AS d1 SET dataelementid=" + destDataElementId + ", categoryoptioncomboid=" + destCategoryOptionComboId + " " - + "WHERE dataelementid=" + sourceDataElementId + " AND categoryoptioncomboid=" + sourceCategoryOptionComboId + " " + "AND NOT EXISTS ( " - + "SELECT * FROM datavalue AS d2 " + "WHERE d2.dataelementid=" + destDataElementId + " " - + "AND d2.categoryoptioncomboid=" + destCategoryOptionComboId + " " + "AND d1.periodid=d2.periodid " - + "AND d1.sourceid=d2.sourceid );"; - } - - public String getMoveFromSourceToDestination( int destDataElementId, int destCategoryOptionComboId, - int sourceDataElementId, int sourceCategoryOptionComboId ) - { - return "UPDATE datavalue SET value=d2.value,storedby=d2.storedby,lastupdated=d2.lastupdated,comment=d2.comment,followup=d2.followup " - + "FROM datavalue AS d2 " - + "WHERE datavalue.periodid=d2.periodid " - + "AND datavalue.sourceid=d2.sourceid " - + "AND datavalue.lastupdated '" + upperBound + "' )"; - } - - public String archiveData( String startDate, String endDate ) - { - return "DELETE FROM datavaluearchive AS a " - + "USING period AS p " - + "WHERE a.periodid=p.periodid " - + "AND p.startdate>='" + startDate + "' " - + "AND p.enddate<='" + endDate + "'"; - } - - public String unArchiveData( String startDate, String endDate ) - { - return "DELETE FROM datavaluearchive AS a " - + "USING period AS p " + "WHERE a.periodid=p.periodid " - + "AND p.startdate>='" + startDate + "' " - + "AND p.enddate<='" + endDate + "'"; - } - - public String deleteRegularOverlappingData() - { - return "DELETE FROM datavalue AS d " - + "USING datavaluearchive AS a " - + "WHERE d.dataelementid=a.dataelementid " - + "AND d.periodid=a.periodid " - + "AND d.sourceid=a.sourceid " - + "AND d.categoryoptioncomboid=a.categoryoptioncomboid"; - } - - public String deleteArchivedOverlappingData() - { - return "DELETE FROM datavaluearchive AS a " - + "USING datavalue AS d " - + "WHERE a.dataelementid=d.dataelementid " - + "AND a.periodid=d.periodid " - + "AND a.sourceid=d.sourceid " - + "AND a.categoryoptioncomboid=d.categoryoptioncomboid"; - } - - public String deleteOldestOverlappingDataValue() - { - return "DELETE FROM datavalue AS d " - + "USING datavaluearchive AS a " - + "WHERE d.dataelementid=a.dataelementid " - + "AND d.periodid=a.periodid " - + "AND d.sourceid=a.sourceid " - + "AND d.categoryoptioncomboid=a.categoryoptioncomboid " + "AND d.lastupdated= '" + startDate + "' " - + "AND pi.enddate <= '" + endDate + "';"; - } - - public String unArchivePatientData( String startDate, String endDate ) - { - return "DELETE FROM patientdatavaluearchive AS pdv " - + "USING programstageinstance AS psi , programinstance AS pi " - + "WHERE pdv.programstageinstanceid = psi.programstageinstanceid " - + "AND pi.programinstanceid = psi.programinstanceid " - + "WHERE pi.enddate >= '" + startDate + "' " - + "AND pi.enddate <= '" + endDate + "';"; - } - - public String deleteRegularOverlappingPatientData() - { - return "DELETE FROM patientdatavalue AS d " - + "USING patientdatavaluearchive AS a " - + "WHERE d.programstageinstanceid=a.programstageinstanceid " - + "AND d.dataelementid=a.dataelementid " - + "AND d.timestamp betweenPeriodIds) - { - StringBuffer sqlsb = new StringBuffer(); - - int i = 0; - for ( Integer periodId : betweenPeriodIds ) - { - i++; - - sqlsb.append( "SELECT de.dataelementid, (de.name || ' ' || cc.categoryoptioncomboname) AS DataElement, dv.value AS counts_of_aggregated_values, p.periodid AS PeriodId, p.startDate AS ColumnHeader " ); - sqlsb.append( "FROM dataelement AS de " ); - sqlsb.append( "INNER JOIN datavalue AS dv ON (de.dataelementid = dv.dataelementid) " ); - sqlsb.append( "INNER JOIN period p ON (dv.periodid = p.periodid) " ); - sqlsb.append( "INNER JOIN categorycombos_optioncombos cat_opts on de.categorycomboid = cat_opts.categorycomboid "); - sqlsb.append( "INNER JOIN _categoryoptioncomboname cc on cat_opts.categoryoptioncomboid = cc.categoryoptioncomboid "); - sqlsb.append( "WHERE dv.sourceid = '" + orgUnitId + "' " ); - sqlsb.append( "AND dv.periodid = '" + periodId + "' " ); - - sqlsb.append( i == betweenPeriodIds.size() ? "ORDER BY ColumnHeader,dataelement" : " UNION " ); - } - return sqlsb.toString(); - } - - public String limitRecord( int min, int max ) - { - return " LIMIT " + max + " OFFSET " + min; - } - - public String getAddDate( String dateField, int days ) - { - return "DATEADD('DAY'," + days + "," + dateField + ")"; - } - - public String getPatientFullName() - { - return "concat( firstname, \" \",middleName , \" \" , lastname)"; - } -} === modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/StatementBuilderFactoryBean.java' --- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/StatementBuilderFactoryBean.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/StatementBuilderFactoryBean.java 2012-07-23 12:46:36 +0000 @@ -69,10 +69,6 @@ { this.statementBuilder = new H2StatementBuilder(); } - else if ( statementDialect.equals( StatementDialect.DERBY ) ) - { - this.statementBuilder = new DerbyStatementBuilder(); - } else { throw new RuntimeException( "Unsupported dialect: " + statementDialect.toString() );