← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20050: Removed unused code. Code style.

 

------------------------------------------------------------
revno: 20050
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-08 22:58:02 +0200
message:
  Removed unused code. Code style.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.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/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2015-08-25 10:17:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2015-09-08 20:58:02 +0000
@@ -417,8 +417,6 @@
 
     OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet( Integer maxlevels );
 
-    void filterOrganisationUnitsWithoutData( Collection<OrganisationUnit> organisationUnits );
-
     List<OrganisationUnit> getOrganisationUnitsBetween( int first, int max );
 
     List<OrganisationUnit> getOrganisationUnitsBetweenByName( String name, int first, int max );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2015-07-07 14:54:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2015-09-08 20:58:02 +0000
@@ -146,9 +146,6 @@
      */
     Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap();
 
-    Set<Integer> getOrganisationUnitIdsWithoutData();
-
-
     /**
      * Retrieves the objects determined by the given first result and max result
      * which status is like the current status.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2015-09-03 03:11:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2015-09-08 20:58:02 +0000
@@ -718,21 +718,6 @@
     }
 
     @Override
-    public void filterOrganisationUnitsWithoutData( Collection<OrganisationUnit> organisationUnits )
-    {
-        final Set<Integer> unitsWithoutData = organisationUnitStore.getOrganisationUnitIdsWithoutData();
-
-        FilterUtils.filter( organisationUnits, new Filter<OrganisationUnit>()
-        {
-            @Override
-            public boolean retain( OrganisationUnit unit )
-            {
-                return unit != null && (!unitsWithoutData.contains( unit.getId() ) || unit.hasChild());
-            }
-        } );
-    }
-
-    @Override
     public List<OrganisationUnit> getOrganisationUnitsBetween( int first, int max )
     {
         return i18n( i18nService, organisationUnitStore.getAllOrderedName( first, max ) );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-07-08 02:38:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-09-08 20:58:02 +0000
@@ -28,6 +28,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
@@ -51,17 +61,6 @@
 import org.springframework.jdbc.core.RowCallbackHandler;
 import org.springframework.security.access.AccessDeniedException;
 
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * @author Kristian Nordal
  */
@@ -249,26 +248,6 @@
     }
 
     @Override
-    public Set<Integer> getOrganisationUnitIdsWithoutData()
-    {
-        final String sql = "select organisationunitid from organisationunit ou where not exists (" +
-            "select sourceid from datavalue where sourceid=ou.organisationunitid)";
-
-        final Set<Integer> units = new HashSet<>();
-
-        jdbcTemplate.query( sql, new RowCallbackHandler()
-        {
-            @Override
-            public void processRow( ResultSet rs ) throws SQLException
-            {
-                units.add( rs.getInt( 1 ) );
-            }
-        } );
-
-        return units;
-    }
-
-    @Override
     @SuppressWarnings( "unchecked" )
     public List<OrganisationUnit> getBetweenByStatus( boolean status, int first, int max )
     {
@@ -305,13 +284,13 @@
     @SuppressWarnings( "unchecked" )
     public List<OrganisationUnit> getWithinCoordinateArea( double[] box )
     {
-        return getQuery( "from OrganisationUnit o"
-                + " where o.featureType='Point'"
-                + " and o.coordinates is not null"
-                + " and CAST( SUBSTRING(o.coordinates, 2, LOCATE(',', o.coordinates) - 2) AS big_decimal ) >= " + box[3]
-                + " and CAST( SUBSTRING(o.coordinates, 2, LOCATE(',', o.coordinates) - 2) AS big_decimal ) <= " + box[1]
-                + " and CAST( SUBSTRING(coordinates, LOCATE(',', o.coordinates) + 1, LOCATE(']', o.coordinates) - LOCATE(',', o.coordinates) - 1 ) AS big_decimal ) >= " + box[2]
-                + " and CAST( SUBSTRING(coordinates, LOCATE(',', o.coordinates) + 1, LOCATE(']', o.coordinates) - LOCATE(',', o.coordinates) - 1 ) AS big_decimal ) <= " + box[0]
+        return getQuery( "from OrganisationUnit o " +
+            "where o.featureType='Point' " +
+            "and o.coordinates is not null " +
+            "and cast( substring(o.coordinates, 2, locate(',', o.coordinates) - 2) AS big_decimal ) >= " + box[3] + " " +
+            "and cast( substring(o.coordinates, 2, locate(',', o.coordinates) - 2) AS big_decimal ) <= " + box[1] + " " +
+            "and cast( substring(coordinates, locate(',', o.coordinates) + 1, locate(']', o.coordinates) - locate(',', o.coordinates) - 1 ) AS big_decimal ) >= " + box[2] + " " +
+            "and cast( substring(coordinates, locate(',', o.coordinates) + 1, locate(']', o.coordinates) - locate(',', o.coordinates) - 1 ) AS big_decimal ) <= " + box[0]
         ).list();
     }
 
@@ -346,7 +325,8 @@
         Session session = sessionFactory.getCurrentSession();
         int counter = 0;
 
-        // use SF directly since we don't need to check for access etc here, just a simple update with no changes (so that path gets re-generated)
+        // Use session directly since we don't need to check for access
+        
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
             session.update( organisationUnit );
@@ -368,7 +348,8 @@
         Session session = sessionFactory.getCurrentSession();
         int counter = 0;
 
-        // use SF directly since we don't need to check for access etc here, just a simple update with no changes (so that path gets re-generated)
+        // Use session directly since we don't need to check for access
+        
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
             session.update( organisationUnit );