← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9339: local vn - Auto form - Fixed in updating the expression of validation rule. And rollback action f...

 

------------------------------------------------------------
revno: 9339
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-12-17 19:53:25 +0700
message:
  local vn - Auto form - Fixed in updating the expression of validation rule. And rollback action fixed.
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/autoGenerateForm.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/preview/action/AutoGenerateFormByTemplate.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java	2012-12-17 10:36:42 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java	2012-12-17 12:53:25 +0000
@@ -254,8 +254,6 @@
 
     public String execute()
     {
-        cleanUp();
-
         Set<Integer> collectSheets = new HashSet<Integer>();
         collectSheets.add( 1 );
 
@@ -306,8 +304,6 @@
         {
             e.printStackTrace();
 
-            cleanUp();
-
             return ERROR;
         }
 
@@ -541,17 +537,6 @@
         xml.append( "<ds id='" + dataSetId + "' n='" + commonName + "'/>" );
     }
 
-    /**
-     * Writes out the WORKBOOK data as XML, with formatting information
-     * 
-     * @throws Exception
-     */
-
-    private void cleanUp()
-    {
-        System.gc();
-    }
-
     private String printFormatInfo( Sheet sheet, Cell objCell )
     {
         // The format information
@@ -674,11 +659,8 @@
         {
             ValidationRule vr = validationRuleService.getValidationRule( id );
 
-            Expression leftSide = vr.getLeftSide();
-            Expression rightSide = vr.getRightSide();
-
-            String leftExpression = leftSide.getExpression();
-            String rightExpression = rightSide.getExpression();
+            String leftExpression = vr.getLeftSide().getExpression();
+            String rightExpression = vr.getRightSide().getExpression();
 
             for ( String key2 : deMap2.keySet() )
             {
@@ -688,14 +670,13 @@
                 rightExpression = rightExpression.replaceAll( "\\[" + key2 + "\\]", operandId );
             }
 
-            leftSide.setDataElementsInExpression( expressionService.getDataElementsInExpression( leftExpression ) );
-            leftSide.setOptionCombosInExpression( expressionService.getOptionCombosInExpression( leftExpression ) );
-
-            rightSide.setDataElementsInExpression( expressionService.getDataElementsInExpression( rightExpression ) );
-            rightSide.setOptionCombosInExpression( expressionService.getOptionCombosInExpression( rightExpression ) );
-
-            vr.setLeftSide( leftSide );
-            vr.setRightSide( rightSide );
+            vr.getLeftSide().setExpression( leftExpression );
+            vr.getLeftSide().setDataElementsInExpression( expressionService.getDataElementsInExpression( leftExpression ) );
+            vr.getLeftSide().setOptionCombosInExpression( expressionService.getOptionCombosInExpression( leftExpression ) );
+
+            vr.getRightSide().setExpression( rightExpression );
+            vr.getRightSide().setDataElementsInExpression( expressionService.getDataElementsInExpression( rightExpression ) );
+            vr.getRightSide().setOptionCombosInExpression( expressionService.getOptionCombosInExpression( rightExpression ) );
 
             validationRuleService.updateValidationRule( vr );
         }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java	2012-12-17 10:36:42 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java	2012-12-17 12:53:25 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.reportsheet.ExportReport;
 import org.hisp.dhis.reportsheet.ExportReportService;
@@ -71,16 +72,16 @@
     // Input && Output
     // -------------------------------------------------------------------------
 
-    private int exportReportId;
+    private Integer exportReportId;
 
-    public void setExportReportId( int exportReportId )
+    public void setExportReportId( Integer exportReportId )
     {
         this.exportReportId = exportReportId;
     }
 
-    private int dataSetId;
+    private Integer dataSetId;
 
-    public void setDataSetId( int dataSetId )
+    public void setDataSetId( Integer dataSetId )
     {
         this.dataSetId = dataSetId;
     }
@@ -112,20 +113,6 @@
 
     public String execute()
     {
-        cleanUp();
-
-        autoRollBack();
-
-        return SUCCESS;
-    }
-
-    private void cleanUp()
-    {
-        System.gc();
-    }
-
-    private void autoRollBack()
-    {
         try
         {
             message = "";
@@ -137,13 +124,11 @@
                 if ( exportReport != null )
                 {
                     message += i18n.getString( "report_with_name" ) + " \"" + exportReport.getDisplayName();
+
+                    exportReportService.deleteExportReport( exportReportId );
+
+                    message += "\" " + i18n.getString( "deleted" );
                 }
-
-                exportReportService.deleteExportReport( exportReportId );
-
-                message += "\" " + i18n.getString( "deleted" );
-
-                exportReportId = 0;
             }
             if ( dataSetId > 0 )
             {
@@ -152,13 +137,11 @@
                 if ( ds != null )
                 {
                     message += "<br/>" + i18n.getString( "data_set_with_name" ) + " \"" + ds.getDisplayName();
+
+                    dataSetService.deleteDataSet( ds );
+
+                    message += "\" " + i18n.getString( "deleted" );
                 }
-
-                dataSetService.deleteDataSet( ds );
-
-                message += "\" " + i18n.getString( "deleted" );
-
-                dataSetId = 0;
             }
 
             int i = 0;
@@ -167,8 +150,13 @@
             {
                 for ( Integer id : indicatorIds )
                 {
-                    indicatorService.deleteIndicator( indicatorService.getIndicator( id ) );
-                    i++;
+                    Indicator indicator = indicatorService.getIndicator( id );
+
+                    if ( indicator != null )
+                    {
+                        indicatorService.deleteIndicator( indicator );
+                        i++;
+                    }
                 }
 
                 message += "<br/>" + i18n.getString( "indicators" ) + ": " + i + "/" + indicatorIds.size() + " "
@@ -184,8 +172,8 @@
                     i++;
                 }
 
-                message += "<br/>" + i18n.getString( "validation_rules" ) + ": " + i + "/" + validationRuleIds.size() + " "
-                    + i18n.getString( "deleted" );
+                message += "<br/>" + i18n.getString( "validation_rules" ) + ": " + i + "/" + validationRuleIds.size()
+                    + " " + i18n.getString( "deleted" );
             }
             if ( dataElementIds != null && !dataElementIds.isEmpty() )
             {
@@ -206,6 +194,10 @@
             message = i18n.getString( "auto_roll_back_failed" );
 
             e.printStackTrace();
+
+            return ERROR;
         }
+
+        return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/autoGenerateForm.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/autoGenerateForm.js	2012-12-17 10:36:42 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/autoGenerateForm.js	2012-12-17 12:53:25 +0000
@@ -69,14 +69,14 @@
 		var validationRuleTag	= parentElement.getElementsByTagName( 'validationRules' )[0];
 
 		var dataElements 		= dataElementTag.getElementsByTagName( 'id' );
-		var indicators 			= dataElementTag.getElementsByTagName( 'id' );
-		var validationRules 	= dataElementTag.getElementsByTagName( 'id' );
+		var indicators 			= indicatorTag.getElementsByTagName( 'id' );
+		var validationRules 	= validationRuleTag.getElementsByTagName( 'id' );
 		
 		var reportId = getElementAttribute( parentElement, 'exportReport', 'id' );
 		var dataSetId = getElementAttribute( parentElement, 'dataSet', 'id' );
 		
 		var url = 'autoGenerateFormRollback.action?';
-		
+
 		for ( var i  = 0 ; i < dataElements.length ; i ++ )
 		{
 			url += 'dataElementIds=' + dataElements[i].firstChild.nodeValue + '&';
@@ -94,7 +94,7 @@
 		
 		jQuery.post( url, {}, function( json ) {
 			if ( json.response == "success" ) {
-				showSuccessMessage( json.message, 7000 );
+				showSuccessMessage( json.message, 8000 );
 			} else {
 				showErrorMessage( json.message, 5000 );
 			}