dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39686
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20106: Program - org unit assignment, performance improvement
------------------------------------------------------------
revno: 20106
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-09-13 16:54:57 +0200
message:
Program - org unit assignment, performance improvement
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.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-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2015-09-13 14:17:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2015-09-13 14:54:57 +0000
@@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -56,6 +55,8 @@
import org.joda.time.DateTime;
import org.springframework.transaction.annotation.Transactional;
+import com.google.common.collect.Sets;
+
/**
* @author Lars Helge Overland
* @version $Id: DefaultDataSetService.java 6255 2008-11-10 16:01:24Z larshelg $
@@ -422,12 +423,12 @@
@Override
public void mergeWithCurrentUserOrganisationUnits( DataSet dataSet, Collection<OrganisationUnit> mergeOrganisationUnits )
{
- Set<OrganisationUnit> selectedOrgUnits = new HashSet<>( dataSet.getSources() );
+ Set<OrganisationUnit> selectedOrgUnits = Sets.newHashSet( dataSet.getSources() );
OrganisationUnitQueryParams params = new OrganisationUnitQueryParams();
params.setParents( currentUserService.getCurrentUser().getOrganisationUnits() );
- List<OrganisationUnit> userOrganisationUnits = organisationUnitService.getOrganisationUnitsByQuery( params );
+ Set<OrganisationUnit> userOrganisationUnits = Sets.newHashSet( organisationUnitService.getOrganisationUnitsByQuery( params ) );
selectedOrgUnits.removeAll( userOrganisationUnits );
selectedOrgUnits.addAll( mergeOrganisationUnits );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2015-09-13 14:17:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2015-09-13 14:54:57 +0000
@@ -28,7 +28,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.google.common.collect.Sets;
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.common.ValueType;
@@ -53,15 +60,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
+import com.google.common.collect.Sets;
/**
* @author Abyot Asalefew
@@ -322,18 +321,18 @@
@Override
public void mergeWithCurrentUserOrganisationUnits( Program program, Collection<OrganisationUnit> mergeOrganisationUnits )
{
- Set<OrganisationUnit> selectedOrgUnits = new HashSet<>( program.getOrganisationUnits() );
-
+ Set<OrganisationUnit> selectedOrgUnits = Sets.newHashSet( program.getOrganisationUnits() );
+
OrganisationUnitQueryParams params = new OrganisationUnitQueryParams();
params.setParents( currentUserService.getCurrentUser().getOrganisationUnits() );
- List<OrganisationUnit> userOrganisationUnits = organisationUnitService.getOrganisationUnitsByQuery( params );
+ Set<OrganisationUnit> userOrganisationUnits = Sets.newHashSet( organisationUnitService.getOrganisationUnitsByQuery( params ) );
- selectedOrgUnits.removeAll( userOrganisationUnits );
+ selectedOrgUnits.removeAll( userOrganisationUnits );
selectedOrgUnits.addAll( mergeOrganisationUnits );
-
+
program.updateOrganisationUnits( selectedOrgUnits );
-
+
updateProgram( program );
}