Long fromPeriod = getFromPeriod(chartTimespan, keyObject);
Long toPeriod = getToPeriod(keyObject);
List<LiveStatistics> liveList = null;
String seriesLabel = null;
Alert alert = null;
GroupedStatistics groupedStatistics = null;
XYDataSetCollection valueCollection = new XYDataSetCollection();
//TODO: This if-else code block needs refactoring. Its not DRY
if (isAlertChart(id)) {
id = id.replaceAll("\\%20", " ").replaceAll("\\%25", "%");
String alertName = id.substring(8, id.length());
log.info("isAlert! " + alertName);
alert = getBerkeleyTreeMenuService().getAlert(alertName, loggedInAccountName);
if (alert != null) {
chartPath = alert.getGuiPath();
seriesLabel = "Alert: " + alert.getAlertName();
}
liveList = getBerkeleyTreeMenuService().getLiveStatistics(chartPath, loggedInAccountName, fromPeriod, toPeriod);
Collections.sort(liveList);
valueCollection = ChartUtil.generateChart(liveList, seriesLabel, fromPeriod * 15000, toPeriod * 15000, chartResolution);