dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33103
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16861: Removed the OrganisationUnitGroup > DataSet associations. Speeds up loading of data entry meta-data.
------------------------------------------------------------
revno: 16861
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-09-29 20:29:02 +0200
message:
Removed the OrganisationUnitGroup > DataSet associations. Speeds up loading of data entry meta-data.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.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/dataapproval/DataApprovalSelection.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.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/OrganisationUnitGroupDeletionHandler.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/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm
--
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/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2014-09-15 20:06:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2014-09-29 18:29:02 +0000
@@ -28,13 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.HashSet;
+import java.util.Set;
+
import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
@@ -56,12 +52,16 @@
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.mapping.MapLegendSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.user.UserGroup;
-import java.util.HashSet;
-import java.util.Set;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
/**
* This class is used for defining the standardized DataSets. A DataSet consists
@@ -116,11 +116,6 @@
private Set<OrganisationUnit> sources = new HashSet<>();
/**
- * All OrganisationUnitGroup that register data with this DataSet.
- */
- private Set<OrganisationUnitGroup> organisationUnitGroups = new HashSet<>();
-
- /**
* The Sections associated with the DataSet.
*/
private Set<Section> sections = new HashSet<>();
@@ -311,44 +306,6 @@
}
}
- public void addOrganisationUnitGroup( OrganisationUnitGroup group )
- {
- organisationUnitGroups.add( group );
- group.getDataSets().add( this );
- }
-
- public boolean removeOrganisationUnitGroup( OrganisationUnitGroup group )
- {
- organisationUnitGroups.remove( group );
- return group.getDataSets().remove( this );
- }
-
- public void removeAllOrganisationUnitGroups()
- {
- for ( OrganisationUnitGroup group : organisationUnitGroups )
- {
- group.getDataSets().remove( this );
- }
-
- organisationUnitGroups.clear();
- }
-
- public void updateOrganisationUnitGroups( Set<OrganisationUnitGroup> updates )
- {
- for ( OrganisationUnitGroup group : new HashSet<>( organisationUnitGroups ) )
- {
- if ( !updates.contains( group ) )
- {
- removeOrganisationUnitGroup( group );
- }
- }
-
- for ( OrganisationUnitGroup group : updates )
- {
- addOrganisationUnitGroup( group );
- }
- }
-
public void addDataElement( DataElement dataElement )
{
dataElements.add( dataElement );
@@ -399,24 +356,6 @@
compulsoryDataElementOperands.remove( dataElementOperand );
}
- /**
- * Returns all organisation units assigned to this data set, including
- * org units assigned directly and organisation units assigned through groups.
- */
- public Set<OrganisationUnit> getAllOrganisationUnits()
- {
- Set<OrganisationUnit> units = new HashSet<>();
-
- units.addAll( sources );
-
- for ( OrganisationUnitGroup group : organisationUnitGroups )
- {
- units.addAll( group.getMembers() );
- }
-
- return units;
- }
-
public boolean hasDataEntryForm()
{
return dataEntryForm != null && dataEntryForm.hasForm();
@@ -588,21 +527,6 @@
this.sources = sources;
}
- @JsonProperty( value = "organisationUnitGroups" )
- @JsonSerialize( contentAs = BaseIdentifiableObject.class )
- @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } )
- @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
- public Set<OrganisationUnitGroup> getOrganisationUnitGroups()
- {
- return organisationUnitGroups;
- }
-
- public void setOrganisationUnitGroups( Set<OrganisationUnitGroup> organisationUnitGroups )
- {
- this.organisationUnitGroups = organisationUnitGroups;
- }
-
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JsonView( { DetailedView.class, WithoutOrganisationUnitsView.class } )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2014-09-29 18:29:02 +0000
@@ -671,18 +671,6 @@
return builder.toString();
}
- public Set<DataSet> getAllDataSets()
- {
- Set<DataSet> allDataSets = new HashSet<>( dataSets );
-
- for ( OrganisationUnitGroup organisationUnitGroup : groups )
- {
- allDataSets.addAll( organisationUnitGroup.getDataSets() );
- }
-
- return allDataSets;
- }
-
/**
* Returns a mapping between the uid and the uid parent graph of the given
* organisation units.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2014-09-29 18:29:02 +0000
@@ -39,7 +39,6 @@
import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
-import org.hisp.dhis.dataset.DataSet;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
@@ -65,9 +64,6 @@
@Scanned
private Set<OrganisationUnit> members = new HashSet<>();
- @Scanned
- private Set<DataSet> dataSets = new HashSet<>();
-
private OrganisationUnitGroupSet groupSet;
/**
@@ -132,44 +128,6 @@
addOrganisationUnit( unit );
}
}
-
- public void addDataSet( DataSet dataSet )
- {
- dataSets.add( dataSet );
- dataSet.getOrganisationUnitGroups().add( this );
- }
-
- public void removeDataSet( DataSet dataSet )
- {
- dataSets.remove( dataSet );
- dataSet.getOrganisationUnitGroups().remove( this );
- }
-
- public void removeAllDataSets()
- {
- for ( DataSet ds : dataSets )
- {
- ds.getOrganisationUnitGroups().remove( this );
- }
-
- dataSets.clear();
- }
-
- public void updateDataSets( Set<DataSet> updates )
- {
- for ( DataSet ds : new HashSet<>( dataSets ) )
- {
- if ( !updates.contains( ds ) )
- {
- removeDataSet( ds );
- }
- }
-
- for ( DataSet ds : updates )
- {
- addDataSet( ds );
- }
- }
public boolean hasSymbol()
{
@@ -236,20 +194,6 @@
this.attributeValues = attributeValues;
}
- @JsonProperty( value = "dataSets" )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "dataSets", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 )
- public Set<DataSet> getDataSets()
- {
- return dataSets;
- }
-
- public void setDataSets( Set<DataSet> dataSets )
- {
- this.dataSets = dataSets;
- }
-
@Override
public void mergeWith( IdentifiableObject other )
{
=== 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 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java 2014-09-29 18:29:02 +0000
@@ -123,8 +123,6 @@
Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap();
- Map<String, Set<String>> getOrganisationUnitGroupDataSetAssocationMap();
-
Set<Integer> getOrganisationUnitIdsWithoutData();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalSelection.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalSelection.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalSelection.java 2014-09-29 18:29:02 +0000
@@ -749,7 +749,7 @@
{
log.debug( "isUnapprovedBelow( " + orgUnit.getName() + " )" );
- if ( dataSetAssignedAtOrBelowLevel == false && orgUnit.getAllDataSets().contains( dataSet ) )
+ if ( dataSetAssignedAtOrBelowLevel == false && orgUnit.getDataSets().contains( dataSet ) )
{
dataSetAssignedAtOrBelowLevel = true;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java 2014-09-29 18:29:02 +0000
@@ -34,7 +34,6 @@
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.system.deletion.DeletionHandler;
/**
@@ -138,17 +137,4 @@
dataSetService.updateDataSet( dataSet );
}
}
-
- @Override
- public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
- {
- Iterator<DataSet> iterator = group.getDataSets().iterator();
-
- while ( iterator.hasNext() )
- {
- DataSet dataSet = iterator.next();
- dataSet.getOrganisationUnitGroups().remove( group );
- dataSetService.updateDataSet( dataSet );
- }
- }
}
=== 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 2014-09-28 20:14:48 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2014-09-29 18:29:02 +0000
@@ -28,16 +28,26 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.google.common.collect.Maps;
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+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 org.apache.commons.collections.CollectionUtils;
import org.hisp.dhis.common.IdentifiableObjectUtils;
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.hierarchy.HierarchyViolationException;
import org.hisp.dhis.i18n.I18nService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitLevelComparator;
import org.hisp.dhis.system.filter.OrganisationUnitPolygonCoveringCoordinateFilter;
-import org.hisp.dhis.system.util.ConversionUtils;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
import org.hisp.dhis.system.util.GeoUtils;
@@ -47,19 +57,7 @@
import org.hisp.dhis.version.VersionService;
import org.springframework.transaction.annotation.Transactional;
-import java.awt.geom.Point2D;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-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.i18n;
+import com.google.common.collect.Maps;
/**
* @author Torgeir Lorange Ostby
@@ -559,20 +557,6 @@
public OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet()
{
Map<String, Set<String>> associationSet = Maps.newHashMap( organisationUnitStore.getOrganisationUnitDataSetAssocationMap() );
- Map<String, Set<String>> groupAssociationSet = organisationUnitStore.getOrganisationUnitGroupDataSetAssocationMap();
-
- // merge maps
- for ( String key : groupAssociationSet.keySet() )
- {
- if ( associationSet.containsKey( key ) )
- {
- associationSet.get( key ).addAll( groupAssociationSet.get( key ) );
- }
- else
- {
- associationSet.put( key, groupAssociationSet.get( key ) );
- }
- }
filterUserDataSets( associationSet );
filterChildOrganisationUnits( associationSet );
@@ -596,13 +580,18 @@
return set;
}
+ /**
+ * Retains only the data sets from the map which the current user has access to.
+ *
+ * @param associationMap the associations between organisation unit and data sets.
+ */
private void filterUserDataSets( Map<String, Set<String>> associationMap )
{
User currentUser = currentUserService.getCurrentUser();
if ( currentUser != null && !currentUser.getUserCredentials().isSuper() )
{
- Collection<String> userDataSets = ConversionUtils.getUids( DataSet.class, currentUser.getUserCredentials().getAllDataSets() );
+ Collection<String> userDataSets = IdentifiableObjectUtils.getUids( currentUser.getUserCredentials().getAllDataSets() );
for ( Set<String> dataSets : associationMap.values() )
{
@@ -611,17 +600,24 @@
}
}
+ /**
+ * Retains only the organisation units in the sub-tree of the current user.
+ *
+ * TODO use offline levels
+ *
+ * @param associationMap the associations between organisation unit and data sets.
+ */
private void filterChildOrganisationUnits( Map<String, Set<String>> associationMap )
{
User currentUser = currentUserService.getCurrentUser();
- if ( currentUser != null )
+ if ( currentUser != null && currentUser.getOrganisationUnits() != null )
{
- Collection<String> parentIds = ConversionUtils.getUids( OrganisationUnit.class,
- currentUser.getOrganisationUnits() );
+ Collection<String> parentIds = IdentifiableObjectUtils.getUids( currentUser.getOrganisationUnits() );
Collection<OrganisationUnit> organisationUnitsWithChildren = getOrganisationUnitsWithChildren( parentIds );
- Collection<String> children = ConversionUtils.getUids( OrganisationUnit.class, organisationUnitsWithChildren );
+
+ Collection<String> children = IdentifiableObjectUtils.getUids( organisationUnitsWithChildren );
associationMap.keySet().retainAll( children );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java 2014-09-29 18:29:02 +0000
@@ -28,7 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.system.deletion.DeletionHandler;
/**
@@ -68,14 +67,4 @@
organisationUnitGroupService.updateOrganisationUnitGroup( group );
}
}
-
- @Override
- public void deleteDataSet( DataSet dataSet )
- {
- for ( OrganisationUnitGroup group : dataSet.getOrganisationUnitGroups() )
- {
- group.getDataSets().remove( dataSet );
- organisationUnitGroupService.updateOrganisationUnitGroup( group );
- }
- }
}
=== 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 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2014-09-29 18:29:02 +0000
@@ -33,7 +33,6 @@
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -46,6 +45,7 @@
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.AuditLogUtil;
+import org.hisp.dhis.common.SetMap;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
@@ -194,56 +194,15 @@
"left join organisationunit ou on ou.organisationunitid=d.sourceid " +
"left join dataset ds on ds.datasetid=d.datasetid";
- final Map<String, Set<String>> map = new HashMap<>();
-
- jdbcTemplate.query( sql, new RowCallbackHandler()
- {
- public void processRow( ResultSet rs ) throws SQLException
- {
- String dataSetId = rs.getString( "ds_uid" );
- String organisationUnitId = rs.getString( "ou_uid" );
-
- Set<String> dataSets = map.get( organisationUnitId );
-
- if ( dataSets == null )
- {
- dataSets = new HashSet<>();
- map.put( organisationUnitId, dataSets );
- }
-
- dataSets.add( dataSetId );
- }
- } );
-
- return map;
- }
-
- @Override
- public Map<String, Set<String>> getOrganisationUnitGroupDataSetAssocationMap()
- {
- final String sql = "select ds.uid as ds_uid, ou.uid as ou_uid from orgunitgroupdatasets ougds " +
- "left join orgunitgroupmembers ougm on ougds.orgunitgroupid=ougm.orgunitgroupid " +
- "left join organisationunit ou on ou.organisationunitid=ougm.organisationunitid " +
- "left join dataset ds on ds.datasetid=ougds.datasetid";
-
- final Map<String, Set<String>> map = new HashMap<>();
-
- jdbcTemplate.query( sql, new RowCallbackHandler()
- {
- public void processRow( ResultSet rs ) throws SQLException
- {
- String dataSetId = rs.getString( "ds_uid" );
- String organisationUnitId = rs.getString( "ou_uid" );
-
- Set<String> dataSets = map.get( organisationUnitId );
-
- if ( dataSets == null )
- {
- dataSets = new HashSet<>();
- map.put( organisationUnitId, dataSets );
- }
-
- dataSets.add( dataSetId );
+ final SetMap<String, String> map = new SetMap<>();
+
+ jdbcTemplate.query( sql, new RowCallbackHandler()
+ {
+ public void processRow( ResultSet rs ) throws SQLException
+ {
+ String dataSetId = rs.getString( "ds_uid" );
+ String organisationUnitId = rs.getString( "ou_uid" );
+ map.putValue( organisationUnitId, dataSetId );
}
} );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-09-29 10:21:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-09-29 18:29:02 +0000
@@ -128,6 +128,7 @@
executeSql( "DROP TABLE categoryoptioncombousergroupaccesses" );
executeSql( "DROP TABLE validationrulegroupuserrolestoalert" );
executeSql( "DROP TABLE expressionoptioncombo" );
+ executeSql( "DROP TABLE orgunitgroupdatasets" );
executeSql( "ALTER TABLE categoryoptioncombo drop column userid" );
executeSql( "ALTER TABLE categoryoptioncombo drop column publicaccess" );
executeSql( "ALTER TABLE dataelementcategoryoption drop column categoryid" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2014-09-15 20:06:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2014-09-29 18:29:02 +0000
@@ -50,11 +50,6 @@
foreign-key="fk_dataset_organisationunit" />
</set>
- <set name="organisationUnitGroups" table="orgunitgroupdatasets" inverse="true">
- <key column="datasetid" />
- <many-to-many class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" column="orgunitgroupid"/>
- </set>
-
<set name="sections" order-by="sortorder" inverse="true">
<cache usage="read-write" />
<key column="datasetid" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml 2013-10-10 15:32:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml 2014-09-29 18:29:02 +0000
@@ -28,13 +28,6 @@
foreign-key="fk_orgunitgroup_organisationunitid" />
</set>
- <set name="dataSets" table="orgunitgroupdatasets">
- <cache usage="read-write" />
- <key column="orgunitgroupid" foreign-key="fk_orgunitgroupdatasets_orgunitgroupid" />
- <many-to-many class="org.hisp.dhis.dataset.DataSet" column="datasetid"
- foreign-key="fk_orgunitgroup_datasetid" />
- </set>
-
<!-- Access properties -->
<many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_indicator_userid" />
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java 2014-09-26 10:43:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java 2014-09-29 18:29:02 +0000
@@ -28,23 +28,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.ActionSupport;
+import java.util.Collection;
+import java.util.List;
+
import org.hisp.dhis.attribute.AttributeService;
-import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.system.util.AttributeUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import com.opensymphony.xwork2.ActionSupport;
/**
* @author Torgeir Lorange Ostby
*/
-@SuppressWarnings( "serial" )
public class AddOrganisationUnitGroupAction
extends ActionSupport
{
@@ -73,13 +71,6 @@
this.attributeService = attributeService;
}
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -119,13 +110,6 @@
this.jsonAttributeValues = jsonAttributeValues;
}
- private List<String> dsSelected = new ArrayList<>();
-
- public void setDsSelected( List<String> dsSelected )
- {
- this.dsSelected = dsSelected;
- }
-
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -157,14 +141,6 @@
jsonAttributeValues, attributeService );
}
- if ( dsSelected != null )
- {
- for ( String id : dsSelected )
- {
- organisationUnitGroup.addDataSet( dataSetService.getDataSet( id ) );
- }
- }
-
organisationUnitGroupService.updateOrganisationUnitGroup( organisationUnitGroup );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java 2014-09-26 10:43:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java 2014-09-29 18:29:02 +0000
@@ -28,21 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.ActionSupport;
+import java.util.Collection;
+import java.util.List;
+
import org.hisp.dhis.attribute.AttributeService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.system.util.AttributeUtils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import com.opensymphony.xwork2.ActionSupport;
/**
* @author Torgeir Lorange Ostby
@@ -76,13 +72,6 @@
this.attributeService = attributeService;
}
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -129,13 +118,6 @@
this.jsonAttributeValues = jsonAttributeValues;
}
- private List<String> dsSelected = new ArrayList<>();
-
- public void setDsSelected( List<String> dsSelected )
- {
- this.dsSelected = dsSelected;
- }
-
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -163,22 +145,6 @@
jsonAttributeValues, attributeService );
}
- if ( dsSelected != null )
- {
- Set<DataSet> dataSets = new HashSet<>();
-
- for ( String id : dsSelected )
- {
- dataSets.add( dataSetService.getDataSet( id ) );
- }
-
- organisationUnitGroup.updateDataSets( dataSets );
- }
- else
- {
- organisationUnitGroup.getDataSets().clear();
- }
-
organisationUnitGroupService.updateOrganisationUnitGroup( organisationUnitGroup );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2014-06-06 12:39:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2014-09-29 18:29:02 +0000
@@ -91,7 +91,6 @@
<property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunitgroup.UpdateOrganisationUnitGroupAction" class="org.hisp.dhis.oum.action.organisationunitgroup.UpdateOrganisationUnitGroupAction"
@@ -99,7 +98,6 @@
<property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunitgroup.RemoveOrganisationUnitGroupAction" class="org.hisp.dhis.oum.action.organisationunitgroup.RemoveOrganisationUnitGroupAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupForm.vm 2014-09-26 10:43:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitGroupForm.vm 2014-09-29 18:29:02 +0000
@@ -7,19 +7,11 @@
}, {
'beforeValidateHandler' : function()
{
- $("#dsSelected").find("option").attr("selected", "selected");
#tblDynamicAttributesJavascript()
},
'rules' : getValidationRules( "organisationUnitGroup" )
} );
- $('#dsAvailable').selected({
- url: '../dhis-web-commons-ajax-json/getDataSets.action',
- target: $('#dsSelected'),
- search: $('#dsAvailableSearch'),
- iterator: 'dataSets'
- });
-
checkValueIsExist( "name", "validateOrganisationUnitGroup.action" );
checkValueIsExist( "shortName", "validateOrganisationUnitGroup.action" );
checkValueIsExist( "code", "validateOrganisationUnitGroup.action" );
@@ -68,12 +60,6 @@
</tr>
</table>
-#jqSelected({
- "prefix": "ds",
- "i18n_available": "available_data_sets",
- "i18n_selected": "selected_data_sets"
-})
-
<p>
<input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:10em"/>
<input type="button" onclick="window.location.href='organisationUnitGroup.action'" value="$i18n.getString( 'cancel' )" style="width:10em"/>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm 2014-09-26 10:43:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm 2014-09-29 18:29:02 +0000
@@ -6,18 +6,10 @@
}, {
'beforeValidateHandler' : function()
{
- $("#dsSelected").find("option").attr("selected", "selected");
#tblDynamicAttributesJavascript()
},
'rules' : getValidationRules( "organisationUnitGroup" )
} );
-
- $('#dsAvailable').selected({
- url: '../dhis-web-commons-ajax-json/getDataSets.action',
- target: $('#dsSelected'),
- search: $('#dsAvailableSearch'),
- iterator: 'dataSets'
- });
checkValueIsExist( "name", "validateOrganisationUnitGroup.action", {id:$!organisationUnitGroup.id} );
checkValueIsExist( "shortName", "validateOrganisationUnitGroup.action", {id:$!organisationUnitGroup.id} );
@@ -70,13 +62,6 @@
</tr>
</table>
-#jqSelected({
- "prefix": "ds",
- "i18n_available": "available_data_sets",
- "i18n_selected": "selected_data_sets",
- "objects": $organisationUnitGroup.dataSets
-})
-
<p>
<input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:10em"/>
<input type="button" onclick="window.location.href='organisationUnitGroup.action'" value="$i18n.getString( 'cancel' )" style="width:10em"/>