← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10668: Impl support for categories as dimensions in analytics tables

 

------------------------------------------------------------
revno: 10668
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-22 19:22:52 +0200
message:
  Impl support for categories as dimensions in analytics tables
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm


--
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/DataElementCategoryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2013-02-22 08:14:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2013-04-22 17:22:52 +0000
@@ -35,7 +35,6 @@
 
 /**
  * @author Abyot Asalefew
- * @version $Id$
  */
 public interface DataElementCategoryService
 {
@@ -103,6 +102,13 @@
     DataElementCategory getDataElementCategoryByName( String name );
 
     /**
+     * Returns DataElementCategories which are considered data dimensions.
+     * 
+     * @return DataElementCategories which are considered data dimensions.
+     */
+    Collection<DataElementCategory> getDataDimensionDataElementCategories();
+    
+    /**
      * Returns all DataElementCategories.
      *
      * @return a collection of all DataElementCategories, or an empty collection if there

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2013-04-22 08:10:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2013-04-22 17:22:52 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.analytics.AnalyticsIndex;
 import org.hisp.dhis.analytics.AnalyticsTableManager;
 import org.hisp.dhis.common.CodeGenerator;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -63,6 +64,9 @@
     
     @Autowired
     protected OrganisationUnitGroupService organisationUnitGroupService;
+    
+    @Autowired
+    protected DataElementCategoryService categoryService;
    
     @Autowired
     protected StatementBuilder statementBuilder;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2013-04-21 19:53:13 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2013-04-22 17:22:52 +0000
@@ -38,6 +38,7 @@
 import java.util.concurrent.Future;
 
 import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -161,6 +162,7 @@
             "from datavalue dv " +
             "left join _dataelementgroupsetstructure degs on dv.dataelementid=degs.dataelementid " +
             "left join _organisationunitgroupsetstructure ougs on dv.sourceid=ougs.organisationunitid " +
+            "left join _categorystructure cs on dv.categoryoptioncomboid=cs.categoryoptioncomboid " +
             "left join _orgunitstructure ous on dv.sourceid=ous.organisationunitid " +
             "left join _periodstructure ps on dv.periodid=ps.periodid " +
             "left join dataelement de on dv.dataelementid=de.dataelementid " +
@@ -187,10 +189,13 @@
         
         Collection<OrganisationUnitGroupSet> orgUnitGroupSets = 
             organisationUnitGroupService.getAllOrganisationUnitGroupSets();
-        
+
+        Collection<DataElementCategory> categories =
+            categoryService.getDataDimensionDataElementCategories();
+
         Collection<OrganisationUnitLevel> levels =
             organisationUnitService.getOrganisationUnitLevels();
-
+        
         for ( DataElementGroupSet groupSet : dataElementGroupSets )
         {
             String[] col = { groupSet.getUid(), "character(11)", "degs." + groupSet.getUid() };
@@ -203,6 +208,12 @@
             columns.add( col );
         }
         
+        for ( DataElementCategory category : categories )
+        {
+            String[] col = { category.getUid(), "character(11)", "cs." + category.getUid() };
+            columns.add( col );
+        }
+        
         for ( OrganisationUnitLevel level : levels )
         {
             String column = PREFIX_ORGUNITLEVEL + level.getLevel();

=== 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	2013-02-22 12:26:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2013-04-22 17:22:52 +0000
@@ -27,6 +27,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.common.GenericDimensionalObjectStore;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
@@ -36,16 +46,6 @@
 import org.hisp.dhis.system.util.FilterUtils;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -122,6 +122,21 @@
         dataElementCategoryStore.delete( dataElementCategory );
     }
 
+    public Collection<DataElementCategory> getDataDimensionDataElementCategories()
+    {
+        Collection<DataElementCategory> categories = getAllDataElementCategories();
+        
+        FilterUtils.filter( categories, new Filter<DataElementCategory>()
+        {
+            public boolean retain( DataElementCategory category )
+            {
+                return category != null && category.isDataDimension();
+            }            
+        } );
+        
+        return categories;
+    }
+    
     public Collection<DataElementCategory> getAllDataElementCategories()
     {
         return i18n( i18nService, dataElementCategoryStore.getAll() );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm	2013-04-22 10:01:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm	2013-04-22 17:22:52 +0000
@@ -42,7 +42,7 @@
       <td><input type="text" id="name" name="name"/></td>
     </tr>
     <tr>
-      <td><label for="dataDimension">$i18n.getString( "use_as_data_dimension" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+      <td><label for="dataDimension">$i18n.getString( "use_as_data_dimension" )</label></td>
       <td><input type="checkbox" id="dataDimension" name="dataDimension" value="true" /></td>
     </tr>
     <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm	2013-04-22 10:01:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm	2013-04-22 17:22:52 +0000
@@ -47,7 +47,7 @@
       <td><input type="text" id="name" name="name" value="$!encoder.htmlEncode( $dataElementCategory.name )"/></td>
     </tr>
     <tr>
-      <td><label for="dataDimension">$i18n.getString( "use_as_data_dimension" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+      <td><label for="dataDimension">$i18n.getString( "use_as_data_dimension" )</label></td>
       <td><input type="checkbox" id="dataDimension" name="dataDimension" value="true"#if( $dataElementCategory.dataDimension ) checked="checked"#end/></td>
     </tr>     
     <tr>