Search in sources :

Example 6 with FaultMember

use of alma.acs.alarmsystem.generated.FaultMember 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 7 with FaultMember

use of alma.acs.alarmsystem.generated.FaultMember 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 8 with FaultMember

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

the class AlarmManagerTest method testGetFaultMember.

public void testGetFaultMember() {
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ffList = _am.getAllAlarms();
    assertNotNull(ffList);
    for (FaultFamily faultFamily : ffList) {
        FaultMember[] members = faultFamily.getFaultMember();
        assertNotNull(members);
        for (int i = 0; i < members.length; i++) {
            FaultMember member = _am.getFaultMember(faultFamily.getName(), members[i].getName());
            assertNotNull(member);
            assertEquals(member.getName(), members[i].getName());
            if (member.getLocation() != null) {
                assertEquals(member.getLocation().getBuilding(), members[i].getLocation().getBuilding());
                assertEquals(member.getLocation().getFloor(), members[i].getLocation().getFloor());
                assertEquals(member.getLocation().getRoom(), members[i].getLocation().getRoom());
                assertEquals(member.getLocation().getMnemonic(), members[i].getLocation().getMnemonic());
                assertEquals(member.getLocation().getPosition(), members[i].getLocation().getPosition());
            }
        }
    }
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 9 with FaultMember

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

the class AlarmsView method fillFMWidgets.

private void fillFMWidgets(String fmName, String ffName) {
    FaultMember fm = _alarmManager.getFaultMember(ffName, fmName);
    // This should never happen anyways...
    if (fm == null)
        return;
    String name = "";
    String building = "";
    String floor = "";
    String room = "";
    String mnemonic = "";
    String position = "";
    name = fm.getName();
    if (fm.getLocation() != null) {
        if (fm.getLocation().getBuilding() != null)
            building = fm.getLocation().getBuilding().trim();
        if (fm.getLocation().getFloor() != null)
            floor = fm.getLocation().getFloor().trim();
        if (fm.getLocation().getRoom() != null)
            room = fm.getLocation().getRoom().trim();
        if (fm.getLocation().getMnemonic() != null)
            mnemonic = fm.getLocation().getMnemonic().trim();
        if (fm.getLocation().getPosition() != null)
            position = fm.getLocation().getPosition().trim();
    }
    _fmNameText.setText(name);
    _fmLocBuildingText.setText(building);
    _fmLocFloorText.setText(floor);
    _fmLocRoomText.setText(room);
    _fmLocMnemonicText.setText(mnemonic);
    _fmLocPositionText.setText(position);
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember)

Example 10 with FaultMember

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

the class ReductionsView method fillMRParentWidgets.

private void fillMRParentWidgets(String ff, String fm, int fc) {
    ReductionRule mrr = _reductionManager.getMRParentByTriplet(ff, fm, fc);
    Alarm parent = null;
    // This should happen only when creating a new rule...
    if (mrr == null) {
        parent = _alarmManager.getAlarm(ff + ":" + fm + ":" + fc);
        _MRParentErrorMessageLabel.setText("No Reduction Rule for this triplet.");
    } else {
        parent = mrr.getParent();
        if (mrr.getChildrenCount() < mrr.getThreshold())
            _MRParentErrorMessageLabel.setText("You need to have at least threshold (" + mrr.getThreshold() + ") childs for this triplet.");
    }
    _MRParentFFCombo.removeAll();
    _MRParentChFFCombo.removeAll();
    _MRParentChFFCombo.add("Any");
    _MRParentChFFCombo.select(0);
    List<FaultFamily> ffList = _alarmManager.getAllAlarms();
    List<String> tmp = new ArrayList<String>();
    List<FaultFamily> sortedFFList = new ArrayList<FaultFamily>();
    for (FaultFamily tff : ffList) tmp.add(tff.getName());
    Collections.sort(tmp, IGNORE_CASE_ORDER);
    for (String sff : tmp) sortedFFList.add(_alarmManager.getFaultFamily(sff));
    ffList = sortedFFList;
    FaultFamily ffs = null;
    int i = -1;
    for (Iterator<FaultFamily> iterator = ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = iterator.next();
        if (fft.getFaultCodeCount() > 0 && fft.getFaultMemberCount() > 0)
            _MRParentFFCombo.add(fft.getName());
        _MRParentChFFCombo.add(fft.getName());
        if (parent != null && fft.getName().compareTo(parent.getTriplet().getFaultFamily()) == 0) {
            i = _MRParentFFCombo.getItemCount() - 1;
            ffs = fft;
        }
    }
    _MRParentFFCombo.select(i);
    _MRParentFMCombo.removeAll();
    if (ffs != null) {
        i = -1;
        FaultMember[] fml = ffs.getFaultMember();
        List<FaultMember> fmList = Arrays.asList(fml);
        tmp = new ArrayList<String>();
        List<FaultMember> sortedFMList = new ArrayList<FaultMember>();
        for (FaultMember tfm : fmList) tmp.add(tfm.getName());
        Collections.sort(tmp, IGNORE_CASE_ORDER);
        for (String sfm : tmp) for (FaultMember tfm : fmList) if (sfm.compareTo(tfm.getName()) == 0)
            sortedFMList.add(tfm);
        fmList = sortedFMList;
        for (FaultMember fmt : fmList) {
            _MRParentFMCombo.add(fmt.getName());
            if (fmt.getName().compareTo(parent.getTriplet().getFaultMember()) == 0)
                i = _MRParentFMCombo.getItemCount() - 1;
        }
        _MRParentFMCombo.select(i);
    }
    _MRParentFCCombo.removeAll();
    if (ffs != null) {
        i = -1;
        FaultCode[] fcl = ffs.getFaultCode();
        List<FaultCode> fcList = Arrays.asList(fcl);
        tmp = new ArrayList<String>();
        List<FaultCode> sortedFCList = new ArrayList<FaultCode>();
        for (FaultCode tfc : fcList) tmp.add(Integer.toString(tfc.getValue()));
        Collections.sort(tmp);
        for (String sfc : tmp) for (FaultCode tfc : fcList) if (sfc.compareTo(Integer.toString(tfc.getValue())) == 0)
            sortedFCList.add(tfc);
        fcList = sortedFCList;
        for (FaultCode fct : fcList) {
            _MRParentFCCombo.add(Integer.toString(fct.getValue()));
            if (fct.getValue() == parent.getTriplet().getFaultCode())
                i = _MRParentFCCombo.getItemCount() - 1;
        }
        _MRParentFCCombo.select(i);
    }
    _MRParentThresholdText.setText("");
    if (mrr != null)
        _MRParentThresholdText.setText(Integer.toString(mrr.getThreshold()));
    _MRParentChFMCombo.removeAll();
    _MRParentChFMCombo.add("Any");
    _MRParentChFMCombo.select(0);
    _MRParentChFCCombo.removeAll();
    _MRParentChFCCombo.add("Any");
    _MRParentChFCCombo.select(0);
    if (ff.isEmpty() && fm.isEmpty() && fc == 0) {
        if (!_MRParentFFCombo.getText().isEmpty() && !_MRParentFMCombo.getText().isEmpty() && !_MRParentFCCombo.getText().isEmpty())
            fillMRParentChAlarmList(_MRParentFFCombo.getText(), _MRParentFMCombo.getText(), Integer.parseInt(_MRParentFCCombo.getText()));
    } else
        fillMRParentChAlarmList(ff, fm, fc);
//_updateNRParentFF.setEnabled(true);
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultCode(alma.acs.alarmsystem.generated.FaultCode) ArrayList(java.util.ArrayList) ReductionRule(cl.utfsm.acs.acg.core.ReductionRule) Point(org.eclipse.swt.graphics.Point) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarm(cern.laser.business.data.Alarm)

Aggregations

FaultMember (alma.acs.alarmsystem.generated.FaultMember)22 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)19 FaultCode (alma.acs.alarmsystem.generated.FaultCode)12 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)7 Contact (alma.acs.alarmsystem.generated.Contact)6 Alarm (cern.laser.business.data.Alarm)6 Location (alma.acs.alarmsystem.generated.Location)5 ArrayList (java.util.ArrayList)4 Point (org.eclipse.swt.graphics.Point)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 TreeItem (org.eclipse.swt.widgets.TreeItem)3