← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20055: Removed unused code

 

------------------------------------------------------------
revno: 20055
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-09 10:45:33 +0200
message:
  Removed unused code
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
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.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-09-09 08:41:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2015-09-09 08:45:33 +0000
@@ -382,28 +382,6 @@
      */
     List<OrganisationUnit> getOrganisationUnitsWithoutGroups();
 
-    /**
-     * Returns all OrganisationUnit which names are like the given name, or which
-     * code or uid are equal the given name, and are within the given groups.
-     *
-     * @param query  the query to match on name, code or uid.
-     * @param groups the organisation unit groups.
-     * @param limit  the limit of returned objects.
-     * @return a list of OrganisationUnits.
-     */
-    List<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String name, Collection<OrganisationUnitGroup> groups, boolean limit );
-
-    /**
-     * Returns all OrganisationUnit which names are like the given name, or which
-     * code or uid are equal the given name, and are within the given groups.
-     *
-     * @param query  the query to match on name, code or uid.
-     * @param groups the organisation unit groups.
-     * @param limit  the limit of returned objects.
-     * @return a list of OrganisationUnits.
-     */
-    List<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String name, Collection<OrganisationUnitGroup> groups, OrganisationUnit parent, boolean limit );
-
     OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet( Integer maxlevels );
 
     List<OrganisationUnit> getOrganisationUnitsBetween( 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-09-08 21:26:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2015-09-09 08:45:33 +0000
@@ -107,21 +107,16 @@
      * @return all OrganisationUnits which are not a member of any OrganisationUnitGroups.
      */
     List<OrganisationUnit> getOrganisationUnitsWithoutGroups();
-    
+
+    /**
+     * Returns a list of OrganisationUnits based on the given params.
+     * 
+     * @param params the params.
+     * @return a list of OrganisationUnits.
+     */
     List<OrganisationUnit> getOrganisationUnits( OrganisationUnitQueryParams params );
 
     /**
-     * Returns all OrganisationUnit which names are like the given name, or which
-     * code or uid are equal the given name, and are within the given groups.
-     *
-     * @param query  the query to match on name, code or uid.
-     * @param groups the organisation unit groups.
-     * @param limit  the limit of returned objects.
-     * @return a list of OrganisationUnits.
-     */
-    List<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String query, Collection<OrganisationUnitGroup> groups, boolean limit );
-
-    /**
      * Creates a mapping between organisation unit UID and set of data set UIDs
      * being assigned to the organisation unit.
      * 

=== 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-09 08:41:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2015-09-09 08:45:33 +0000
@@ -60,7 +60,6 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 
 /**
  * @author Torgeir Lorange Ostby
@@ -611,38 +610,6 @@
     }
 
     @Override
-    public List<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String query,
-        Collection<OrganisationUnitGroup> groups, boolean limit )
-    {
-        return i18n( i18nService, organisationUnitStore.getOrganisationUnitsByNameAndGroups( query, groups, limit ) );
-    }
-
-    @Override
-    public List<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String name,
-        Collection<OrganisationUnitGroup> groups, OrganisationUnit parent, boolean limit )
-    {
-        // Can only limit in query if parent is not set and we get all units
-
-        boolean _limit = limit && parent == null;
-
-        final Set<OrganisationUnit> result = new HashSet<>( organisationUnitStore.getOrganisationUnitsByNameAndGroups( name,
-            groups, _limit ) );
-
-        if ( parent == null )
-        {
-            return new ArrayList<>( result );
-        }
-
-        final Set<OrganisationUnit> subTree = new HashSet<>( getOrganisationUnitWithChildren( parent.getId() ) );
-
-        List<OrganisationUnit> intersection = new ArrayList<>( Sets.intersection( subTree,
-            result ) );
-
-        return limit && intersection.size() > MAX_LIMIT ? intersection.subList( 0, MAX_LIMIT )
-            : intersection;
-    }
-
-    @Override
     public OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet( Integer maxLevels )
     {
         Map<String, Set<String>> associationSet = Maps.newHashMap( organisationUnitStore.getOrganisationUnitDataSetAssocationMap() );

=== 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-09-09 08:41:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-09-09 08:45:33 +0000
@@ -38,8 +38,6 @@
 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;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.Criteria;
@@ -56,7 +54,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.organisationunit.OrganisationUnitQueryParams;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.OrganisationUnitStore;
 import org.hisp.dhis.system.objectmapper.OrganisationUnitRelationshipRowMapper;
 import org.hisp.dhis.user.CurrentUserService;
@@ -224,63 +221,6 @@
     }
 
     @Override
-    @SuppressWarnings( "unchecked" )
-    public List<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String query,
-        Collection<OrganisationUnitGroup> groups, boolean limit )
-    {
-        boolean first = true;
-
-        query = StringUtils.trimToNull( query );
-        groups = CollectionUtils.isEmpty( groups ) ? null : groups;
-
-        StringBuilder hql = new StringBuilder( "from OrganisationUnit o" );
-
-        if ( query != null )
-        {
-            hql.append( " where ( lower(o.name) like :expression or o.code = :query or o.uid = :query )" );
-
-            first = false;
-        }
-
-        if ( groups != null )
-        {
-            for ( int i = 0; i < groups.size(); i++ )
-            {
-                String clause = first ? " where" : " and";
-
-                hql.append( clause ).append( " :g" ).append( i ).append( " in elements( o.groups )" );
-
-                first = false;
-            }
-        }
-
-        Query q = sessionFactory.getCurrentSession().createQuery( hql.toString() );
-
-        if ( query != null )
-        {
-            q.setString( "expression", "%" + query.toLowerCase() + "%" );
-            q.setString( "query", query );
-        }
-
-        if ( groups != null )
-        {
-            int i = 0;
-
-            for ( OrganisationUnitGroup group : groups )
-            {
-                q.setEntity( "g" + i++, group );
-            }
-        }
-
-        if ( limit )
-        {
-            q.setMaxResults( OrganisationUnitService.MAX_LIMIT );
-        }
-
-        return q.list();
-    }
-
-    @Override
     public Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap()
     {
         final String sql = "select ds.uid as ds_uid, ou.uid as ou_uid from datasetsource d " +

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java	2015-07-08 09:56:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java	2015-09-09 08:45:33 +0000
@@ -533,62 +533,6 @@
         assertEquals( 4, unitK.getLevel() );
     }
 
-    @Test
-    public void testGetOrganisationUnitsByNameAndGroups()
-    {
-        OrganisationUnit unitA = createOrganisationUnit( 'A' );
-        OrganisationUnit unitB = createOrganisationUnit( 'B', unitA );
-        unitA.getChildren().add( unitB );
-        OrganisationUnit unitC = createOrganisationUnit( 'C' );
-        organisationUnitService.addOrganisationUnit( unitA );
-        organisationUnitService.addOrganisationUnit( unitB );
-        organisationUnitService.addOrganisationUnit( unitC );
-
-        OrganisationUnitGroup groupA = createOrganisationUnitGroup( 'A' );
-        OrganisationUnitGroup groupB = createOrganisationUnitGroup( 'B' );
-        OrganisationUnitGroup groupC = createOrganisationUnitGroup( 'C' );
-
-        groupA.getMembers().add( unitA );
-        groupA.getMembers().add( unitB );
-        groupA.getMembers().add( unitC );
-        groupB.getMembers().add( unitA );
-        groupB.getMembers().add( unitB );
-        groupC.getMembers().add( unitA );
-
-        organisationUnitGroupService.addOrganisationUnitGroup( groupA );
-        organisationUnitGroupService.addOrganisationUnitGroup( groupB );
-        organisationUnitGroupService.addOrganisationUnitGroup( groupC );
-
-        List<OrganisationUnitGroup> groups = Arrays.asList( groupA );
-        List<OrganisationUnit> units = organisationUnitService.getOrganisationUnitsByNameAndGroups( null, groups, false );
-        assertEquals( 3, units.size() );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( unitA.getName().toLowerCase(), groups, false );
-        assertEquals( 1, units.size() );
-        assertTrue( units.contains( unitA ) );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( unitA.getName(), null, false );
-        assertEquals( 1, units.size() );
-        assertEquals( unitA, units.iterator().next() );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( null, groups, unitA, false );
-        assertEquals( 2, units.size() );
-        assertFalse( units.contains( unitC ) );
-
-        groups = Arrays.asList( groupA, groupB );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( null, groups, false );
-        assertEquals( 2, units.size() );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( unitB.getName().toUpperCase(), groups, false );
-        assertEquals( 1, units.size() );
-        assertEquals( unitB, units.iterator().next() );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( unitB.getName(), null, false );
-        assertEquals( 1, units.size() );
-        assertEquals( unitB, units.iterator().next() );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( null, groups, unitA, false );
-        assertEquals( 2, units.size() );
-
-        groups = Arrays.asList( groupA, groupB, groupC );
-        units = organisationUnitService.getOrganisationUnitsByNameAndGroups( null, groups, false );
-        assertEquals( 1, units.size() );
-    }
-
     // -------------------------------------------------------------------------
     // OrganisationUnitGroup
     // -------------------------------------------------------------------------