String dayType) throws Exception
{
// to generate a traffic flow report, we must have a default
// flow for this tag
DefaultFlow query = new DefaultFlow();
query.setTagDetails(tagDetails);
DefaultFlow defaultFlow = regionDao.getDefaultFlow(query);
if( defaultFlow == null)
{
/*
* We used to an error here:
* throw new Exception("Cannot generate report. There is no default flow \nfor the '"+tagDetails.getName()+"' tag");
*
* But, according the jarogers, we should have a default flow of 0 for
* all values if there is no default flow entity for this tag.
*
*/
defaultFlow = new DefaultFlow();
defaultFlow.setTagDetails(tagDetails);
defaultFlow.setW2Weekday("0");
defaultFlow.setW2Saturday("0");
defaultFlow.setW2SundayHoliday("0");
defaultFlow.setW3Weekday("0");
defaultFlow.setW3Saturday("0");
defaultFlow.setW3SundayHoliday("0");
defaultFlow.setPcWeekday("0");
defaultFlow.setPcSaturday("0");
defaultFlow.setPcSundayHoliday("0");
defaultFlow.setTxWeekday("0");
defaultFlow.setTxSaturday("0");
defaultFlow.setTxSundayHoliday("0");
defaultFlow.setLdcWeekday("0");
defaultFlow.setLdcSaturday("0");
defaultFlow.setLdcSundayHoliday("0");
defaultFlow.setLdvWeekday("0");
defaultFlow.setLdvSaturday("0");
defaultFlow.setLdvSundayHoliday("0");
defaultFlow.setHdcWeekday("0");
defaultFlow.setHdcSaturday("0");
defaultFlow.setHdcSundayHoliday("0");
defaultFlow.setMdbWeekday("0");
defaultFlow.setMdbSaturday("0");
defaultFlow.setMdbSundayHoliday("0");
defaultFlow.setHdbWeekday("0");
defaultFlow.setHdbSaturday("0");
defaultFlow.setHdbSundayHoliday("0");
}
ArrayList<ArrayList> rawData = dao.getTrafficFlowReportData(tagDetails, dayType);
// create the hasValuesList from the rawData
int hour = 0;
ArrayList<Boolean> hasValuesList = new ArrayList<Boolean>();
for (Iterator iterator = rawData.iterator(); iterator.hasNext();) {
ArrayList row = (ArrayList) iterator.next();
boolean hasValues = hasValues(row);
hour++;
hasValuesList.add(hasValues);
}
ArrayList<String> defaultFlowValues = new ArrayList<String>();
if( dayType.equalsIgnoreCase(TrafficCountRecord.DAYTYPE_WEEKDAY))
{
// extract vehicle flow values from default flow for weekday only
defaultFlowValues.add(defaultFlow.getW2Weekday());
defaultFlowValues.add(defaultFlow.getW3Weekday());
defaultFlowValues.add(defaultFlow.getPcWeekday());
defaultFlowValues.add(defaultFlow.getTxWeekday());
defaultFlowValues.add(defaultFlow.getLdvWeekday());
defaultFlowValues.add(defaultFlow.getLdcWeekday());
defaultFlowValues.add(defaultFlow.getHdcWeekday());
defaultFlowValues.add(defaultFlow.getMdbWeekday());
defaultFlowValues.add(defaultFlow.getHdbWeekday());
} else if (dayType.equalsIgnoreCase(TrafficCountRecord.DAYTYPE_SATURDAY)) {
// extract vehicle flow values from default flow for saturday only
defaultFlowValues.add(defaultFlow.getW2Saturday());
defaultFlowValues.add(defaultFlow.getW3Saturday());
defaultFlowValues.add(defaultFlow.getPcSaturday());
defaultFlowValues.add(defaultFlow.getTxSaturday());
defaultFlowValues.add(defaultFlow.getLdvSaturday());
defaultFlowValues.add(defaultFlow.getLdcSaturday());
defaultFlowValues.add(defaultFlow.getHdcSaturday());
defaultFlowValues.add(defaultFlow.getMdbSaturday());
defaultFlowValues.add(defaultFlow.getHdbSaturday());
} else {
// extract vehicle flow values from default flow for sunday/holiday only
defaultFlowValues.add(defaultFlow.getW2SundayHoliday());
defaultFlowValues.add(defaultFlow.getW3SundayHoliday());
defaultFlowValues.add(defaultFlow.getPcSundayHoliday());
defaultFlowValues.add(defaultFlow.getTxSundayHoliday());
defaultFlowValues.add(defaultFlow.getLdvSundayHoliday());
defaultFlowValues.add(defaultFlow.getLdcSundayHoliday());
defaultFlowValues.add(defaultFlow.getHdcSundayHoliday());
defaultFlowValues.add(defaultFlow.getMdbSundayHoliday());
defaultFlowValues.add(defaultFlow.getHdbSundayHoliday());
}
/*
* Find out where the BEFOREs and AFTERs start
*/