← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1821: Changed from Enums to String as persistent type for ReportTable.dimensionType. Storing Enums as s...

 

------------------------------------------------------------
revno: 1821
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-04-28 12:36:18 +0200
message:
  Changed from Enums to String as persistent type for ReportTable.dimensionType. Storing Enums as strings is easy with hibernate annotations but not with standard hibernate. 
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.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/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2010-04-28 10:36:18 +0000
@@ -153,7 +153,7 @@
     /**
      * The {@link org.hisp.dhis.dimension.DimensionType} for the ReportTable.
      */
-    private DimensionType dimensionType;
+    private String dimensionType;
     
     /**
      * The DataElementCategoryCombo for the ReportTable.
@@ -607,9 +607,9 @@
     {
         if ( dimensionSet != null )
         {
-            dimensionType = dimensionSet.getDimensionType();
-            categoryCombo = dimensionType.equals( DimensionType.CATEGORY ) ? dimensionSet : null;
-            dataElementGroupSets = dimensionType.equals( DimensionType.DATAELEMENTGROUPSET ) ? dimensionSet.getDimensions() : null;
+            dimensionType = dimensionSet.getDimensionType().name();
+            categoryCombo = dimensionType.equals( DimensionType.CATEGORY.name() ) ? dimensionSet : null;
+            dataElementGroupSets = dimensionType.equals( DimensionType.DATAELEMENTGROUPSET.name() ) ? dimensionSet.getDimensions() : null;
             
             verify( dimensionType != null, "Dimension type cannot be null" );
         }
@@ -755,7 +755,7 @@
      */
     public boolean isDimensional( DimensionType dimensionType )
     {
-        return isDimensional() && this.dimensionType.equals( dimensionType );
+        return isDimensional() && this.dimensionType.equals( dimensionType.name() );
     }
     
     /**
@@ -1174,12 +1174,12 @@
         this.units = units;
     }
 
-    public DimensionType getDimensionType()
+    public String getDimensionType()
     {
         return dimensionType;
     }
 
-    public void setDimensionType( DimensionType dimensionType )
+    public void setDimensionType( String dimensionType )
     {
         this.dimensionType = dimensionType;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java	2010-04-26 10:35:12 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/OptionsCategoriesDefaultSortOrderPopulator.java	2010-04-28 10:36:18 +0000
@@ -72,6 +72,7 @@
         executeSql( "drop table columnorder" );
         executeSql( "drop table roworder" );
         executeSql( "alter table dataelementcategoryoption drop column categoryid" );
+        executeSql( "alter table reporttable drop column dimensiontype" ); // New is dimension_type
         
         //categories_categoryoptions
         int c1 = executeSql( "UPDATE categories_categoryoptions SET sort_order=0 WHERE sort_order is NULL OR sort_order=0" ); // set to 0 temporarily

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2009-11-24 11:01:39 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2010-04-28 10:36:18 +0000
@@ -45,7 +45,7 @@
         class="org.hisp.dhis.dataset.DataSet"/>
     </list>
     
-	<property name="dimensionType"/>
+	<property name="dimensionType" column="dimension_type"/>
 	
     <many-to-one name="categoryCombo" class="org.hisp.dhis.dataelement.DataElementCategoryCombo"
       column="categorycomboid" foreign-key="fk_reporttable_categorycombo"/>


Follow ups