Search in sources :

Example 16 with Alarm

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

the class ACSAlarmDAOImpl method updateThreshold.

public void updateThreshold(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");
    rds.getThresholds().addThreshold(th);
    //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)

Example 17 with Alarm

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

Example 18 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 19 with Alarm

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

the class ACSAlarmDAOImplTest method testAddFaultFamily.

public void testAddFaultFamily() {
    boolean exception;
    Alarm al1;
    cern.laser.business.data.Location l;
    //Delete Entry if it exists due to an error in previous test
    {
        FaultFamily ff = new FaultFamily();
        ff.setName("ffTest1");
        try {
            _alarmDAO.removeFaultFamily(ff);
        } catch (Exception e) {
        //This happens when FaultFamily "ffTest1" doesn't exist
        }
    }
    //Check Null Argument
    exception = false;
    try {
        _alarmDAO.addFaultFamily(null);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    //Check new FaultFamily
    FaultFamily ff = new FaultFamily();
    ff.setName("ffTest1");
    ff.setAlarmSource("ALARM_SYSTEM_SOURCES");
    ff.setHelpUrl("http://www.test.com");
    Contact ct = new Contact();
    ct.setEmail("em1");
    ct.setGsm("gsm1");
    ct.setName("cont1");
    ff.setContact(ct);
    FaultCode fc = new FaultCode();
    fc.setValue(1);
    fc.setPriority(0);
    fc.setAction("action1");
    fc.setCause("cause1");
    fc.setConsequence("conseq1");
    fc.setProblemDescription("problem1");
    ff.addFaultCode(fc);
    FaultMemberDefault fmd = new FaultMemberDefault();
    Location lc = new Location();
    lc.setBuilding("b1");
    lc.setFloor("f1");
    lc.setMnemonic("m1");
    lc.setPosition("p1");
    lc.setRoom("r1");
    fmd.setLocation(lc);
    ff.setFaultMemberDefault(fmd);
    FaultMember fm = new FaultMember();
    fm.setName("fmTest1");
    lc = new Location();
    lc.setBuilding("b2");
    lc.setFloor("f2");
    lc.setMnemonic("m2");
    lc.setPosition("p2");
    lc.setRoom("r2");
    fm.setLocation(lc);
    ff.addFaultMember(fm);
    exception = false;
    try {
        _alarmDAO.addFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest1:1");
    assertNotNull(al1);
    assertEquals("ALARM_SYSTEM_SOURCES", al1.getSource().getName());
    assertEquals("http://www.test.com", al1.getHelpURL().toString());
    assertEquals("em1", al1.getPiquetEmail());
    assertEquals("gsm1", al1.getPiquetGSM());
    assertEquals("cont1", al1.getResponsiblePerson().getFamilyName());
    assertEquals(0, al1.getPriority().intValue());
    assertEquals("action1", al1.getAction());
    assertEquals("cause1", al1.getCause());
    assertEquals("conseq1", al1.getConsequence());
    assertEquals("problem1", al1.getProblemDescription());
    l = al1.getLocation();
    assertNotNull(l);
    //assertEquals("b2",l.getBuilding()); //Null
    assertEquals("f2", l.getFloor());
    assertEquals("m2", l.getMnemonic());
    assertEquals("p2", l.getPosition());
    assertEquals("r2", l.getRoom());
    //Check if it already exists
    exception = false;
    try {
        _alarmDAO.addFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarm(cern.laser.business.data.Alarm) Contact(alma.acs.alarmsystem.generated.Contact) FaultMemberDefault(alma.acs.alarmsystem.generated.FaultMemberDefault) Location(alma.acs.alarmsystem.generated.Location)

Example 20 with Alarm

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

the class ACSAlarmDAOImplTest method testUpdateFaultFamily.

public void testUpdateFaultFamily() {
    boolean exception;
    Alarm al1;
    cern.laser.business.data.Location l;
    //Delete Entry if it exists due to an error in previous test
    {
        FaultFamily ff = new FaultFamily();
        ff.setName("ffTest1");
        try {
            _alarmDAO.removeFaultFamily(ff);
        } catch (Exception e) {
        //This happens when FaultFamily "ffTest1" doesn't exist
        }
    }
    //Check Null Argument
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(null);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    //Update a FaultFamily that doesn't exist
    FaultFamily ff = new FaultFamily();
    ff.setName("ffTest1");
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    //Check updating FaultFamily
    ff.setAlarmSource("ALARM_SYSTEM_SOURCES");
    ff.setHelpUrl("http://www.test.com");
    Contact ct = new Contact();
    ct.setEmail("em1");
    ct.setGsm("gsm1");
    ct.setName("cont1");
    ff.setContact(ct);
    FaultCode fc = new FaultCode();
    fc.setValue(1);
    fc.setPriority(0);
    fc.setAction("action1");
    fc.setCause("cause1");
    fc.setConsequence("conseq1");
    fc.setProblemDescription("problem1");
    ff.addFaultCode(fc);
    FaultMember fm = new FaultMember();
    fm.setName("fmTest1");
    Location lc = new Location();
    lc.setBuilding("b2");
    lc.setFloor("f2");
    lc.setMnemonic("m2");
    lc.setPosition("p2");
    lc.setRoom("r2");
    fm.setLocation(lc);
    ff.addFaultMember(fm);
    exception = false;
    try {
        _alarmDAO.addFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    //Update FF information
    //ff.setAlarmSource("ALARM_SYSTEM_SOURCES2");//Can't be changed at the moment.
    ff.setHelpUrl("http://www.test2.com");
    ct.setEmail("em2");
    ct.setGsm("gsm2");
    ct.setName("cont2");
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest1:1");
    assertNotNull(al1);
    assertEquals("ALARM_SYSTEM_SOURCES", al1.getSource().getName());
    //assertEquals("ALARM_SYSTEM_SOURCES2",al1.getSource().getName());
    assertEquals("http://www.test2.com", al1.getHelpURL().toString());
    assertEquals("em2", al1.getPiquetEmail());
    assertEquals("gsm2", al1.getPiquetGSM());
    assertEquals("cont2", al1.getResponsiblePerson().getFamilyName());
    assertEquals(0, al1.getPriority().intValue());
    assertEquals("action1", al1.getAction());
    assertEquals("cause1", al1.getCause());
    assertEquals("conseq1", al1.getConsequence());
    assertEquals("problem1", al1.getProblemDescription());
    l = al1.getLocation();
    //assertEquals("b2",l.getBuilding());
    assertEquals("f2", l.getFloor());
    assertEquals("m2", l.getMnemonic());
    assertEquals("p2", l.getPosition());
    assertEquals("r2", l.getRoom());
    //Update FM Information
    fm.setName("fmTest2");
    lc.setBuilding("b3");
    lc.setFloor("f3");
    lc.setMnemonic("m3");
    lc.setPosition("p3");
    lc.setRoom("r3");
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest2:1");
    assertNotNull(al1);
    //assertEquals("ALARM_SYSTEM_SOURCES2",al1.getSource().getName());
    assertEquals("ALARM_SYSTEM_SOURCES", al1.getSource().getName());
    assertEquals("http://www.test2.com", al1.getHelpURL().toString());
    assertEquals("em2", al1.getPiquetEmail());
    assertEquals("gsm2", al1.getPiquetGSM());
    assertEquals("cont2", al1.getResponsiblePerson().getFamilyName());
    assertEquals(0, al1.getPriority().intValue());
    assertEquals("action1", al1.getAction());
    assertEquals("cause1", al1.getCause());
    assertEquals("conseq1", al1.getConsequence());
    assertEquals("problem1", al1.getProblemDescription());
    l = al1.getLocation();
    //assertEquals("b3",l.getBuilding());
    assertEquals("f3", l.getFloor());
    assertEquals("m3", l.getMnemonic());
    assertEquals("p3", l.getPosition());
    assertEquals("r3", l.getRoom());
    //Update FC Information
    fc.setValue(2);
    fc.setPriority(1);
    fc.setAction("action2");
    fc.setCause("cause2");
    fc.setConsequence("conseq2");
    fc.setProblemDescription("problem2");
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest2:2");
    assertNotNull(al1);
    //assertEquals("ALARM_SYSTEM_SOURCES2",al1.getSource().getName());
    assertEquals("ALARM_SYSTEM_SOURCES", al1.getSource().getName());
    assertEquals("http://www.test2.com", al1.getHelpURL().toString());
    assertEquals("em2", al1.getPiquetEmail());
    assertEquals("gsm2", al1.getPiquetGSM());
    assertEquals("cont2", al1.getResponsiblePerson().getFamilyName());
    assertEquals(1, al1.getPriority().intValue());
    assertEquals("action2", al1.getAction());
    assertEquals("cause2", al1.getCause());
    assertEquals("conseq2", al1.getConsequence());
    assertEquals("problem2", al1.getProblemDescription());
    l = al1.getLocation();
    //assertEquals("b3",l.getBuilding());
    assertEquals("f3", l.getFloor());
    assertEquals("m3", l.getMnemonic());
    assertEquals("p3", l.getPosition());
    assertEquals("r3", l.getRoom());
    //Update Add FM
    FaultMember fm2 = new FaultMember();
    fm2.setName("fmTest3");
    Location lc2 = new Location();
    lc2.setBuilding("b4");
    lc2.setFloor("f4");
    lc2.setMnemonic("m4");
    lc2.setPosition("p4");
    lc2.setRoom("r4");
    fm2.setLocation(lc2);
    ff.addFaultMember(fm2);
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:2");
    assertNotNull(al1);
    //assertEquals("ALARM_SYSTEM_SOURCES2",al1.getSource().getName());
    assertEquals("ALARM_SYSTEM_SOURCES", al1.getSource().getName());
    assertEquals("http://www.test2.com", al1.getHelpURL().toString());
    assertEquals("em2", al1.getPiquetEmail());
    assertEquals("gsm2", al1.getPiquetGSM());
    assertEquals("cont2", al1.getResponsiblePerson().getFamilyName());
    assertEquals(1, al1.getPriority().intValue());
    assertEquals("action2", al1.getAction());
    assertEquals("cause2", al1.getCause());
    assertEquals("conseq2", al1.getConsequence());
    assertEquals("problem2", al1.getProblemDescription());
    l = al1.getLocation();
    //assertEquals("b4",l.getBuilding());
    assertEquals("f4", l.getFloor());
    assertEquals("m4", l.getMnemonic());
    assertEquals("p4", l.getPosition());
    assertEquals("r4", l.getRoom());
    //Update Add FC
    FaultCode fc2 = new FaultCode();
    fc2.setValue(3);
    fc2.setPriority(2);
    fc2.setAction("action3");
    fc2.setCause("cause3");
    fc2.setConsequence("conseq3");
    fc2.setProblemDescription("problem3");
    ff.addFaultCode(fc2);
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:3");
    assertNotNull(al1);
    //assertEquals("ALARM_SYSTEM_SOURCES2",al1.getSource().getName());
    assertEquals("ALARM_SYSTEM_SOURCES", al1.getSource().getName());
    assertEquals("http://www.test2.com", al1.getHelpURL().toString());
    assertEquals("em2", al1.getPiquetEmail());
    assertEquals("gsm2", al1.getPiquetGSM());
    assertEquals("cont2", al1.getResponsiblePerson().getFamilyName());
    assertEquals(2, al1.getPriority().intValue());
    assertEquals("action3", al1.getAction());
    assertEquals("cause3", al1.getCause());
    assertEquals("conseq3", al1.getConsequence());
    assertEquals("problem3", al1.getProblemDescription());
    l = al1.getLocation();
    //assertEquals("b4",l.getBuilding());
    assertEquals("f4", l.getFloor());
    assertEquals("m4", l.getMnemonic());
    assertEquals("p4", l.getPosition());
    assertEquals("r4", l.getRoom());
    //Update Remove FM
    ff.removeFaultMember(fm);
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest2:2");
    assertNull(al1);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest2:3");
    assertNull(al1);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:2");
    assertNotNull(al1);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:3");
    assertNotNull(al1);
    //Update Remove FC
    ff.removeFaultCode(fc);
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:2");
    assertNull(al1);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:3");
    assertNotNull(al1);
    //Update Add Default FM
    FaultMemberDefault fmd = new FaultMemberDefault();
    lc = new Location();
    lc.setBuilding("b1");
    lc.setFloor("f1");
    lc.setMnemonic("m1");
    lc.setPosition("p1");
    lc.setRoom("r1");
    fmd.setLocation(lc);
    ff.setFaultMemberDefault(fmd);
    exception = false;
    try {
        _alarmDAO.updateFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:any:3");
    assertNotNull(al1);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:3");
    assertNotNull(al1);
//Update Remove Default FM
//ff.removeFaultMemberDefault(); Missing method?
/*
		exception = false;
		try{
			_alarmDAO.updateFaultFamily(ff);
		}catch(Exception e){
			exception = true;
		}
		assertFalse(exception);
		al1 = _alarmDAO.getAlarm("ffTest1:any:3");
		assertNull(al1);
		al1 = _alarmDAO.getAlarm("ffTest1:fmTest3:3");
		assertNotNull(al1);
		*/
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarm(cern.laser.business.data.Alarm) Contact(alma.acs.alarmsystem.generated.Contact) Location(alma.acs.alarmsystem.generated.Location) FaultMemberDefault(alma.acs.alarmsystem.generated.FaultMemberDefault)

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