← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2007: Cleaning Code: PhyscialOutput Report Form & Result

 

------------------------------------------------------------
revno: 2007
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-08 14:46:45 +0530
message:
  Cleaning Code: PhyscialOutput Report Form & Result
modified:
  local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/GeneratePhysicalReportResultAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/PhysicalReportFormAction.java
  local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/upward/action/GenerateUpwardReportAnalyserResultAction.java
  local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties
  local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/physicalReportform.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 'local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java'
--- local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2010-11-08 06:10:18 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2010-11-08 09:16:45 +0000
@@ -1022,81 +1022,78 @@
     
  // functoin getBooleanDataValue end
     
-    //function getStartingEndingPeriods starts
-    
-    public List<Calendar> getStartingEndingPeriods( String deType , Period selectedPeriod)
-    {
-
-        List<Calendar> calendarList = new ArrayList<Calendar>();
-
-        Calendar tempStartDate = Calendar.getInstance();
-        Calendar tempEndDate = Calendar.getInstance();
-
-        Period previousPeriod = new Period();
-        previousPeriod = getPreviousPeriod( selectedPeriod );
-
-        if ( deType.equalsIgnoreCase( "ccmcy" ) )
-        {
-            tempStartDate.setTime( selectedPeriod.getStartDate() );
-            if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
-            {
-                tempStartDate.roll( Calendar.YEAR, -1 );
-            }
-            tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
-            tempEndDate.setTime( selectedPeriod.getEndDate() );
-            // System.out.println("CCMCY : "+ String.valueOf(
-            // tempStartDate.getTime()) +" ------ "+String.valueOf(
-            // tempEndDate.getTime()));
-        } 
-        else if ( deType.equalsIgnoreCase( "cpmcy" ) )
-            {
-                tempStartDate.setTime( previousPeriod.getStartDate() );
-                if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
-                {
-                    tempStartDate.roll( Calendar.YEAR, -1 );
-                }
-                tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
-                tempEndDate.setTime( previousPeriod.getEndDate() );
-            } 
-        else if ( deType.equalsIgnoreCase( "cmpy" ) )
-                {
-                    tempStartDate.setTime( selectedPeriod.getStartDate() );
-                    tempEndDate.setTime( selectedPeriod.getEndDate() );
-
-                    tempStartDate.roll( Calendar.YEAR, -1 );
-                    tempEndDate.roll( Calendar.YEAR, -1 );
-                } 
-        else if ( deType.equalsIgnoreCase( "ccmpy" ) )
-                    {
-                        tempStartDate.setTime( selectedPeriod.getStartDate() );
-                        tempEndDate.setTime( selectedPeriod.getEndDate() );
-
-                        tempStartDate.roll( Calendar.YEAR, -1 );
-                        tempEndDate.roll( Calendar.YEAR, -1 );
-
-                        if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
-                        {
-                            tempStartDate.roll( Calendar.YEAR, -1 );
-                        }
-                        tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
-
-                    } else if ( deType.equalsIgnoreCase( "pmcy" ) )
-                        {
-                            tempStartDate.setTime( previousPeriod.getStartDate() );
-                            tempEndDate.setTime( previousPeriod.getEndDate() );
-                        } else
-                        {
-                            tempStartDate.setTime( selectedPeriod.getStartDate() );
-                            tempEndDate.setTime( selectedPeriod.getEndDate() );
-                        }
-
-        // System.out.print(deType+" -- ");
-        calendarList.add( tempStartDate );
-        calendarList.add( tempEndDate );
-
-        return calendarList;
+    
+//function getStartingEndingPeriods starts
+    
+public List<Calendar> getStartingEndingPeriods( String deType , Period selectedPeriod)
+{
+    List<Calendar> calendarList = new ArrayList<Calendar>();
+
+    Calendar tempStartDate = Calendar.getInstance();
+    Calendar tempEndDate = Calendar.getInstance();
+
+    Period previousPeriod = new Period();
+    previousPeriod = getPreviousPeriod( selectedPeriod );
+
+    if ( deType.equalsIgnoreCase( "ccmcy" ) )
+    {
+        tempStartDate.setTime( selectedPeriod.getStartDate() );
+        if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
+        {
+            tempStartDate.roll( Calendar.YEAR, -1 );
+        }
+        tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
+        tempEndDate.setTime( selectedPeriod.getEndDate() );
+    } 
+    else if ( deType.equalsIgnoreCase( "cpmcy" ) )
+    {
+        tempStartDate.setTime( previousPeriod.getStartDate() );
+        if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
+        {
+            tempStartDate.roll( Calendar.YEAR, -1 );
+        }
+        tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
+        tempEndDate.setTime( previousPeriod.getEndDate() );
+    } 
+    else if ( deType.equalsIgnoreCase( "cmpy" ) )
+    {
+        tempStartDate.setTime( selectedPeriod.getStartDate() );
+        tempEndDate.setTime( selectedPeriod.getEndDate() );
+    
+        tempStartDate.roll( Calendar.YEAR, -1 );
+        tempEndDate.roll( Calendar.YEAR, -1 );
+    } 
+    else if ( deType.equalsIgnoreCase( "ccmpy" ) )
+    {
+        tempStartDate.setTime( selectedPeriod.getStartDate() );
+        tempEndDate.setTime( selectedPeriod.getEndDate() );
+
+        tempStartDate.roll( Calendar.YEAR, -1 );
+        tempEndDate.roll( Calendar.YEAR, -1 );
+
+        if ( tempStartDate.get( Calendar.MONTH ) < Calendar.APRIL )
+        {
+            tempStartDate.roll( Calendar.YEAR, -1 );
+        }
+        tempStartDate.set( Calendar.MONTH, Calendar.APRIL );
+    } 
+    else if ( deType.equalsIgnoreCase( "pmcy" ) )
+    {
+        tempStartDate.setTime( previousPeriod.getStartDate() );
+        tempEndDate.setTime( previousPeriod.getEndDate() );
+    } 
+    else
+    {
+        tempStartDate.setTime( selectedPeriod.getStartDate() );
+        tempEndDate.setTime( selectedPeriod.getEndDate() );
     }
-  //function getStartingEndingPeriods end
+
+    calendarList.add( tempStartDate );
+    calendarList.add( tempEndDate );
+
+    return calendarList;
+}
+//function getStartingEndingPeriods end
     
     //function getPreviousPeriod starts
     

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/GeneratePhysicalReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/GeneratePhysicalReportResultAction.java	2010-10-30 10:08:37 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/GeneratePhysicalReportResultAction.java	2010-11-08 09:16:45 +0000
@@ -11,14 +11,8 @@
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 
 import jxl.Workbook;
 import jxl.format.Alignment;
@@ -31,41 +25,22 @@
 import jxl.write.WritableWorkbook;
 
 import org.amplecode.quick.StatementManager;
-import org.hisp.dhis.aggregation.AggregationService;
-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 org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
 import org.hisp.dhis.reports.ReportService;
 import org.hisp.dhis.reports.Report_in;
-import org.hisp.dhis.system.util.MathUtils;
+import org.hisp.dhis.reports.Report_inDesign;
 import org.hisp.dhis.user.CurrentUserService;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 
 import com.opensymphony.xwork2.Action;
 
 public class GeneratePhysicalReportResultAction
     implements Action
 {
-    private static final String NULL_REPLACEMENT = "0";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -77,20 +52,6 @@
         this.statementManager = statementManager;
     }
 
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
     private PeriodService periodService;
 
     public void setPeriodService( PeriodService periodService )
@@ -119,28 +80,6 @@
         this.format = format;
     }
 
-    private AggregationService aggregationService;
-
-    public void setAggregationService( AggregationService aggregationService )
-    {
-        this.aggregationService = aggregationService;
-    }
-
-    private DataElementCategoryService dataElementCategoryOptionComboService;
-
-    public void setDataElementCategoryOptionComboService(
-        DataElementCategoryService dataElementCategoryOptionComboService )
-    {
-        this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
-    }
-
-    private DataValueService dataValueService;
-
-    public void setDataValueService( DataValueService dataValueService )
-    {
-        this.dataValueService = dataValueService;
-    }
-
     // -------------------------------------------------------------------------
     // Properties
     // -------------------------------------------------------------------------
@@ -176,51 +115,30 @@
 
     private List<OrganisationUnit> orgUnitList;
 
-    private List<String> deCodeType;
-
-    private List<String> serviceType;
-
-    private List<Integer> sheetList;
-
-    private List<Integer> rowList;
-
-    private List<Integer> colList;
-
     private String reportModelTB;
 
     private String reportFileNameTB;
 
     private String raFolderName;
 
-    int isAggregated = 0;
-
     String years[];
 
-    int deFlag2;
-
-    int deFlag1;
-
     public String execute()
         throws Exception
     {
         // Intialisation
 
         statementManager.initialise();
-        deCodeType = new ArrayList<String>();
-        serviceType = new ArrayList<String>();
-        sheetList = new ArrayList<Integer>();
-        rowList = new ArrayList<Integer>();
-        colList = new ArrayList<Integer>();
         orgUnitList = new ArrayList<OrganisationUnit>();
         String deCodesXMLFileName = "";
 
-        System.out.println( "Report Generation Start Time is : \t" + new Date() );
-
         // Getting Report Details
         raFolderName = reportService.getRAFolderName();
 
         Report_in selReportObj = reportService.getReport( Integer.parseInt( reportList ) );
 
+        System.out.println( selReportObj.getName()+" : Report Generation Start Time is : " + new Date() );
+
         reportModelTB = selReportObj.getModel();
         reportFileNameTB = selReportObj.getExcelTemplateName();
         deCodesXMLFileName = selReportObj.getXmlTemplateName();
@@ -239,7 +157,7 @@
                 orgUnitList.add( orgUnit );
             }
         }
-        System.out.println( "Size of OrgUnit" + orgUnitList.size() );
+
         // Getting Period Info
 
         years = periodNameList.split( "-" );
@@ -251,9 +169,8 @@
         selPeriod = periodService.getPeriod( sDate, eDate, new YearlyPeriodType() );
 
         // Getting DeCodes
-        List<String> deCodesList = getDECodes( deCodesXMLFileName );
+        List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
 
-        // Getting Exel Template
         String inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
             + "template" + File.separator + reportFileNameTB;
         String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator
@@ -268,15 +185,16 @@
         for ( OrganisationUnit curOrgUnit : orgUnitList )
         {
             int count1 = 0;
-            for ( String deCode : deCodesList )
+            for ( Report_inDesign reportDesign : reportDesignList )
             {
                 String tempStr;
-                String deType = (String) deCodeType.get( count1 );
+                String deCode = reportDesign.getExpression();
+                String deType = reportDesign.getPtype();
 
                 Calendar tempStartDate = Calendar.getInstance();
                 Calendar tempEndDate = Calendar.getInstance();
                 List<Calendar> calendarList = new ArrayList<Calendar>( getStartingEndingPeriods( deType ) );
-                if ( calendarList == null || calendarList.isEmpty() )
+                if( calendarList == null || calendarList.isEmpty() )
                 {
                     tempStartDate.setTime( selPeriod.getStartDate() );
                     tempEndDate.setTime( selPeriod.getEndDate() );
@@ -302,13 +220,12 @@
                 }
                 else
                 {
-                    tempStr = getResultDataValue( deCode, tempStartDate.getTime(), tempEndDate.getTime(), curOrgUnit );
+                    tempStr = reportService.getResultDataValue( deCode, tempStartDate.getTime(), tempEndDate.getTime(), curOrgUnit, reportModelTB );
                 }
 
-                System.out.println( "DECode : " + deCode + "   TempStr : " + tempStr );
-                int tempRowNo = rowList.get( count1 ) + rowCount;
-                int tempColNo = colList.get( count1 );
-                int sheetNo = sheetList.get( count1 );
+                int tempRowNo = reportDesign.getRowno() + rowCount;
+                int tempColNo = reportDesign.getColno();
+                int sheetNo = reportDesign.getSheetno();
                 WritableSheet sheet0 = outputReportWorkbook.getSheet( sheetNo );
 
                 WritableCellFormat wCellformat = new WritableCellFormat();
@@ -320,16 +237,13 @@
                 {
                     sheet0.addCell( new Blank( tempColNo, tempRowNo, wCellformat ) );
                 }
-
                 else
                 {
                     sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, wCellformat ) );
                 }
 
                 count1++;
-                System.out.println( tempStr );
             }
-            System.out.println( "OrgUnitName=" + curOrgUnit.getName() );
 
             rowCount++;
         }
@@ -339,12 +253,12 @@
         outputReportWorkbook.close();
 
         fileName = reportFileNameTB.replace( ".xls", "" );
-        fileName += periodNameList + ".xls";
-        // fileName = reportFileNameTB;
+        fileName += "_"+periodNameList + ".xls";
+
         File outputReportFile = new File( outputReportPath );
         inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
 
-        System.out.println( "Report Generation End Time is : \t" + new Date() );
+        System.out.println( selReportObj.getName()+" : Report Generation End Time is : " + new Date() );
 
         outputReportFile.deleteOnExit();
         statementManager.destroy();
@@ -352,249 +266,8 @@
         return SUCCESS;
     }
 
-    public List<String> getDECodes( String fileName )
-    {
-        List<String> deCodes = new ArrayList<String>();
-        String path = System.getProperty( "user.home" ) + File.separator + "dhis" + File.separator + raFolderName
-            + File.separator + fileName;
-        try
-        {
-            String newpath = System.getenv( "DHIS2_HOME" );
-            if ( newpath != null )
-            {
-                path = newpath + File.separator + raFolderName + File.separator + fileName;
-            }
-        }
-        catch ( NullPointerException npe )
-        {
-            // do nothing, but we might be using this somewhere without
-            // USER_HOME set, which will throw a NPE
-        }
-
-        try
-        {
-            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
-            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
-            Document doc = docBuilder.parse( new File( path ) );
-            if ( doc == null )
-            {
-                return null;
-            }
-
-            NodeList listOfDECodes = doc.getElementsByTagName( "de-code" );
-            int totalDEcodes = listOfDECodes.getLength();
-
-            for ( int s = 0; s < totalDEcodes; s++ )
-            {
-                Element deCodeElement = (Element) listOfDECodes.item( s );
-                NodeList textDECodeList = deCodeElement.getChildNodes();
-
-                deCodes.add( ((Node) textDECodeList.item( 0 )).getNodeValue().trim() );
-                serviceType.add( deCodeElement.getAttribute( "stype" ) );
-                deCodeType.add( deCodeElement.getAttribute( "type" ) );
-                sheetList.add( new Integer( deCodeElement.getAttribute( "sheetno" ) ) );
-                rowList.add( new Integer( deCodeElement.getAttribute( "rowno" ) ) );
-                colList.add( new Integer( deCodeElement.getAttribute( "colno" ) ) );
-
-            }// end of for loop with s var
-        }// try block end
-        catch ( SAXParseException err )
-        {
-            System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() );
-            System.out.println( " " + err.getMessage() );
-        }
-        catch ( SAXException e )
-        {
-            Exception x = e.getException();
-            ((x == null) ? e : x).printStackTrace();
-        }
-        catch ( Throwable t )
-        {
-            t.printStackTrace();
-        }
-        return deCodes;
-    }// getDECodes end
-
-    /**
-     * Converts an expression on the form<br>
-     * [34] + [23], where the numbers are IDs of DataElements, to the form<br>
-     * 200 + 450, where the numbers are the values of the DataValues registered
-     * for the Period and source.
-     * 
-     * @return The generated expression
-     */
-    private String getResultDataValue( String formula, Date startDate, Date endDate, OrganisationUnit organisationUnit )
-    {
-        isAggregated = 0;
-
-        try
-        {
-            Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
-
-            Matcher matcher = pattern.matcher( formula );
-            StringBuffer buffer = new StringBuffer();
-
-            String resultValue = "";
-
-            while ( matcher.find() )
-            {
-                String replaceString = matcher.group();
-
-                replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
-                String optionComboIdStr = replaceString.substring( replaceString.indexOf( '.' ) + 1, replaceString
-                    .length() );
-
-                replaceString = replaceString.substring( 0, replaceString.indexOf( '.' ) );
-
-                int dataElementId = Integer.parseInt( replaceString );
-                int optionComboId = Integer.parseInt( optionComboIdStr );
-
-                DataElement dataElement = dataElementService.getDataElement( dataElementId );
-                DataElementCategoryOptionCombo optionCombo = dataElementCategoryOptionComboService
-                    .getDataElementCategoryOptionCombo( optionComboId );
-                if ( dataElement == null || optionCombo == null )
-                {
-                    replaceString = "";
-                    matcher.appendReplacement( buffer, replaceString );
-                    continue;
-                }
-                if ( dataElement.getType().equalsIgnoreCase( "int" ) )
-                {
-                    Double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo,
-                        startDate, endDate, organisationUnit );
-                    if ( aggregatedValue == 0 )
-                    {
-                        replaceString = NULL_REPLACEMENT;
-                        deFlag2 = 0;
-
-                    }
-                    else
-                    {
-                        replaceString = String.valueOf( aggregatedValue );
-
-                        deFlag2 = 1;
-
-                        isAggregated = 1;
-                    }
-
-                }
-                else
-                {
-                    deFlag1 = 1;
-                    deFlag2 = 0;
-                    PeriodType dePeriodType = getDataElementPeriodType( dataElement );
-                    List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriodsByPeriodType(
-                        dePeriodType, startDate, endDate ) );
-                    Period tempPeriod = new Period();
-                    if ( periodList == null || periodList.isEmpty() )
-                    {
-                        replaceString = "";
-                        matcher.appendReplacement( buffer, replaceString );
-                        continue;
-                    }
-                    else
-                    {
-                        tempPeriod = (Period) periodList.get( 0 );
-                    }
-
-                    DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, tempPeriod,
-                        optionCombo );
-
-                    if ( dataValue != null )
-                    {
-                        // Works for both text and boolean data types
-
-                        replaceString = dataValue.getValue();
-                    }
-                    else
-                    {
-                        replaceString = "";
-                    }
-
-                    if ( replaceString == null )
-                    {
-                        replaceString = "";
-                    }
-                }
-                matcher.appendReplacement( buffer, replaceString );
-
-                resultValue = replaceString;
-            }
-
-            matcher.appendTail( buffer );
-
-            if ( deFlag1 == 0 )
-            {
-
-                double d = 0.0;
-                try
-                {
-                    d = MathUtils.calculateExpression( buffer.toString() );
-                }
-                catch ( Exception e )
-                {
-                    d = 0.0;
-                    resultValue = "";
-                }
-                if ( d == -1 )
-                {
-                    d = 0.0;
-                    resultValue = "";
-                }
-                else
-                {
-
-                    // This is to display financial data as it is like 2.1476838
-                    resultValue = "" + d;
-
-                    // These lines are to display financial data that do not
-                    // have decimals
-                    d = d * 10;
-
-                    if ( d % 10 == 0 )
-                    {
-                        resultValue = "" + (int) d / 10;
-                    }
-
-                    d = d / 10;
-
-                    // These line are to display non financial data that do not
-                    // require decimals
-                    if ( !(reportModelTB.equalsIgnoreCase( "STATIC-FINANCIAL" )) )
-                    {
-                        resultValue = "" + (int) d;
-                    }
-
-                }
-
-            }
-            else
-            {
-                deFlag2 = 0;
-                resultValue = buffer.toString();
-            }
-
-            if ( isAggregated == 0 )
-            {
-                resultValue = " ";
-            }
-
-            if ( resultValue.equalsIgnoreCase( "" ) )
-            {
-                resultValue = " ";
-            }
-
-            return resultValue;
-        }
-        catch ( NumberFormatException ex )
-        {
-            throw new RuntimeException( "Illegal DataElement id", ex );
-        }
-    }
-
     public List<Calendar> getStartingEndingPeriods( String deType )
     {
-
         List<Calendar> calendarList = new ArrayList<Calendar>();
 
         Calendar tempStartDate = Calendar.getInstance();
@@ -639,27 +312,4 @@
 
         return calendarList;
     }
-
-    /*
-     * Returns the PeriodType Object for selected DataElement, If no PeriodType
-     * is found then by default returns Monthly Period type
-     */
-    public PeriodType getDataElementPeriodType( DataElement de )
-    {
-        List<DataSet> dataSetList = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-        Iterator<DataSet> it = dataSetList.iterator();
-        while ( it.hasNext() )
-        {
-            DataSet ds = (DataSet) it.next();
-            List<DataElement> dataElementList = new ArrayList<DataElement>( ds.getDataElements() );
-            if ( dataElementList.contains( de ) )
-            {
-                return ds.getPeriodType();
-            }
-        }
-
-        return null;
-
-    }
-
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/PhysicalReportFormAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/PhysicalReportFormAction.java	2010-09-13 10:03:14 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/physical/action/PhysicalReportFormAction.java	2010-11-08 09:16:45 +0000
@@ -26,8 +26,6 @@
     implements Action
 
 {
-   // private final String ALL = "null";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -46,13 +44,6 @@
         this.reportService = reportService;
     }
 
-    private String reportTypeName;
-
-    public String getReportTypeName()
-    {
-        return reportTypeName;
-    }
-
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -64,34 +55,11 @@
         return periodNameList;
     }
 
-    private SimpleDateFormat simpleDateFormat1;
-
-   // private String id;
-
-   // public void setId( String id )
-   // {
-  //      this.id = id;
-   // }
-
-    private List<Period> periods;
-
-    public List<Period> getPeriods()
-    {
-        return periods;
-    }
-
-    private List<String> reportIds;
-
-    public List<String> getReportIds()
-    {
-        return reportIds;
-    }
-
-    private List<String> reportNames;
-
-    public List<String> getReportNames()
-    {
-        return reportNames;
+    private String reportTypeName;
+
+    public String getReportTypeName()
+    {
+        return reportTypeName;
     }
 
     private List<Report_in> reportList;
@@ -101,10 +69,6 @@
         return reportList;
     }
 
-  //  private String raFolderName;
-
-    int count;
-
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -112,12 +76,11 @@
     public String execute()
         throws Exception
     {
-
-        // reportTypeName = ReportType.RT_PHYSICAL_OUTPUT;
+        reportTypeName = ReportType.RT_PHYSICAL_OUTPUT;
 
         periodNameList = new ArrayList<String>();
 
-        periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new YearlyPeriodType() ) );
+        List<Period> periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new YearlyPeriodType() ) );
 
         Iterator<Period> periodIterator = periods.iterator();
         while ( periodIterator.hasNext() )
@@ -131,18 +94,17 @@
         }
         Collections.sort( periods, new PeriodComparator() );
 
-        simpleDateFormat1 = new SimpleDateFormat( "yyyy" );
+        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat( "yyyy" );
 
         for ( Period p1 : periods )
         {
             int year = Integer.parseInt( simpleDateFormat1.format( p1.getStartDate() ) ) + 1;
             periodNameList.add( simpleDateFormat1.format( p1.getStartDate() ) + "-" + year );
         }
-        System.out.println( periods );
+
         reportList = new ArrayList<Report_in>( reportService.getReportsByReportType( ReportType.RT_PHYSICAL_OUTPUT ) );
 
         return SUCCESS;
-
     }
 
 }

=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/upward/action/GenerateUpwardReportAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/upward/action/GenerateUpwardReportAnalyserResultAction.java	2010-11-08 06:10:18 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/upward/action/GenerateUpwardReportAnalyserResultAction.java	2010-11-08 09:16:45 +0000
@@ -14,9 +14,6 @@
 import java.util.List;
 import java.util.UUID;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
 import jxl.CellType;
 import jxl.Workbook;
 import jxl.format.Alignment;
@@ -41,12 +38,6 @@
 import org.hisp.dhis.reports.ReportService;
 import org.hisp.dhis.reports.Report_in;
 import org.hisp.dhis.reports.Report_inDesign;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 
 import com.opensymphony.xwork2.Action;
 

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2010-11-08 06:10:18 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml	2010-11-08 09:16:45 +0000
@@ -1632,55 +1632,20 @@
 		</property>
 		
 	</bean>
+	
 	<!--physical reports -->
     <bean id="org.hisp.dhis.reports.physical.action.PhysicalReportFormAction"
         class="org.hisp.dhis.reports.physical.action.PhysicalReportFormAction" scope="prototype">
-    <property name="reportService">
-           <ref bean="org.hisp.dhis.reports.ReportService"/>    
-    </property>
-    <property name="periodService">
-           <ref bean="org.hisp.dhis.period.PeriodService"/>
-            </property>
+		<property name="reportService" ref="org.hisp.dhis.reports.ReportService" />    
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     </bean>
     
-		<bean id="org.hisp.dhis.reports.physical.action.GeneratePhysicalReportResultAction"
-			class="org.hisp.dhis.reports.physical.action.GeneratePhysicalReportResultAction" scope="prototype">
-        
-		
-		
-		
-		<!--<property name="reportService">
-            <ref bean="statementManager"/></property>-->
-			
-			<property name="statementManager" ref="statementManager">
-        </property>
-		
-			<property name="reportService">
-				<ref bean="org.hisp.dhis.reports.ReportService"/>
-			</property>	
-		
-            <property name="dataSetService">
-                 <ref bean="org.hisp.dhis.dataset.DataSetService"/>
-            </property>
-            <property name="periodService">
-                 <ref bean="org.hisp.dhis.period.PeriodService"/>
-            </property>
-            <property name="dataElementService">
-                 <ref bean="org.hisp.dhis.dataelement.DataElementService"/>
-            </property>
-            <property name="aggregationService">
-                 <ref bean="org.hisp.dhis.aggregation.AggregationService"/>
-            </property>
-			<property name="dataElementCategoryOptionComboService">
-		    <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService"/>
-		    </property>
-            <property name="dataValueService">
-                 <ref bean="org.hisp.dhis.datavalue.DataValueService"/>
-            </property>
-			<property name="currentUserService">
-                 <ref bean="org.hisp.dhis.user.CurrentUserService"/>
-            </property>
-        
+	<bean id="org.hisp.dhis.reports.physical.action.GeneratePhysicalReportResultAction"
+		class="org.hisp.dhis.reports.physical.action.GeneratePhysicalReportResultAction" scope="prototype">
+		<property name="statementManager" ref="statementManager" />
+		<property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
     </bean>
 	
 	<!-- CS Review Reports Start 09/08/2010-->

=== modified file 'local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties'
--- local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties	2010-11-08 06:10:18 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties	2010-11-08 09:16:45 +0000
@@ -1,5 +1,6 @@
 goi_ra = Government of India Reports Analyser
 routine_ra = Routine Report Analyser
+physical_output_ra = Quarterly Physical Output Report
 periodtype = PeriodType
 organisationunit = OrganisationUnit
 select_periodtype = Select PeriodType
@@ -8,6 +9,7 @@
 all = ALL
 selected_only = Selected Only
 orgunitgrouptype = OrgUnitGroupType 
+year = Year
 
 please_select_an_orgUnit= Please select an OrganisationUnit.
 please_select_a_dataset= Please select a dataset.

=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/physicalReportform.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/physicalReportform.vm	2010-09-18 13:07:13 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/physicalReportform.vm	2010-11-08 09:16:45 +0000
@@ -1,70 +1,55 @@
 <script>
-  //Global Variables
-   
-  var reportModels = new HashTable();
-  var reportFileNames = new HashTable();
-          
-  function formValidations()
-  {                 
-    var reportListIndex = document.physicalForm.reportList.selectedIndex;
-    var periodIndex = document.physicalForm.availablePeriods.selectedIndex;
-    var orgunitIdValue = document.physicalForm.ouIDTB.value;
-                      
-    if (reportListIndex < 0 || document.physicalForm.reportList.options[reportListIndex].text == null) {alert("Please Select Report"); return false;}
-    else if(document.physicalForm.availablePeriods.options[periodIndex].text == null || document.reportForm.availablePeriods.options[periodIndex].text== "") {alert("Please Select Period"); return false;}
-    else if(orgunitIdValue == null || orgunitIdValue=="" || orgunitIdValue==" ") {alert("Please Select OrganisationUnit"); return false;}
-            
-    document.physicalForm.reportModelTB.value = reportModels.get(document.physicalForm.reportList.options[reportListIndex].value);
-    document.physicalForm.reportFileNameTB.value = reportFileNames.get(document.physicalForm.reportList.options[reportListIndex].value);
-    return true;
-  }     
+	function formValidations()
+	{                 
+		var reportList = document.getElementById("reportList");
+		var reportListIndex = reportList.selectedIndex;
+		var periodList = document.getElementById("availablePeriods");
+		var periodIndex = periodList.selectedIndex;
+	
+		if( reportListIndex < 0 || reportList.options[reportListIndex].text == null ) { alert("Please Select Report"); return false; }
+		else if( periodList.options[periodIndex].text == null || periodList.options[periodIndex].text == "") { alert("Please Select Period"); return false; }
+
+		return true;
+	}
 </script>
-<h3>Quarterly Physical output Report</h3>
-<hr>  </hr>
-
-<br />
+
+<h3>$i18n.getString( "physical_output_ra" )</h3>
+<hr><br />
+
 <form id="PhysicalForm" name="PhysicalForm" action="generatePhysicalReport.action" method="post" onsubmit="return formValidations()" target="_blank">        
-  <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>                    
-    <tr>
-      <td class="NormalB">
-        Years : <br />
-                <select id="periodNameList" name="periodNameList" style="width:220px">
-          
-          #foreach ( $type in $periodNameList )
-            <option value="$type">$type</option>
+	<table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="730" border=0>                    
+		<tr>
+			<td class="NormalB">
+				$i18n.getString( "year" ) :<br />
+                <select id="periodNameList" name="periodNameList" style="width:220px">          
+					#foreach ( $periodName in $periodNameList )
+						<option value="$periodName">$periodName</option>
                     #end
                 </select>
-        </td>
+			</td>
             <td class="NormalB">
-        Report Lists :<br />
+				$i18n.getString( "reports" ) :<br />
                 <select id="reportList" name="reportList" style="width:200px">
                     #foreach( $report in $reportList )                      
-          <option value="$report.id">$report.name</option>
-                #end
-        </select>
+						<option value="$report.id">$report.name</option>
+					#end
+				</select>
             </td>
         </tr>
         <tr>
-      <td>&nbsp;</td>
+			<td>&nbsp;</td>
             <td>&nbsp;</td>
         </tr>
         <tr>
-      <td>&nbsp;</td>
+			<td>&nbsp;</td>
             <td>&nbsp;</td>
         </tr>     
-  <tr>
-   
-    <!--  <input type="submit" id="Generate" name ="Generate" title= "Generate report" value="$i18n.getString( "generate" )" style="width:6em" disable="false"> -->
-      <td><input type="submit" id= "generate" name="generate" title= "Generate report" value="$i18n.getString( "generate" )"  style="width:6em" #if( $!reportList.size() == 0 ) disabled #end >      
-    </td>  
-  </tr>
-      <tr>
-      <td>&nbsp;</td>
-            <td>
-                <input type="hidden" name="reportModelTB" id="reportModelTB">
-                <input type="hidden" name="reportFileNameTB" id="reportFileNameTB">
-                <input type="hidden" name="reportListFileNameTB" id="reportListFileNameTB" value="">  
-            </td>
-        </tr>
+		<tr>
+			<td>
+				<input type="submit" id= "generate" name="generate" title= "Generate report" value="$i18n.getString( "generate" )"  style="width:6em" #if( $!reportList.size() == 0 ) disabled #end >
+			</td>
+			<td>&nbsp;</td>
+		</tr>
     </table>
+	<input type="hidden" name="reportTypeNameTB" id="reportTypeNameTB" value="$reportTypeName">  
 </form>