use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class CoreServiceImpl method getAlarmsBySource.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getAlarmsBySource(java.lang.Integer)
*/
public Collection getAlarmsBySource(String sourceId) {
Collection result = null;
try {
String[] alarms = sourceDAO.getAlarms(sourceId);
result = new ArrayList(alarms.length);
for (int i = 0; i < alarms.length; i++) {
Alarm alarm = alarmCache.getReference(alarms[i]);
result.add(alarm);
}
} catch (Exception e) {
LOGGER.error("unable to get alarms by source " + sourceId, e);
//throw new EJBException("unable to get alarms by source " + sourceId, e);
}
return result;
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class CoreServiceImpl method getMultiplicityThreshold.
/*
* (non-Javadoc)
*
* @see cern.laser.business.ejb.CoreServiceSessionEJB#getMultiplicityThreshold(java.lang.Integer)
*/
public Integer getMultiplicityThreshold(String parentId) {
Integer result = new Integer(0);
try {
Alarm parent = alarmCache.getReference(parentId);
result = parent.getMultiplicityThreshold();
} catch (AlarmCacheException onf) {
LOGGER.warn("multiplicity parent " + parentId + " not found");
} catch (Exception e) {
LOGGER.error("unable to get multiplicity threshold for " + parentId, e);
//throw new EJBException("unable to get multiplicity threshold for " + parentId, e);
}
return result;
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class CoreServiceImpl method archiveSearch.
/**
* @param categoryIds
* @param sql
* @param clientId
*/
public void archiveSearch(Integer[] categoryIds, String sql, String clientId) {
String destination = getSearchRootTopic() + "." + clientId;
String category_constraints = buildCategorySQLFilter(categoryIds);
String select_sql = "select alarm_id from alarm_definition where " + sql + " and alarm_id in " + "(select alarm_id from alarm_category where " + category_constraints + ")";
if (LOGGER.isDebugEnabled())
LOGGER.debug("search sql " + select_sql);
Collection search_result = alarmDAO.archiveSearch(select_sql);
Collection found_alarms = new ArrayList(search_result.size());
try {
for (Iterator iter = search_result.iterator(); iter.hasNext(); ) {
Alarm alarm = alarmCache.getReference((String) iter.next());
found_alarms.add(alarm);
}
} catch (AlarmCacheException e) {
throw new LaserRuntimeException("unable to search alarms", e);
}
alarmPublisher.sendSearch(found_alarms, destination);
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class ACSAlarmCacheImpl method getCopy.
public Alarm getCopy(String identifier) throws AlarmCacheException {
// This method get the reference to the object first and then
// create a copy to return to the caller
// The Alarm to return a copy of
lock.lock();
Alarm retAl;
try {
retAl = getReference(identifier);
return (Alarm) (((AlarmImpl) retAl).clone());
} finally {
lock.unlock();
}
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method assignCategoryToAlarms.
/**
* Assign the category to the all the alarms of a given FaultFamily.
*
* In the CDB each category has a list (eventually empty) of FaultFamily.
* If a FaultFamily appear in the definition of a Category then add
* such category to all the alarms of such FF.
*
* @param category The category to assign to the alarms
* @param FF The fault family of the alarms to assign the category to
*/
private void assignCategoryToAlarms(Category category, String FF) {
if (category == null) {
throw new IllegalArgumentException("Invalid null category");
}
if (FF == null) {
throw new IllegalArgumentException("Invalid null fault family");
}
String[] alarmIDs = ((ACSAlarmDAOImpl) alarmDao).getAllAlarmIDs();
for (String id : alarmIDs) {
Alarm alarm = alarmDao.getAlarm(id);
if (alarm == null) {
logger.log(AcsLogLevel.WARNING, "Got a null alarm for ID=" + id);
continue;
}
if (alarm.getTriplet().getFaultFamily().equals(FF)) {
Collection<Category> alarmCategories = alarm.getCategories();
if (!alarmCategories.contains(category)) {
alarmCategories.add(category);
logger.log(AcsLogLevel.DEBUG, "Category " + category.getName() + " assigned to alarm " + alarm.getAlarmId());
}
}
}
}
Aggregations