use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class TestAlarmDAO method testGetAlarmID.
/**
* Test the getting of alarms by their ID.
*
* it check the alarm, its ID, its triplet, its priority, its description,
* action, cause, consequence
*/
public void testGetAlarmID() throws Exception {
for (AlarmTriplets triplet : AlarmTriplets.values()) {
if (!triplet.ID.contains("*")) {
Alarm alarm = alarmDAO.getAlarm(triplet.ID);
assertNotNull(alarm);
// CHeck the ID
assertEquals(triplet.ID, alarm.getAlarmId());
// Check the triplet
Triplet alarmTriplet = alarm.getTriplet();
assertNotNull(alarmTriplet);
Triplet defTriplet = triplet.getTriplet();
assertEquals(defTriplet.getFaultFamily(), alarmTriplet.getFaultFamily());
assertEquals(defTriplet.getFaultMember(), alarmTriplet.getFaultMember());
assertEquals(defTriplet.getFaultCode(), alarmTriplet.getFaultCode());
// Check the priority
assertEquals(Integer.valueOf(triplet.priority), alarm.getPriority());
// Check the description
assertEquals(triplet.description, alarm.getProblemDescription());
// Action
assertEquals(triplet.action, alarm.getAction());
// The cause
assertEquals(triplet.cause, alarm.getCause());
// Conseuqnces
assertEquals(triplet.consequence, alarm.getConsequence());
}
}
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class TestAlarmDAO method testDeleteAlarm.
/**
* Test the deletion of alarms
*/
public void testDeleteAlarm() {
int size = alarmDAO.getAllAlarmIDs().length;
Alarm alarmToDelete = alarmDAO.getAlarm(AlarmTriplets.PS_PSM_1.ID);
assertNotNull(alarmToDelete);
alarmDAO.deleteAlarm(alarmToDelete);
assertEquals(size - 1, alarmDAO.getAllAlarmIDs().length);
Alarm deletedAlarm = alarmDAO.getAlarm(alarmToDelete.getAlarmId());
assertNull(deletedAlarm);
// Try to delete an alarm that does not exist
size = alarmDAO.getAllAlarmIDs().length;
alarmDAO.deleteAlarm(alarmToDelete);
assertEquals(size, alarmDAO.getAllAlarmIDs().length);
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class AlarmCacheServerImpl method store.
public void store(Collection updated) {
try {
logger.log(AcsLogLevel.DELOUSE, "storing " + updated.size() + " alarm(s)...");
Iterator iterator = updated.iterator();
while (iterator.hasNext()) {
Alarm alarm = (Alarm) iterator.next();
Status status = alarm.getStatus();
// if (status.getStatusId() == null || status.getStatusId().equals("")) {
// if (LOGGER.isDebugEnabled()) LOGGER.debug("saving status ...");
// status.setStatusId(alarm.getAlarmId());
// alarmDAO.saveStatus(status);
// } else {
// if (LOGGER.isDebugEnabled()) LOGGER.debug("updating status ...");
alarmDAO.updateStatus(status);
// }
}
logger.log(AcsLogLevel.DELOUSE, "stored");
} catch (Exception e) {
throw new LaserRuntimeException("unable to store alarm(s)", e);
}
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method createNodeLinkInternal.
private void createNodeLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
Alarm[] parent_child = validateReductionLink(link);
AdminUser admin_user = adminUserDAO.findAdminUser(userId);
try {
LOGGER.info("user " + admin_user.getName() + " creating node link : " + link);
//alarmDAO.findAlarm(link.getParent().getAlarmId());
Alarm parent = parent_child[0];
//alarmDAO.findAlarm(link.getChild().getAlarmId());
Alarm child = parent_child[1];
parent.addNodeChild(child);
alarmDAO.updateAlarm(parent);
LOGGER.info("node link created");
} catch (Exception e) {
throw new LaserRuntimeException("unable to create the node link " + link + " : " + e.getMessage(), e);
}
}
use of cern.laser.business.data.Alarm in project ACS by ACS-Community.
the class AlarmDefinitionServiceImpl method validateReductionLink.
private Alarm[] validateReductionLink(ReductionLink link) throws LaserDefinitionException {
if (link == null) {
throw new LaserDefinitionNotValidException("reduction link is null");
}
if (link.getParent() == null) {
throw new LaserDefinitionNotValidException("malformed reduction link: parent is null");
}
if (link.getChild() == null) {
throw new LaserDefinitionNotValidException("malformed reduction link: child is null");
}
Alarm parent = alarmDAO.getAlarm(link.getParent().getAlarmId());
if (parent == null) {
throw new LaserDefinitionNotFoundException("reduction parent " + link.getParent().getAlarmId() + " does not exist");
}
Alarm child = alarmDAO.getAlarm(link.getChild().getAlarmId());
if (child == null) {
throw new LaserDefinitionNotFoundException("reduction child " + link.getChild().getAlarmId() + " does not exist");
}
return new Alarm[] { parent, child };
}
Aggregations