← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1324: Implemented user interface for organisation unit merge

 

------------------------------------------------------------
revno: 1324
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-01-22 00:27:33 +0100
message:
  Implemented user interface for organisation unit merge
added:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseDataElement.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseOrganisationUnit.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/organisationunitmerge/
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/organisationunitmerge/MergeOrganisationUnitsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/organisationUnitMerge.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/organisationUnitMergeForm.vm
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/jdbc/JdbcDataMergeStore.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/NoAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.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
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js


--
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/datamerge/jdbc/JdbcDataMergeStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/jdbc/JdbcDataMergeStore.java	2009-12-25 17:33:46 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/jdbc/JdbcDataMergeStore.java	2010-01-21 23:27:33 +0000
@@ -65,7 +65,11 @@
         final int destCategoryOptionComboId = destCategoryOptionCombo.getId();
         final int sourceDataElementId = sourceDataElemenet.getId();
         final int sourceCategoryOptionComboId = sourceCategoryOptionCombo.getId();
-        
+
+        // -------------------------------------------------------------------------
+        // DataMergeStore implementation
+        // -------------------------------------------------------------------------
+
         final String sql =         
             "UPDATE datavalue AS d1 SET dataelementid=" + destDataElementId + ", categoryoptioncomboid=" + destCategoryOptionComboId + " " +
             "WHERE dataelementid=" + sourceDataElementId + " and categoryoptioncomboid=" + sourceCategoryOptionComboId + " " +

=== added directory 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json'
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseDataElement.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseDataElement.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseDataElement.vm	2010-01-21 23:27:33 +0000
@@ -0,0 +1,13 @@
+{
+  "dataElement":
+  {
+    "name": "$!{encoder.jsEncode( ${dataElement.name} )}",
+    "shortName": "$!{encoder.jsEncode( ${dataElement.shortName} )}",
+    "code": "$!{encoder.jsEncode( ${dataElement.code} )}",
+    "alternativeName": "$!{encoder.jsEncode( ${dataElement.alternativeName} )}",
+    "domainType": "$!{encoder.jsEncode( ${dataElement.domainType} )}",
+    "type": "$!{encoder.jsEncode( ${dataElement.type} )}",
+    "aggregationOperator": "$!{encoder.jsEncode( ${dataElement.aggregationOperator} )}",
+    "url": "$!{encoder.jsEncode( ${dataElement.url} )}"    
+  }
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseOrganisationUnit.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseOrganisationUnit.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/json/responseOrganisationUnit.vm	2010-01-21 23:27:33 +0000
@@ -0,0 +1,11 @@
+{
+  "organisationUnit":
+  {
+    "name": "$!{encoder.jsEncode( ${organisationUnit.name} )}",
+    "shortName": "$!{encoder.jsEncode( ${organisationUnit.shortName} )}",
+    "code": "$!{encoder.jsEncode( ${organisationUnit.code} )}",
+    "type": "$!{encoder.jsEncode( ${organisationUnit.type} )}",
+    "comment": "$!{encoder.jsEncode( ${organisationUnit.comment} )}",
+    "url": "$!{encoder.jsEncode( ${organisationUnit.url} )}"
+  }
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java	2010-01-21 23:27:33 +0000
@@ -0,0 +1,68 @@
+package org.hisp.dhis.commons.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetDataElementAction
+    implements Action
+{
+    private DataElementService dataElementService;
+    
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private Integer id;
+    
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private DataElement dataElement;
+
+    public DataElement getDataElement()
+    {
+        return dataElement;
+    }
+
+    public String execute()
+    {
+        dataElement = dataElementService.getDataElement( id );      
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java	2010-01-21 23:27:33 +0000
@@ -0,0 +1,71 @@
+package org.hisp.dhis.commons.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetOrganisationUnitAction
+    implements Action
+{
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+    
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
+    {
+        return organisationUnit;
+    }
+
+    public String execute()
+    {
+        if ( id != null )
+        {
+            organisationUnit = organisationUnitService.getOrganisationUnit( id );
+        }
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/NoAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/NoAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/NoAction.java	2010-01-21 23:27:33 +0000
@@ -36,6 +36,8 @@
 public class NoAction
     implements Action
 {
+    //TODO remove not required with struts2
+    
     public String execute()
     {
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2010-01-12 08:46:46 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2010-01-21 23:27:33 +0000
@@ -46,8 +46,7 @@
 		</property>
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.webportal.interceptor.WebWorkPortalParamsInterceptor"
+	<bean id="org.hisp.dhis.webportal.interceptor.WebWorkPortalParamsInterceptor"
 		class="org.hisp.dhis.webportal.interceptor.WebWorkPortalParamsInterceptor">
 		<property name="standardParams">
 			<set>
@@ -64,8 +63,7 @@
 		</property>
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.webportal.interceptor.WebWorkPortalModuleInterceptor"
+	<bean id="org.hisp.dhis.webportal.interceptor.WebWorkPortalModuleInterceptor"
 		class="org.hisp.dhis.webportal.interceptor.WebWorkPortalModuleInterceptor">
 		<property name="moduleManager">
 			<ref local="org.hisp.dhis.webportal.module.ModuleManager" />
@@ -88,16 +86,14 @@
 		</property>
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.webportal.interceptor.WebWorkPortalMenuInterceptor"
+	<bean id="org.hisp.dhis.webportal.interceptor.WebWorkPortalMenuInterceptor"
 		class="org.hisp.dhis.webportal.interceptor.WebWorkPortalMenuInterceptor">
 		<property name="menuStateManager">
 			<ref local="org.hisp.dhis.webportal.menu.MenuStateManager" />
 		</property>
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.webportal.interceptor.WebWorkPortalUserInterceptor"
+	<bean id="org.hisp.dhis.webportal.interceptor.WebWorkPortalUserInterceptor"
 		class="org.hisp.dhis.webportal.interceptor.WebWorkPortalUserInterceptor">
 		<property name="currentUserService">
 			<ref bean="org.hisp.dhis.user.CurrentUserService" />
@@ -540,6 +536,11 @@
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 	</bean>
 
+	<bean id="org.hisp.dhis.commons.action.GetDataElementAction"
+        class="org.hisp.dhis.commons.action.GetDataElementAction" scope="prototype">
+        <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+	</bean>
+		
 	<bean id="org.hisp.dhis.commons.action.GetDataSetsAction" class="org.hisp.dhis.commons.action.GetDataSetsAction"
 		scope="prototype">
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
@@ -563,6 +564,12 @@
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
+    <bean id="org.hisp.dhis.commons.action.GetOrganisationUnitAction"
+        class="org.hisp.dhis.commons.action.GetOrganisationUnitAction" scope="prototype">
+        <property name="organisationUnitService"
+            ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+    </bean>
+
 	<bean id="org.hisp.dhis.commons.action.GetPeriodsAction" class="org.hisp.dhis.commons.action.GetPeriodsAction"
 		scope="prototype">
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2010-01-19 07:28:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2010-01-21 23:27:33 +0000
@@ -277,43 +277,57 @@
 
 		<action name="getDataElements"
 			class="org.hisp.dhis.commons.action.GetDataElementsAction">
-			<result name="success" type="velocity">
+			<result name="success" type="velocity-xml">
 				/dhis-web-commons/ajax/responseDataElement.vm</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getDataSets" class="org.hisp.dhis.commons.action.GetDataSetsAction">
-			<result name="success" type="velocity">
+			<result name="success" type="velocity-xml">
 				/dhis-web-commons/ajax/responseDataSet.vm</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getIndicators" class="org.hisp.dhis.commons.action.GetIndicatorsAction">
-			<result name="success" type="velocity">
+			<result name="success" type="velocity-xml">
 				/dhis-web-commons/ajax/responseIndicator.vm</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getOrganisationUnitChildren"
 			class="org.hisp.dhis.commons.action.GetOrganisationUnitChildrenAction">
-			<result name="success" type="velocity">
-				/dhis-web-commons/ajax/responseOrganisationUnit.vm</result>
-			<param name="onExceptionReturn">plainTextError</param>
-		</action>
-
-		<action name="getOrganisationUnits"
-			class="org.hisp.dhis.commons.action.GetOrganisationUnitsAction">
-			<result name="success" type="velocity">
-				/dhis-web-commons/ajax/responseOrganisationUnit.vm</result>
-			<param name="onExceptionReturn">plainTextError</param>
-		</action>
-
+			<result name="success" type="velocity-xml">
+				/dhis-web-commons/ajax/responseOrganisationUnit.vm</result>
+			<param name="onExceptionReturn">plainTextError</param>
+		</action>
+
+        <action name="getOrganisationUnits"
+            class="org.hisp.dhis.commons.action.GetOrganisationUnitsAction">
+            <result name="success" type="velocity-xml">
+                /dhis-web-commons/ajax/responseOrganisationUnit.vm</result>
+            <param name="onExceptionReturn">plainTextError</param>
+        </action>
+        
 		<action name="getPeriods" class="org.hisp.dhis.commons.action.GetPeriodsAction">
-			<result name="success" type="velocity">
+			<result name="success" type="velocity-xml">
 				/dhis-web-commons/ajax/responsePeriod.vm</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
+        <action name="getDataElement"
+            class="org.hisp.dhis.commons.action.GetDataElementAction">
+            <result name="success" type="velocity-json">
+                /dhis-web-commons/ajax/json/responseDataElement.vm</result>
+            <param name="onExceptionReturn">plainTextError</param>
+        </action>
+
+        <action name="getOrganisationUnit"
+            class="org.hisp.dhis.commons.action.GetOrganisationUnitAction">
+            <result name="success" type="velocity-json">
+                /dhis-web-commons/ajax/json/responseOrganisationUnit.vm</result>
+            <param name="onExceptionReturn">plainTextError</param>
+        </action>       
+
 	</package>
 
 	<!-- About -->

=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/organisationunitmerge'
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/organisationunitmerge/MergeOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/organisationunitmerge/MergeOrganisationUnitsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/organisationunitmerge/MergeOrganisationUnitsAction.java	2010-01-21 23:27:33 +0000
@@ -0,0 +1,91 @@
+package org.hisp.dhis.dataadmin.action.organisationunitmerge;
+
+/*
+ * Copyright (c) 2004-2007, 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.datamerge.DataMergeService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class MergeOrganisationUnitsAction
+    extends ActionSupport
+{
+    private static final Log log = LogFactory.getLog( MergeOrganisationUnitsAction.class );
+    
+    private DataMergeService dataMergeService;
+
+    public void setDataMergeService( DataMergeService dataMergeService )
+    {
+        this.dataMergeService = dataMergeService;
+    }
+    
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private Integer organisationUnitToEliminate;
+    
+    public void setOrganisationUnitToEliminate( Integer organisationUnitToEliminate )
+    {
+        this.organisationUnitToEliminate = organisationUnitToEliminate;
+    }
+
+    private Integer organisationUnitToKeep;
+    
+    public void setOrganisationUnitToKeep( Integer organisationUnitToKeep )
+    {
+        this.organisationUnitToKeep = organisationUnitToKeep;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        OrganisationUnit eliminate = organisationUnitService.getOrganisationUnit( organisationUnitToEliminate );
+        OrganisationUnit keep = organisationUnitService.getOrganisationUnit( organisationUnitToKeep );
+
+        log.info( "Merging '" + eliminate + "' into '" + keep + "'" );
+        
+        //dataMergeService.mergeOrganisationUnits( keep, eliminate );
+        
+        log.info( "Merging complete" );
+        
+        return SUCCESS;
+    }
+}

=== 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	2009-12-29 07:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml	2010-01-21 23:27:33 +0000
@@ -270,5 +270,16 @@
   <bean id="org.hisp.dhis.dataadmin.action.databrowser.ExportPDFActionAction" 
     class="org.hisp.dhis.dataadmin.action.databrowser.ExportPDFAction"
     scope="prototype"/>
-    
+  
+  <!-- Organisation unit merge -->
+  
+  <bean id="org.hisp.dhis.dataadmin.action.organisationunitmerge.MergeOrganisationUnitsAction"
+	class="org.hisp.dhis.dataadmin.action.organisationunitmerge.MergeOrganisationUnitsAction"
+	scope="prototype">
+    <property name="dataMergeService"
+      ref="org.hisp.dhis.datamerge.DataMergeService"/>
+    <property name="organisationUnitService" 
+      ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+  </bean>
+  
 </beans>

=== 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	2010-01-19 14:24:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2010-01-21 23:27:33 +0000
@@ -124,6 +124,7 @@
 intro_data_integrity												= Run data integrity checks and unveil anomalies and problems in the meta data setup.
 intro_maintenance													= Perform maintenance tasks such as pruning of data values and periods and clearing of database resource tables.
 intro_resource_table												= Generate resource database tables for the organisation unit hierarchy and group set structure among others.
+intro_organisation_unit_merge										= Merge two organisation units and their data values. Data is merged depending on existence and date of last modification.
 intro_data_statistics												= Browse the number of objects in the database.
 intro_cache_statistics												= See the system database cache status and clear the cache.
 expression_is_empty 												= Expression is empty
@@ -137,3 +138,11 @@
 invalid_validation_rule_left_side_expressions						= Invalid validation rule left side expressions
 invalid_validation_rule_right_side_expressions						= Invalid validation rule right side expressions
 category_structure													= Category structure
+organisation_unit_merge												= Organisation Unit Merge
+select_the_org_unit_to_eliminate									= Select the organisation unit to eliminate
+not_selected														= Not selected
+select_the_org_unit_to_keep											= Select the organisation unit to keep
+merge																= Merge
+reset																= Reset
+confirm																= Confirm
+merging																= Merging

=== 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	2009-12-29 07:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2010-01-21 23:27:33 +0000
@@ -235,6 +235,19 @@
         <param name="bufferSize">10240</param>
       </result>
     </action>
+	
+	<!-- Organisation unit merge -->
+	
+    <action name="displayOrganisationUnitMergeForm" class="org.hisp.dhis.dataadmin.action.NoAction">
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-maintenance-dataadmin/organisationUnitMergeForm.vm</param>
+      <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/organisationUnitMerge.js</param>
+    </action>
+	
+	<action name="mergeOrganisationUnits" class="org.hisp.dhis.dataadmin.action.organisationunitmerge.MergeOrganisationUnitsAction">
+	  <result name="success" type="redirect">displayOrganisationUnitMergeForm.action</result>
+	</action>
     
   </package>
 </struts>

=== 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	2009-11-27 10:27:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm	2010-01-21 23:27:33 +0000
@@ -6,6 +6,7 @@
     #introListItem( "displayDataIntegrityForm.action" "data_integrity" )
     #introListItem( "displayMaintenanceForm.action" "maintenance" )
     #introListItem( "displayResourceTableForm.action" "resource_table" )
+    #introListItem( "displayOrganisationUnitMergeForm.action" "organisation_unit_merge" )
     #introListItem( "viewStatistics.action" "data_statistics" )
     #introListItem( "showCache.action" "cache_statistics" )
     #introListItem( "displayLockingForm.action" "data_locking" )

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/organisationUnitMerge.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/organisationUnitMerge.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/organisationUnitMerge.js	2010-01-21 23:27:33 +0000
@@ -0,0 +1,64 @@
+
+var organisationUnitToEliminate = 0;
+var organisationUnitToKeep = 0;
+var organisationUnitSelected = 0;
+
+function treeSelected( unitIds )
+{
+	organisationUnitSelected = unitIds[0];
+	
+	$.getJSON( 
+        "../dhis-web-commons-ajax/getOrganisationUnit.action",
+        {
+            "id": organisationUnitSelected
+        },
+        function( json )
+        {
+        	if ( organisationUnitToEliminate == 0 ) // Step 1
+        	{
+	            document.getElementById( "eliminateNameField" ).innerHTML = json.organisationUnit.name;
+	            document.getElementById( "confirmOrganisationUnitToEliminateButton" ).disabled = false;        
+        	}
+        	else // Step 2
+        	{
+        		document.getElementById( "keepNameField" ).innerHTML = json.organisationUnit.name;
+                document.getElementById( "confirmOrganisationUnitToKeepButton" ).disabled = false; 
+        	}   
+        }
+    );
+}
+
+function organisationUnitToEliminateConfirmed()
+{
+	organisationUnitToEliminate = organisationUnitSelected;	
+    document.getElementById( "confirmOrganisationUnitToEliminateButton" ).disabled = true;
+                
+	document.getElementById( 'step1' ).style.backgroundColor = 'white';
+	document.getElementById( 'step2' ).style.backgroundColor = '#ccffcc';
+}
+
+function organisationUnitToKeepConfirmed()
+{
+	organisationUnitToKeep = organisationUnitSelected;	
+	document.getElementById( "confirmOrganisationUnitToKeepButton" ).disabled = true;	
+    document.getElementById( "mergeButton" ).disabled = false;
+                
+    document.getElementById( 'step2' ).style.backgroundColor = 'white';
+    document.getElementById( 'step3' ).style.backgroundColor = '#ccffcc';              
+}
+
+function mergeOrganisationUnits()
+{
+	setMessage( i18n_merging + "..." );
+	
+	$.getJSON( 
+	    "mergeOrganisationUnits.action",
+        {
+	   	    "organisationUnitToEliminate": organisationUnitToEliminate,
+	   	    "organisationUnitToKeep": organisationUnitToKeep
+	    },
+	    function( json )
+	    {
+	    }
+	);
+}

=== 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	2009-11-27 10:27:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/menu.vm	2010-01-21 23:27:33 +0000
@@ -5,6 +5,7 @@
         <li><a href="displayDataIntegrityForm.action">$i18n.getString( "data_integrity" )&nbsp;</a></li>
 		<li><a href="displayMaintenanceForm.action">$i18n.getString( "maintenance" )&nbsp;</a></li>
 		<li><a href="displayResourceTableForm.action">$i18n.getString( "resource_table" )&nbsp;</a></li>
+		<li><a href="displayOrganisationUnitMergeForm.action">$i18n.getString( "organisation_unit_merge" )&nbsp;</a></li>
 		<li><a href="viewStatistics.action">$i18n.getString( "data_statistics" )&nbsp;</a></li>
         <li><a href="displayLockingForm.action">$i18n.getString( "data_locking" )&nbsp;</a></li>
 	</ul>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/organisationUnitMergeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/organisationUnitMergeForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/organisationUnitMergeForm.vm	2010-01-21 23:27:33 +0000
@@ -0,0 +1,59 @@
+
+<h3>$i18n.getString( "organisation_unit_merge" )</h3>
+
+<div id="selectionTree" style="width:500px; height:200px"></div>
+                    
+<script type="text/javascript">
+    selectionTreeSelection.setMultipleSelectionAllowed( false );
+    selectionTreeSelection.setListenerFunction( treeSelected );
+    selectionTree.buildSelectionTree();
+</script>
+
+<br>
+	
+<table>
+    <col style="width:2em">
+    <col>
+    <tr>
+        <td rowspan="3" id="step1" style="text-align:center;background-color:#ccffcc">1.</td>
+        <th>$i18n.getString( "select_the_org_unit_to_eliminate" )</th>
+    </tr>
+    <tr>
+        <td><span id="eliminateNameField">[$i18n.getString( "not_selected" )]</span></td>
+    </tr>
+    <tr>
+        <td><input id="confirmOrganisationUnitToEliminateButton" type="button" value="$i18n.getString( "confirm" )" onclick="organisationUnitToEliminateConfirmed()" style="width:10em" disabled="disabled"></td>
+    </tr>
+    <tr>
+        <td colspan="2">&nbsp;</td>
+    </tr>
+    <tr>
+        <td rowspan="3" id="step2" style="text-align:center">2.</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="confirmOrganisationUnitToKeepButton" type="button" value="$i18n.getString( "confirm" )" onclick="organisationUnitToKeepConfirmed()" style="width:10em" disabled="disabled"></td>
+    </tr>
+    <tr>
+        <td colspan="2">&nbsp;</td>
+    </tr>
+    <tr>
+        <td rowspan="2" id="step3" style="text-align:center">3.</td>
+        <th>$i18n.getString( "merge" )</th>
+    </tr>
+    <tr>
+        <td><input type="button" id="mergeButton" value="$i18n.getString( "merge" )" style="width:10em" onclick="mergeOrganisationUnits()" disabled="disabled"><input 
+                   type="button" value="$i18n.getString( "reset" )" style="width:10em" onclick="window.location.href='displayOrganisationUnitMergeForm.action'"></td>
+    </tr>
+</table>
+
+<p><span id="message"></span></p>
+
+<script type="text/javascript">
+    var i18n_merging = '$encoder.jsEscape( $i18n.getString( "merging" ), "'" )';
+    var i18n_performing_maintenance = '$encoder.jsEscape( $i18n.getString( "performing_maintenance" ), "'" )';
+    var i18n_maintenance_performed = '$encoder.jsEscape( $i18n.getString( "maintenance_performed" ), "'" )';
+</script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml	2009-11-16 17:04:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml	2010-01-21 23:27:33 +0000
@@ -131,7 +131,6 @@
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
-
 		<action name="openAddOrganisationUnitGroup"
 			class="org.hisp.dhis.oum.action.organisationunitgroup.select.SetupAssociationsTreeAction">
 			<result name="success" type="velocity">/main.vm</result>
@@ -146,8 +145,6 @@
 			</result>
 			<param name="requiredAuthorities">F_ORGUNITGROUP_ADD</param>
 		</action>
-		
-		
 
 		<action name="openUpdateOrganisationUnitGroup"
 			class="org.hisp.dhis.oum.action.organisationunitgroup.select.SetupAssociationsTreeAction">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js	2010-01-21 23:27:33 +0000
@@ -41,14 +41,6 @@
   var periodTypeName = periodTypeList.options[ periodTypeList.selectedIndex ].value;
   var level = levelList.options[ levelList.selectedIndex ].value;
   
-  /* DEBUG 
-  indicatorGroupId = "1152";
-  periodTypeName = "Monthly";
-  startDate = "2006-01-01";
-  endDate = "2007-01-01";
-  level = "4";  
-  /* DEBUG */
-  
   document.getElementById( "dataLabel" ).innerHTML = 
     i18n_indicator_group + ": " + indicatorGroupName +
     ", " + i18n_start_date + ": " + startDate +