dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39247
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19886: Converting callables and comparators to lambdas
------------------------------------------------------------
revno: 19886
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-08-30 16:51:28 +0200
message:
Converting callables and comparators to lambdas
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalPermissionsEvaluator.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java
dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/ListUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.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-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2015-07-15 09:45:45 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2015-08-30 14:51:28 +0000
@@ -33,7 +33,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Comparator;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
@@ -46,6 +45,8 @@
import org.hisp.dhis.common.ListMap;
import org.hisp.dhis.common.SetMap;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.commons.filter.Filter;
+import org.hisp.dhis.commons.filter.FilterUtils;
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -73,8 +74,6 @@
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.system.filter.OrganisationUnitGroupWithoutGroupSetFilter;
-import org.hisp.dhis.commons.filter.Filter;
-import org.hisp.dhis.commons.filter.FilterUtils;
import org.hisp.dhis.validation.ValidationRule;
import org.hisp.dhis.validation.ValidationRuleService;
import org.springframework.transaction.annotation.Transactional;
@@ -240,14 +239,7 @@
for ( DataElementGroupSet groupSet : groupSets )
{
Collection<DataElement> duplicates = getDuplicates(
- new ArrayList<>( groupSet.getDataElements() ), new Comparator<DataElement>()
- {
- @Override
- public int compare( DataElement d1, DataElement d2 )
- {
- return d1.getName().compareTo( d2.getName() );
- }
- } );
+ new ArrayList<>( groupSet.getDataElements() ), IdentifiableObjectNameComparator.INSTANCE );
for ( DataElement duplicate : duplicates )
{
@@ -478,14 +470,7 @@
for ( IndicatorGroupSet groupSet : groupSets )
{
Collection<Indicator> duplicates = getDuplicates(
- new ArrayList<>( groupSet.getIndicators() ), new Comparator<Indicator>()
- {
- @Override
- public int compare( Indicator o1, Indicator o2 )
- {
- return o1.getName().compareTo( o2.getName() );
- }
- } );
+ new ArrayList<>( groupSet.getIndicators() ), IdentifiableObjectNameComparator.INSTANCE );
for ( Indicator duplicate : duplicates )
{
@@ -606,14 +591,7 @@
for ( OrganisationUnitGroupSet groupSet : groupSets )
{
Collection<OrganisationUnit> duplicates = getDuplicates(
- new ArrayList<>( groupSet.getOrganisationUnits() ), new Comparator<OrganisationUnit>()
- {
- @Override
- public int compare( OrganisationUnit o1, OrganisationUnit o2 )
- {
- return o1.getName().compareTo( o2.getName() );
- }
- } );
+ new ArrayList<>( groupSet.getOrganisationUnits() ), IdentifiableObjectNameComparator.INSTANCE );
for ( OrganisationUnit duplicate : duplicates )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalPermissionsEvaluator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalPermissionsEvaluator.java 2015-07-15 09:45:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalPermissionsEvaluator.java 2015-08-30 14:51:28 +0000
@@ -31,9 +31,9 @@
import static org.hisp.dhis.setting.SystemSettingManager.KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -42,9 +42,9 @@
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
/**
* This package private class holds the context for deciding on data approval permissions.
@@ -224,14 +224,8 @@
try
{
- userApprovalLevel = ( USER_APPROVAL_LEVEL_CACHE.get( user.getId() + "-" + da.getOrganisationUnit().getId(), new Callable<DataApprovalLevel>()
- {
- @Override
- public DataApprovalLevel call() throws ExecutionException
- {
- return dataApprovalLevelService.getUserApprovalLevel( user, dataApproval.getOrganisationUnit() );
- }
- } ) );
+ userApprovalLevel = USER_APPROVAL_LEVEL_CACHE.get( user.getId() + "-" + da.getOrganisationUnit().getId(),
+ () -> dataApprovalLevelService.getUserApprovalLevel( user, dataApproval.getOrganisationUnit() ) );
}
catch ( CacheLoader.InvalidCacheLoadException ex )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-08-30 14:21:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-08-30 14:51:28 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdentifiers;
+import static org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString;
import static org.hisp.dhis.dataapproval.DataApprovalState.ACCEPTED_HERE;
import static org.hisp.dhis.dataapproval.DataApprovalState.APPROVED_ABOVE;
import static org.hisp.dhis.dataapproval.DataApprovalState.APPROVED_HERE;
@@ -36,18 +38,13 @@
import static org.hisp.dhis.dataapproval.DataApprovalState.UNAPPROVED_READY;
import static org.hisp.dhis.dataapproval.DataApprovalState.UNAPPROVED_WAITING;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL;
-import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdentifiers;
-import static org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -55,6 +52,8 @@
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.IdentifiableObjectUtils;
+import org.hisp.dhis.commons.collection.CachingMap;
+import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.dataapproval.DataApproval;
import org.hisp.dhis.dataapproval.DataApprovalLevel;
import org.hisp.dhis.dataapproval.DataApprovalLevelService;
@@ -72,14 +71,14 @@
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.commons.collection.CachingMap;
import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
+import com.google.common.collect.Lists;
+
/**
* @author Jim Grace
*/
@@ -454,23 +453,9 @@
DataApprovalLevel statusLevel = ( level == 0 ? null : levelMap.get( level ) ); // null if not approved
DataApprovalLevel daLevel = ( statusLevel == null ? lowestApprovalLevelForOrgUnit : statusLevel );
- DataElementCategoryOptionCombo optionCombo = ( aoc == null || aoc == 0 ? null : optionComboCache.get( aoc, new Callable<DataElementCategoryOptionCombo>()
- {
- @Override
- public DataElementCategoryOptionCombo call() throws ExecutionException
- {
- return categoryService.getDataElementCategoryOptionCombo( aoc );
- }
- } ) );
+ DataElementCategoryOptionCombo optionCombo = aoc == null || aoc == 0 ? null : optionComboCache.get( aoc, () -> categoryService.getDataElementCategoryOptionCombo( aoc ) );
- OrganisationUnit ou = ( orgUnit != null ? orgUnit : orgUnitCache.get( ouId, new Callable<OrganisationUnit>()
- {
- @Override
- public OrganisationUnit call() throws ExecutionException
- {
- return organisationUnitService.getOrganisationUnit( ouId );
- }
- } ) );
+ OrganisationUnit ou = orgUnit != null ? orgUnit : orgUnitCache.get( ouId, () -> organisationUnitService.getOrganisationUnit( ouId ) );
if ( ou != null )
{
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2015-07-15 09:45:45 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2015-08-30 14:51:28 +0000
@@ -46,7 +46,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Callable;
import org.amplecode.quick.BatchHandler;
import org.amplecode.quick.BatchHandlerFactory;
@@ -57,6 +56,9 @@
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.IdentifiableProperty;
import org.hisp.dhis.common.IllegalQueryException;
+import org.hisp.dhis.commons.collection.CachingMap;
+import org.hisp.dhis.commons.util.Clock;
+import org.hisp.dhis.commons.util.DebugUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -93,9 +95,6 @@
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.ValidationUtils;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.commons.collection.CachingMap;
-import org.hisp.dhis.commons.util.Clock;
-import org.hisp.dhis.commons.util.DebugUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.csvreader.CsvReader;
@@ -739,14 +738,8 @@
attrOptionCombo = fallbackCategoryOptionCombo;
}
- boolean inUserHierarchy = orgUnitInHierarchyMap.get( orgUnit.getUid(), new Callable<Boolean>()
- {
- @Override
- public Boolean call() throws Exception
- {
- return organisationUnitService.isInUserHierarchy( orgUnit.getUid(), currentOrgUnits );
- }
- } );
+ boolean inUserHierarchy = orgUnitInHierarchyMap.get( orgUnit.getUid(),
+ () -> organisationUnitService.isInUserHierarchy( orgUnit.getUid(), currentOrgUnits ) );
if ( !inUserHierarchy )
{
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-08-06 17:12:37 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-08-30 14:51:28 +0000
@@ -1252,14 +1252,8 @@
// side, we only need name and id
private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileProgramWithoutData( Program program )
{
- Comparator<ProgramStageDataElement> OrderBySortOrder = new Comparator<ProgramStageDataElement>()
- {
- @Override
- public int compare( ProgramStageDataElement i1, ProgramStageDataElement i2 )
- {
- return i1.getSortOrder().compareTo( i2.getSortOrder() );
- }
- };
+ Comparator<ProgramStageDataElement> orderBySortOrder =
+ ( ProgramStageDataElement i1, ProgramStageDataElement i2 ) -> i1.getSortOrder().compareTo( i2.getSortOrder() );
org.hisp.dhis.api.mobile.model.LWUITmodel.Program anonymousProgramMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
@@ -1271,14 +1265,11 @@
{
anonymousProgramMobile.setVersion( program.getVersion() );
- // anonymousProgramMobile.setStatus( ProgramInstance.STATUS_ACTIVE
- // );
-
ProgramStage programStage = program.getProgramStages().iterator().next();
List<ProgramStageDataElement> programStageDataElements = new ArrayList<>(
programStage.getProgramStageDataElements() );
- Collections.sort( programStageDataElements, OrderBySortOrder );
+ Collections.sort( programStageDataElements, orderBySortOrder );
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<>();
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2015-08-30 14:21:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2015-08-30 14:51:28 +0000
@@ -35,14 +35,12 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import org.amplecode.quick.BatchHandler;
import org.amplecode.quick.BatchHandlerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.commons.collection.CachingMap;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.completeness.DataSetCompletenessService;
@@ -163,15 +161,8 @@
{
final String periodKey = dataSet.getPeriodType().getName() + period.getStartDate().toString() + period.getEndDate().toString();
- final List<Integer> periodsBetweenDates = periodCache.get( periodKey, new Callable<List<Integer>>()
- {
- public List<Integer> call()
- throws Exception
- {
- List<Period> periods = periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() );
- return IdentifiableObjectUtils.getIdentifiers( periods );
- }
- } );
+ final List<Integer> periodsBetweenDates = periodCache.get( periodKey,
+ () -> getIdentifiers( periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) ) );
final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, unit, relevantSources, dataSet );
=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/ListUtils.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/ListUtils.java 2015-08-05 15:46:59 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/collection/ListUtils.java 2015-08-30 14:51:28 +0000
@@ -141,7 +141,7 @@
* @param comparator the comparator.
* @return a set of duplicates from the given list.
*/
- public static <T> Set<T> getDuplicates( List<T> list, Comparator<T> comparator )
+ public static <T> Set<T> getDuplicates( List<T> list, Comparator<? super T> comparator )
{
Set<T> duplicates = new HashSet<>();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java 2015-07-09 04:31:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java 2015-08-30 14:51:28 +0000
@@ -28,8 +28,20 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import static com.google.common.collect.Lists.newArrayList;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataapproval.DataApproval;
import org.hisp.dhis.dataapproval.DataApprovalLevel;
@@ -67,19 +79,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* This controller uses both /dataApprovals and /dataAcceptances.
*
@@ -89,8 +88,6 @@
@RequestMapping
public class DataApprovalController
{
- private final static Log log = LogFactory.getLog( DataApprovalController.class );
-
public static final String APPROVALS_PATH = "/dataApprovals";
private static final String STATUS_PATH = APPROVALS_PATH + "/status";
private static final String MULTIPLE_SAVE_RESOURCE_PATH = APPROVALS_PATH + "/multiple";
@@ -136,8 +133,6 @@
@RequestParam String ou, HttpServletResponse response )
throws IOException, WebMessageException
{
- log.info( "GET " + APPROVALS_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
-
DataSet dataSet = dataSetService.getDataSet( ds );
if ( dataSet == null )
@@ -306,8 +301,6 @@
@RequestParam String pe,
@RequestParam String ou, HttpServletResponse response ) throws WebMessageException
{
- log.info( "POST " + APPROVALS_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
-
DataSet dataSet = dataSetService.getDataSet( ds );
if ( dataSet == null )
@@ -430,8 +423,6 @@
@RequestParam String pe,
@RequestParam String ou, HttpServletResponse response ) throws WebMessageException
{
- log.info( "POST " + APPROVALS_PATH + ACCEPTANCES_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
-
DataSet dataSet = dataSetService.getDataSet( ds );
if ( dataSet == null )
@@ -553,8 +544,6 @@
@RequestParam String pe,
@RequestParam String ou, HttpServletResponse response ) throws WebMessageException
{
- log.info( "DELETE " + APPROVALS_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
-
Set<DataSet> dataSets = new HashSet<>( objectManager.getByUid( DataSet.class, ds ) );
if ( dataSets.size() != ds.size() )
@@ -603,8 +592,6 @@
@RequestParam String pe,
@RequestParam String ou, HttpServletResponse response ) throws WebMessageException
{
- log.info( "DELETE " + APPROVALS_PATH + ACCEPTANCES_PATH + "?ds=" + ds + "&pe=" + pe + "&ou=" + ou );
-
DataSet dataSet = dataSetService.getDataSet( ds );
if ( dataSet == null )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.java 2015-08-30 14:51:28 +0000
@@ -28,18 +28,19 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.commons.collection.ListUtils;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.commons.collection.ListUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
+import com.opensymphony.xwork2.Action;
/**
* @author Lars Helge Overland
@@ -139,14 +140,7 @@
units.addAll( organisationUnitGroupService.getOrganisationUnitGroup( groupId ).getMembers() );
}
- Collection<OrganisationUnit> duplicates = ListUtils.getDuplicates( units, new Comparator<OrganisationUnit>()
- {
- @Override
- public int compare( OrganisationUnit o1, OrganisationUnit o2 )
- {
- return o1.getName().compareTo( o2.getName() );
- }
- } );
+ Collection<OrganisationUnit> duplicates = ListUtils.getDuplicates( units, IdentifiableObjectNameComparator.INSTANCE );
if ( duplicates.size() > 0 )
{