} catch (RuntimeException e) {
// Exception must be handled and recorded in table SbiKpiError, if it is a datasetexception
if(e instanceof DatasetException){
logger.error("write exception in tabe kpiError ", e);
IKpiErrorDAO dao= DAOFactory.getKpiErrorDAO();
dao.setUserProfile(profile);
dao.insertKpiError(
(DatasetException)e,
modInstNodeId,
kVal.getR() != null ? kVal.getR().getName() : null );
}
else{
logger.error("Exception not handled by table KpiError ", e);
}
throw e;
}
IDataStore dataStore = dataSet.getDataStore();
logger.debug("Got the datastore");
if (dataStore != null && !dataStore.isEmpty()) {
// Transform result into KPIValue (I suppose that the result has a unique value)
IDataStoreMetaData d = dataStore.getMetaData();
int indexRes = d.getFieldIndex(RESOURCE);
if(indexRes!=-1){
Iterator it = dataStore.iterator();
while(it.hasNext()){
kpiValTemp = kVal.clone();
IRecord record =(IRecord)it.next();
List fields = record.getFields();
kpiValTemp = setKpiValuesFromDataset(kpiValTemp,fields,d, begD, endDate, dataSet.getLabel(),modInstNodeId, kVal);
if (kpiValTemp.getR()!=null && kVal.getR()!=null && kpiValTemp.getR().getId()!=null &&
kVal.getR().getId()!=null && kpiValTemp.getR().getId().equals(kVal.getR().getId())){
kVal = kpiValTemp.clone() ;
}
logger.debug("New value calculated");
if(register_values && kpiValTemp.getR().getName()!=null){
if(doSave){
// Insert new Value into the DB
IKpiDAO dao= DAOFactory.getKpiDAO();
dao.setUserProfile(profile);
Integer kpiValueId = dao.insertKpiValue(kpiValTemp);
kVal.setKpiValueId(kpiValueId);
logger.info("New value inserted in the DB. Resource="+kpiValTemp.getR().getName()+" KpiInstanceId="+kpiValTemp.getKpiInstanceId());
}
// Checks if the value is alarming (out of a certain range)
// If the value is alarming a new line will be inserted in the