← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22269: Set static UID/Code on generated TrackedEntity Person (on empty databases)

 

------------------------------------------------------------
revno: 22269
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2016-03-13 14:34:13 +0700
message:
  Set static UID/Code on generated TrackedEntity Person (on empty databases)
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.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/trackedentity/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java	2016-03-07 10:32:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java	2016-03-13 07:34:13 +0000
@@ -32,12 +32,12 @@
 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.dataelement.DataElementService;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.program.ProgramExpression;
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.system.startup.AbstractStartupRoutine;
+import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.ValidationUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -45,6 +45,7 @@
 
 import java.sql.ResultSet;
 import java.sql.Statement;
+import java.util.Date;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -256,7 +257,7 @@
         executeSql( "update trackedentityattribute set aggregationype='AVERAGE' where aggregationtype is null" );
 
         executeSql( "UPDATE trackedentityattribute SET valuetype='string' WHERE valuetype='localId';" );
-        executeSql( "UPDATE trackedentityattribute SET valuetype='number' WHERE valuetype='age'" );        
+        executeSql( "UPDATE trackedentityattribute SET valuetype='number' WHERE valuetype='age'" );
 
         executeSql( "update trackedentityattribute set searchscope='NOT_SEARCHABLE' where confidential=true" );
         executeSql( "update trackedentityattribute set searchscope='SEARCH_ORG_UNITS' where searchscope is null" );
@@ -380,10 +381,13 @@
 
         if ( exist == 0 )
         {
+
             String id = statementBuilder.getAutoIncrementValue();
+            String uid = "MCPQUTHX1Ze";
+            String date = DateUtils.getSqlDateString( new Date() );
 
-            jdbcTemplate.execute( "INSERT INTO trackedentity(trackedentityid,uid, name, description) values(" + id
-                + ",'" + CodeGenerator.generateCode() + "','Person','Person')" );
+            jdbcTemplate.execute( "INSERT INTO trackedentity(trackedentityid,uid, code, created, lastupdated,name, description) values("
+                + id + ",'" + uid + "','Person','" + date + "','" + date + "','Person','Person')" );
 
             jdbcTemplate.execute( "UPDATE program SET trackedentityid="
                 + "  (SELECT trackedentityid FROM trackedentity where name='Person') where trackedentityid is null" );