← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6137: Removed org unit prune function in data admin module, poorly implemented and not in use

 

------------------------------------------------------------
revno: 6137
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-02-29 10:21:50 +0100
message:
  Removed org unit prune function in data admin module, poorly implemented and not in use
removed:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/DefaultDataPruneService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/jdbc/
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/jdbc/JdbcDataPruneStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataprune/
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataprune/PruneOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/pruneOrganisationUnit.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/pruneOrganisationUnitForm.vm
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.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
=== removed directory 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune'
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/DefaultDataPruneService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/DefaultDataPruneService.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/DefaultDataPruneService.java	1970-01-01 00:00:00 +0000
@@ -1,134 +0,0 @@
-package org.hisp.dhis.dataprune;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * @author Quang Nguyen
- * @version Apr 6, 2010 5:48:15 PM
- */
-
-public class DefaultDataPruneService
-    implements DataPruneService
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private DataPruneStore dataPruneStore;
-
-    public void setDataPruneStore( DataPruneStore dataPruneStore )
-    {
-        this.dataPruneStore = dataPruneStore;
-    }
-
-    // -------------------------------------------------------------------------
-    // DataPruneService implementation
-    // -------------------------------------------------------------------------
-
-    @Transactional
-    public int pruneOrganisationUnit( OrganisationUnit organisationUnit )
-    {
-        deleteLevels( organisationUnit );
-
-        if ( organisationUnit.getParent() != null )
-        {
-            organisationUnit.setParent( null );
-            organisationUnitService.updateOrganisationUnit( organisationUnit );
-        }
-
-        List<OrganisationUnit> deletedOrgUnits = pruneOrganisationUnitLocal( organisationUnit );
-        
-        return dataPruneStore.deleteMultiOrganisationUnit( deletedOrgUnits );
-    }
-
-    private void deleteLevels( OrganisationUnit organisationUnit )
-    {
-        if ( organisationUnit.getParent() != null )
-        {
-            OrganisationUnitLevel level = organisationUnitService
-                .getOrganisationUnitLevelByLevel( organisationUnitService.getLevelOfOrganisationUnit( organisationUnit.getParent().getId() ) );
-
-            if ( level != null )
-            {
-                organisationUnitService.deleteOrganisationUnitLevel( level );
-            }
-        }
-        
-        if ( organisationUnit.getParent().getParent() != null )
-        {
-            deleteLevels( organisationUnit.getParent() );
-        }
-    }
-    
-    private List<OrganisationUnit> pruneOrganisationUnitLocal( OrganisationUnit organisationUnit )
-    {
-        List<OrganisationUnit> deleteOrgUnits = new ArrayList<OrganisationUnit>();
-
-        for ( OrganisationUnit eachRoot : organisationUnitService.getRootOrganisationUnits() )
-        {
-            if ( !eachRoot.equals( organisationUnit ) )
-            {
-                deleteBranch( eachRoot, deleteOrgUnits );
-            }
-        }
-
-        return deleteOrgUnits;
-    }
-
-    private void deleteBranch( OrganisationUnit organisationUnit, List<OrganisationUnit> deletedOrgUnits )
-    {
-        if ( !organisationUnit.getChildren().isEmpty() )
-        {
-            Set<OrganisationUnit> tmp = organisationUnit.getChildren();
-            Object[] childrenAsArray = tmp.toArray();
-
-            for ( Object eachChild : childrenAsArray )
-            {
-                deleteBranch( (OrganisationUnit) eachChild, deletedOrgUnits );
-            }
-        }
-
-        deletedOrgUnits.add( organisationUnit );
-    }
-}

=== removed directory 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/jdbc'
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/jdbc/JdbcDataPruneStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/jdbc/JdbcDataPruneStore.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataprune/jdbc/JdbcDataPruneStore.java	1970-01-01 00:00:00 +0000
@@ -1,368 +0,0 @@
-package org.hisp.dhis.dataprune.jdbc;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.List;
-
-import org.amplecode.quick.StatementHolder;
-import org.amplecode.quick.StatementManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.dataprune.DataPruneStore;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.system.util.ConversionUtils;
-import org.hisp.dhis.system.util.TextUtils;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * @author Quang Nguyen
- * @version Apr 6, 2010 5:48:15 PM
- */
-public class JdbcDataPruneStore 
-    implements DataPruneStore
-{
-    private static final Log log = LogFactory.getLog( JdbcDataPruneStore.class );
-    
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private JdbcTemplate jdbcTemplate;
-
-    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
-    {
-        this.jdbcTemplate = jdbcTemplate;
-    }
-    
-    private StatementManager statementManager;
-
-    public void setStatementManager( StatementManager statementManager )
-    {
-        this.statementManager = statementManager;
-    }
-
-    // -------------------------------------------------------------------------
-    // DataPruneService implementation
-    // -------------------------------------------------------------------------
-
-    public int deleteMultiOrganisationUnit( List<OrganisationUnit> orgUnits )
-    {
-        try
-        {
-            String orgUnitIds = TextUtils.getCommaDelimitedString( ConversionUtils.getIdentifiers( OrganisationUnit.class, orgUnits ) );
-
-            // delete values into datasetlocksource table
-            String sql = "delete from datasetlocksource where sourceid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into datasetlocksource sucessfully" );
-            
-            // delete values into completedatasetregistration table
-            sql = "delete from completedatasetregistration where sourceid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into completedatasetregistration sucessfully" );
-    
-            // delete values into datasetsource table
-            sql = "delete from datasetsource where sourceid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into datasetsource sucessfully" );
-    
-            // delete values into minmaxdataelement table
-            sql = "delete from minmaxdataelement where sourceid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into minmaxdataelement sucessfully" );
-    
-            // delete values into orgunitgroupmembers table
-            sql = "delete from orgunitgroupmembers where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into orgunitgroupmembers sucessfully" );
-    
-            // delete values into usermembership table
-            sql = "delete from usermembership where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into usermembership sucessfully" );
-    
-            // delete values into datamartexportorgunits table
-            sql = "delete from datamartexportorgunits where orgunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into datamartexportorgunits sucessfully" );
-    
-            // delete values into patientidentifier table
-            sql = "delete from patientidentifier where patientid in "+
-                    "( select patientid from patient where organisationunitid in (" + orgUnitIds + ") );";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patientidentifier sucessfully" );
-            
-            // delete values into patientattributevalue table
-            sql = "delete from patientdatavalue where programstageinstanceid in " +
-                    "( select programstageinstanceid from programstageinstance "+
-                        "join programinstance on programinstance.programinstanceid = programstageinstance.programinstanceid " + 
-                        "join patient on programinstance.patientid = patient.patientid "+
-                        "where patient.organisationunitid in  (" + orgUnitIds + ") );";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patientattributevalue sucessfully" );
-            
-            // delete values into patientattributevalue table
-            sql = "delete from patientattributevalue where patientid in " +
-                    "( select patientid from patient where organisationunitid in  (" + orgUnitIds + ") );";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patientattributevalue sucessfully" );
-            
-            // delete values into patient_attributes table
-            sql = "delete from patient_attributes where patientid in "+
-                    "( select patientid from patient where organisationunitid in (" + orgUnitIds + ") );";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patient_attributes sucessfully" );
-            
-            // delete values into patient_programs table
-            sql = "delete from patient_programs where patientid in "+
-                    "( select patientid from patient where organisationunitid in (" + orgUnitIds + ") );";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patient_programs sucessfully" );
-            
-            // delete values into relationship table
-            sql = "delete from relationship where patientaid in "+
-                    "( select patientid from patient where organisationunitid in ( " + orgUnitIds + ")) OR "+
-                    "patientbid in ( select patientid from patient where organisationunitid in ( " + orgUnitIds + ")); ";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patient sucessfully" );
-            
-            // update values into representativeid column of patient table
-            deleteRepresentative(orgUnitIds);
-            log.info( "Updating values into representativeid column of patient table sucessfully" );
-            
-            // delete values into patientdatavalue table
-            sql = "delete from patientdatavalue where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patientdatavalue sucessfully" );
-
-            // delete values into patientdatavaluearchive table
-            if ( isExistTable( "patientdatavaluearchive" ) )
-            {
-                sql = "delete from patientdatavaluearchive where organisationunitid in (" + orgUnitIds + ");";
-                jdbcTemplate.execute( sql );
-                log.info( "Deleting values into patientdatavaluearchive sucessfully" );
-            }
-
-            // delete values into programinstance_attributes table
-            sql = "delete from programinstance_attributes where programinstanceid in "+
-                    "( select programinstanceid from programinstance "+
-                    "join patient on programinstance.patientid = patient.patientid "+
-                    "where patient.organisationunitid in ( " + orgUnitIds + "));";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into programinstance_attributes sucessfully" );
-            
-            // delete values into programattributevalue table
-            sql = "delete from programattributevalue where programinstanceid in "+
-                    "( select programinstanceid from programinstance " +
-                    "join patient on programinstance.patientid = patient.patientid "+
-                    "where patient.organisationunitid in ( " + orgUnitIds + "));";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into programattributevalue sucessfully" );
-            
-            // delete values into programstageinstance table
-            sql = "delete from programstageinstance where programinstanceid in "+
-                    "( select programinstanceid from programinstance "+
-                    "join patient on programinstance.patientid = patient.patientid "+
-                    "where patient.organisationunitid in ( " + orgUnitIds + "));";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into programstageinstance sucessfully" );
-            
-            // delete values into programinstance table
-            sql = "delete from programinstance where patientid in "+
-                    "( select patientid from patient where organisationunitid in ( " + orgUnitIds + "));";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into programinstance sucessfully" );
-            
-            
-            // delete values into patient table
-            deleteOrganisation(orgUnitIds );
-            sql = "delete from patient where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into patient sucessfully" );
-            
-            // delete values into program_organisationunits table
-            sql = "delete from program_organisationunits where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into program_organisationunits sucessfully" );
-            
-            // delete values into chart_organisationunits table
-            sql = "delete from chart_organisationunits where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into chart_organisationunits sucessfully" );
-    
-            // delete values into reporttable_organisationunits table
-            sql = "delete from reporttable_organisationunits where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into reporttable_organisationunits sucessfully" );
-
-            // delete value into datavalue_audit table
-            if ( isExistTable( "datavalue_audit" ) )
-            {
-                sql = "delete from datavalue_audit where (dataelementid, periodid, sourceid, categoryoptioncomboid) in (select dataelementid, periodid, sourceid, categoryoptioncomboid from datavalue where sourceid in ("
-                    + orgUnitIds + "));";
-                jdbcTemplate.execute( sql );
-                log.info( "Deleting values into datavalue_audit sucessfully" );
-            }
-
-            // delete values into datavalue table
-            sql = "delete from datavalue where sourceid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into datavalue sucessfully" );
-
-            // delete values into datavaluearchive table
-            if ( isExistTable( "datavaluearchive" ) )
-            {
-                sql = "delete from datavaluearchive where sourceid in (" + orgUnitIds + ");";
-                jdbcTemplate.execute( sql );
-                log.info( "Deleting values into datavaluearchive sucessfully" );
-            }
-
-            // delete values into mapfile table
-            if ( isExistTable( "mapfile" ) )
-            {
-                sql = "delete from mapfile where organisationunitid in (" + orgUnitIds + ");";
-                jdbcTemplate.execute( sql );
-                log.info( "Deleting values into mapfile sucessfully" );
-            }
-
-            // delete values into feature table
-            if ( isExistTable( "feature" ) )
-            {
-                sql = "delete from feature where organisationunitid in (" + orgUnitIds + ");";
-                jdbcTemplate.execute( sql );
-                log.info( "Deleting values into feature sucessfully" );
-            }
-
-            // delete values into orgunitgroupmembers table
-            sql = "delete from orgunitgroupmembers where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into orgunitgroupmembers sucessfully" );
-
-            // delete values into organisationunit table
-            sql = "delete from organisationunit where organisationunitid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into organisationunit sucessfully" );
-            
-            // delete values into source table
-            sql = "delete from source where sourceid in (" + orgUnitIds + ");";
-            jdbcTemplate.execute( sql );
-            log.info( "Deleting values into source sucessfully" );
-            
-            log.info( "Deleting " + orgUnits.size() + " organisations units successfully" );
-
-            return 0;            
-        }
-        catch (Exception ex) 
-        {
-            ex.printStackTrace();
-        }
-        
-        return 1;
-    }
-    
-    private boolean isExistTable(String tableName)
-    {
-        StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            holder.getStatement().executeQuery( "SELECT * FROM " + tableName );
-            
-            return true;
-        }
-        catch ( Exception ex )
-        {
-            return false;
-        }
-        finally
-        {
-            holder.close();
-        }
-    }
-    
-    private void deleteRepresentative( String orgUnitIds )
-    {        
-        StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {
-            Statement statement = holder.getStatement();
-            
-            ResultSet patient = statement.executeQuery( "select patientid from patient where organisationunitid in ( " + orgUnitIds + ")" );
-
-            String patientIds = "0";
-            
-            while ( patient.next() )
-            {
-                patientIds += "," + patient.getInt( 1 );
-            }
-            
-            jdbcTemplate.execute( "UPDATE patient SET representativeid=null WHERE representativeid in ( " + patientIds + " );" );
-        }
-        catch ( Exception ex )
-        {
-            log.error( ex );
-        }
-        finally
-        {
-            holder.close();
-        }        
-    }
-    
-    public void deleteOrganisation(String orgUnitIds )
-    {
-        StatementHolder holder = statementManager.getHolder();
-
-        try
-        {
-            Statement statement = holder.getStatement();
-            
-            ResultSet parent = statement
-                .executeQuery( "select organisationunitid from organisationunit where organisationunitid in  ( " + orgUnitIds + ")" );
-
-            String parentIds = "0";
-            
-            while ( parent.next() )
-            {
-                parentIds += "," + parent.getInt( 1 );
-            }
-            
-            jdbcTemplate.execute( "UPDATE organisationunit SET parentid=null WHERE parentid in ( " + parentIds + " );" );
-        }
-        catch ( Exception ex )
-        {
-            log.error( ex );
-        }
-        finally
-        {
-            holder.close();
-        }
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2012-02-16 12:58:37 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2012-02-29 09:21:50 +0000
@@ -79,18 +79,6 @@
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
   </bean>
   
-  <!-- Data prune -->
-
-  <bean id="org.hisp.dhis.dataprune.DataPruneService" class="org.hisp.dhis.dataprune.DefaultDataPruneService">
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="dataPruneStore" ref="org.hisp.dhis.dataprune.DataPruneStore" />
-  </bean>
-
-  <bean id="org.hisp.dhis.dataprune.DataPruneStore" class="org.hisp.dhis.dataprune.jdbc.JdbcDataPruneStore">
-    <property name="jdbcTemplate" ref="jdbcTemplate" />
-    <property name="statementManager" ref="statementManager" />
-  </bean> 
-  
   <!-- Data archive -->
 
   <bean id="org.hisp.dhis.dataarchive.DataArchiveStore" class="org.hisp.dhis.dataarchive.jdbc.JdbcDataArchiveStore">

=== removed directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataprune'
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataprune/PruneOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataprune/PruneOrganisationUnitAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/dataprune/PruneOrganisationUnitAction.java	1970-01-01 00:00:00 +0000
@@ -1,96 +0,0 @@
-package org.hisp.dhis.dataadmin.action.dataprune;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.dataprune.DataPruneService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.oust.manager.SelectionTreeManager;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Quang Nguyen
- * @version Apr 6, 2010 6:27:10 PM
- */
-
-public class PruneOrganisationUnitAction
-    implements Action
-{
-    private static final Log log = LogFactory.getLog( PruneOrganisationUnitAction.class );
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private DataPruneService dataPruneService;
-
-    public void setDataPruneService( DataPruneService dataPruneService )
-    {
-        this.dataPruneService = dataPruneService;
-    }
-
-    private SelectionTreeManager selectionTreeManager;
-
-    public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
-    {
-        this.selectionTreeManager = selectionTreeManager;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        OrganisationUnit kept = selectionTreeManager.getSelectedOrganisationUnit();
-
-        log.info( "Pruning Organisation Unit, " + kept + " is kept" );
-
-        if ( kept.getParent() == null )
-        {
-            log.info( "Pruning is interrupted" );
-
-            return ERROR;
-        }
-
-        int codeError = dataPruneService.pruneOrganisationUnit( kept );
-
-        if ( codeError == 0 )
-        {
-
-            log.info( "Pruning complete" );
-
-            return SUCCESS;
-        }
-        else
-            return ERROR;
-    }
-
-}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2012-02-16 12:58:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2012-02-29 09:21:50 +0000
@@ -97,15 +97,6 @@
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
   </bean>
 
-  <!-- Prune Organisation unit -->
-
-  <bean id="org.hisp.dhis.dataadmin.action.dataprune.PruneOrganisationUnitAction"
-      class="org.hisp.dhis.dataadmin.action.dataprune.PruneOrganisationUnitAction"
-      scope="prototype">
-    <property name="dataPruneService" ref="org.hisp.dhis.dataprune.DataPruneService" />
-    <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
-  </bean>
-
   <!-- Duplicate data elimination -->
 
   <bean id="org.hisp.dhis.dataadmin.action.duplicatedataelimination.EliminateDuplicateDataAction"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2012-02-23 11:12:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2012-02-29 09:21:50 +0000
@@ -150,7 +150,6 @@
 unarchiving=Unarchiving
 done_number_of_values=done. Number of archived values is now
 prune=Prune
-prune_organisation_unit_confirmation=WARNING: If 'YES' then whole of organisation units, which are not belong to this selected unit, will be pruned.\nAre you sure you want to prune ?
 pruning=Pruning
 pruning_done=Pruning done
 browser=Data browser

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2012-02-22 11:53:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2012-02-29 09:21:50 +0000
@@ -78,23 +78,6 @@
 	  <param name="requiredAuthorities">F_PERFORM_MAINTENANCE</param>
     </action>
 
-    <!-- Prune Organisation unit -->
-
-    <action name="displayPruneOrganisationUnitForm" class="org.hisp.dhis.dataadmin.action.NoAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">
-        /dhis-web-maintenance-dataadmin/pruneOrganisationUnitForm.vm</param>
-      <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
-      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/pruneOrganisationUnit.js</param>
-	  <param name="requiredAuthorities">F_PRUNE_ORGANISATION_UNITS</param>
-    </action>
-
-    <action name="pruneOrganisationUnit" class="org.hisp.dhis.dataadmin.action.dataprune.PruneOrganisationUnitAction">
-      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-      <result name="error" type="velocity-json">/dhis-web-commons/ajax/jsonResponseError.vm</result>
-	  <param name="requiredAuthorities">F_PRUNE_ORGANISATION_UNITS</param>
-    </action>
-
     <!-- Statistics -->
 
     <action name="viewStatistics" class="org.hisp.dhis.dataadmin.action.statistics.GetStatisticsAction">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm	2012-02-16 13:44:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm	2012-02-29 09:21:50 +0000
@@ -20,7 +20,6 @@
     #introListImgItem( "viewStatistics.action" "data_statistics" "datastatistics" )
     #introListImgItem( "lockException.action" "lock_exception" "datalocking" )
     #introListImgItem( "zeroValueStorageManagement.action" "zero_storage_management" "zerovaluestorage" )
-    #introListImgItem( "displayPruneOrganisationUnitForm.action" "organisation_unit_pruning" "organisationunitpruning" )
 	#introListImgItem( "getMinMaxValidationParams.action" "min_max_value_generation" "minmaxvaluegeneration" ) 
     #introListImgItem( "showCache.action" "cache_statistics" "cachestatistics" )
     #introListImgItem( "constant.action" "constant" "constant" )

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/pruneOrganisationUnit.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/pruneOrganisationUnit.js	2010-11-08 09:21:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/pruneOrganisationUnit.js	1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-
-var organisationUnitSelected = 0;
-
-function treeSelected( unitIds )
-{
-	organisationUnitSelected = unitIds[0];
-	
-	if ( organisationUnitSelected != null && organisationUnitSelected != 0 )
-	{
-		$.getJSON( 
-	        "../dhis-web-commons-ajax-json/getOrganisationUnit.action",
-	        {
-	            "id": organisationUnitSelected
-	        },
-	        function( json )
-	        {
-	            setInnerHTML( 'keepNameField', json.organisationUnit.name );
-	            enable( 'pruneButton' );
-				hideHeaderMessage( 'message' );
-	        }
-	    );
-	}
-	else
-	{
-		setInnerHTML( 'keepNameField', i18n_not_selected );
-	    disable( 'pruneButton' );
-	}
-}
-
-function pruneOrganisationUnit() 
-{
-	var result = window.confirm(i18n_confirmation);
-
-	if ( result ) {
-	
-		setHeaderWaitMessage( i18n_pruning + "..." );
-
-		$.getJSON(
-			"pruneOrganisationUnit.action", {},
-			function( json )
-			{
-				hideHeaderMessage( 'message' );
-				
-				if ( json.response == "success" )
-				{	
-					showSuccessMessage( i18n_pruning_done );
-					setTimeout( "window.location.href='displayPruneOrganisationUnitForm.action'", 2500);
-				}
-				else
-				{
-					showErrorMessage( i18n_pruning_interrupted );
-				}
-			}
-		);
-	}
-}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm	2012-02-16 13:44:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm	2012-02-29 09:21:50 +0000
@@ -14,7 +14,6 @@
 	<li><a href="viewStatistics.action">$i18n.getString( "data_statistics" )&nbsp;</a></li>
     <li><a href="lockException.action">$i18n.getString( "lock_exception" )&nbsp;</a></li>
 	<li><a href="zeroValueStorageManagement.action">$i18n.getString( "zero_storage_management" )&nbsp;</a></li>
-	<li><a href="displayPruneOrganisationUnitForm.action">$i18n.getString( "organisation_unit_pruning" )&nbsp;</a></li>
 	<li><a href="getMinMaxValidationParams.action">$i18n.getString( "min_max_value_generation")&nbsp;</a></li>
 	<li><a href="constant.action">$i18n.getString( "constant")&nbsp;</a></li>
 	<li><a href="optionSet.action">$i18n.getString( "option_set")&nbsp;</a></li>

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/pruneOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/pruneOrganisationUnitForm.vm	2011-03-17 14:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/pruneOrganisationUnitForm.vm	1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
-<script type="text/javascript">
-	jQuery(document).ready( function(){
-		// Override the listener after tree loaded succesfully
-		selectionTreeSelection.setListenerFunction( treeSelected );
-	});
-
-	var i18n_confirmation = '$encoder.jsEscape( $i18n.getString( "prune_organisation_unit_confirmation" ), "'" )';
-    var i18n_pruning = '$encoder.jsEscape( $i18n.getString( "pruning" ), "'" )';
-	var i18n_not_selected = '$encoder.jsEscape( $i18n.getString( "not_selected" ), "'" )';
-    var i18n_pruning_done = '$encoder.jsEscape( $i18n.getString( "pruning_done" ), "'" )';
-    var i18n_pruning_interrupted = '$encoder.jsEscape( $i18n.getString( "pruning_interrupted" ), "'" )';
-</script>
-
-<h3>$i18n.getString( "organisation_unit_pruning" )</h3>
-
-<table>
-	<tr><td>#organisationUnitSelectionTree( true, false, false )</td></tr>
-</table>
-<br/>
-<table>
-    <col style="width:2em"/>
-    <col/>
-    <tr>
-        <td rowspan="3" style="text-align:center;background-color:#ccffcc"></td>
-        <th>$i18n.getString( "select_the_org_unit_to_keep" )</th>
-    </tr>
-    <tr>
-        <td><span id="keepNameField">[$i18n.getString( "not_selected" )]</span></td>
-    </tr>
-    <tr>
-        <td><input id="pruneButton" type="button" value="$i18n.getString( 'prune' )" onclick="pruneOrganisationUnit()" style="width:10em" disabled="disabled" /></td>
-    </tr>
-</table>
-
-<p><span id="message"></span></p>