← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13996: Centralized store method for getting objects defined as data dimensions

 

------------------------------------------------------------
revno: 13996
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-02-12 15:22:58 +0100
message:
  Centralized store method for getting objects defined as data dimensions
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSetStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.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/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementGroupSetStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitGroupSetStore.java


--
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/common/GenericNameableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java	2013-09-21 09:35:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericNameableObjectStore.java	2014-02-12 14:22:58 +0000
@@ -70,4 +70,13 @@
      * @return a List of objects.
      */
     List<T> getAllEqShortNameIgnoreCase( String shortName );
+    
+    /**
+     * Retrieves a List of dimensional objects. TODO move to new 
+     * GenericDimensionObjectStore.
+     * 
+     * @param dataDimension indicates whether to fetch objects defined as dimensional.
+     * @return a List of objects.
+     */
+    List<T> getByDataDimension( boolean dataDimension );
 }

=== 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	2014-02-12 12:08:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java	2014-02-12 14:22:58 +0000
@@ -579,4 +579,6 @@
     Collection<CategoryOptionGroupSet> getCategoryOptionGroupSetsBetweenByName( int first, int max, String name );
 
     Collection<CategoryOptionGroupSet> getAllCategoryOptionGroupSets();
+    
+    Collection<CategoryOptionGroupSet> getDataDimensionCategoryOptionGroupSets();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSetStore.java	2013-12-30 11:02:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSetStore.java	2014-02-12 14:22:58 +0000
@@ -30,13 +30,10 @@
 
 import org.hisp.dhis.common.GenericNameableObjectStore;
 
-import java.util.Collection;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public interface DataElementGroupSetStore
     extends GenericNameableObjectStore<DataElementGroupSet>
 {
-    Collection<DataElementGroupSet> getByDataDimension( boolean dataDimension );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java	2013-12-30 11:12:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSetStore.java	2014-02-12 14:22:58 +0000
@@ -30,13 +30,10 @@
 
 import org.hisp.dhis.common.GenericNameableObjectStore;
 
-import java.util.Collection;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public interface OrganisationUnitGroupSetStore
     extends GenericNameableObjectStore<OrganisationUnitGroupSet>
 {
-    Collection<OrganisationUnitGroupSet> getByDataDimension( boolean dataDimension );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2013-12-23 09:13:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2014-02-12 14:22:58 +0000
@@ -609,6 +609,16 @@
     }
 
     @Override
+    @SuppressWarnings("unchecked")
+    public List<T> getByDataDimension( boolean dataDimension )
+    {
+        Query query = getQuery( "from " + clazz.getName() + " c where c.dataDimension = :dataDimension" );
+        query.setBoolean( "dataDimension", dataDimension );
+
+        return query.list();
+    }
+    
+    @Override
     public List<T> getByUid( Collection<String> uids )
     {
         List<T> list = new ArrayList<T>();

=== 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	2014-02-12 12:08:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2014-02-12 14:22:58 +0000
@@ -42,7 +42,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.GenericDimensionalObjectStore;
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.common.GenericNameableObjectStore;
 import org.hisp.dhis.concept.Concept;
 import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.system.util.Filter;
@@ -90,16 +90,16 @@
         this.categoryOptionComboStore = categoryOptionComboStore;
     }
 
-    private GenericIdentifiableObjectStore<CategoryOptionGroup> categoryOptionGroupStore;
+    private GenericNameableObjectStore<CategoryOptionGroup> categoryOptionGroupStore;
 
-    public void setCategoryOptionGroupStore( GenericIdentifiableObjectStore<CategoryOptionGroup> categoryOptionGroupStore )
+    public void setCategoryOptionGroupStore( GenericNameableObjectStore<CategoryOptionGroup> categoryOptionGroupStore )
     {
         this.categoryOptionGroupStore = categoryOptionGroupStore;
     }
 
-    private GenericIdentifiableObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore;
+    private GenericNameableObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore;
 
-    public void setCategoryOptionGroupSetStore( GenericIdentifiableObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore )
+    public void setCategoryOptionGroupSetStore( GenericNameableObjectStore<CategoryOptionGroupSet> categoryOptionGroupSetStore )
     {
         this.categoryOptionGroupSetStore = categoryOptionGroupSetStore;
     }
@@ -844,5 +844,10 @@
     public Collection<CategoryOptionGroupSet> getAllCategoryOptionGroupSets()
     {
         return categoryOptionGroupSetStore.getAll();
-    }    
+    }
+    
+    public Collection<CategoryOptionGroupSet> getDataDimensionCategoryOptionGroupSets()
+    {
+        return categoryOptionGroupSetStore.getByDataDimension( true );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2013-12-30 11:02:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2014-02-12 14:22:58 +0000
@@ -618,7 +618,7 @@
     @Override
     public Collection<DataElementGroupSet> getDataDimensionDataElementGroupSets()
     {
-        return i18n( i18nService, dataElementGroupSetStore.getByDataDimension(true) );
+        return i18n( i18nService, dataElementGroupSetStore.getByDataDimension( true ) );
     }
 
     public Collection<DataElementGroupSet> getDataElementGroupSets( final Collection<Integer> identifiers )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementGroupSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementGroupSetStore.java	2013-12-30 11:02:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementGroupSetStore.java	2014-02-12 14:22:58 +0000
@@ -28,13 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hibernate.Query;
 import org.hisp.dhis.common.hibernate.HibernateDimensionalObjectStore;
 import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementGroupSetStore;
 
-import java.util.Collection;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -42,13 +39,4 @@
     extends HibernateDimensionalObjectStore<DataElementGroupSet>
     implements DataElementGroupSetStore
 {
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Collection<DataElementGroupSet> getByDataDimension( boolean dataDimension )
-    {
-        Query query = getQuery( "SELECT d FROM DataElementGroupSet d WHERE d.dataDimension=:dataDimension" );
-        query.setBoolean( "dataDimension", dataDimension );
-
-        return query.list();
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitGroupSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitGroupSetStore.java	2013-12-30 11:14:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitGroupSetStore.java	2014-02-12 14:22:58 +0000
@@ -28,27 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hibernate.Query;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSetStore;
 
-import java.util.Collection;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public class HibernateOrganisationUnitGroupSetStore
     extends HibernateIdentifiableObjectStore<OrganisationUnitGroupSet>
     implements OrganisationUnitGroupSetStore
-{
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Collection<OrganisationUnitGroupSet> getByDataDimension( boolean dataDimension )
-    {
-        Query query = getQuery( "SELECT d FROM OrganisationUnitGroupSet d WHERE d.dataDimension=:dataDimension" );
-        query.setBoolean( "dataDimension", dataDimension );
-
-        return query.list();
-    }
+{ 
 }