}
@Override
public Alert mapRow(ResultSet rs, int rowNum) throws SQLException {
long id = rs.getLong("alertId");
Alert a = null;
try {
if (isCacheEnabled() && lookupCache(cacheManager) != null) {
Element element;
if ((element = lookupCache(cacheManager).get(DbUtils.hashCodeCacheKeyFor(id))) != null) {
log.debug("Cache hit on map for Alert " + id);
return (Alert)element.getObjectValue();
}
}
try {
if (rs.getLong("userId") == LimsUtils.SYSTEM_USER_ID) {
a = new SystemAlert();
}
else {
User u = securityManager.getUserById(rs.getLong("userId"));
a = new DefaultAlert(u);
}
a.setAlertId(id);
a.setAlertTitle(rs.getString("title"));
a.setAlertText(rs.getString("text"));
a.setAlertRead(rs.getBoolean("isRead"));
a.setAlertLevel(AlertLevel.get(rs.getString("level")));
a.setAlertDate(rs.getDate("date"));
}
catch (IOException e1) {
e1.printStackTrace();
}