← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 788: Added uuid to DataElementCategory

 

------------------------------------------------------------
revno: 788
committer: Bob Jolliffe <bobj@bobj-laptop>
branch nick: trunk
timestamp: Mon 2009-09-28 16:23:37 +0100
message:
  Added uuid to DataElementCategory
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java
  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/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.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-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java	2009-09-28 15:23:37 +0000
@@ -32,6 +32,11 @@
 import java.util.Set;
 
 /**
+ * A Category is a dimension of a data element.  DataElements can have sets 
+ * of dimensions (known as CategoryCombos).  An Example of a Category might 
+ * be "Sex".  The Category could have two (or more) CategoryOptions such as 
+ * "Male" and "Female".
+ * 
  * @author Abyot Asalefew
  * @version $Id$
  */
@@ -40,8 +45,19 @@
 {
     public static final String DEFAULT_NAME = "default";
     
+    /**
+     * The database internal identifier for this Category.
+     */
     private int id;
     
+    /**
+     * The Universally Unique Identifer for this Category. 
+     */    
+    private String uuid;
+
+    /**
+     * The name of this Category. Required and unique.
+     */
     private String name;
     
     private Set<DataElementCategoryOption> categoryOptions = new HashSet<DataElementCategoryOption>();
@@ -118,6 +134,16 @@
         this.id = id;
     }
     
+    public String getUuid()
+    {
+        return uuid;
+    }
+
+    public void setUuid( String uuid )
+    {
+        this.uuid = uuid;
+    }
+
     public String getName()
     {
         return name;

=== 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	2009-06-20 14:26:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2009-09-28 15:23:37 +0000
@@ -33,6 +33,7 @@
 import java.util.TreeMap;
 
 import org.hisp.dhis.common.GenericNameStore;
+import org.hisp.dhis.system.util.UUIdUtils;
 import org.hisp.dhis.i18n.I18nService;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -75,6 +76,11 @@
 
     public int addDataElementCategory( DataElementCategory dataElementCategory )
     {
+	if ( dataElementCategory.getUuid() == null )
+	{
+	    dataElementCategory.setUuid( UUIdUtils.getUUId() );
+	}
+
         int id = dataElementCategoryStore.save( dataElementCategory );
         
         i18nService.addObject( dataElementCategory );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategory.hbm.xml	2009-09-28 15:23:37 +0000
@@ -9,7 +9,11 @@
     <id name="id" column="categoryid">
       <generator class="native"/>
     </id>
-        	
+ 
+    <property name="uuid">
+      <column name="uuid" length="40"/>
+    </property>
+       	
     <property name="name">
       <column name="name" not-null="true" unique="true" length="160"/>
     </property>