← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2317: Implemented export to PDF for Validation Rule.

 

------------------------------------------------------------
revno: 2317
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-09 12:53:20 +0700
message:
  Implemented export to PDF for Validation Rule.
added:
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/pdf/
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/pdf/ExportToPdfAction.java
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ValidationRuleConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/ExtendedDataElementConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitHierarchyConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/PDFPipeThread.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-validationrule/pom.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.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-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ValidationRuleConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ValidationRuleConverter.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ValidationRuleConverter.java	2010-12-09 05:53:20 +0000
@@ -49,7 +49,8 @@
  * @version $Id: ValidationRuleConverter.java 6455 2008-11-24 08:59:37Z larshelg $
  */
 public class ValidationRuleConverter
-    extends ValidationRuleImporter implements XMLConverter
+    extends ValidationRuleImporter
+    implements XMLConverter
 {
     public static final String COLLECTION_NAME = "validationRules";
     public static final String ELEMENT_NAME = "validationRule";
@@ -68,8 +69,9 @@
     // -------------------------------------------------------------------------
 
     private Map<Object, Integer> dataElementMapping;
+
     private Map<Object, Integer> categoryOptionComboMapping;
-    
+
     // -------------------------------------------------------------------------
     // Constructor
     // -------------------------------------------------------------------------
@@ -78,10 +80,19 @@
      * Constructor for write operations.
      */
     public ValidationRuleConverter( ValidationRuleService validationRuleService )
-    {   
-        this.validationRuleService = validationRuleService;
-    }
-    
+    {
+        this.validationRuleService = validationRuleService;
+    }
+
+    /**
+     * Constructor for write operations.
+     */
+    public ValidationRuleConverter( ValidationRuleService validationRuleService, ExpressionService expressionService )
+    {
+        this.validationRuleService = validationRuleService;
+        this.expressionService = expressionService;
+    }
+
     /**
      * Constructor for read operations.
      * 
@@ -90,11 +101,9 @@
      * @param expressionService the expressionService to use.
      * @param dataElementMapping the data element mapping to use.
      */
-    public ValidationRuleConverter( ImportObjectService importObjectService, 
-        ValidationRuleService validationRuleService,
-        ExpressionService expressionService,
-        Map<Object, Integer> dataElementMapping,
-        Map<Object, Integer> categoryOptionComboMapping )
+    public ValidationRuleConverter( ImportObjectService importObjectService,
+        ValidationRuleService validationRuleService, ExpressionService expressionService,
+        Map<Object, Integer> dataElementMapping, Map<Object, Integer> categoryOptionComboMapping )
     {
         this.importObjectService = importObjectService;
         this.validationRuleService = validationRuleService;
@@ -109,16 +118,17 @@
 
     public void write( XMLWriter writer, ExportParams params )
     {
-        Collection<ValidationRule> validationRules = validationRuleService.getValidationRules( params.getValidationRules() );
-        
+        Collection<ValidationRule> validationRules = validationRuleService.getValidationRules( params
+            .getValidationRules() );
+
         if ( validationRules != null && validationRules.size() > 0 )
         {
             writer.openElement( COLLECTION_NAME );
-            
+
             for ( ValidationRule rule : validationRules )
             {
                 writer.openElement( ELEMENT_NAME );
-                
+
                 writer.writeElement( FIELD_NAME, rule.getName() );
                 writer.writeElement( FIELD_DESCRIPTION, rule.getDescription() );
                 writer.writeElement( FIELD_TYPE, rule.getType() );
@@ -127,47 +137,50 @@
                 writer.writeElement( FIELD_LEFTSIDE_DESCRIPTION, rule.getLeftSide().getDescription() );
                 writer.writeElement( FIELD_RIGHTSIDE_EXPRESSION, rule.getRightSide().getExpression() );
                 writer.writeElement( FIELD_RIGHTSIDE_DESCRIPTION, rule.getRightSide().getDescription() );
-                
+
                 writer.closeElement();
             }
-            
+
             writer.closeElement();
         }
     }
-    
+
     public void read( XMLReader reader, ImportParams params )
     {
         while ( reader.moveToStartElement( ELEMENT_NAME, COLLECTION_NAME ) )
         {
             final Map<String, String> values = reader.readElements( ELEMENT_NAME );
-            
+
             final ValidationRule validationRule = new ValidationRule();
-            
+
             final Expression leftSide = new Expression();
             final Expression rightSide = new Expression();
-            
+
             validationRule.setLeftSide( leftSide );
             validationRule.setRightSide( rightSide );
-            
+
             validationRule.setName( values.get( FIELD_NAME ) );
             validationRule.setDescription( values.get( FIELD_DESCRIPTION ) );
             validationRule.setType( values.get( FIELD_TYPE ) );
             validationRule.setOperator( values.get( FIELD_OPERATOR ) );
-            
-            validationRule.getLeftSide().setExpression( expressionService.convertExpression( 
-                values.get( FIELD_LEFTSIDE_EXPRESSION ), dataElementMapping, categoryOptionComboMapping ) );
+
+            validationRule.getLeftSide().setExpression(
+                expressionService.convertExpression( values.get( FIELD_LEFTSIDE_EXPRESSION ), dataElementMapping,
+                    categoryOptionComboMapping ) );
             validationRule.getLeftSide().setDescription( values.get( FIELD_LEFTSIDE_DESCRIPTION ) );
-            validationRule.getLeftSide().setDataElementsInExpression( 
+            validationRule.getLeftSide().setDataElementsInExpression(
                 expressionService.getDataElementsInExpression( validationRule.getLeftSide().getExpression() ) );
-            
-            validationRule.getRightSide().setExpression( expressionService.convertExpression( 
-                values.get( FIELD_RIGHTSIDE_EXPRESSION ), dataElementMapping, categoryOptionComboMapping ) );  
-            validationRule.getRightSide().setDescription( values.get( FIELD_RIGHTSIDE_DESCRIPTION ) );            
+
+            validationRule.getRightSide().setExpression(
+                expressionService.convertExpression( values.get( FIELD_RIGHTSIDE_EXPRESSION ), dataElementMapping,
+                    categoryOptionComboMapping ) );
+            validationRule.getRightSide().setDescription( values.get( FIELD_RIGHTSIDE_DESCRIPTION ) );
             validationRule.getRightSide().setDataElementsInExpression(
                 expressionService.getDataElementsInExpression( validationRule.getRightSide().getExpression() ) );
-            
-            validationRule.setPeriodType( PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME ) ); //TODO Intermediate hack!
-            
+
+            // TODO Intermediate hack!
+            validationRule.setPeriodType( PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME ) );
+
             importObject( validationRule, params );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java	2010-12-06 23:20:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/DataElementConverter.java	2010-12-09 05:53:20 +0000
@@ -70,7 +70,7 @@
         I18n i18n = params.getI18n();
         I18nFormat format = params.getFormat();
 
-        PDFUtils.printDataElementFrontPage( document, params.getDataElements(), i18n, format );
+        PDFUtils.printObjectFrontPage( document, params.getDataElements(), i18n, format, "data_elements" );
 
         List<DataElement> elements = new ArrayList<DataElement>( dataElementService.getDataElements( params.getDataElements() ) );
         Collections.sort( elements, new DataElementNameComparator() );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/ExtendedDataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/ExtendedDataElementConverter.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/ExtendedDataElementConverter.java	2010-12-09 05:53:20 +0000
@@ -70,7 +70,7 @@
         I18n i18n = params.getI18n();
         I18nFormat format = params.getFormat();
 
-        PDFUtils.printDataElementFrontPage( document, params.getDataElements(), i18n, format );
+        PDFUtils.printObjectFrontPage( document, params.getDataElements(), i18n, format, "data_elments" );
 
         Collection<DataElement> elements = dataElementService.getDataElements( params.getDataElements() );
 

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java	2010-12-06 23:20:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/IndicatorConverter.java	2010-12-09 05:53:20 +0000
@@ -74,7 +74,7 @@
         I18n i18n = params.getI18n();
         I18nFormat format = params.getFormat();
 
-        PDFUtils.printIndicatorFrontPage( document, params.getIndicators(), i18n, format );
+        PDFUtils.printObjectFrontPage( document, params.getIndicators(), i18n, format, "indicators" );
 
         List<Indicator> indicators = new ArrayList<Indicator>( indicatorService.getIndicators( params.getIndicators() ) );
         Collections.sort( indicators, new IndicatorNameComparator() );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java	2010-12-06 23:20:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitConverter.java	2010-12-09 05:53:20 +0000
@@ -71,7 +71,7 @@
         I18n i18n = params.getI18n();
         I18nFormat format = params.getFormat();
 
-        PDFUtils.printOrganisationUnitFrontPage( document, params.getOrganisationUnits(), i18n, format );
+        PDFUtils.printObjectFrontPage( document, params.getOrganisationUnits(), i18n, format, "organisation_units" );
 
         List<OrganisationUnit> units = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnits( params.getOrganisationUnits() ) );
         Collections.sort( units, new OrganisationUnitNameComparator() );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitHierarchyConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitHierarchyConverter.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/converter/OrganisationUnitHierarchyConverter.java	2010-12-09 05:53:20 +0000
@@ -72,7 +72,7 @@
         I18n i18n = params.getI18n();
         I18nFormat format = params.getFormat();
 
-        PDFUtils.printOrganisationUnitHierarchyFrontPage( document, params.getOrganisationUnits(), i18n, format );
+        PDFUtils.printObjectFrontPage( document, params.getOrganisationUnits(), i18n, format, "organisation_unit_hierarchy" );
 
         if ( params.getOrganisationUnits() != null && params.getOrganisationUnits().size() > 0 )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java	2010-10-29 08:56:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/ITextPDFExportService.java	2010-12-09 05:53:20 +0000
@@ -45,8 +45,10 @@
 import org.hisp.dhis.importexport.pdf.converter.IndicatorConverter;
 import org.hisp.dhis.importexport.pdf.converter.OrganisationUnitConverter;
 import org.hisp.dhis.importexport.pdf.converter.OrganisationUnitHierarchyConverter;
+import org.hisp.dhis.importexport.pdf.converter.ValidationRuleConverter;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.validation.ValidationRuleService;
 
 /**
  * @author Lars Helge Overland
@@ -94,6 +96,13 @@
         this.expressionService = expressionService;
     }
 
+    private ValidationRuleService validationRuleService;
+
+    public void setValidationRuleService( ValidationRuleService validationRuleService )
+    {
+        this.validationRuleService = validationRuleService;
+    }
+
     // -------------------------------------------------------------------------
     // ExportService implementation
     // -------------------------------------------------------------------------
@@ -127,6 +136,7 @@
             thread.setOrganisationUnitHierarchyConverter( new OrganisationUnitHierarchyConverter(
                 organisationUnitService ) );
             thread.setOrganisationUnitConverter( new OrganisationUnitConverter( organisationUnitService ) );
+            thread.setValidationRuleConverter( new ValidationRuleConverter( validationRuleService, expressionService ) );
 
             thread.start();
 
@@ -137,4 +147,5 @@
             throw new RuntimeException( "Error occured during PDF export", ex );
         }
     }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/PDFPipeThread.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/PDFPipeThread.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/pdf/exporter/PDFPipeThread.java	2010-12-09 05:53:20 +0000
@@ -94,6 +94,13 @@
         this.organisationUnitConverter = organisationUnitConverter;
     }
 
+    private PDFConverter validationRuleConverter;
+
+    public void setValidationRuleConverter( PDFConverter validationRuleConverter )
+    {
+        this.validationRuleConverter = validationRuleConverter;
+    }
+
     // -------------------------------------------------------------------------
     // Constructor
     // -------------------------------------------------------------------------
@@ -131,6 +138,8 @@
             organisationUnitHierarchyConverter.write( document, exportParams );
 
             organisationUnitConverter.write( document, exportParams );
+            
+            validationRuleConverter.write( document, exportParams );
 
             PDFUtils.closeDocument( document );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-11-12 17:58:03 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-12-09 05:53:20 +0000
@@ -341,6 +341,8 @@
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="expressionService"
 			ref="org.hisp.dhis.expression.ExpressionService" />
+		<property name="validationRuleService"
+			ref="org.hisp.dhis.validation.ValidationRuleService" />
 	</bean>
 
 	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java	2010-11-23 06:12:14 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java	2010-12-09 05:53:20 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.validation.ValidationRule;
 
 import com.lowagie.text.Document;
 import com.lowagie.text.DocumentException;
@@ -593,92 +594,12 @@
      * @param format The i18nFormat object
      * 
      */
-    public static void printDataElementFrontPage( Document document, Collection<Integer> dataElementIds, I18n i18n,
-        I18nFormat format )
-    {
-        if ( dataElementIds == null || dataElementIds.size() > 0 )
-        {
-            String title = i18n.getString( "data_elements" );
-
-            printFrontPage( document, title, i18n, format );
-        }
-    }
-
-    /**
-     * Writes a "Indicators" title in front of page
-     * 
-     * @param document The document
-     * @param indicatorIds the identifier list of Indicators
-     * @param i18n The i18n object
-     * @param format The i18nFormat object
-     * 
-     */
-    public static void printIndicatorFrontPage( Document document, Collection<Integer> indicatorIds, I18n i18n,
-        I18nFormat format )
-    {
-        if ( indicatorIds == null || indicatorIds.size() > 0 )
-        {
-            String title = i18n.getString( "indicators" );
-
-            printFrontPage( document, title, i18n, format );
-        }
-    }
-
-    /**
-     * Writes a "Data element concepts" title in front of page
-     * 
-     * @param document The document
-     * @param indicatorIds the identifier list of Indicators
-     * @param i18n The i18n object
-     * @param format The i18nFormat object
-     * 
-     */
-    public static void printDataElementConceptFrontPage( Document document, Collection<Integer> indicatorIds,
-        I18n i18n, I18nFormat format )
-    {
-        if ( indicatorIds == null || indicatorIds.size() > 0 )
-        {
-            String title = i18n.getString( "data_element_concepts" );
-
-            printFrontPage( document, title, i18n, format );
-        }
-    }
-
-    /**
-     * Writes a "Organization unit hierarchy" title in front of page
-     * 
-     * @param document The document
-     * @param unitIds the identifier list of organization units
-     * @param i18n The i18n object
-     * @param format The i18nFormat object
-     * 
-     */
-    public static void printOrganisationUnitHierarchyFrontPage( Document document, Collection<Integer> unitIds,
-        I18n i18n, I18nFormat format )
-    {
-        if ( unitIds == null || unitIds.size() > 0 )
-        {
-            String title = i18n.getString( "organisation_unit_hierarchy" );
-
-            printFrontPage( document, title, i18n, format );
-        }
-    }
-
-    /**
-     * Writes a "Organization units" title in front of page
-     * 
-     * @param document The document
-     * @param unitIds the identifier list of organization units
-     * @param i18n The i18n object
-     * @param format The i18nFormat object
-     * 
-     */
-    public static void printOrganisationUnitFrontPage( Document document, Collection<Integer> unitIds, I18n i18n,
-        I18nFormat format )
-    {
-        if ( unitIds == null || unitIds.size() > 0 )
-        {
-            String title = i18n.getString( "organisation_units" );
+    public static void printObjectFrontPage( Document document, Collection<?> objectIds, I18n i18n,
+        I18nFormat format, String frontPageLabel )
+    {
+        if ( objectIds == null || objectIds.size() > 0 )
+        {
+            String title = i18n.getString( frontPageLabel );
 
             printFrontPage( document, title, i18n, format );
         }
@@ -821,13 +742,13 @@
         {
             table.addCell( getItalicCell( i18n.getString( "code" ), 1, ITALIC ) );
             table.addCell( getTextCell( indicator.getCode() ) );
-        }        
+        }
         if ( nullIfEmpty( indicator.getDescription() ) != null )
         {
             table.addCell( getItalicCell( i18n.getString( "description" ), 1, ITALIC ) );
             table.addCell( getTextCell( indicator.getDescription(), TEXT ) );
         }
-        
+
         table.addCell( getItalicCell( i18n.getString( "annualized" ), 1, ITALIC ) );
         table.addCell( getTextCell( i18n.getString( getBoolean().get( indicator.getAnnualized() ) ), TEXT ) );
 
@@ -883,13 +804,13 @@
 
         table.addCell( getItalicCell( i18n.getString( "short_name" ), 1, ITALIC ) );
         table.addCell( getTextCell( unit.getShortName(), TEXT ) );
-        
+
         if ( nullIfEmpty( unit.getCode() ) != null )
         {
             table.addCell( getItalicCell( i18n.getString( "code" ), 1, ITALIC ) );
             table.addCell( getTextCell( unit.getCode() ) );
         }
-        
+
         table.addCell( getItalicCell( i18n.getString( "opening_date" ), 1, ITALIC ) );
         table.addCell( getTextCell( unit.getOpeningDate() != null ? format.formatDate( unit.getOpeningDate() ) : "" ) );
 
@@ -898,7 +819,7 @@
             table.addCell( getItalicCell( i18n.getString( "closed_date" ), 1, ITALIC ) );
             table.addCell( getTextCell( unit.getClosedDate() != null ? format.formatDate( unit.getClosedDate() ) : "" ) );
         }
-        
+
         table.addCell( getItalicCell( i18n.getString( "active" ), 1, ITALIC ) );
         table.addCell( getTextCell( i18n.getString( getBoolean().get( unit.isActive() ) ), TEXT ) );
 
@@ -907,7 +828,64 @@
             table.addCell( getItalicCell( i18n.getString( "comment" ), 1, ITALIC ) );
             table.addCell( getTextCell( unit.getComment(), TEXT ) );
         }
-        
+
+        table.addCell( getCell( 2, 30 ) );
+
+        return table;
+    }
+
+    /**
+     * Creates a table with the given validation rule
+     * 
+     * @param validationRule The validation rule
+     * @param i18n i18n object
+     * @param expressionService The expression service
+     * @param HEADER3 The header3 font
+     * @param ITALIC The italic font
+     * @param TEXT The text font
+     * @param keepTogether Indicates whether the table could be broken across
+     *        multiple pages or should be kept at one page.
+     * @param columnWidths The column widths.
+     */
+    public static PdfPTable printValidationRule( ValidationRule validationRule, I18n i18n,
+        ExpressionService expressionService, Font HEADER3, Font ITALIC, Font TEXT, boolean keepTogether,
+        float... columnWidths )
+    {
+        PdfPTable table = getPdfPTable( keepTogether, columnWidths );
+
+        table.addCell( getHeader3Cell( validationRule.getName(), 2, HEADER3 ) );
+
+        table.addCell( getCell( 2, 15 ) );
+
+        if ( nullIfEmpty( validationRule.getDescription() ) != null )
+        {
+            table.addCell( getItalicCell( i18n.getString( "description" ), 1, ITALIC ) );
+            table.addCell( getTextCell( validationRule.getDescription(), TEXT ) );
+        }
+
+        table.addCell( getItalicCell( i18n.getString( "type" ), 1, ITALIC ) );
+        table.addCell( getTextCell( i18n.getString( validationRule.getType() ), TEXT ) );
+
+        table.addCell( getItalicCell( i18n.getString( "operator" ), 1, ITALIC ) );
+        table.addCell( getTextCell( i18n.getString( validationRule.getOperator() ), TEXT ) );
+
+        table.addCell( getItalicCell( i18n.getString( "left_side_of_expression" ), 1, ITALIC ) );
+        table.addCell( getTextCell( expressionService.getExpressionDescription( validationRule.getLeftSide()
+            .getExpression() ), TEXT ) );
+
+        table.addCell( getItalicCell( i18n.getString( "left_side_description" ), 1, ITALIC ) );
+        table.addCell( getTextCell( validationRule.getLeftSide().getDescription(), TEXT ) );
+
+        table.addCell( getItalicCell( i18n.getString( "right_side_of_expression" ), 1, ITALIC ) );
+        table.addCell( getTextCell( expressionService.getExpressionDescription( validationRule.getRightSide()
+            .getExpression() ), TEXT ) );
+
+        table.addCell( getItalicCell( i18n.getString( "right_side_description" ), 1, ITALIC ) );
+        table.addCell( getTextCell( validationRule.getRightSide().getDescription(), TEXT ) );
+
+        table.addCell( getItalicCell( i18n.getString( "period_type" ), 1, ITALIC ) );
+        table.addCell( getTextCell( i18n.getString( validationRule.getPeriodType().getName() ), TEXT ) );
+
         table.addCell( getCell( 2, 30 ) );
 
         return table;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java	2010-12-06 23:20:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java	2010-12-09 05:53:20 +0000
@@ -140,7 +140,7 @@
 
             if ( type.equals( TYPE_DATAELEMENT ) )
             {
-                if ( ( activeIds != null) && !activeIds.isEmpty() )
+                if ( (activeIds != null) && !activeIds.isEmpty() )
                 {
                     params.setDataElements( activeIds );
                 }
@@ -148,14 +148,14 @@
                 {
                     params.setDataElements( null );
                 }
-                
+
                 fileName = FILENAME_DATAELEMENT;
 
                 log.info( "Exporting to PDF for object type: " + TYPE_DATAELEMENT );
             }
             else if ( type.equals( TYPE_INDICATOR ) )
             {
-                if ( ( activeIds != null) && !activeIds.isEmpty() )
+                if ( (activeIds != null) && !activeIds.isEmpty() )
                 {
                     params.setIndicators( activeIds );
                 }
@@ -182,5 +182,4 @@
 
         return SUCCESS;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml	2010-09-23 15:16:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml	2010-12-09 05:53:20 +0000
@@ -855,7 +855,8 @@
 
 	<!-- PDF -->
 
-	<bean id="org.hisp.dhis.dd.action.pdf.ExportToPdfAction" class="org.hisp.dhis.dd.action.pdf.ExportToPdfAction"
+	<bean id="org.hisp.dhis.dd.action.pdf.ExportToPdfAction" 
+		class="org.hisp.dhis.dd.action.pdf.ExportToPdfAction" 
 		scope="prototype">
 		<property name="serviceProvider">
 			<ref bean="exportServiceProvider" />

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/pom.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/pom.xml	2010-08-20 09:13:09 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/pom.xml	2010-12-09 05:53:20 +0000
@@ -31,6 +31,10 @@
     </dependency>
     <dependency>
       <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-service-importexport</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-service-reporting</artifactId>
     </dependency>
     <dependency>

=== added directory 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/pdf'
=== added file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/pdf/ExportToPdfAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/pdf/ExportToPdfAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/pdf/ExportToPdfAction.java	2010-12-09 05:53:20 +0000
@@ -0,0 +1,158 @@
+package org.hisp.dhis.validationrule.action.pdf;
+
+/*
+ * Copyright (c) 2004-2010, 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.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.ServiceProvider;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.importexport.ExportParams;
+import org.hisp.dhis.importexport.ExportService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class ExportToPdfAction
+    implements Action
+{
+    private static final Log log = LogFactory.getLog( ExportToPdfAction.class );
+
+    private static final String EXPORT_FORMAT_PDF = "PDF";
+
+    private static final String TYPE_VALIDATION_RULE = "validationrule";
+
+    private static final String FILENAME_VALIDATION_RULE = "ValidationRules.zip";
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ServiceProvider<ExportService> serviceProvider;
+
+    public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
+    {
+        this.serviceProvider = serviceProvider;
+    }
+
+    private I18n i18n;
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private InputStream inputStream;
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+
+    private String fileName;
+
+    public String getFileName()
+    {
+        return fileName;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    private List<Integer> activeIds = new ArrayList<Integer>();
+
+    public void setActiveIds( List<Integer> activeIds )
+    {
+        this.activeIds = activeIds;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        if ( type != null )
+        {
+            ExportParams params = new ExportParams();
+
+            if ( type.equals( TYPE_VALIDATION_RULE ) )
+            {
+                if ( (activeIds != null) && !activeIds.isEmpty() )
+                {
+                    params.setValidationRules( activeIds );
+                }
+                else
+                {
+                    params.setValidationRules( null );
+                }
+
+                fileName = FILENAME_VALIDATION_RULE;
+                
+                log.info( "Exporting to PDF for object type: " + TYPE_VALIDATION_RULE );
+            }
+
+            params.setIncludeDataValues( false );
+            params.setI18n( i18n );
+            params.setFormat( format );
+
+            ExportService exportService = serviceProvider.provide( EXPORT_FORMAT_PDF );
+
+            inputStream = exportService.exportData( params );
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml	2010-12-09 05:53:20 +0000
@@ -299,5 +299,15 @@
     <property name="categoryService" 
       ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
   </bean>	
+
+  <!-- PDF -->
+
+  <bean id="org.hisp.dhis.validationrule.action.pdf.ExportToPdfAction" 
+	  class="org.hisp.dhis.validationrule.action.pdf.ExportToPdfAction" 
+	  scope="prototype">
+	  <property name="serviceProvider">
+		<ref bean="exportServiceProvider" />
+	  </property>
+  </bean>
   
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2010-12-03 16:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2010-12-09 05:53:20 +0000
@@ -221,5 +221,16 @@
 	  <result name="success" type="velocity-xml">/dhis-web-validationrule/responseSuccess.vm</result>
 	</action>
 	
+	<!-- PDF -->
+
+	<action name="exportToPdf" class="org.hisp.dhis.validationrule.action.pdf.ExportToPdfAction">
+		<result name="success" type="stream">
+			<param name="contentType">application/zip</param>
+			<param name="inputName">inputStream</param>
+			<param name="contentDisposition">filename="${fileName}"</param>
+			<param name="bufferSize">10240</param>
+		</result>
+	</action>
+	
   </package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm	2010-12-03 16:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm	2010-12-09 05:53:20 +0000
@@ -6,7 +6,10 @@
 			<table width="100%">
 				<tr>
 					<td>#filterDiv( "showValidationRuleForm" )</td>
-					<td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddValidationRuleForm.action'"></td>
+					<td style="text-align:right">
+						<input type="button" value="$i18n.getString( 'get_pdf' )" onclick="exportPdfByType( 'validationrule' );" style="width:80px"/>
+						<input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddValidationRuleForm.action'">
+					</td>
 				</tr>	
 			</table>
 			<table class="listTable" id="listTable"> 
@@ -26,9 +29,9 @@
 					<td onclick="showValidationRuleDetails( $validationRule.id )">$!encoder.htmlEncode( $validationRule.name )</td>
 					<td onclick="showValidationRuleDetails( $validationRule.id )">$i18n.getString($!validationRule.periodType.name) </td>
 					<td style="text-align:right">
-						<a href="showUpdateValidationRuleForm.action?id=$validationRule.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+						<a href="showUpdateValidationRuleForm.action?id=$validationRule.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
 						<a href="javascript:removeValidationRule( $validationRule.id, '$encoder.jsEncode( $validationRule.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
-						<a href="javascript:showValidationRuleDetails( $validationRule.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
+						<a href="javascript:showValidationRuleDetails( $validationRule.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
 					</td>
 				</tr>
 				#end
@@ -42,7 +45,7 @@
 
 			<div id="detailsArea" style="display:none">
 				<div style="float:right">
-					<a href="javascript:hideDetails()" title="$i18n.getString( "hide_details" )"><img src="../images/close.png" alt="$i18n.getString( "hide_details" )"></a>
+					<a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"></a>
 				</div>				
 				<p><label>$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>
 				<p><label>$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
@@ -53,7 +56,7 @@
 			
 			<div id="warningArea" style="position:fixed;right:10px;top:200px;display:none">
 				<div style="float:right">
-					<a href="javascript:hideWarning()" title='$i18n.getString( 'hide_warning' )'><img src="../images/close.png" alt=$i18n.getString( "hide_warning" )'></a>
+					<a href="javascript:hideWarning()" title="$i18n.getString( 'hide_warning' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_warning' )"></a>
 				</div>
 				<p><span id="warningField"></span></p>
 			</div>