ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/DBReporter2/ReportMaker.java
(Generate patch)

Comparing projects/cms/source/reports/DBReporter2/ReportMaker.java (file contents):
Revision 1.1 by pjm2, Sat Feb 3 14:56:14 2001 UTC vs.
Revision 1.2 by pjm2, Sat Feb 3 17:26:07 2001 UTC

# Line 5 | Line 5 | import java.io.*;
5  
6   import uk.ac.ukc.iscream.util.*;
7  
8 +
9 + // ReportMaker class - used to produce each type of report for a machine.
10   public class ReportMaker {
11 <    
11 >
12 >    // Constructor.  This takes the database Statement.    
13      public ReportMaker(Statement stmt, String dateDir, long startTime, long endTime) {
14          _stmt = stmt;
15          _dateDir = dateDir;
# Line 14 | Line 17 | public class ReportMaker {
17          _endTime = endTime;
18      }
19      
20 <    public void produce(ReportList reports, String machine) {
20 >    // Produce all reports in the report list for the machine.
21 >    public void produce(ReportList reports, String machine) throws SQLException {
22          
19        if (1==1)
20            return;
21        
23          System.out.println("Producing reports for " + machine + ".");
24  
25 +        // Make a list of PlotData objects to build the charts.
26 +        LinkedList plots = new LinkedList();
27          Iterator reportIt = reports.iterator();
28          while (reportIt.hasNext()) {
29 <            Report report = (Report)reportIt.next();
30 <            report.setPlotData(null);
28 <            report.setPlotData(new PlotData(_startTime, _endTime));
29 >            reportIt.next();
30 >            plots.add(new PlotData(_startTime, _endTime));
31          }
32          
33 <        String sql = "SELECT receipt_date, xml FROM ipacket WHERE machine_name='" + machine + "' ORDER BY receipt_date;";
34 <
33 >        
34 >        // Select the data we nede from the database.
35 >        String sql = "SELECT receipt_date, xml FROM ipacket WHERE machine_name='" + machine + "' AND receipt_date>=" + _startTime + " AND receipt_date<=" + _endTime + " ORDER BY receipt_date;";
36          ResultSet rs = null;
37          try {
38              rs = _stmt.executeQuery(sql);
# Line 52 | Line 55 | public class ReportMaker {
55                  pm = new XMLPacketMaker(xml);
56                  packet = pm.createXMLPacket();
57                  reportIt = reports.iterator();
58 +                Iterator plotIt = plots.iterator();
59                  while (reportIt.hasNext()) {
60 +                    PlotData plotData = (PlotData)plotIt.next();
61                      Report report = (Report)reportIt.next();
62                      String reportField = report.getReportField();
58                    PlotData plotData = report.getPlotData();
63                      long x = rs.getLong("receipt_date");
64                      double y;
65                      try {
# Line 68 | Line 72 | public class ReportMaker {
72                      plotData.addPoint(x, y);
73                  }
74              }
75 +            rs.close();
76          }
77          catch (SQLException e) {
78              System.out.println("SQLException: " + e);
# Line 75 | Line 80 | public class ReportMaker {
80          
81          System.out.println("[DEBUG]Writing graphs to disk.");
82          
83 +        // Write a chart of each report to disk.
84 +        Iterator plotIt = plots.iterator();
85          reportIt = reports.iterator();
86          while (reportIt.hasNext()) {
87              Report report = (Report)reportIt.next();
88              String reportField = report.getReportField();
89 <            PlotData plotData = report.getPlotData();
89 >            PlotData plotData = (PlotData)plotIt.next();
90              plotData.flushPoints();
91              plotData.scaleToFitX(SHTMLLayout.CHART_WIDTH, SHTMLLayout.CHART_HEIGHT);
92              IscreamChart chart = new IscreamChart(_startTime, _endTime);
# Line 90 | Line 97 | public class ReportMaker {
97              BufferedImage img = chart.drawChart(plotData, SHTMLLayout.CHART_WIDTH, SHTMLLayout.CHART_HEIGHT, 24, 10, maxY);
98              IscreamChartWriter imgWriter = new IscreamChartWriter();
99              imgWriter.writeChart(img, _dateDir + "_" + machine + "_" + reportField + ".gif");
100 <            System.out.println("[DEBUG]Point count: " + plotData.countPoints());
94 <            report.clearPlotData();
95 <            System.out.println("[DEBUG]Point count: " + plotData.countPoints());
100 >            System.out.println("[DEBUG]Point count: " + plotData.countPoints());            
101          }
102          
103      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines