case BAMCalendar.YEAR:
time = summaryGenerationDSStub.getLatestEndpointStatYearlySummaryYearId(
endpoint.getServerId(), endpoint.getName(), endpoint.getDirection());
break;
default:
throw new BAMException("Unexpected timeInterval");
}
cal = getTimeStampForId(summaryPeriod, time);
if (cal == null) {
//This is the first time we are running the summary. So, get the minimum time stamp
//for this server from "server user data" table
TimeStamp[] timeStamps = summaryGenerationDSStub.getServerUserDataMinimumPeriodId(endpoint.getServerId());
if (timeStamps != null && timeStamps[0] != null) {
//we are sure that there will be only one record.
cal = BAMCalendar.getInstance(timeStamps[0].getTimeStamp());
}else{
//We are running for the first time and there are no records in
//"server user data". So, we can start from now
cal = BAMCalendar.getInstance();
}
//Start with last period so that it will include our intended period
cal.add(summaryPeriod, -2);
}
} catch (Exception e) {
String msg = "Unable to get LatestSummaryTime for endpoint";
log.error(msg);
throw new BAMException(msg, e);
}
return cal;
}