KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > mysql > reports > TableStatusAScriptlet


1 package net.sf.jasperreports.mysql.reports;
2
3 import net.sf.jasperreports.engine.JRDefaultScriptlet;
4 import net.sf.jasperreports.engine.JRScriptletException;
5
6 /**
7  *
8  */

9 public class TableStatusAScriptlet extends JRDefaultScriptlet
10 {
11
12     /**
13      *
14      */

15 // private DefaultPieDataset pieDataset = null;
16
// private Long other = null;
17
private Long JavaDoc sizeInitDatabaseGroup = null;
18     private Long JavaDoc sizeGrowthSumDatabaseGroup = null;
19     private Long JavaDoc rowsInitDatabaseGroup = null;
20     private Long JavaDoc rowsGrowthSumDatabaseGroup = null;
21     private Long JavaDoc indexInitDatabaseGroup = null;
22     private Long JavaDoc indexGrowthSumDatabaseGroup = null;
23     
24     /**
25      *
26      */

27     public void beforeGroupInit(String JavaDoc group) throws JRScriptletException
28     {
29         if ("DatabaseGroup".equals(group))
30         {
31 // pieDataset = new DefaultPieDataset();
32
// other = null;
33
sizeInitDatabaseGroup = new Long JavaDoc(0);
34             sizeGrowthSumDatabaseGroup = new Long JavaDoc(0);
35             rowsInitDatabaseGroup = new Long JavaDoc(0);
36             rowsGrowthSumDatabaseGroup = new Long JavaDoc(0);
37             indexInitDatabaseGroup = new Long JavaDoc(0);
38             indexGrowthSumDatabaseGroup = new Long JavaDoc(0);
39         }
40         else if ("TableGroup".equals(group))
41         {
42             Long JavaDoc sizeGrowthSumTableGroup = (Long JavaDoc)getVariableValue("sizeGrowthSumTableGroup");
43             sizeGrowthSumDatabaseGroup =
44                 new Long JavaDoc(
45                     sizeGrowthSumDatabaseGroup.longValue()
46                     + (sizeGrowthSumTableGroup == null ? 0 : sizeGrowthSumTableGroup.longValue())
47                     );
48             Long JavaDoc rowsGrowthSumTableGroup = (Long JavaDoc)getVariableValue("rowsGrowthSumTableGroup");
49             rowsGrowthSumDatabaseGroup =
50                 new Long JavaDoc(
51                     rowsGrowthSumDatabaseGroup.longValue()
52                     + (rowsGrowthSumTableGroup == null ? 0 : rowsGrowthSumTableGroup.longValue())
53                     );
54             Long JavaDoc indexGrowthSumTableGroup = (Long JavaDoc)getVariableValue("indexGrowthSumTableGroup");
55             indexGrowthSumDatabaseGroup =
56                 new Long JavaDoc(
57                     indexGrowthSumDatabaseGroup.longValue()
58                     + (indexGrowthSumTableGroup == null ? 0 : indexGrowthSumTableGroup.longValue())
59                     );
60         }
61     }
62
63     /**
64      *
65      */

66     public void afterGroupInit(String JavaDoc group) throws JRScriptletException
67     {
68         if ("DatabaseGroup".equals(group))
69         {
70 // pieDataset = new DefaultPieDataset();
71
// other = null;
72
}
73         else if ("TableGroup".equals(group))
74         {
75             Long JavaDoc size = (Long JavaDoc)getFieldValue("data_length");
76             sizeInitDatabaseGroup =
77                 new Long JavaDoc(
78                     sizeInitDatabaseGroup.longValue()
79                     + (size == null ? 0 : size.longValue())
80                     );
81             Long JavaDoc rows = (Long JavaDoc)getFieldValue("rows");
82             rowsInitDatabaseGroup =
83                 new Long JavaDoc(
84                     rowsInitDatabaseGroup.longValue()
85                     + (rows == null ? 0 : rows.longValue())
86                     );
87             Long JavaDoc index = (Long JavaDoc)getFieldValue("index_length");
88             indexInitDatabaseGroup =
89                 new Long JavaDoc(
90                     indexInitDatabaseGroup.longValue()
91                     + (index == null ? 0 : index.longValue())
92                     );
93         }
94     }
95
96     /**
97      *
98      */

99     public void afterDetailEval() throws JRScriptletException
100     {
101 // String name = (String)getFieldValue("name");
102
// Number size = (Number)getFieldValue("data_length");
103
//
104
// if (size == null)
105
// {
106
// size = new Long(0);
107
// }
108
//
109
// if (((Number)getVariableValue("DatabaseGroup_COUNT")).intValue() >= 6)
110
// {
111
// if (other == null)
112
// {
113
// other = new Long(0);
114
// }
115
// other = new Long(other.longValue() + size.longValue());
116
// name = "Other";
117
// size = other;
118
// }
119
//
120
// pieDataset.setValue(name, size);
121
Long JavaDoc sizeGrowthSumTableGroup = (Long JavaDoc)getVariableValue("sizeGrowthSumTableGroup");
122         sizeGrowthSumTableGroup =
123             new Long JavaDoc(
124                 sizeGrowthSumDatabaseGroup.longValue()
125                 + (sizeGrowthSumTableGroup == null ? 0 : sizeGrowthSumTableGroup.longValue())
126                 );
127         setVariableValue(
128             "sizeGrowthSumDatabaseGroup",
129             sizeGrowthSumTableGroup
130             );
131         setVariableValue(
132             "sizeGrowthPercentDatabaseGroup",
133             new Double JavaDoc(100d * sizeGrowthSumTableGroup.longValue() / sizeInitDatabaseGroup.longValue())
134             );
135
136         Long JavaDoc rowsGrowthSumTableGroup = (Long JavaDoc)getVariableValue("rowsGrowthSumTableGroup");
137         rowsGrowthSumTableGroup =
138             new Long JavaDoc(
139                 rowsGrowthSumDatabaseGroup.longValue()
140                 + (rowsGrowthSumTableGroup == null ? 0 : rowsGrowthSumTableGroup.longValue())
141                 );
142         setVariableValue(
143             "rowsGrowthSumDatabaseGroup",
144             rowsGrowthSumTableGroup
145             );
146         setVariableValue(
147             "rowsGrowthPercentDatabaseGroup",
148             new Double JavaDoc(100d * rowsGrowthSumTableGroup.longValue() / rowsInitDatabaseGroup.longValue())
149             );
150
151         Long JavaDoc indexGrowthSumTableGroup = (Long JavaDoc)getVariableValue("indexGrowthSumTableGroup");
152         indexGrowthSumTableGroup =
153             new Long JavaDoc(
154                 indexGrowthSumDatabaseGroup.longValue()
155                 + (indexGrowthSumTableGroup == null ? 0 : indexGrowthSumTableGroup.longValue())
156                 );
157         setVariableValue(
158             "indexGrowthSumDatabaseGroup",
159             indexGrowthSumTableGroup
160             );
161         setVariableValue(
162             "indexGrowthPercentDatabaseGroup",
163             new Double JavaDoc(100d * indexGrowthSumTableGroup.longValue() / indexInitDatabaseGroup.longValue())
164             );
165     }
166
167     /**
168      *
169      *
170     public JRRenderable getChart()
171     {
172         JFreeChart chart =
173             ChartFactory.createPieChart(
174                 "Table size",
175                 pieDataset,
176                 true,
177                 true,
178                 false
179                 );
180         
181         chart.setBackgroundPaint(Color.white);
182         chart.getPlot().setOutlinePaint(Color.white);
183         
184         return new JCommonDrawableRenderer(chart);
185     }
186     */

187
188 }
189
Popular Tags