← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7085: Removed blood type script from table alteror, not necessary

 

------------------------------------------------------------
revno: 7085
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-29 21:37:01 +0200
message:
  Removed blood type script from table alteror, not necessary
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml


--
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-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-05-29 15:37:40 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-05-29 19:37:01 +0000
@@ -35,8 +35,6 @@
 import org.amplecode.quick.StatementManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.system.startup.AbstractStartupRoutine;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -63,13 +61,6 @@
         this.statementManager = statementManager;
     }
 
-    private PatientAttributeService patientAttributeService;
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -106,9 +97,8 @@
         executeSql( "ALTER TABLE patientattribute DROP COLUMN noChars" );
         executeSql( "ALTER TABLE programstageinstance ALTER executiondate TYPE date" );
         
-        createPatientAttribute();
         executeSql( "ALTER TABLE patientidentifier ALTER COLUMN patientid DROP NOT NULL" );
-        //executeSql( "ALTER TABLE patientmobilesetting DROP COLUMN bloodGroup" );
+        executeSql( "ALTER TABLE patient DROP COLUMN bloodgroup" );
     }
 
     // -------------------------------------------------------------------------
@@ -147,47 +137,6 @@
         }
     }
 
-    private void createPatientAttribute()
-    {
-        PatientAttribute patientAttribute = patientAttributeService.getPatientAttributeByName( "Blood group" );
-        if( patientAttribute == null )
-        {
-            patientAttribute = new PatientAttribute();
-            patientAttribute.setName( "Blood group" );
-            patientAttribute.setDescription( "Blood group" );
-            patientAttribute.setValueType( PatientAttribute.TYPE_STRING );
-            patientAttribute.setMandatory( false );
-            patientAttribute.setInheritable( false );
-            patientAttribute.setGroupBy( false );
-            int patientAttributeId = patientAttributeService.savePatientAttribute( patientAttribute );
-            
-            StatementHolder holder = statementManager.getHolder();
-
-            try
-            {
-                Statement statement = holder.getStatement();
-
-                ResultSet resultSet = statement.executeQuery( "SELECT patientid, bloodgroup FROM patient where bloodgroup is not null and bloodgroup != '' " );
-
-                while ( resultSet.next() )
-                {
-                    executeSql( "INSERT INTO patientattributevalue(patientid, patientattributeid, value) VALUES ( " +
-                        resultSet.getInt( 1 )+ "," + patientAttributeId + ",'" + resultSet.getString( 2 ) + "' )" );
-                }
-
-                executeSql( "ALTER TABLE patient DROP COLUMN bloodgroup" );
-            }
-            catch ( Exception ex )
-            {
-                log.error( ex );
-            }
-            finally
-            {
-                holder.close();
-            }
-        }
-    }
-    
     private int executeSql( String sql )
     {
         try

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-05-29 15:37:40 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-05-29 19:37:01 +0000
@@ -364,7 +364,6 @@
 	
 	<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror" >
 		<property name="statementManager" ref="statementManager" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="name" value="PatientTableAlteror" />
 		<property name="runlevel" value="4" />
 		<property name="skipInTests" value="true" />