← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4920: Added Report Type and method in Report service

 

------------------------------------------------------------
revno: 4920
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-10-13 12:31:58 +0530
message:
  Added Report Type and method in Report service
modified:
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java
  local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java
  local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java


--
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-api/src/main/java/org/hisp/dhis/reports/ReportService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2011-05-27 11:25:15 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportService.java	2011-10-13 07:01:58 +0000
@@ -156,5 +156,7 @@
     Map<String, String> getDataFromDataValueTable( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma );
     
     Map<String, String> getDataFromDataValueTableByPeriodAgg( String orgUnitIdsByComma, String dataElmentIdsByComma, String periodIdsByComma );
+    
+    List<Report_inDesign> getReportDesignWithMergeCells( String fileName );
         
 }

=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java	2011-06-27 07:27:58 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/ReportType.java	2011-10-13 07:01:58 +0000
@@ -55,6 +55,11 @@
     public final static String RT_ADVANCED_REPORT = "Advanced Reports";      
     
     public final static String RT_BULK_REPORT = "Bulk Reports";
+    
+    public final static String RT_IDSP_REPORT = "IDSP Reports";
+    
+    public final static String RT_LINELIST_BULK_REPORT = "Linelisting Bulk Reports";
+
 
     public static List<String> getReportTypes()
     {
@@ -84,6 +89,10 @@
         
         reportTypes.add( RT_LINELIST_WEB_PORTAL );
         
+        reportTypes.add( RT_IDSP_REPORT );
+        
+        reportTypes.add( RT_LINELIST_BULK_REPORT );
+        
         return reportTypes;
     }
 }

=== 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	2011-09-03 05:48:23 +0000
+++ local/in/dhis-in-services/dhis-in-service-reports/src/main/java/org/hisp/dhis/reports/DefaultReportService.java	2011-10-13 07:01:58 +0000
@@ -1448,6 +1448,81 @@
            
         }
     
+
+// -------------------------------------------------------------------------
+// Get ReportDesign (decode tags) from corresponding xml file 
+// -------------------------------------------------------------------------
+
+public List<Report_inDesign> getReportDesignWithMergeCells( String fileName )
+{
+    List<Report_inDesign> reportDesignList = new ArrayList<Report_inDesign>();
+    
+    String path = System.getProperty( "user.home" ) + File.separator + "dhis" + File.separator + configurationService.getConfigurationByKey( Configuration_IN.KEY_REPORTFOLDER ).getValue()
+        + File.separator + fileName;
+    try
+    {
+        String newpath = System.getenv( "DHIS2_HOME" );
+        if ( newpath != null )
+        {
+            path = newpath + File.separator + configurationService.getConfigurationByKey( Configuration_IN.KEY_REPORTFOLDER ).getValue() + File.separator + fileName;
+        }
+    }
+    catch ( NullPointerException npe )
+    {
+        System.out.println("DHIS2_HOME not set");
+    }
+
+    try
+    {
+        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+        Document doc = docBuilder.parse( new File( path ) );
+        if ( doc == null )
+        {
+            System.out.println( "There is no DECodes related XML file in the ra folder" );
+            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();
+            
+            String expression = ((Node) textDECodeList.item( 0 )).getNodeValue().trim();
+            String stype = deCodeElement.getAttribute( "stype" );
+            String ptype = deCodeElement.getAttribute( "type" );
+            int sheetno = new Integer( deCodeElement.getAttribute( "sheetno" ) );
+            int rowno = new Integer( deCodeElement.getAttribute( "rowno" ) );
+            int colno = new Integer( deCodeElement.getAttribute( "colno" ) );
+            int rowMerge = new Integer( deCodeElement.getAttribute( "rowmerge" ) );
+            int colMerge = new Integer( deCodeElement.getAttribute( "colmerge" ) );
+
+            Report_inDesign report_inDesign = new Report_inDesign( stype, ptype, sheetno, rowno, colno, rowMerge, colMerge, expression );
+            reportDesignList.add( report_inDesign );
+        }// 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 reportDesignList;
+}
+
+
+
     // -------------------------------------------------------------------------
     // Get Aggregated Result for dataelement expression 
     // -------------------------------------------------------------------------