dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04032
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1332: Impl GUI for duplicate data elimination
------------------------------------------------------------
revno: 1332
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-01-25 12:54:22 +0100
message:
Impl GUI for duplicate data elimination
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementName.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlCategoryOptionCombos.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java
modified:
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/java/org/hisp/dhis/dataadmin/action/duplicatedataelimination/EliminateDuplicateDataAction.java
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/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js
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
--
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.
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCategoryOptionCombos.vm 2010-01-25 11:54:22 +0000
@@ -0,0 +1,9 @@
+#set( $size = $categoryOptionCombos.size() )
+{ "categoryOptionCombos": [
+#foreach( $coc in $categoryOptionCombos )
+ {
+ "id": $!{coc.id},
+ "name": "$!{coc.name}"
+ }#if( $velocityCount < $size ),#end
+#end
+] }
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementName.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementName.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementName.vm 2010-01-25 11:54:22 +0000
@@ -0,0 +1,1 @@
+{ "name": "$!{name}" }
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlCategoryOptionCombos.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlCategoryOptionCombos.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlCategoryOptionCombos.vm 2010-01-25 11:54:22 +0000
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<categoryOptionCombos>
+#foreach( $coc in $categoryOptionCombos )
+ <categoryOptionCombo>
+ <id>$coc.id</id>
+ <name>$!encoder.xmlEncode( $coc.name )</name>
+ </categoryOptionCombo>
+#end
+</categoryOptionCombos>
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java 2010-01-25 11:54:22 +0000
@@ -0,0 +1,89 @@
+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 java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetCategoryOptionCombosAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Set<DataElementCategoryOptionCombo> categoryOptionCombos;
+
+ public Set<DataElementCategoryOptionCombo> getCategoryOptionCombos()
+ {
+ return categoryOptionCombos;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ DataElement dataElement = dataElementService.getDataElement( id );
+
+ categoryOptionCombos = dataElement.getCategoryCombo().getOptionCombos();
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java 2010-01-25 11:54:22 +0000
@@ -0,0 +1,104 @@
+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.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetDataElementNameAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer dataElementId;
+
+ public void setDataElementId( Integer dataElementId )
+ {
+ this.dataElementId = dataElementId;
+ }
+
+ private Integer categoryOptionComboId;
+
+ public void setCategoryOptionComboId( Integer categoryOptionComboId )
+ {
+ this.categoryOptionComboId = categoryOptionComboId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionComboId );
+
+ name = dataElement.getName() + " " + categoryOptionCombo.getName();
+
+ 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-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2010-01-25 11:54:22 +0000
@@ -595,6 +595,19 @@
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
+ <bean id="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction"
+ class="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction"
+ scope="prototype">
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.commons.action.GetDataElementNameAction"
+ class="org.hisp.dhis.commons.action.GetDataElementNameAction"
+ scope="prototype">
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService"/>
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
+ </bean>
+
<bean id="org.hisp.dhis.commons.action.NoAction"
class="org.hisp.dhis.commons.action.NoAction" />
=== 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-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2010-01-25 11:54:22 +0000
@@ -346,6 +346,12 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="getCategoryOptionCombos" class="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-commons/ajax/xmlCategoryOptionCombos.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
</package>
<!-- Common actions JSON -->
@@ -424,6 +430,18 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="getCategoryOptionCombos" class="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-commons/ajax/jsonCategoryOptionCombos.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="getDataElementName" class="org.hisp.dhis.commons.action.GetDataElementNameAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-commons/ajax/jsonDataElementName.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
</package>
<!-- About -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/duplicatedataelimination/EliminateDuplicateDataAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/duplicatedataelimination/EliminateDuplicateDataAction.java 2010-01-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/duplicatedataelimination/EliminateDuplicateDataAction.java 2010-01-25 11:54:22 +0000
@@ -119,7 +119,10 @@
log.info( "Eliminating: " + dataElementEliminate + " " + categoryOptionComboEliminate );
log.info( "Keeping: " + dataElementKeep + " " + categoryOptionComboKeep );
- //dataMergeService.mergeDataElements( dataElementKeep, categoryOptionComboKeep, dataElementEliminate, categoryOptionComboEliminate );
+ if ( !( dataElementToEliminate == dataElementToKeep && categoryOptionComboEliminate == categoryOptionComboKeep ) )
+ {
+ //dataMergeService.mergeDataElements( dataElementKeep, categoryOptionComboKeep, dataElementEliminate, categoryOptionComboEliminate );
+ }
log.info( "Elimination done" );
=== modified 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 2010-01-25 09:23:35 +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-25 11:54:22 +0000
@@ -90,7 +90,10 @@
log.info( "Merging " + eliminate + " into " + keep );
- //dataMergeService.mergeOrganisationUnits( keep, eliminate );
+ if ( !( organisationUnitToEliminate == organisationUnitToKeep ) )
+ {
+ //dataMergeService.mergeOrganisationUnits( keep, eliminate );
+ }
log.info( "Merging complete" );
=== 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-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2010-01-25 11:54:22 +0000
@@ -151,6 +151,9 @@
reset = Reset
confirm = Confirm
merging = Merging
+merging_done = Merging done
+eliminating = Eliminating
+elimination_done = Elimination done
select_the_data_element_to_eliminate = Select the data element to eliminate
select_the_data_element_to_keep = Select the data element to keep
eliminate = Eliminate
@@ -158,3 +161,6 @@
move_selected = Move Selected
duplicate_data_elimination = Duplicate Data Elimination
intro_duplicate_data_elimination = Eliminate data registered for duplicate data elements.
+select_different_org_units = Please select two different organisation units
+select_different_data_elements = Please select two different data elements
+filter = Filter
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm 2010-01-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm 2010-01-25 11:54:22 +0000
@@ -2,9 +2,10 @@
<h3>$i18n.getString( "duplicate_data_elimination" )</h3>
<div>
- <input type="text" style="width:294px"><br>
- <select id="dataElementList" size="6" style="width:300px"></select>
- <select id="categoryOptionCombolist" size="6" style="width:200px"></select>
+ <label>$i18n.getString( "filter" ):</label><br>
+ <input type="text" style="width:294px" onkeyup="filterList( this.value, 'dataElementList' )"><br>
+ <select id="dataElementList" size="6" style="width:300px" onclick="dataElementSelected()"></select>
+ <select id="categoryOptionComboList" size="6" style="width:200px" onclick="categoryOptionComboSelected()"></select>
</div>
<br>
@@ -51,6 +52,10 @@
<p><span id="message"></span></p>
<script type="text/javascript">
+ var i18n_eliminating = '$encoder.jsEscape( $i18n.getString( "eliminating" ), "'" )';
+ var i18n_elimination_done = '$encoder.jsEscape( $i18n.getString( "elimination_done" ), "'" )';
+ var i18n_select_different_data_elements = '$encoder.jsEscape( $i18n.getString( "select_different_data_elements" ), "'" )';
+
initLists();
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js 2010-01-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js 2010-01-25 11:54:22 +0000
@@ -1,4 +1,9 @@
+var dataElementToEliminate = 0;
+var categoryOptionComboToEliminate = 0;
+var dataElementToKeep = 0;
+var categoryOptionComboToKeep = 0;
+
function initLists()
{
$.getJSON(
@@ -6,8 +11,6 @@
{},
function( json )
{
- var dataElementList = document.getElementById( "dataElementList" );
-
var elements = json.dataElements;
for ( var i = 0; i < elements.length; i++ )
@@ -17,4 +20,99 @@
}
}
);
-}
\ No newline at end of file
+}
+
+function dataElementSelected()
+{
+ $( "#categoryOptionComboList" ).children().remove();
+
+ var dataElementId = $( "#dataElementList" ).val();
+
+ $.getJSON(
+ "../dhis-web-commons-ajax-json/getCategoryOptionCombos.action",
+ {
+ "id": dataElementId
+ },
+ function( json )
+ {
+ var cocs = json.categoryOptionCombos;
+
+ for ( var i = 0; i < cocs.length; i++ )
+ {
+ $( "#categoryOptionComboList" ).append( "<option value='" +
+ cocs[i].id + "'>" + cocs[i].name + "</option>" );
+ }
+ }
+ );
+}
+
+function categoryOptionComboSelected()
+{
+ $.getJSON(
+ "../dhis-web-commons-ajax-json/getDataElementName.action",
+ {
+ "dataElementId": $( "#dataElementList" ).val(),
+ "categoryOptionComboId": $( "#categoryOptionComboList" ).val()
+ },
+ function( json )
+ {
+ if ( dataElementToEliminate == 0 && categoryOptionComboToEliminate == 0 ) // Step 1
+ {
+ $( "#eliminateNameField" ).html( json.name );
+ $( "#confirmEliminateButton" ).removeAttr( "disabled" );
+ }
+ else // Step 2
+ {
+ $( "#keepNameField" ).html( json.name );
+ $( "#confirmKeepButton" ).removeAttr( "disabled" );
+ }
+ }
+ );
+}
+
+function eliminateConfirmed()
+{
+ dataElementToEliminate = $( "#dataElementList" ).val();
+ categoryOptionComboToEliminate = $( "#categoryOptionComboList" ).val();
+
+ $( "#confirmEliminateButton" ).attr( "disabled", "disabled" );
+
+ $( "#step1" ).css( "background-color", "white" );
+ $( "#step2" ).css( "background-color", "#ccffcc" );
+}
+
+function keepConfirmed()
+{
+ dataElementToKeep = $( "#dataElementList" ).val();
+ categoryOptionComboToKeep = $( "#categoryOptionComboList" ).val();
+
+ if ( dataElementToEliminate == dataElementToKeep &&
+ categoryOptionComboToEliminate == categoryOptionComboToKeep )
+ {
+ setMessage( i18n_select_different_data_elements );
+ return;
+ }
+
+ $( "#confirmKeepButton" ).attr( "disabled", "disabled" );
+ $( "#eliminateButton" ).removeAttr( "disabled" );
+
+ $( "#step2" ).css( "background-color", "white" );
+ $( "#step3" ).css( "background-color", "#ccffcc" );
+}
+
+function eliminate()
+{
+ setMessage( i18n_eliminating + "..." );
+
+ $.ajax({
+ "url": "eliminateDuplicateData.action",
+ "data": {
+ "dataElementToKeep": dataElementToKeep,
+ "categoryOptionComboToKeep": categoryOptionComboToKeep,
+ "dataElementToEliminate": dataElementToEliminate,
+ "categoryOptionComboToEliminate": categoryOptionComboToEliminate },
+ "success": function()
+ {
+ setMessage( i18n_elimination_done );
+ } });
+}
=== modified 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 2010-01-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/organisationUnitMerge.js 2010-01-25 11:54:22 +0000
@@ -7,25 +7,28 @@
{
organisationUnitSelected = unitIds[0];
- $.getJSON(
- "../dhis-web-commons-ajax-json/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;
- }
- }
- );
+ if ( organisationUnitSelected != null && organisationUnitSelected != 0 )
+ {
+ $.getJSON(
+ "../dhis-web-commons-ajax-json/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()
@@ -39,7 +42,14 @@
function organisationUnitToKeepConfirmed()
{
- organisationUnitToKeep = organisationUnitSelected;
+ organisationUnitToKeep = organisationUnitSelected;
+
+ if ( organisationUnitToEliminate == organisationUnitToKeep )
+ {
+ setMessage( i18n_select_different_org_units );
+ return;
+ }
+
document.getElementById( "confirmOrganisationUnitToKeepButton" ).disabled = true;
document.getElementById( "mergeButton" ).disabled = false;
@@ -51,14 +61,13 @@
{
setMessage( i18n_merging + "..." );
- $.getJSON(
- "mergeOrganisationUnits.action",
- {
- "organisationUnitToEliminate": organisationUnitToEliminate,
- "organisationUnitToKeep": organisationUnitToKeep
- },
- function( json )
- {
- }
- );
+ $.ajax({
+ "url": "mergeOrganisationUnits.action",
+ "data": {
+ "organisationUnitToEliminate": organisationUnitToEliminate,
+ "organisationUnitToKeep": organisationUnitToKeep },
+ "success": function()
+ {
+ setMessage( i18n_merging_done );
+ } });
}
=== modified 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 2010-01-25 09:23:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/organisationUnitMergeForm.vm 2010-01-25 11:54:22 +0000
@@ -54,4 +54,6 @@
<script type="text/javascript">
var i18n_merging = '$encoder.jsEscape( $i18n.getString( "merging" ), "'" )';
+ var i18n_merging_done = '$encoder.jsEscape( $i18n.getString( "merging_done" ), "'" )';
+ var i18n_select_different_org_units = '$encoder.jsEscape( $i18n.getString( "select_different_org_units" ), "'" )';
</script>