1 package net.sf.jasperreports.mysql.reports; 2 3 import net.sf.jasperreports.engine.JRDefaultScriptlet; 4 import net.sf.jasperreports.engine.JRScriptletException; 5 6 9 public class TableStatusAScriptlet extends JRDefaultScriptlet 10 { 11 12 15 private Long sizeInitDatabaseGroup = null; 18 private Long sizeGrowthSumDatabaseGroup = null; 19 private Long rowsInitDatabaseGroup = null; 20 private Long rowsGrowthSumDatabaseGroup = null; 21 private Long indexInitDatabaseGroup = null; 22 private Long indexGrowthSumDatabaseGroup = null; 23 24 27 public void beforeGroupInit(String group) throws JRScriptletException 28 { 29 if ("DatabaseGroup".equals(group)) 30 { 31 sizeInitDatabaseGroup = new Long (0); 34 sizeGrowthSumDatabaseGroup = new Long (0); 35 rowsInitDatabaseGroup = new Long (0); 36 rowsGrowthSumDatabaseGroup = new Long (0); 37 indexInitDatabaseGroup = new Long (0); 38 indexGrowthSumDatabaseGroup = new Long (0); 39 } 40 else if ("TableGroup".equals(group)) 41 { 42 Long sizeGrowthSumTableGroup = (Long )getVariableValue("sizeGrowthSumTableGroup"); 43 sizeGrowthSumDatabaseGroup = 44 new Long ( 45 sizeGrowthSumDatabaseGroup.longValue() 46 + (sizeGrowthSumTableGroup == null ? 0 : sizeGrowthSumTableGroup.longValue()) 47 ); 48 Long rowsGrowthSumTableGroup = (Long )getVariableValue("rowsGrowthSumTableGroup"); 49 rowsGrowthSumDatabaseGroup = 50 new Long ( 51 rowsGrowthSumDatabaseGroup.longValue() 52 + (rowsGrowthSumTableGroup == null ? 0 : rowsGrowthSumTableGroup.longValue()) 53 ); 54 Long indexGrowthSumTableGroup = (Long )getVariableValue("indexGrowthSumTableGroup"); 55 indexGrowthSumDatabaseGroup = 56 new Long ( 57 indexGrowthSumDatabaseGroup.longValue() 58 + (indexGrowthSumTableGroup == null ? 0 : indexGrowthSumTableGroup.longValue()) 59 ); 60 } 61 } 62 63 66 public void afterGroupInit(String group) throws JRScriptletException 67 { 68 if ("DatabaseGroup".equals(group)) 69 { 70 } 73 else if ("TableGroup".equals(group)) 74 { 75 Long size = (Long )getFieldValue("data_length"); 76 sizeInitDatabaseGroup = 77 new Long ( 78 sizeInitDatabaseGroup.longValue() 79 + (size == null ? 0 : size.longValue()) 80 ); 81 Long rows = (Long )getFieldValue("rows"); 82 rowsInitDatabaseGroup = 83 new Long ( 84 rowsInitDatabaseGroup.longValue() 85 + (rows == null ? 0 : rows.longValue()) 86 ); 87 Long index = (Long )getFieldValue("index_length"); 88 indexInitDatabaseGroup = 89 new Long ( 90 indexInitDatabaseGroup.longValue() 91 + (index == null ? 0 : index.longValue()) 92 ); 93 } 94 } 95 96 99 public void afterDetailEval() throws JRScriptletException 100 { 101 Long sizeGrowthSumTableGroup = (Long )getVariableValue("sizeGrowthSumTableGroup"); 122 sizeGrowthSumTableGroup = 123 new Long ( 124 sizeGrowthSumDatabaseGroup.longValue() 125 + (sizeGrowthSumTableGroup == null ? 0 : sizeGrowthSumTableGroup.longValue()) 126 ); 127 setVariableValue( 128 "sizeGrowthSumDatabaseGroup", 129 sizeGrowthSumTableGroup 130 ); 131 setVariableValue( 132 "sizeGrowthPercentDatabaseGroup", 133 new Double (100d * sizeGrowthSumTableGroup.longValue() / sizeInitDatabaseGroup.longValue()) 134 ); 135 136 Long rowsGrowthSumTableGroup = (Long )getVariableValue("rowsGrowthSumTableGroup"); 137 rowsGrowthSumTableGroup = 138 new Long ( 139 rowsGrowthSumDatabaseGroup.longValue() 140 + (rowsGrowthSumTableGroup == null ? 0 : rowsGrowthSumTableGroup.longValue()) 141 ); 142 setVariableValue( 143 "rowsGrowthSumDatabaseGroup", 144 rowsGrowthSumTableGroup 145 ); 146 setVariableValue( 147 "rowsGrowthPercentDatabaseGroup", 148 new Double (100d * rowsGrowthSumTableGroup.longValue() / rowsInitDatabaseGroup.longValue()) 149 ); 150 151 Long indexGrowthSumTableGroup = (Long )getVariableValue("indexGrowthSumTableGroup"); 152 indexGrowthSumTableGroup = 153 new Long ( 154 indexGrowthSumDatabaseGroup.longValue() 155 + (indexGrowthSumTableGroup == null ? 0 : indexGrowthSumTableGroup.longValue()) 156 ); 157 setVariableValue( 158 "indexGrowthSumDatabaseGroup", 159 indexGrowthSumTableGroup 160 ); 161 setVariableValue( 162 "indexGrowthPercentDatabaseGroup", 163 new Double (100d * indexGrowthSumTableGroup.longValue() / indexInitDatabaseGroup.longValue()) 164 ); 165 } 166 167 187 188 } 189 | Popular Tags |