← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19839: Removed unecessary service method

 

------------------------------------------------------------
revno: 19839
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-08-25 09:43:48 +0200
message:
  Removed unecessary service method
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.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/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties


--
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/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2015-06-16 05:11:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2015-08-25 07:43:48 +0000
@@ -401,17 +401,6 @@
      */
     DataElementGroup getDataElementGroupByCode( String code );
 
-
-    /**
-     * Returns all DataElementGroups which contain the given DataElement.
-     *
-     * @param dataElement the DataElement which the DataElementGroups must
-     *                    contain.
-     * @return a collection of all DataElementGroups that contain the given
-     *         DataElement.
-     */
-    List<DataElementGroup> getGroupsContainingDataElement( DataElement dataElement );
-
     /**
      * Returns data elements with identifier in the given id.
      *

=== 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	2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2015-08-25 07:43:48 +0000
@@ -28,29 +28,32 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.i18n.I18nUtils.getCountByName;
+import static org.hisp.dhis.i18n.I18nUtils.getObjectsBetween;
+import static org.hisp.dhis.i18n.I18nUtils.getObjectsBetweenByName;
+import static org.hisp.dhis.i18n.I18nUtils.getObjectsByName;
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.hisp.dhis.common.GenericDimensionalObjectStore;
 import org.hisp.dhis.common.GenericNameableObjectStore;
 import org.hisp.dhis.common.ListMap;
+import org.hisp.dhis.commons.filter.Filter;
+import org.hisp.dhis.commons.filter.FilterUtils;
 import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.commons.filter.Filter;
-import org.hisp.dhis.commons.filter.FilterUtils;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.hisp.dhis.i18n.I18nUtils.*;
-
 /**
  * @author Kristian Nordal
  */
@@ -520,24 +523,6 @@
     }
 
     @Override
-    public List<DataElementGroup> getGroupsContainingDataElement( DataElement dataElement )
-    {
-        List<DataElementGroup> groups = getAllDataElementGroups();
-
-        Iterator<DataElementGroup> iterator = groups.iterator();
-
-        while ( iterator.hasNext() )
-        {
-            if ( !iterator.next().getMembers().contains( dataElement ) )
-            {
-                iterator.remove();
-            }
-        }
-
-        return groups;
-    }
-
-    @Override
     public Set<DataElement> getDataElementsByGroupId( int groupId )
     {
         return i18n( i18nService, dataElementGroupStore.get( groupId ).getMembers() );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java	2015-06-16 05:11:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java	2015-08-25 07:43:48 +0000
@@ -34,9 +34,7 @@
 import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.hisp.dhis.DhisSpringTest;
 import org.junit.Test;
@@ -501,51 +499,4 @@
         DataElementGroup dataElementGroupC = dataElementService.getDataElementGroupByName( "DataElementGroupC" );
         assertNull( dataElementGroupC );
     }
-
-    @Test
-    public void testGetGroupsContainingDataElement() throws Exception
-    {
-        DataElement dataElementA = createDataElement( 'A' );
-        DataElement dataElementB = createDataElement( 'B' );
-        DataElement dataElementC = createDataElement( 'C' );
-        DataElement dataElementD = createDataElement( 'D' );
-        dataElementService.addDataElement( dataElementA );
-        dataElementService.addDataElement( dataElementB );
-        dataElementService.addDataElement( dataElementC );
-        dataElementService.addDataElement( dataElementD );
-        
-        DataElementGroup dataElementGroupA = new DataElementGroup( "DataElementGroupA" );
-        DataElementGroup dataElementGroupB = new DataElementGroup( "DataElementGroupB" );
-        DataElementGroup dataElementGroupC = new DataElementGroup( "DataElementGroupC" );
-        DataElementGroup dataElementGroupD = new DataElementGroup( "DataElementGroupD" );
-        
-        Set<DataElement> membersA = new HashSet<>();
-        membersA.add( dataElementA );
-        membersA.add( dataElementB );
-        membersA.add( dataElementC );
-        
-        Set<DataElement> membersB = new HashSet<>();
-        membersB.add( dataElementC );
-        membersB.add( dataElementD );
-
-        dataElementGroupA.setMembers( membersA );
-        dataElementGroupB.setMembers( membersB );
-        dataElementGroupC.setMembers( membersA );
-        dataElementGroupD.setMembers( membersB );
-        
-        dataElementService.addDataElementGroup( dataElementGroupA );
-        dataElementService.addDataElementGroup( dataElementGroupB );
-        dataElementService.addDataElementGroup( dataElementGroupC );
-        dataElementService.addDataElementGroup( dataElementGroupD );
-        
-        List<DataElementGroup> groupsA = dataElementService.getGroupsContainingDataElement( dataElementA );
-        
-        assertTrue( groupsA.size() == 2 );
-        assertTrue( groupsA.contains( dataElementGroupA ) );
-        assertTrue( groupsA.contains( dataElementGroupC ) );        
-
-        List<DataElementGroup> groupsB = dataElementService.getGroupsContainingDataElement( dataElementC );
-        
-        assertTrue( groupsB.size() == 4 );
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementAction.java	2015-08-25 07:43:48 +0000
@@ -91,9 +91,8 @@
     public String execute()
     {
         dataElement = dataElementService.getDataElement( id );
-
-        dataElementGroups = new ArrayList<>( dataElementService
-            .getGroupsContainingDataElement( dataElement ) );
+        
+        dataElementGroups = new ArrayList<>( dataElement.getGroups() );
         
         Collections.sort( dataElementGroups, IdentifiableObjectNameComparator.INSTANCE );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java	2015-06-16 10:36:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java	2015-08-25 07:43:48 +0000
@@ -87,7 +87,7 @@
         {
             DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
-            dataElementGroups = dataElementService.getGroupsContainingDataElement( dataElement );
+            dataElementGroups = new ArrayList<>( dataElement.getGroups() );
 
             Collections.sort( dataElementGroups, IdentifiableObjectNameComparator.INSTANCE );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2015-08-18 22:46:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2015-08-25 07:43:48 +0000
@@ -96,7 +96,7 @@
 object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type
 hide_warning=Hide warning
 update_dataelement_group_members=Update Data Element Group Member
-update_success=Update Success
+update_success=Update was successful
 member_of=Member of
 data_element_group_editor=Data Element Group Editor
 move_up=Move up