Search in sources :

Example 11 with FaultCode

use of alma.acs.alarmsystem.generated.FaultCode in project ACS by ACS-Community.

the class ACSAlarmDAOImplTest method testRemoveFaultFamily.

public void testRemoveFaultFamily() {
    Alarm al1;
    boolean exception;
    //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.removeFaultFamily(null);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    //Check Remove FF that doesn't exist
    FaultFamily ff = new FaultFamily();
    ff.setName("ffTest1");
    exception = false;
    try {
        _alarmDAO.removeFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    //Check Remove FF
    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);
    try {
        _alarmDAO.removeFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    al1 = _alarmDAO.getAlarm("ffTest1:fmTest1:1");
    assertNull(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) FaultMemberDefault(alma.acs.alarmsystem.generated.FaultMemberDefault) Location(alma.acs.alarmsystem.generated.Location)

Example 12 with FaultCode

use of alma.acs.alarmsystem.generated.FaultCode in project ACS by ACS-Community.

the class AlarmManagerTest method testSaveToCDB.

public void testSaveToCDB() {
    boolean exception;
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ff1 = _am.getAllAlarms();
    assertNotNull(ff1);
    int size1 = ff1.size();
    int size2;
    exception = false;
    FaultFamily ff = new FaultFamily();
    size1 = ff1.size();
    ff.setName("foobar");
    ff.setHelpUrl("http://www.foobar.cl/");
    Contact ct = new Contact();
    ct.setEmail("test@foobar.cl");
    ct.setGsm("da");
    ct.setName("Foobar");
    ff.setContact(ct);
    FaultCode fc = new FaultCode();
    fc.setValue(1);
    fc.setAction("a1");
    fc.setCause("c1");
    fc.setConsequence("co1");
    fc.setPriority(1);
    fc.setProblemDescription("pd1");
    ff.addFaultCode(fc);
    FaultMember fm = new FaultMember();
    fm.setName("fmFoobar");
    Location lc = new Location();
    lc.setBuilding("b1");
    lc.setFloor("f1");
    lc.setMnemonic("m1");
    lc.setPosition("p1");
    lc.setRoom("r1");
    fm.setLocation(lc);
    try {
        _am.addFaultFamily(ff);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.size();
    assertEquals(size1, size2 - 1);
    _am.saveToCDB();
    _am.loadFromCDB();
    FaultFamily fft = _am.getFaultFamily("foobar");
    assertNotNull(fft);
    assertEquals(fft.getName(), ff.getName());
    assertEquals(fft.getHelpUrl(), ff.getHelpUrl());
    exception = false;
    try {
        _am.deleteFaultFamily(fft);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    _am.saveToCDB();
    _am.loadFromCDB();
    fft = _am.getFaultFamily("foobar");
    assertNull(fft);
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Contact(alma.acs.alarmsystem.generated.Contact) Location(alma.acs.alarmsystem.generated.Location)

Example 13 with FaultCode

use of alma.acs.alarmsystem.generated.FaultCode in project ACS by ACS-Community.

the class AlarmManagerTest method testUpdateFaultCode.

public void testUpdateFaultCode() throws Exception {
    boolean exception = false;
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ff1 = _am.getAllAlarms();
    assertNotNull(ff1);
    FaultFamily ff;
    FaultCode fc, fcm;
    int size1;
    int size2;
    ff = new FaultFamily();
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(null, null, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, null, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    ff.setName("foo");
    fc = new FaultCode();
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, fc, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    fcm = new FaultCode();
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, null, fcm);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    ff.setName(ff1.get(0).getName());
    fc.setValue(10342);
    fcm.setValue(10343);
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, fc, fcm);
    } catch (IllegalOperationException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.addFaultCode(ff, fc);
    } catch (IllegalOperationException e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2 - 1);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, fc, fcm);
    } catch (IllegalOperationException e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    assertNotNull(_am.getFaultCode(ff1.get(0).getName(), 10343));
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 14 with FaultCode

use of alma.acs.alarmsystem.generated.FaultCode in project ACS by ACS-Community.

the class CDBSender method readAlarmsFromCDB.

/**
	 * Read alarms from the TM/CDB with the help of {@link ACSAlarmDAOImpl}.
	 * <P>
	 * This method can be quite slow so it would be better to run 
	 * in a dedicated thread.
	 * 
	 * @throws Exception
	 */
private void readAlarmsFromCDB() throws Exception {
    ConfigurationAccessor conf;
    conf = ConfigurationAccessorFactory.getInstance(contSvcs);
    ACSAlarmDAOImpl alarmDAO = new ACSAlarmDAOImpl(contSvcs.getLogger());
    alarmDAO.setConfAccessor(conf);
    List<FaultFamily> FFs = alarmDAO.loadAlarms();
    synchronized (alarms) {
        for (FaultFamily ff : FFs) {
            String faultFamily = ff.getName();
            for (FaultMember fm : ff.getFaultMember()) {
                for (FaultCode fc : ff.getFaultCode()) {
                    alarms.add(new AlarmRead(faultFamily + "," + fm.getName() + "," + fc.getValue(), null));
                }
            }
            // Has this FF a default fault member?
            if (ff.getFaultMemberDefault() != null) {
                System.out.println("Found a default fault member for " + ff.getName());
                for (FaultCode fc : ff.getFaultCode()) {
                    alarms.add(new AlarmRead(faultFamily + ",*," + fc.getValue(), null));
                }
            }
        }
    }
}
Also used : ConfigurationAccessor(com.cosylab.acs.laser.dao.ConfigurationAccessor) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) ACSAlarmDAOImpl(com.cosylab.acs.laser.dao.ACSAlarmDAOImpl)

Example 15 with FaultCode

use of alma.acs.alarmsystem.generated.FaultCode in project ACS by ACS-Community.

the class AlarmManager method checkCDB.

public String checkCDB() {
    List<FaultFamily> ffs = _ffList;
    String error = "";
    for (FaultFamily ff : ffs) {
        if (ff.getName() == null || ff.getName().length() == 0)
            error += "Fault Family " + ff.getName() + " doesn't have a name.\n";
        try {
            new URI(ff.getHelpUrl());
        } catch (MalformedURIException e1) {
            error += "Fault Family " + ff.getName() + " has malformed URL.\n";
        }
        if (ff.getContact() == null)
            error += "Fault Family " + ff.getName() + " doesn't define Contact entity.\n";
        if (ff.getContact().getName() == null || ff.getContact().getName().length() == 0)
            error += "Fault Family " + ff.getName() + " doesn't define Contact name.\n";
        if (ff.getAlarmSource().compareTo("ALARM_SYSTEM_SOURCES") != 0)
            error += "Fault Family " + ff.getName() + " has wrong Source defined.\n";
        if (ff.getFaultMemberCount() == 0 && ff.getFaultMemberDefault() == null)
            error += "Fault Family " + ff.getName() + " doesn't define any Fault Member and doesn't have a Default Fault Member.\n";
        FaultMember[] fms = ff.getFaultMember();
        for (FaultMember fm : fms) {
            if (fm.getName() == null || fm.getName().length() == 0)
                error += "Fault Member " + fm.getName() + " defined in Fault Family " + ff.getName() + " doesn't have a name.\n";
        }
        FaultCode[] fcs = ff.getFaultCode();
        for (FaultCode fc : fcs) {
            if (fc.getValue() <= 0)
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " has an invalid value (Must be > 0).\n";
            if (!fc.hasPriority())
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " doesn't define a priority.\n";
            if (fc.getPriority() < 0 || fc.getPriority() > 3)
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " has an invalid a priority (Must be in [0;3]).\n";
            if (fc.getProblemDescription() == null || fc.getProblemDescription().length() == 0)
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " doesn't define a problem description.\n";
        }
    }
    return error;
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultCode(alma.acs.alarmsystem.generated.FaultCode) MalformedURIException(org.apache.xerces.util.URI.MalformedURIException) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) URI(org.apache.xerces.util.URI)

Aggregations

FaultCode (alma.acs.alarmsystem.generated.FaultCode)22 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)19 FaultMember (alma.acs.alarmsystem.generated.FaultMember)12 Contact (alma.acs.alarmsystem.generated.Contact)6 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)6 Alarm (cern.laser.business.data.Alarm)6 Point (org.eclipse.swt.graphics.Point)5 Location (alma.acs.alarmsystem.generated.Location)4 ArrayList (java.util.ArrayList)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 Triplet (cern.laser.business.data.Triplet)3 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)3 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)3 Vector (java.util.Vector)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Event (org.eclipse.swt.widgets.Event)3