← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8734: Centralized method

 

------------------------------------------------------------
revno: 8734
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-26 14:27:47 +0200
message:
  Centralized method
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.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/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2012-07-01 11:33:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2012-10-26 12:27:47 +0000
@@ -31,6 +31,7 @@
 import java.util.Date;
 import java.util.List;
 
+import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.user.User;
 
 /**
@@ -138,6 +139,16 @@
      * Retrieves objects associated with the given user.
      * 
      * @param user the user.
+     * @param a list of objects.
      */
     Collection<T> getByUser( User user );
+    
+    /**
+     * Retrieves objects which are accessible to the given user, which includes
+     * public objects and objects owned by this user.
+     * 
+     * @param user the user.
+     * @return a list of objects.
+     */
+    Collection<Map> getAccessibleByUser( User user );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java	2012-10-25 16:44:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapStore.java	2012-10-26 12:27:47 +0000
@@ -27,10 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.user.User;
 
 /**
  * @author Lars Helge Overland
@@ -38,5 +35,4 @@
 public interface MapStore
     extends GenericIdentifiableObjectStore<Map>
 {
-    Collection<Map> getSystemAndUserMaps( User user );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java	2012-10-25 12:07:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java	2012-10-26 12:27:47 +0000
@@ -27,12 +27,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -41,7 +43,11 @@
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 
-import java.util.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Kristian Nordal

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-10-25 16:27:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-10-26 12:27:47 +0000
@@ -433,7 +433,7 @@
     {
         User user = currentUserService.getCurrentUser();
         
-        return mapStore.getSystemAndUserMaps( user );
+        return mapStore.getAccessibleByUser( user );
     }
         
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java	2012-10-25 16:44:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapStore.java	2012-10-26 12:27:47 +0000
@@ -27,13 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-
-import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.mapping.MapStore;
-import org.hisp.dhis.user.User;
 
 /**
  * @author Lars Helge Overland
@@ -41,11 +37,4 @@
 public class HibernateMapStore
     extends HibernateIdentifiableObjectStore<Map> implements MapStore
 {
-    @SuppressWarnings("unchecked")
-    public Collection<Map> getSystemAndUserMaps( User user )
-    {
-        return getCriteria( Restrictions.or( 
-            Restrictions.eq( "user", user ),
-            Restrictions.isNull( "user" ) ) ).list();
-    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2012-10-18 13:04:28 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2012-10-26 12:27:47 +0000
@@ -36,6 +36,7 @@
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Required;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -377,4 +378,15 @@
     {
         return getCriteria( Restrictions.eq( "user", user ) ).list();
     }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Collection<Map> getAccessibleByUser( User user )
+    {
+        //TODO link to interface
+        
+        return getCriteria( Restrictions.or( 
+            Restrictions.eq( "user", user ),
+            Restrictions.isNull( "user" ) ) ).list();
+    }
 }