dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19893
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8867: Upgraded the MapViewUpgrader
------------------------------------------------------------
revno: 8867
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-11-05 12:54:00 +0300
message:
Upgraded the MapViewUpgrader
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/MapViewUpgrader.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-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 2012-11-05 06:27:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/MapViewUpgrader.java 2012-11-05 09:54:00 +0000
@@ -7,11 +7,11 @@
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;
-import org.springframework.transaction.annotation.Transactional;
public class MapViewUpgrader
extends AbstractStartupRoutine
@@ -33,7 +33,6 @@
}
@Override
- @Transactional
public void execute()
{
executeSql( "update mapview set valuetype=mapvaluetype where valuetype is null" );
@@ -62,8 +61,11 @@
while ( rs.next() )
{
+ log.info( "Upgrading map view..." );
+
User user = null;
int userId = rs.getInt( "userid" );
+ int mapViewId = rs.getInt( "mapviewid" );
if ( userId != 0 )
{
@@ -71,17 +73,22 @@
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 );
- batchHandler.addObject( map );
+ 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( ex );
+ log.error( "Error", ex );
return;
}
finally
@@ -104,7 +111,7 @@
}
catch ( Exception ex )
{
- log.debug( ex );
+ log.error( "Execution error", ex );
return -1;
}
}