}
public SpeedDistributionReport getSpeedDistributionReport(TagDetails tagDetails) throws Exception
{
SpeedDistributionReport report = new SpeedDistributionReport();
report.setTagId(tagDetails.getId());
report.setCreated(new Date());
ArrayList<ArrayList> rows = new ArrayList<ArrayList>();
try {
Connection connection = getConnection();
Statement s = connection.createStatement();
String tagId = tagDetails.getId();
String sql = "SELECT * FROM speeddistribution WHERE tagid = '"+tagId+"' ORDER BY dayType desc, hourbin, speedbin";
logger.debug("SQL for getSpeedDistributionReport: " + sql);
ResultSet r = s.executeQuery(sql);
while (r.next()) {
ArrayList<String> row = new ArrayList<String>();
// skip first two columns (oid, tagid)
row.add(r.getString(3)); // daytype
row.add(r.getString(4)); // hourbin
row.add(r.getString(5)); // speedbin
row.add(r.getString(6)); // secondsinbin
row.add(r.getString(7)); // metersinbin
row.add(r.getString(8)); // avgmeterspersecond
row.add(r.getString(9)); // percentsecondsinbin
row.add(r.getString(10)); // percentmetersinbin
rows.add(row);
}
report.setReporValues(rows);
logger.debug("getSpeedDistribution DAO complete: rowcount=" + rows.size());
return report;
} catch (SQLException e) {
logger.error(e.getMessage());