Search in sources :

Example 41 with Alarm

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());
        }
    }
}
Also used : Triplet(cern.laser.business.data.Triplet) Alarm(cern.laser.business.data.Alarm)

Example 42 with Alarm

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);
}
Also used : Alarm(cern.laser.business.data.Alarm)

Example 43 with Alarm

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);
    }
}
Also used : Status(cern.laser.business.data.Status) Alarm(cern.laser.business.data.Alarm) Iterator(java.util.Iterator) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 44 with Alarm

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);
    }
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 45 with Alarm

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 };
}
Also used : LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) Alarm(cern.laser.business.data.Alarm) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException)

Aggregations

Alarm (cern.laser.business.data.Alarm)91 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)24 LaserRuntimeException (cern.laser.business.LaserRuntimeException)21 ArrayList (java.util.ArrayList)21 Category (cern.laser.business.data.Category)16 Collection (java.util.Collection)14 AlarmImpl (cern.laser.business.data.AlarmImpl)13 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)12 AdminUser (cern.laser.business.data.AdminUser)11 AlarmDefinition (alma.alarmsystem.alarmmessage.generated.AlarmDefinition)10 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)10 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)10 Iterator (java.util.Iterator)10 LaserProcessingException (cern.laser.business.LaserProcessingException)9 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)9 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)7 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)7 FaultCode (alma.acs.alarmsystem.generated.FaultCode)6 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)6 FaultMember (alma.acs.alarmsystem.generated.FaultMember)6