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);
}
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);
}
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());
}
}
}
}
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);
}
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);
}
Aggregations