← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20461: Removed MapViewUpgrader. Done its job.

 

------------------------------------------------------------
revno: 20461
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-10-02 10:28:58 +0200
message:
  Removed MapViewUpgrader. Done its job.
removed:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/MapViewUpgrader.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.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
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/MapViewUpgrader.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/MapViewUpgrader.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/MapViewUpgrader.java	1970-01-01 00:00:00 +0000
@@ -1,147 +0,0 @@
-package org.hisp.dhis.startup;
-
-/*
- * Copyright (c) 2004-2015, 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 java.sql.ResultSet;
-
-import org.amplecode.quick.BatchHandler;
-import org.amplecode.quick.BatchHandlerFactory;
-import org.amplecode.quick.StatementManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.CodeGenerator;
-import org.hisp.dhis.jdbc.batchhandler.MapBatchHandler;
-import org.hisp.dhis.mapping.Map;
-import org.hisp.dhis.system.startup.AbstractStartupRoutine;
-import org.hisp.dhis.user.User;
-
-public class MapViewUpgrader
-    extends AbstractStartupRoutine
-{
-    private static final Log log = LogFactory.getLog( MapViewUpgrader.class );
-    
-    private StatementManager statementManager;
-    
-    public void setStatementManager( StatementManager statementManager )
-    {
-        this.statementManager = statementManager;
-    }
-    
-    private BatchHandlerFactory batchHandlerFactory;
-
-    public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
-    {
-        this.batchHandlerFactory = batchHandlerFactory;
-    }
-    
-    @Override
-    public void execute()
-    {
-        executeSql( "update mapview set valuetype=mapvaluetype where valuetype is null" );
-        executeSql( "update mapview set legendtype=maplegendtype where legendtype is null" );
-        executeSql( "update mapview set legendsetid=maplegendsetid where legendsetid is null" );
-        
-        executeSql( "alter table mapview drop column mapvaluetype" );
-        executeSql( "alter table mapview drop column maplegendtype" );
-        executeSql( "alter table mapview drop column maplegendsetid" );
-        
-        executeSql( "alter table mapview drop column bounds" );
-        executeSql( "alter table mapview drop column code" );
-        executeSql( "alter table mapview drop column periodtypeid" );
-        
-        executeSql( "update mapview set layer='thematic1' where layer is null" );
-        executeSql( "update mapview set valuetype='dataElement' where valuetype='dataelement'" );
-        executeSql( "alter table mapview alter column opacity type double precision" );
-        
-        String sql = "select mapviewid, name, userid, longitude, latitude, zoom from mapview where mapviewid not in (" +
-            "select mapviewid from mapmapviews)";
-
-        BatchHandler<Map> batchHandler = batchHandlerFactory.createBatchHandler( MapBatchHandler.class ).init();
-        
-        try
-        {
-            ResultSet rs = statementManager.getHolder().getStatement().executeQuery( sql );
-            
-            while ( rs.next() )
-            {
-                log.info( "Upgrading map view..." );
-                
-                User user = null;
-                int userId = rs.getInt( "userid" );
-                int mapViewId = rs.getInt( "mapviewid" );
-                
-                if ( userId != 0 )
-                {
-                    user = new User();
-                    user.setId( userId );
-                }
-
-                String uid = CodeGenerator.generateCode();
-                
-                Map map = new Map( rs.getString( "name" ), user, 
-                    rs.getDouble( "longitude" ), rs.getDouble( "latitude" ), rs.getInt( "zoom" ) );
-                map.setUid( uid );
-
-                int mapId = batchHandler.insertObject( map, true );
-                
-                statementManager.getHolder().executeUpdate( "insert into mapmapviews (mapid,mapviewid,sort_order) values(" + mapId + "," + mapViewId + ",0);" );
-                
-                log.info( "Upgraded map view: " + map );
-            }
-        }
-        catch ( Exception ex )
-        {
-            log.debug( "Error", ex );
-            return;
-        }
-        finally
-        {
-            batchHandler.flush();
-        }
-
-        executeSql( "alter table mapview drop column name" );
-        executeSql( "alter table mapview drop column userid" );
-        executeSql( "alter table mapview drop column longitude" );
-        executeSql( "alter table mapview drop column latitude" );
-        executeSql( "alter table mapview drop column zoom" );
-    }
-
-    private int executeSql( String sql )
-    {
-        try
-        {
-            return statementManager.getHolder().executeUpdate( sql );
-        }
-        catch ( Exception ex )
-        {
-            log.debug( "Execution error", ex );
-            return -1;
-        }
-    }
-}

=== 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	2015-10-01 09:45:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2015-10-02 08:28:58 +0000
@@ -1425,14 +1425,6 @@
     <property name="skipInTests" value="true" />
   </bean>
 
-  <bean id="org.hisp.dhis.startup.MapViewUpgrader" class="org.hisp.dhis.startup.MapViewUpgrader">
-    <property name="statementManager" ref="statementManager" />
-    <property name="batchHandlerFactory" ref="batchHandlerFactory" />
-    <property name="name" value="MapViewUpgrader" />
-    <property name="runlevel" value="8" />
-    <property name="skipInTests" value="true" />
-  </bean>
-
   <bean id="org.hisp.dhis.startup.FavoriteDataItemUpgrader" class="org.hisp.dhis.startup.FavoriteDataItemUpgrader">
     <property name="name" value="FavoriteDataItemUpgrader" />
     <property name="runlevel" value="9" />
@@ -1477,7 +1469,6 @@
           <ref bean="org.hisp.dhis.startup.TableCreator" />
           <ref bean="org.hisp.dhis.startup.TableAlteror" />
           <ref bean="org.hisp.dhis.trackedentity.startup.TableAlteror" />
-          <ref bean="org.hisp.dhis.startup.MapViewUpgrader" />
           <ref bean="org.hisp.dhis.startup.FavoriteDataItemUpgrader" />
           <ref bean="org.hisp.dhis.dataentryform.DataEntryFormUpgrader" />
           <ref bean="org.hisp.dhis.startup.ExpressionUpgrader" />

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java	2015-10-02 08:02:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java	2015-10-02 08:28:58 +0000
@@ -212,13 +212,13 @@
             throw new ADXException( ADXDataService.ORGUNIT + " attribute is required on 'group'" );
         }
 
-        // translate adx period to dxf2
+        // translate ADX period to dxf2
         String periodStr = groupAttributes.get( ADXDataService.PERIOD );
         groupAttributes.remove( ADXDataService.PERIOD );
         Period period = ADXPeriod.parse( periodStr );
         groupAttributes.put( ADXDataService.PERIOD, period.getIsoDate());
 
-        // process adx group attributes
+        // process ADX group attributes
         if ( !groupAttributes.containsKey( ADXDataService.ATTOPTCOMBO )
             && groupAttributes.containsKey( ADXDataService.DATASET ) )
         {
@@ -288,7 +288,7 @@
             throw new ADXException(dvAttributes.get( ADXDataService.DATAELEMENT), "No matching dataelement");
         }
         
-        // process ADX datavalue attributes
+        // process ADX data value attributes
         if ( !dvAttributes.containsKey( ADXDataService.CATOPTCOMBO ) )
         {
             log.debug( "No categoryOptionCombo present." );