dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05071
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1689: Fixed bug with update of orgunit levels. Removed caching property from hibernate config for excel...
------------------------------------------------------------
revno: 1689
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-03-24 09:18:26 +0100
message:
Fixed bug with update of orgunit levels. Removed caching property from hibernate config for excel reporting, no point as no queries are cached
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/DataElementGroupOrder.hbm.xml
dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/PeriodColumn.hbm.xml
dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitlevel/SaveOrganisationUnitLevelsAction.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 2010-02-15 12:29:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2010-03-24 08:18:26 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.hierarchy.HierarchyViolationException;
@@ -271,6 +272,10 @@
void updateOrganisationUnitLevel( OrganisationUnitLevel level );
+ void addOrUpdateOrganisationUnitLevel( OrganisationUnitLevel level );
+
+ void pruneOrganisationUnitLevels( Set<Integer> currentLevels );
+
OrganisationUnitLevel getOrganisationUnitLevel( int id );
Collection<OrganisationUnitLevel> getOrganisationUnitLevels( Collection<Integer> identifiers );
=== 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 2010-02-15 12:29:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2010-03-24 08:18:26 +0000
@@ -475,6 +475,33 @@
organisationUnitStore.updateOrganisationUnitLevel( level );
}
+ public void addOrUpdateOrganisationUnitLevel( OrganisationUnitLevel level )
+ {
+ OrganisationUnitLevel existing = getOrganisationUnitLevelByLevel( level.getLevel() );
+
+ if ( existing == null )
+ {
+ addOrganisationUnitLevel( level );
+ }
+ else
+ {
+ existing.setName( level.getName() );
+
+ updateOrganisationUnitLevel( existing );
+ }
+ }
+
+ public void pruneOrganisationUnitLevels( Set<Integer> currentLevels )
+ {
+ for ( OrganisationUnitLevel level : getOrganisationUnitLevels() )
+ {
+ if ( !currentLevels.contains( level.getLevel() ) )
+ {
+ deleteOrganisationUnitLevel( level );
+ }
+ }
+ }
+
public OrganisationUnitLevel getOrganisationUnitLevel( int id )
{
return organisationUnitStore.getOrganisationUnitLevel( id );
=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/DataElementGroupOrder.hbm.xml'
--- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/DataElementGroupOrder.hbm.xml 2010-03-11 06:27:12 +0000
+++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/DataElementGroupOrder.hbm.xml 2010-03-24 08:18:26 +0000
@@ -4,7 +4,6 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.hisp.dhis.reportexcel.DataElementGroupOrder" table="reportexcel_dataelementgrouporders">
- <cache usage="read-write"/>
<id name="id" column="id">
<generator class="native" />
</id>
=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/PeriodColumn.hbm.xml'
--- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/PeriodColumn.hbm.xml 2010-03-11 06:27:12 +0000
+++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/hibernate/PeriodColumn.hbm.xml 2010-03-24 08:18:26 +0000
@@ -4,7 +4,6 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.hisp.dhis.reportexcel.PeriodColumn" table="reportexcel_periodcolumns">
- <cache usage="read-write"/>
<id name="id" column="periodcolumnid">
<generator class="native" />
</id>
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java 2009-04-23 17:16:55 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java 2010-03-24 08:18:26 +0000
@@ -72,16 +72,14 @@
}
@Override
- public boolean allowDeleteOrganisationUnitLevel( OrganisationUnitLevel level )
+ public void deleteOrganisationUnitLevel( OrganisationUnitLevel level )
{
for ( Map map : mappingService.getAllMaps() )
{
if ( map.getOrganisationUnitLevel().equals( level ) )
{
- return false;
+ mappingService.deleteMap( map );
}
}
-
- return true;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitlevel/SaveOrganisationUnitLevelsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitlevel/SaveOrganisationUnitLevelsAction.java 2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitlevel/SaveOrganisationUnitLevelsAction.java 2010-03-24 08:18:26 +0000
@@ -27,7 +27,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.Map.Entry;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -62,11 +64,11 @@
// -------------------------------------------------------------------------
public String execute()
- {
- organisationUnitService.deleteOrganisationUnitLevels();
-
+ {
Map<String, String> params = ContextUtils.getParameterMap( ServletActionContext.getRequest() );
+ Set<Integer> levels = new HashSet<Integer>();
+
for ( Entry<String, String> param : params.entrySet() )
{
String key = param.getKey();
@@ -76,12 +78,16 @@
{
if ( value != null && value.trim().length() > 0 )
{
- String level = key.substring( LEVEL_PARAM_PREFIX.length(), key.length() );
-
- organisationUnitService.addOrganisationUnitLevel( new OrganisationUnitLevel( Integer.parseInt( level ), value ) );
+ int level = Integer.parseInt( key.substring( LEVEL_PARAM_PREFIX.length(), key.length() ) );
+
+ organisationUnitService.addOrUpdateOrganisationUnitLevel( new OrganisationUnitLevel( level, value ) );
+
+ levels.add( level );
}
}
- }
+ }
+
+ organisationUnitService.pruneOrganisationUnitLevels( levels );
return SUCCESS;
}