← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20954: remove getAll(order) methods from HibGenStore, not in use, and causes issues for new Operator impl

 

------------------------------------------------------------
revno: 20954
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-11-05 10:16:36 +0700
message:
  remove getAll(order) methods from HibGenStore, not in use, and causes issues for new Operator impl
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryUtils.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/GenericStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java	2015-03-27 17:33:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java	2015-11-05 03:16:36 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.query.Order;
-
 import java.util.List;
 
 /**
@@ -74,10 +72,10 @@
      * @return the object identified by the given identifier.
      */
     T get( int id );
-    
+
     /**
      * Retrieves the object with the given identifier. Bypasses the ACL solution.
-     * 
+     *
      * @param id the object identifier.
      * @return the object identified by the given identifier.
      */
@@ -100,20 +98,6 @@
     List<T> getAll();
 
     /**
-     * Retrieves a List of all objects, ordered as specified (only persisted properties are supported).
-     *
-     * @return a List of all objects.
-     */
-    List<T> getAll( Order order );
-
-    /**
-     * Retrieves a List of all objects, ordered as specified (only persisted properties are supported).
-     *
-     * @return a List of all objects.
-     */
-    List<T> getAll( List<Order> order );
-
-    /**
      * Retrieves a paged List of all objects.
      *
      * @return a List of all objects.
@@ -121,20 +105,6 @@
     List<T> getAll( int first, int max );
 
     /**
-     * Retrieves a paged List of all objects, ordered as specified (only persisted properties are supported).
-     *
-     * @return a List of all objects.
-     */
-    List<T> getAll( int first, int max, Order order );
-
-    /**
-     * Retrieves a paged List of all objects, ordered as specified (only persisted properties are supported).
-     *
-     * @return a List of all objects.
-     */
-    List<T> getAll( int first, int max, List<Order> order );
-
-    /**
      * Removes the given object instance.
      *
      * @param object the object instance to delete.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryUtils.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryUtils.java	2015-10-11 18:48:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryUtils.java	2015-11-05 03:16:36 +0000
@@ -33,8 +33,10 @@
 import com.google.common.collect.Lists;
 import org.hisp.dhis.system.util.DateUtils;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -123,6 +125,49 @@
         return null;
     }
 
+    public static List<org.hibernate.criterion.Order> getHibernateOrders( List<Order> order )
+    {
+        List<org.hibernate.criterion.Order> orders = new ArrayList<>();
+
+        for ( Order o : order )
+        {
+            org.hibernate.criterion.Order hibernateOrder = getHibernateOrder( o );
+
+            if ( hibernateOrder != null )
+            {
+                orders.add( hibernateOrder );
+            }
+        }
+
+        return orders;
+    }
+
+    public static org.hibernate.criterion.Order getHibernateOrder( Order order )
+    {
+        if ( order.getProperty() == null || !order.getProperty().isPersisted() || !order.getProperty().isSimple() )
+        {
+            return null;
+        }
+
+        org.hibernate.criterion.Order criteriaOrder;
+
+        if ( order.isAscending() )
+        {
+            criteriaOrder = org.hibernate.criterion.Order.asc( order.getProperty().getFieldName() );
+        }
+        else
+        {
+            criteriaOrder = org.hibernate.criterion.Order.desc( order.getProperty().getFieldName() );
+        }
+
+        if ( order.isIgnoreCase() )
+        {
+            criteriaOrder.ignoreCase();
+        }
+
+        return criteriaOrder;
+    }
+
     private QueryUtils()
     {
     }

=== 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	2015-07-14 07:21:33 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2015-11-05 03:16:36 +0000
@@ -39,12 +39,11 @@
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.DetachedCriteria;
 import org.hibernate.criterion.Disjunction;
+import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Property;
 import org.hibernate.criterion.Restrictions;
 import org.hibernate.criterion.Subqueries;
-import org.hisp.dhis.security.acl.AccessStringHelper;
-import org.hisp.dhis.security.acl.AclService;
 import org.hisp.dhis.common.AuditLogUtil;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.GenericStore;
@@ -55,7 +54,8 @@
 import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
 import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
 import org.hisp.dhis.interpretation.Interpretation;
-import org.hisp.dhis.query.Order;
+import org.hisp.dhis.security.acl.AccessStringHelper;
+import org.hisp.dhis.security.acl.AclService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -63,7 +63,6 @@
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.util.Assert;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -181,7 +180,7 @@
 
     /**
      * Creates a Criteria for the implementation Class type.
-     * <p/>
+     * <p>
      * Please note that sharing is not considered.
      *
      * @return a Criteria instance.
@@ -196,7 +195,7 @@
         return getSharingCriteria( "r%" );
     }
 
-    private final Criteria getSharingCriteria( String access )
+    private Criteria getSharingCriteria( String access )
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( getClazz(), "c" ).setCacheable( cacheable );
 
@@ -338,7 +337,7 @@
             if ( clearSharing )
             {
                 identifiableObject.setPublicAccess( AccessStringHelper.DEFAULT );
-                
+
                 if ( identifiableObject.getUserGroupAccesses() != null )
                 {
                     identifiableObject.getUserGroupAccesses().clear();
@@ -478,27 +477,6 @@
     }
 
     @Override
-    public final List<T> getAll( Order order )
-    {
-        return getAll( Lists.newArrayList( order ) );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public List<T> getAll( List<Order> order )
-    {
-        Criteria criteria = getSharingCriteria();
-        List<org.hibernate.criterion.Order> hibernateOrders = getHibernateOrders( order );
-
-        for ( org.hibernate.criterion.Order ho : hibernateOrders )
-        {
-            criteria.addOrder( ho );
-        }
-
-        return criteria.list();
-    }
-
-    @Override
     @SuppressWarnings( "unchecked" )
     public final List<T> getAll( int first, int max )
     {
@@ -509,30 +487,6 @@
     }
 
     @Override
-    public List<T> getAll( int first, int max, Order order )
-    {
-        return getAll( first, max, Lists.newArrayList( order ) );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public List<T> getAll( int first, int max, List<Order> order )
-    {
-        Criteria criteria = getSharingCriteria();
-        List<org.hibernate.criterion.Order> hibernateOrders = getHibernateOrders( order );
-
-        for ( org.hibernate.criterion.Order ho : hibernateOrders )
-        {
-            criteria.addOrder( ho );
-        }
-
-        return criteria
-            .setFirstResult( first )
-            .setMaxResults( max )
-            .list();
-    }
-
-    @Override
     public int getCount()
     {
         return ((Number) getSharingCriteria()
@@ -642,47 +596,4 @@
 
         return true;
     }
-
-    protected List<org.hibernate.criterion.Order> getHibernateOrders( List<Order> order )
-    {
-        List<org.hibernate.criterion.Order> orders = new ArrayList<>();
-
-        for ( Order o : order )
-        {
-            org.hibernate.criterion.Order hibernateOrder = getHibernateOrder( o );
-
-            if ( hibernateOrder != null )
-            {
-                orders.add( hibernateOrder );
-            }
-        }
-
-        return orders;
-    }
-
-    protected org.hibernate.criterion.Order getHibernateOrder( Order order )
-    {
-        if ( order.getProperty() == null || !order.getProperty().isPersisted() || !order.getProperty().isSimple() )
-        {
-            return null;
-        }
-
-        org.hibernate.criterion.Order criteriaOrder;
-
-        if ( order.isAscending() )
-        {
-            criteriaOrder = org.hibernate.criterion.Order.asc( order.getProperty().getFieldName() );
-        }
-        else
-        {
-            criteriaOrder = org.hibernate.criterion.Order.desc( order.getProperty().getFieldName() );
-        }
-
-        if ( order.isIgnoreCase() )
-        {
-            criteriaOrder.ignoreCase();
-        }
-
-        return criteriaOrder;
-    }
 }