← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2003: Fixed bug: Validation rule analysis result not sorted or displayed properly

 

------------------------------------------------------------
revno: 2003
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Mon 2010-08-30 08:24:45 +0200
message:
  Fixed bug: Validation rule analysis result not sorted or displayed properly
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/PdfService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/impl/ItextPdfService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultPDFAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultWorkbookAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.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
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java	2010-05-28 19:17:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java	2010-08-30 06:24:45 +0000
@@ -109,10 +109,7 @@
             {
                 if ( (relevantRules = getRelevantValidationRules( dataSet )).size() > 0 )
                 {
-                    for ( Period period : relevantPeriods ) // TODO use only
-                    // period with
-                    // validation rule
-                    // period type
+                    for ( Period period : relevantPeriods ) // TODO use only period with validation rule period type
                     {
                         validationViolations.addAll( validate( period, source, relevantRules ) );
                     }
@@ -253,13 +250,11 @@
     {
         final Collection<ValidationRule> relevantValidationRules = new HashSet<ValidationRule>();
 
-        for ( final ValidationRule validationRule : validationRules )
+        for ( ValidationRule validationRule : validationRules )
         {
-            // Check periodType of the validationRule
-
             if ( validationRule.getPeriodType() == dataSet.getPeriodType() )
             {
-                for ( final DataElement dataElement : dataSet.getDataElements() )
+                for ( DataElement dataElement : dataSet.getDataElements() )
                 {
                     if ( validationRule.getLeftSide().getDataElementsInExpression().contains( dataElement )
                         || validationRule.getRightSide().getDataElementsInExpression().contains( dataElement ) )

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/PdfService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/PdfService.java	2010-06-03 08:06:09 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/PdfService.java	2010-08-30 06:24:45 +0000
@@ -56,6 +56,6 @@
     void writeDataSetCompletenessResult( Collection<DataSetCompletenessResult> results, OutputStream out, I18n i18n,
         OrganisationUnit unit, DataSet dataSet );
 
-    void writeValidationResult( Map<String, List<ValidationResult>> results, OutputStream out, I18n i18n,
+    void writeValidationResult( List<ValidationResult> results, OutputStream out, I18n i18n,
         I18nFormat format );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/impl/ItextPdfService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/impl/ItextPdfService.java	2010-06-08 07:00:46 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pdf/impl/ItextPdfService.java	2010-08-30 06:24:45 +0000
@@ -288,7 +288,7 @@
         closeDocument( document );
     }
 
-    public void writeValidationResult( Map<String, List<ValidationResult>> results, OutputStream out, I18n i18n,
+    public void writeValidationResult( List<ValidationResult> results, OutputStream out, I18n i18n,
         I18nFormat format )
     {
         Document document = openDocument( out );
@@ -318,31 +318,22 @@
 
         if ( results != null )
         {
-            for ( String periodTypeName : results.keySet() )
+            for ( ValidationResult validationResult : results )
             {
-                List<ValidationResult> validationResults = results.get( periodTypeName );
-
-                table.addCell( getCell( 7, 8 ) );
-
-                table.addCell( getItalicCell( periodTypeName, 7 ) );
-
-                for ( ValidationResult validationResult : validationResults )
-                {
-                    OrganisationUnit unit = (OrganisationUnit) validationResult.getSource();
-
-                    Period period = validationResult.getPeriod();
-
-                    table.addCell( getTextCell( unit.getName(), TEXT ) );
-                    table.addCell( getTextCell( format.formatPeriod( period ), TEXT ) );
-                    table.addCell( getTextCell( validationResult.getValidationRule().getLeftSide().getDescription(),
-                        TEXT ) );
-                    table.addCell( getTextCell( String.valueOf( validationResult.getLeftsideValue() ) ) );
-                    table.addCell( getTextCell( i18n.getString( validationResult.getValidationRule().getOperator() ),
-                        1, ALIGN_CENTER ) );
-                    table.addCell( getTextCell( String.valueOf( validationResult.getRightsideValue() ) ) );
-                    table.addCell( getTextCell( validationResult.getValidationRule().getRightSide().getDescription(),
-                        TEXT ) );
-                }
+                OrganisationUnit unit = (OrganisationUnit) validationResult.getSource();
+
+                Period period = validationResult.getPeriod();
+
+                table.addCell( getTextCell( unit.getName(), TEXT ) );
+                table.addCell( getTextCell( format.formatPeriod( period ), TEXT ) );
+                table.addCell( getTextCell( validationResult.getValidationRule().getLeftSide().getDescription(),
+                    TEXT ) );
+                table.addCell( getTextCell( String.valueOf( validationResult.getLeftsideValue() ) ) );
+                table.addCell( getTextCell( i18n.getString( validationResult.getValidationRule().getOperator() ),
+                    1, ALIGN_CENTER ) );
+                table.addCell( getTextCell( String.valueOf( validationResult.getRightsideValue() ) ) );
+                table.addCell( getTextCell( validationResult.getValidationRule().getRightSide().getDescription(),
+                    TEXT ) );
             }
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java	2010-05-26 15:58:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java	2010-08-30 06:24:45 +0000
@@ -30,7 +30,6 @@
 import java.io.OutputStream;
 import java.util.Collection;
 import java.util.List;
-import java.util.Map;
 
 import org.hisp.dhis.completeness.DataSetCompletenessResult;
 import org.hisp.dhis.dataset.DataSet;
@@ -57,5 +56,5 @@
 
     void writeDataSetCompletenessResult( Collection<DataSetCompletenessResult> results, OutputStream out, I18n i18n, OrganisationUnit unit, DataSet dataSet );
     
-    void writeValidationResult( Map<String, List<ValidationResult>> results, OutputStream out, I18n i18n, I18nFormat format );
+    void writeValidationResult( List<ValidationResult> results, OutputStream out, I18n i18n, I18nFormat format );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java	2010-05-26 15:58:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java	2010-08-30 06:24:45 +0000
@@ -395,8 +395,7 @@
         }
     }
 
-    public void writeValidationResult( Map<String, List<ValidationResult>> results, OutputStream out, I18n i18n,
-        I18nFormat format )
+    public void writeValidationResult( List<ValidationResult> results, OutputStream out, I18n i18n, I18nFormat format )
     {
         final int MARGIN_LEFT = 1;
 
@@ -434,38 +433,31 @@
 
             if ( results != null )
             {
-                for ( String periodTypeName : results.keySet() )
+                for ( ValidationResult result : results )
                 {
-                    List<ValidationResult> validationResults = results.get( periodTypeName );
-                    
-                    sheet.addCell( new Label( MARGIN_LEFT + 0, row++, periodTypeName, columnHeader ) );
-                    
-                    for ( ValidationResult result : validationResults )
-                    {
-                        OrganisationUnit unit = (OrganisationUnit) result.getSource();
-
-                        Period period = result.getPeriod();
-
-                        sheet.addCell( new Label( MARGIN_LEFT + 0, row, unit.getName(), text ) );
-                        sheet.addCell( new Label( MARGIN_LEFT + 1, row, format.formatPeriod( period ), text ) );
-                        sheet.addCell( new Label( MARGIN_LEFT + 2, row, result.getValidationRule().getLeftSide()
-                            .getDescription(), text ) );
-                        sheet.addCell( new Number( MARGIN_LEFT + 3, row, result.getLeftsideValue(), text ) );
-                        sheet.addCell( new Label( MARGIN_LEFT + 4, row, i18n.getString( result.getValidationRule()
-                            .getOperator() ), text ) );
-                        sheet.addCell( new Number( MARGIN_LEFT + 5, row, result.getRightsideValue(), text ) );
-                        sheet.addCell( new Label( MARGIN_LEFT + 6, row, result.getValidationRule().getRightSide()
-                            .getDescription(), text ) );
-
-                        row++;
-                    }
+                    OrganisationUnit unit = (OrganisationUnit) result.getSource();
+
+                    Period period = result.getPeriod();
+
+                    sheet.addCell( new Label( MARGIN_LEFT + 0, row, unit.getName(), text ) );
+                    sheet.addCell( new Label( MARGIN_LEFT + 1, row, format.formatPeriod( period ), text ) );
+                    sheet.addCell( new Label( MARGIN_LEFT + 2, row, result.getValidationRule().getLeftSide()
+                        .getDescription(), text ) );
+                    sheet.addCell( new Number( MARGIN_LEFT + 3, row, result.getLeftsideValue(), text ) );
+                    sheet.addCell( new Label( MARGIN_LEFT + 4, row, i18n.getString( result.getValidationRule()
+                        .getOperator() ), text ) );
+                    sheet.addCell( new Number( MARGIN_LEFT + 5, row, result.getRightsideValue(), text ) );
+                    sheet.addCell( new Label( MARGIN_LEFT + 6, row, result.getValidationRule().getRightSide()
+                        .getDescription(), text ) );
+
+                    row++;
                 }
 
                 workbook.write();
 
                 workbook.close();
                 
-            }// end if
+            }
         }
         catch ( IOException ex )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-07-04 23:55:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-08-30 06:24:45 +0000
@@ -122,10 +122,7 @@
 	var i18n_aggregate = '$encoder.jsEscape( $i18n.getString( "aggregate" ) , "'")';
 	var i18n_patient = '$encoder.jsEscape( $i18n.getString( "patient" ) , "'")';
 	
-	
 	jQuery(document).ready(function(){	
 		tableSorter( 'dataElementList' );	
 	});
-	
-	
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultPDFAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultPDFAction.java	2010-05-26 15:58:31 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultPDFAction.java	2010-08-30 06:24:45 +0000
@@ -31,7 +31,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.util.List;
-import java.util.Map;
 
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -94,7 +93,7 @@
     public String execute()
         throws Exception
     {
-        Map<String, List<ValidationResult>> results = (Map<String, List<ValidationResult>>) SessionUtils.
+        List<ValidationResult> results = (List<ValidationResult>) SessionUtils.
             getSessionVar( KEY_VALIDATIONRESULT );
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultWorkbookAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultWorkbookAction.java	2010-05-27 08:42:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GenerateValidationResultWorkbookAction.java	2010-08-30 06:24:45 +0000
@@ -31,7 +31,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.util.List;
-import java.util.Map;
 
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -94,7 +93,7 @@
     public String execute()
         throws Exception
     {
-        Map<String, List<ValidationResult>> results = (Map<String, List<ValidationResult>>) SessionUtils.
+        List<ValidationResult> results = (List<ValidationResult>) SessionUtils.
             getSessionVar( KEY_VALIDATIONRESULT );
         
         ByteArrayOutputStream out = new ByteArrayOutputStream();

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java	2010-06-30 16:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java	2010-08-30 06:24:45 +0000
@@ -30,10 +30,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -41,7 +39,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.oust.manager.SelectionTreeManager;
-import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.source.Source;
 import org.hisp.dhis.util.SessionUtils;
 import org.hisp.dhis.validation.ValidationResult;
@@ -129,12 +126,12 @@
     {
         this.validationRuleGroupId = validationRuleGroupId;
     }
-
-    private Map<String, List<ValidationResult>> mapValidationResults;
-
-    public Map<String, List<ValidationResult>> getMapValidationResults()
+    
+    private List<ValidationResult> validationResults;
+
+    public List<ValidationResult> getValidationResults()
     {
-        return mapValidationResults;
+        return validationResults;
     }
 
     // -------------------------------------------------------------------------
@@ -154,8 +151,6 @@
 
         sources = organisationUnits;
 
-        List<ValidationResult> validationResults = null;
-
         if ( validationRuleGroupId == -1 )
         {
             log.info( "Validating all rules" );
@@ -175,29 +170,7 @@
 
         Collections.sort( validationResults, new ValidationResultComparator() );
 
-        mapValidationResults = new HashMap<String, List<ValidationResult>>();
-
-        for ( ValidationResult validationResult : validationResults )
-        {
-            PeriodType periodType = validationResult.getPeriod().getPeriodType();
-
-            if ( periodType != null )
-            {
-
-                List<ValidationResult> result = mapValidationResults.get( periodType.getName() );
-
-                if ( result == null )
-                {
-                    result = new ArrayList<ValidationResult>();
-                }
-
-                result.add( validationResult );
-
-                mapValidationResults.put( periodType.getName(), result );
-            }
-        }
-
-        SessionUtils.setSessionVar( KEY_VALIDATIONRESULT, mapValidationResults );
+        SessionUtils.setSessionVar( KEY_VALIDATIONRESULT, validationResults );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2010-06-30 16:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2010-08-30 06:24:45 +0000
@@ -27,6 +27,7 @@
 			$( "div#analysisInput" ).hide();
 			$( "div#analysisResult" ).show();
 			$( "div#analysisResult" ).html( data );
+			pageInit();
 		} );
     }
     else if ( type == 'error' )

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.vm	2010-05-26 15:58:31 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/viewValidationResultForm.vm	2010-08-30 06:24:45 +0000
@@ -35,16 +35,16 @@
 	<span id="info">$i18n.getString( "validation_passed_successfully" )</span>
 #else
 
-<table style="width:100%">
+<table class="listTable" style="width:100%">
 	<colgroup>
-	    <col width="150">
-	    <col width="200">
-        <col width="150">
-		<col width="150">
-	    <col width="150">
-        <col width="150">
-		<col width="150">
-	    <col>
+	    <col>
+	    <col>
+	    <col>
+	    <col>
+	    <col width="40">
+	    <col>
+	    <col>
+		<col width="40">
 	</colgroup>
 	<thead>
 		<tr>
@@ -58,45 +58,24 @@
 			<th>$i18n.getString( "details" )</th>
 		</tr>
 	</thead>
-	<tr>
-		<td colspan='8'>
-	#foreach($periodType in $mapValidationResults.keySet())
-	<fieldset>
-		<legend>$periodType</legend>
-		<table style="width:100%" class="listTable">
-			<colgroup>
-					<col width="150">
-					<col width="200">
-					<col width="150">
-					<col width="150">
-					<col width="150">
-					<col width="150">
-					<col width="150">
-					<col>
-			</colgroup>
-			<tbody id="list">
-			#foreach( $result in $mapValidationResults.get($periodType) )
-			<tr id="tr${result.id}">
-				<td>$!result.source.name</td>
-				<td>$!format.formatPeriod( $result.period )</td>
-				<td>$!result.validationRule.leftSide.description</td>
-				<td>$!result.leftsideValue</td>
-				<td style="text-align:center">$i18n.getString( $!result.validationRule.operator )</td>
-				<td>$!result.rightsideValue</td>
-				<td>$!result.validationRule.rightSide.description</td>
-				<td style="text-align:center">
-					<a href="#" onclick="viewValidationResultDetails( $result.validationRule.id, $result.source.id, $result.period.id )" title="$i18n.getString( 'show_details' )">
-					   <img src="../images/information.png" alt="$i18n.getString( 'show_details' )">
-					</a>
-				</td>
-			</tr>
-			#end
-			</tbody>
-		</table>
-	</fieldset>
-	#end
-		</td>
-	</tr>
+	<tbody>
+		#foreach( $result in $validationResults )
+		<tr id="tr${result.id}">
+		  <td>$!result.source.name</td>
+		  <td>$!format.formatPeriod( $result.period )</td>
+		  <td>$!result.validationRule.leftSide.description</td>
+		  <td>$!result.leftsideValue</td>
+		  <td style="text-align:center">$i18n.getString( $!result.validationRule.operator )</td>
+		  <td>$!result.rightsideValue</td>
+		  <td>$!result.validationRule.rightSide.description</td>
+		  <td style="text-align:center">
+		    <a href="#" onclick="viewValidationResultDetails( $result.validationRule.id, $result.source.id, $result.period.id )" title="$i18n.getString( 'show_details' )">
+		      <img src="../images/information.png" alt="$i18n.getString( 'show_details' )">
+			</a>
+		  </td>
+		</tr>
+		#end
+	</tbody>
 </table>
 
 #end