← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9157: local vn - Fixed roll-back importing value

 

------------------------------------------------------------
revno: 9157
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-12-01 18:00:04 +0700
message:
  local vn - Fixed roll-back importing value
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/GetPeriodsByImportReportAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/NumberUtils.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.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 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java	2012-11-26 09:12:15 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java	2012-12-01 11:00:04 +0000
@@ -1,7 +1,7 @@
 package org.hisp.dhis.reportsheet.importing;
 
 /*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,7 @@
  */
 
 import java.util.Date;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElement;
@@ -113,7 +114,13 @@
         {
             Period period = periodGenericManager.getSelectedPeriod();
 
-            executeToImport( organisationUnit, period, importItemIds );
+            Set<DataValue> oldDataValues = new HashSet<DataValue>();
+            Set<DataValue> newDataValues = new HashSet<DataValue>();
+
+            executeToImport( organisationUnit, period, importItemIds, oldDataValues, newDataValues );
+
+            selectionManager.setOldDataValueList( oldDataValues );
+            selectionManager.setNewDataValueList( newDataValues );
         }
 
         message = i18n.getString( "import_successfully" );
@@ -125,7 +132,8 @@
     // Abstract method
     // -------------------------------------------------------------------------
 
-    public abstract void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds );
+    public abstract void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds,
+        Set<DataValue> oldDataValues, Set<DataValue> newDataValues );
 
     // -------------------------------------------------------------------------
     // Supportive methods
@@ -134,7 +142,7 @@
     protected void addDataValue( OrganisationUnit unit, Period period, String expression, String value,
         Set<DataValue> oldList, Set<DataValue> newList )
     {
-        value = value.replaceAll( "\\.", "" ).replace( ",", "." );
+        //value = value.replaceAll( "\\.", "" ).replace( ",", "." );
 
         DataElementOperand operand = expressionService.getOperandsInExpression( expression ).iterator().next();
 
@@ -156,7 +164,9 @@
         }
         else
         {
-            oldList.add( dataValue );
+            DataValue backedUpDataValue = new DataValue( dataElement, period, unit, dataValue.getValue(), optionCombo );
+
+            oldList.add( backedUpDataValue );
 
             dataValue.setValue( value );
             dataValue.setTimestamp( new Date() );

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/GetPeriodsByImportReportAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/GetPeriodsByImportReportAction.java	2011-08-04 08:39:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/GetPeriodsByImportReportAction.java	2012-12-01 11:00:04 +0000
@@ -84,7 +84,7 @@
     public String execute()
         throws Exception
     {
-        if ( importReportId == null || importReportId.equals( "null" ) )
+        if ( importReportId == null || importReportId.equals( "null" ) || importReportId.trim().isEmpty() )
         {
             message = i18n.getString( "there_is_no_import_report" );
 

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java	2012-11-26 09:12:15 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java	2012-12-01 11:00:04 +0000
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
 import java.util.Set;
 
 import org.hisp.dhis.datavalue.DataValue;
@@ -47,18 +46,13 @@
     // Override the abstract method
     // -------------------------------------------------------------------------
 
-    public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds )
+    public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds,
+        Set<DataValue> oldDataValues, Set<DataValue> newDataValues )
     {
-        Set<DataValue> oldDataValues = new HashSet<DataValue>();
-        Set<DataValue> newDataValues = new HashSet<DataValue>();
-
         for ( int i = 0; i < importItemIds.length; i++ )
         {
             addDataValue( organisationUnit, period, importItemIds[i].split( "_" )[0], importItemIds[i].split( "_" )[1],
                 oldDataValues, newDataValues );
         }
-
-        selectionManager.setOldDataValueList( oldDataValues );
-        selectionManager.setNewDataValueList( newDataValues );
     }
 }
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java	2012-11-26 09:12:15 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java	2012-12-01 11:00:04 +0000
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
 import java.util.Set;
 
 import org.hisp.dhis.datavalue.DataValue;
@@ -47,18 +46,13 @@
     // Override the abstract method
     // -------------------------------------------------------------------------
 
-    public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds )
+    public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds,
+        Set<DataValue> oldDataValues, Set<DataValue> newDataValues )
     {
-        Set<DataValue> oldDataValues = new HashSet<DataValue>();
-        Set<DataValue> newDataValues = new HashSet<DataValue>();
-
         for ( int i = 0; i < importItemIds.length; i++ )
         {
             addDataValue( organisationUnit, period, importItemIds[i].split( "_" )[0], importItemIds[i].split( "_" )[1],
                 oldDataValues, newDataValues );
         }
-
-        selectionManager.setOldDataValueList( oldDataValues );
-        selectionManager.setNewDataValueList( newDataValues );
     }
 }
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java	2012-11-27 04:26:35 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java	2012-12-01 11:00:04 +0000
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
 import java.util.Set;
 
 import org.hisp.dhis.datavalue.DataValue;
@@ -48,11 +47,9 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds )
+    public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds,
+        Set<DataValue> oldDataValues, Set<DataValue> newDataValues )
     {
-        Set<DataValue> oldDataValues = new HashSet<DataValue>();
-        Set<DataValue> newDataValues = new HashSet<DataValue>();
-
         for ( int i = 0; i < importItemIds.length; i++ )
         {
             OrganisationUnit o = organisationUnitService.getOrganisationUnit( Integer.parseInt( importItemIds[i]
@@ -61,8 +58,5 @@
             addDataValue( o, period, importItemIds[i].split( "_" )[1], importItemIds[i].split( "_" )[2], oldDataValues,
                 newDataValues );
         }
-
-        selectionManager.setOldDataValueList( oldDataValues );
-        selectionManager.setNewDataValueList( newDataValues );
     }
 }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/NumberUtils.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/NumberUtils.java	2012-11-28 07:33:12 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/NumberUtils.java	2012-12-01 11:00:04 +0000
@@ -42,7 +42,7 @@
 
     // This pattern used for VN
     public static final String PATTERN_DECIMAL_FORMAT1 = "#,##0.######";
-    
+
     // This pattern is default in DHIS2
     public static final String PATTERN_DECIMAL_FORMAT2 = "#0.######";
 

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-11-27 11:50:14 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-12-01 11:00:04 +0000
@@ -287,11 +287,12 @@
 		
 	jQuery.postJSON( 'generateExportReport.action',
 	{
-		showSubItem: !isChecked( 'showSubItem' )	
+		showSubItem: !isChecked( 'showSubItem' ),
+		generateByDataSet: generateByDataSet
 	},
 	function ( json ) {
 		if ( json.response == "success" ) {
-			window.location = "downloadFile.action";		
+			window.location = "downloadFile.action";
 			unLockScreen();
 		}
 	});

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-11-28 17:09:45 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-12-01 11:00:04 +0000
@@ -85,11 +85,13 @@
 
 function previewExportReport()
 {
-	jQuery.get( spreadsheetTreePath + "previewExportReport.action",
-	{
-		showSubItem: !isChecked( 'showSubItem' ),
-		generateByDataSet: generateByDataSet
-	}, previewExportReportReceived );
+	$.ajax({
+		cache: false,
+		url: spreadsheetTreePath + "previewExportReport.action",
+		dataType: 'xml',
+		data: 'showSubItem=' + !isChecked( 'showSubItem' ) + '&generateByDataSet=' + generateByDataSet + '&_=[TIMESTAMP]',
+		success: previewExportReportReceived
+	});
 }
 
 function previewAdvandReport() 
@@ -126,7 +128,7 @@
 		_sHTMLBUTTONS.push( "</div>" );
 	}
 	else {
-		_sHTMLBUTTONS.push( "&nbsp;&nbsp;<a href='../dhis-web-spreadsheet-reporting/downloadFile.action' title='Download'><img src='images/download.png'/></a></div>" );
+		_sHTMLBUTTONS.push( "&nbsp;&nbsp;<a href='../dhis-web-spreadsheet-reporting/downloadFile.action' title='Download'><img src='../dhis-web-spreadsheet-reporting/images/download.png'/></a></div>" );
 	}
 	
 	var tabsHTML 	= [ _sHTMLBUTTONS.join('') + '<div id="tabs"><ul>' ];