* "data.points.fetched.maximum".
*
*/
public void loadData() throws DBException {
//long time;
DataSet results;
//DatabaseAccess db;
DataSetsDAO dataSetsDAO;
DataSetDAO dataSetDAO;
int sets;
String[] headings;
long intervalStart;
long intervalEnd;
long intervalTime;
int numValues;
//double pointValue;
int fetchedMaximum;
dataSets.setSessionID(sessionID);
dataSets.setStartTime(startTime);
dataSets.setFinishTime(finishTime);
try {
dataSetsDAO = DAOFactory.getDataSetsDAO();
dataSetDAO = DAOFactory.getDataSetDAO();
dataSets.setDataType(DataType.types[dataSetsDAO.retrieveSessionDataTypeID(sessionID)]);
dataSets.setDevice(new Device(dataSetsDAO.retrieveSessionDevice(sessionID)));
dataSets.setPortString(dataSetsDAO.retrieveSessionPort(sessionID));
dataSets.setPollInterval(dataSetsDAO.retrieveSessionPollInterval(sessionID));
dataSets.setTitle(dataSetsDAO.retrieveSessionTitle(sessionID));
dataSets.setDirection(dataSetsDAO.retrieveSessionDirection(sessionID));
headings = DAOFactory.getDataHeadingsDAO().retrieve(sessionID);
for ( int set = 0; set < headings.length; set++ ) {
dataSets.addSet(headings[set]);
}
fetchedMaximum = Configuration.getPropertyInt("data.points.fetched.maximum");
logger.debug("Fetching data for " + headings.length + " data sets ("
+ startTime + " to " + finishTime + ")");
sets = dataSets.getDataSetCount();
taskLength = sets * fetchedMaximum;
for ( int set = 0; set < sets; set++ ) {
taskProgress = set * fetchedMaximum;
//logger.debug("Current: " + current);
numValues = dataSetsDAO.retrieveNumberOfPoints(sessionID, set, startTime, finishTime);
if ( numValues <= fetchedMaximum ) {
dataSets.setDataSet(set, dataSetDAO.retrieve(sessionID, set, startTime, finishTime + 1));
checkCancelled();
} else {
intervalTime = ( finishTime - startTime ) / fetchedMaximum;
for ( int interval = 0; interval < fetchedMaximum; interval++ ) {
intervalStart = startTime + intervalTime * interval;
intervalEnd = startTime + intervalTime * (interval + 1);
results = dataSetDAO.retrieve(sessionID, set, intervalStart, intervalEnd);
dataSets.getDataSet(set).add(results.aggregate(aggregation, intervalStart, intervalEnd));
taskProgress = set * fetchedMaximum + interval;
checkCancelled();
//logger.debug("Point " + interval + " aggregation of " + results + " : (" + results.aggregate(aggregation, intervalStart, intervalEnd) + ")");
}
}