← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2849: Added uuid to categoryoptiocombo (might have missed some places)

 

------------------------------------------------------------
revno: 2849
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-02-15 12:08:47 +0530
message:
  Added uuid to categoryoptiocombo (might have missed some places)
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.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-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2011-01-06 13:33:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2011-02-15 06:38:47 +0000
@@ -254,6 +254,11 @@
 
     public int addDataElementCategoryOptionCombo( DataElementCategoryOptionCombo dataElementCategoryOptionCombo )
     {
+        if ( dataElementCategoryOptionCombo != null && dataElementCategoryOptionCombo.getUuid() == null )
+        {
+            dataElementCategoryOptionCombo.setUuid( UUIdUtils.getUUId() );
+        }
+
         return dataElementCategoryOptionComboStore.save( dataElementCategoryOptionCombo );
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java	2011-02-15 06:38:47 +0000
@@ -31,12 +31,18 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.system.startup.AbstractStartupRoutine;
 import org.hisp.dhis.system.util.UUIdUtils;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author Bob Jolliffe
  * @version $Id$
  * 
  * Provides uuids to uniquely indentifiable objects which do not already have them.
+ * 
+ * <p>Should be all the things requiring uuids .. there are more.
+ *    What follows is a bit of a compromise hack essentially copying
+ *    and pasting 3 times. Should reimplement with common interface
+ *    IdentifiableObject or something similar.
  */
 public class UuidPopulator
     extends AbstractStartupRoutine
@@ -47,11 +53,6 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    // Should be all the things requiring uuids .. there are more.
-    // What follows is a bit of a compromise hack essentially copying
-    // and pasting 3 times. Should reimplement with common interface
-    // IdentifiableObject or something similar.
-
     private DataElementCategoryService categoryService;
 
     private DataElementService dataElementService;
@@ -70,6 +71,7 @@
     // StartupRoutine implementation
     // -------------------------------------------------------------------------
 
+    @Transactional
     public void execute()
         throws Exception
     {
@@ -108,5 +110,17 @@
             }
         }
         log.info( "Checked DataElement uuids" );
+
+        for ( DataElementCategoryOptionCombo combo : categoryService.getAllDataElementCategoryOptionCombos() )
+        {
+            if ( combo.getUuid() == null )
+            {
+                combo.setUuid( UUIdUtils.getUUId() );
+                categoryService.updateDataElementCategoryOptionCombo( combo );
+                log.info( "Added uuid for CategoryOptionCombo '" + combo.getName() + "'" );
+            }
+        }
+        log.info( "Checked CategoryOptionCombo uuids" );
+
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml	2011-01-07 11:38:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOptionCombo.hbm.xml	2011-02-15 06:38:47 +0000
@@ -10,6 +10,10 @@
       <generator class="native"/>
     </id>      
 
+    <property name="uuid">
+      <column name="uuid" length="40"/>
+    </property>
+
     <list name="categoryOptions" table="categoryoptioncombos_categoryoptions">
       <key column="categoryoptioncomboid"/>
       <list-index column="sort_order" base="1"/>