Search in sources :

Example 71 with Alarm

use of cern.laser.business.data.Alarm in project ACS by ACS-Community.

the class ACSCategoryDAOImpl method assignDefaultCategory.

/**
	 * Assign the default category to the alarms not assigned to any category
	 * 
	 * Scans all the alarms to check for alarms without any category and assign the default
	 * category to them.
	 * 
	 * @param defCategory The default category
	 */
private void assignDefaultCategory(Category defCategory) {
    if (defCategory == null) {
        throw new IllegalArgumentException("Invalid null category");
    }
    String[] IDs = ((ACSAlarmDAOImpl) alarmDao).getAllAlarmIDs();
    for (String alarmID : IDs) {
        Alarm alarm = alarmDao.getAlarm(alarmID);
        if (alarm == null) {
            logger.log(AcsLogLevel.WARNING, "Got a null alarm for ID=" + alarmID);
            continue;
        }
        Collection<Category> categories = alarm.getCategories();
        if (categories == null) {
            categories = new HashSet<Category>();
        }
        if (categories.size() == 0) {
            categories.add(defCategory);
            alarm.setCategories(categories);
            StringBuilder str = new StringBuilder("Alarm ");
            str.append(alarm.getAlarmId());
            str.append(" assigned to default category ");
            str.append(defCategory.getPath());
            logger.log(AcsLogLevel.DEBUG, str.toString());
        }
    }
}
Also used : Category(cern.laser.business.data.Category) Alarm(cern.laser.business.data.Alarm)

Example 72 with Alarm

use of cern.laser.business.data.Alarm in project ACS by ACS-Community.

the class TestAlarmDAO method testResponsiblePerson.

/**
	 * Test the setting of the responsible person
	 * by getting PS and one of the TEST member
	 * 
	 * @throws Exception
	 */
public void testResponsiblePerson() throws Exception {
    Alarm ps = alarmDAO.getAlarm(AlarmTriplets.PS_PSM_1.ID);
    assertNotNull(ps);
    assertEquals("123456", ps.getResponsiblePerson().getGsmNumber());
    assertEquals("test@eso.org", ps.getResponsiblePerson().getEMail());
    assertEquals("", ps.getResponsiblePerson().getFirstName());
    assertEquals("Alessandro", ps.getResponsiblePerson().getFamilyName());
    Alarm test = alarmDAO.getAlarm(AlarmTriplets.TEST_TM1_1.ID);
    assertNotNull(test);
    assertEquals("", test.getResponsiblePerson().getGsmNumber());
    assertEquals("", test.getResponsiblePerson().getEMail());
    assertEquals("", test.getResponsiblePerson().getFirstName());
    assertEquals("Alex", test.getResponsiblePerson().getFamilyName());
}
Also used : Alarm(cern.laser.business.data.Alarm)

Example 73 with Alarm

use of cern.laser.business.data.Alarm in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method addReductionRule.

public void addReductionRule(ReductionDefinitions rds, ReductionLinkType rl) {
    if (rl == null)
        throw new IllegalArgumentException("Null Reduction Link argument");
    //alma.alarmsystem.alarmmessage.generated.ReductionDefinitions rds = getReductionRules();
    //Store changes in the CDB.
    alma.alarmsystem.alarmmessage.generated.ReductionLinkType[] tmp = rds.getLinksToCreate().getReductionLink();
    for (int i = 0; i < tmp.length; i++) {
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition p1 = tmp[i].getParent().getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition c1 = tmp[i].getChild().getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition p2 = rl.getParent().getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition c2 = rl.getChild().getAlarmDefinition();
        String n1 = new String(p1.getFaultFamily() + ":" + p1.getFaultMember() + ":" + p1.getFaultCode());
        String n2 = new String(c1.getFaultFamily() + ":" + c1.getFaultMember() + ":" + c1.getFaultCode());
        String n3 = new String(p2.getFaultFamily() + ":" + p2.getFaultMember() + ":" + p2.getFaultCode());
        String n4 = new String(c2.getFaultFamily() + ":" + c2.getFaultMember() + ":" + c2.getFaultCode());
        if (n1.compareTo(n3) == 0 && n2.compareTo(n4) == 0 && tmp[i].getType().getType() == rl.getType().getType())
            throw new IllegalStateException("Reduction Rule already exist");
    }
    rds.getLinksToCreate().addReductionLink(rl);
    //Reflect the changes into the AlarmDAO
    alma.alarmsystem.alarmmessage.generated.AlarmDefinition in = rl.getParent().getAlarmDefinition();
    Alarm p = getAlarm(in.getFaultFamily() + ":" + in.getFaultMember() + ":" + in.getFaultCode());
    in = rl.getChild().getAlarmDefinition();
    Alarm c = getAlarm(in.getFaultFamily() + ":" + in.getFaultMember() + ":" + in.getFaultCode());
    if (rl.getType().getType() == ReductionLinkTypeTypeType.NODE_TYPE)
        p.addNodeChild(c);
    else if (rl.getType().getType() == ReductionLinkTypeTypeType.MULTIPLICITY_TYPE)
        p.addMultiplicityChild(c);
//Store new values in the CDB.
//flushReductionRules(rds);
}
Also used : Alarm(cern.laser.business.data.Alarm) AlarmDefinition(alma.alarmsystem.alarmmessage.generated.AlarmDefinition) ReductionLinkType(alma.alarmsystem.alarmmessage.generated.ReductionLinkType)

Example 74 with Alarm

use of cern.laser.business.data.Alarm in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method deleteReductionRule.

public void deleteReductionRule(ReductionDefinitions rds, ReductionLinkType rl) {
    if (rl == null)
        throw new IllegalArgumentException("Null Reduction Link argument");
    //alma.alarmsystem.alarmmessage.generated.ReductionDefinitions rds = getReductionRules();
    boolean removed = false;
    alma.alarmsystem.alarmmessage.generated.ReductionLinkType[] tmp = rds.getLinksToCreate().getReductionLink();
    for (int i = 0; i < tmp.length; i++) {
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition p1 = tmp[i].getParent().getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition c1 = tmp[i].getChild().getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition p2 = rl.getParent().getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition c2 = rl.getChild().getAlarmDefinition();
        String n1 = new String(p1.getFaultFamily() + ":" + p1.getFaultMember() + ":" + p1.getFaultCode());
        String n2 = new String(c1.getFaultFamily() + ":" + c1.getFaultMember() + ":" + c1.getFaultCode());
        String n3 = new String(p2.getFaultFamily() + ":" + p2.getFaultMember() + ":" + p2.getFaultCode());
        String n4 = new String(c2.getFaultFamily() + ":" + c2.getFaultMember() + ":" + c2.getFaultCode());
        if (n1.compareTo(n3) == 0 && n2.compareTo(n4) == 0 && tmp[i].getType().getType() == rl.getType().getType())
            removed = rds.getLinksToCreate().removeReductionLink(tmp[i]);
    }
    if (!removed)
        throw new IllegalStateException("Reduction Rule doesn't exist");
    //Reflect the changes into the AlarmDAO
    alma.alarmsystem.alarmmessage.generated.AlarmDefinition in = rl.getParent().getAlarmDefinition();
    Alarm p = getAlarm(in.getFaultFamily() + ":" + in.getFaultMember() + ":" + in.getFaultCode());
    in = rl.getChild().getAlarmDefinition();
    Alarm c = getAlarm(in.getFaultFamily() + ":" + in.getFaultMember() + ":" + in.getFaultCode());
    if (rl.getType().getType() == ReductionLinkTypeTypeType.NODE_TYPE)
        p.removeNodeChild(c);
    else if (rl.getType().getType() == ReductionLinkTypeTypeType.MULTIPLICITY_TYPE)
        p.removeMultiplicityChild(c);
//Store new values in the CDB.
//flushReductionRules(rds);
}
Also used : AlarmDefinition(alma.alarmsystem.alarmmessage.generated.AlarmDefinition) ReductionLinkType(alma.alarmsystem.alarmmessage.generated.ReductionLinkType) Alarm(cern.laser.business.data.Alarm)

Example 75 with Alarm

use of cern.laser.business.data.Alarm in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method deleteThreshold.

public void deleteThreshold(alma.alarmsystem.alarmmessage.generated.ReductionDefinitions rds, alma.alarmsystem.alarmmessage.generated.Threshold th) {
    if (th == null)
        throw new IllegalArgumentException("Null Threshold argument");
    boolean removed = false;
    //alma.alarmsystem.alarmmessage.generated.ReductionDefinitions rds = getReductionRules();
    alma.alarmsystem.alarmmessage.generated.Threshold[] tmp = rds.getThresholds().getThreshold();
    for (int i = 0; i < tmp.length; i++) {
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition p1 = th.getAlarmDefinition();
        alma.alarmsystem.alarmmessage.generated.AlarmDefinition p2 = tmp[i].getAlarmDefinition();
        String n1 = new String(p1.getFaultFamily() + ":" + p1.getFaultMember() + ":" + p1.getFaultCode());
        String n2 = new String(p2.getFaultFamily() + ":" + p2.getFaultMember() + ":" + p2.getFaultCode());
        if (n1.compareTo(n2) == 0)
            removed = rds.getThresholds().removeThreshold(tmp[i]);
    }
    if (!removed)
        throw new IllegalStateException("Threshold doesn't exist");
    //Reflect the changes into the AlarmDAO
    alma.alarmsystem.alarmmessage.generated.AlarmDefinition in = th.getAlarmDefinition();
    Alarm p = getAlarm(in.getFaultFamily() + ":" + in.getFaultMember() + ":" + in.getFaultCode());
    p.setMultiplicityThreshold(th.getValue());
//flushReductionRules(rds);
}
Also used : AlarmDefinition(alma.alarmsystem.alarmmessage.generated.AlarmDefinition) Alarm(cern.laser.business.data.Alarm) Threshold(alma.alarmsystem.alarmmessage.generated.Threshold)

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