Search in sources :

Example 1 with Alarm

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

the class ConfigurationImpl method buildCommentedAlarmMap.

//
// -- PROTECTED METHODS -------------------------------------------
//
//
// -- PRIVATE METHODS ---------------------------------------------
//
private CommentedAlarmMap buildCommentedAlarmMap(Collection commentedAlarmRefs, boolean removeChanged) throws Exception {
    CommentedAlarmMap result = new CommentedAlarmMap();
    if ((commentedAlarmRefs == null) || (commentedAlarmRefs.size() == 0)) {
        return result;
    }
    Iterator iterator = commentedAlarmRefs.iterator();
    while (iterator.hasNext()) {
        CommentedAlarmRef ref = (CommentedAlarmRef) iterator.next();
        Alarm alarm = AlarmBrowsingHandler.get(orb, logger).getAlarmById(ref.getAlarmId());
        if ((!removeChanged) || (removeChanged && alarm.getStatus().getSourceTimestamp().equals(ref.getSourceTimestamp()))) {
            result.put(new CommentedAlarm(alarm, ref.getComment()));
        }
    }
    return result;
}
Also used : CommentedAlarmMap(cern.laser.console.CommentedAlarmMap) CommentedAlarm(cern.laser.console.CommentedAlarm) Alarm(cern.laser.client.data.Alarm) Iterator(java.util.Iterator) CommentedAlarm(cern.laser.console.CommentedAlarm)

Example 2 with Alarm

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

the class AlarmTable method changeSelection.

/**
	 * Override {@link JTable#changeSelection(int, int, boolean, boolean)} to show
	 * the selected alarm in the detail panel.
	 */
@Override
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
    super.changeSelection(rowIndex, columnIndex, toggle, extend);
    int idx = sorter.convertRowIndexToModel(rowIndex);
    AlarmTableEntry alarmEntry = model.getAlarmAt(idx);
    panel.showAlarmDetails(alarmEntry);
    selectedAlarmId = alarmEntry.getAlarmId();
    // to avoid concurrency issues
    AlarmSelectionListener listenerCopy = listener;
    if (listenerCopy != null) {
        Alarm alarm = alarmEntry.getEncapsulatedAlarm();
        if (alarm != null) {
            listenerCopy.notifyAlarmSelected(alarm);
        }
    }
}
Also used : AlarmSelectionListener(alma.acsplugins.alarmsystem.gui.viewcoordination.ViewCoordinator.AlarmSelectionListener) Alarm(cern.laser.client.data.Alarm) Point(java.awt.Point)

Example 3 with Alarm

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

the class AlarmContainerTest method testReplaceAlarm.

/**
	 * Test <code>replaceAlarm()</code>
	 * 
	 * @throws Exception
	 */
public void testReplaceAlarm() throws Exception {
    // Add some alarms
    Vector<Alarm> alarms = new Vector<Alarm>();
    int notReduced = populateContainer(CONTAINER_SIZE / 2, "TEST", alarms, null);
    class EDTReader implements Runnable {

        // The value to check after reading from EDT
        private final int value;

        EDTReader(int val) {
            value = val;
        }

        public void run() {
            assertEquals("Wrong not reduced size", CONTAINER_SIZE / 2, container.size(false));
            assertEquals("Wrong reduced size", value, container.size(true));
        }
    }
    EDTExecutor.instance().executeSync(new EDTReader(notReduced));
    // replace the first alarm with another one changing the
    // active attribute
    Alarm alarmToReplace = alarms.get(0);
    assertNotNull(alarmToReplace);
    Alarm newAlarm = new TestAlarm(alarmToReplace.getAlarmId(), alarmToReplace.isNodeChild(), alarmToReplace.isNodeParent(), !alarmToReplace.getStatus().isActive(), alarmToReplace.getStatus().isMasked(), alarmToReplace.getStatus().isReduced());
    class ReplaceAndCheck implements Runnable {

        private final Alarm newAlarm;

        ReplaceAndCheck(Alarm newAlarm) {
            this.newAlarm = newAlarm;
        }

        public void run() {
            try {
                container.replace(new AlarmTableEntry(newAlarm));
            } catch (Throwable t) {
                System.err.println("Error replacing alarm " + newAlarm.getAlarmId());
                t.printStackTrace();
            }
            AlarmTableEntry entry = container.get(newAlarm.getAlarmId());
            assertEquals(newAlarm.getAlarmId(), entry.getAlarmId());
            assertEquals(newAlarm.getStatus().isActive(), entry.getStatus().isActive());
        }
    }
    EDTExecutor.instance().executeSync(new ReplaceAndCheck(newAlarm));
    // replace the LAST alarm with another one changing the
    // active attribute
    alarmToReplace = alarms.get(alarms.size() - 1);
    assertNotNull(alarmToReplace);
    newAlarm = new TestAlarm(alarmToReplace.getAlarmId(), alarmToReplace.isNodeChild(), alarmToReplace.isNodeParent(), !alarmToReplace.getStatus().isActive(), alarmToReplace.getStatus().isMasked(), alarmToReplace.getStatus().isReduced());
    EDTExecutor.instance().executeSync(new ReplaceAndCheck(newAlarm));
    // replace a middle-list alarm with another one changing the
    // active attribute
    alarmToReplace = alarms.get(alarms.size() / 2);
    assertNotNull(alarmToReplace);
    newAlarm = new TestAlarm(alarmToReplace.getAlarmId(), alarmToReplace.isNodeChild(), alarmToReplace.isNodeParent(), !alarmToReplace.getStatus().isActive(), alarmToReplace.getStatus().isMasked(), alarmToReplace.getStatus().isReduced());
    EDTExecutor.instance().executeSync(new ReplaceAndCheck(newAlarm));
}
Also used : Alarm(cern.laser.client.data.Alarm) AlarmTableEntry(alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry) Vector(java.util.Vector)

Example 4 with Alarm

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

the class AlarmContainerTest method testRemoveInactivAls.

/**
	 * Test the removal of inactive alarms
	 * 
	 * @throws Exception
	 */
public void testRemoveInactivAls() throws Exception {
    final Vector<Alarm> alarms = new Vector<Alarm>();
    int notReduced;
    // Stores for each priority the number of inactive alarms
    final int[] priorities = new int[AlarmGUIType.values().length - 1];
    // The test is done for each AlarmGUIType corresponding to a priority
    for (AlarmGUIType alarmType : AlarmGUIType.values()) {
        // Add some alarms
        alarms.clear();
        assertEquals(0, alarms.size());
        EDTExecutor.instance().executeSync(new Runnable() {

            @Override
            public void run() {
                container.clear();
                assertEquals(0, container.size(false));
            }
        });
        for (int t = 0; t < 4; t++) {
            priorities[t] = 0;
        }
        notReduced = populateContainer(CONTAINER_SIZE / 2, "TEST", alarms, null);
        class EDTReader implements Runnable {

            // The value to check after reading from EDT
            private final int value;

            EDTReader(int val) {
                value = val;
            }

            public void run() {
                assertEquals("Wrong not reduced size", CONTAINER_SIZE / 2, container.size(false));
                assertEquals("Wrong reduced size", value, container.size(true));
            }
        }
        EDTExecutor.instance().executeSync(new EDTReader(notReduced));
        for (Alarm al : alarms) {
            if (!al.getStatus().isActive()) {
                priorities[al.getPriority()]++;
            }
        }
        class Checker implements Runnable {

            private final AlarmGUIType alarmType;

            public Checker(AlarmGUIType alarmType) {
                this.alarmType = alarmType;
            }

            public void run() {
                try {
                    container.removeInactiveAlarms(alarmType);
                } catch (Throwable t) {
                    System.out.println("Error removing inactive alarms for " + alarmType);
                    t.printStackTrace();
                    return;
                }
                if (alarmType != AlarmGUIType.INACTIVE) {
                    assertEquals(alarms.size() - priorities[alarmType.ordinal()], container.size(false));
                } else {
                    int newSize = alarms.size() - priorities[0] - priorities[1] - priorities[2] - priorities[3];
                    assertEquals(newSize, container.size(false));
                }
            }
        }
        EDTExecutor.instance().executeSync(new Checker(alarmType));
    }
}
Also used : AlarmGUIType(alma.acsplugins.alarmsystem.gui.table.AlarmGUIType) Alarm(cern.laser.client.data.Alarm) Vector(java.util.Vector)

Example 5 with Alarm

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

the class SpecialAlarmTest method testSpecialAlarmTest.

public void testSpecialAlarmTest() throws Exception {
    Alarm alarm = new SpecialAlarm(family, member, code, true, action, description, cause, consequences, priority, url, email, props);
    assertEquals(alarm.getTriplet().getFaultFamily(), family);
    assertEquals(alarm.getTriplet().getFaultMember(), member);
    assertEquals(alarm.getTriplet().getFaultCode(), Integer.valueOf(code));
    assertEquals(alarm.getHelpURL().toString(), url);
    assertEquals(alarm.getAction(), action);
    assertEquals(alarm.getCause(), cause);
    assertEquals(alarm.getConsequence(), consequences);
    assertEquals(alarm.getPiquetEmail(), email);
    assertEquals(alarm.getProblemDescription(), description);
    assertEquals(alarm.getPriority(), Integer.valueOf(priority));
    assertEquals(alarm.getStatus().isActive(), true);
    assertEquals(family + ":" + member + ":" + code, alarm.getAlarmId());
    Properties p = alarm.getStatus().getUserProperties();
    assertNotNull(p);
    assertTrue(p.size() == 2);
    String v1 = p.getProperty(prop1Key);
    assertEquals(prop1Val, v1);
    String v2 = p.getProperty(prop2Key);
    assertEquals(prop2Val, v2);
}
Also used : Alarm(cern.laser.client.data.Alarm) SpecialAlarm(alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm) SpecialAlarm(alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm) Properties(java.util.Properties)

Aggregations

Alarm (cern.laser.client.data.Alarm)21 AlarmTableEntry (alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry)4 AlarmClientException (alma.alarmsystem.clients.alarm.AlarmClientException)4 Vector (java.util.Vector)4 SpecialAlarm (alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm)2 CategoryClient (alma.alarmsystem.clients.CategoryClient)2 LaserSelectionException (cern.laser.client.services.selection.LaserSelectionException)2 Properties (java.util.Properties)2 AlarmGUIType (alma.acsplugins.alarmsystem.gui.table.AlarmGUIType)1 AlarmContainerException (alma.acsplugins.alarmsystem.gui.table.AlarmsContainer.AlarmContainerException)1 AlarmSelectionListener (alma.acsplugins.alarmsystem.gui.viewcoordination.ViewCoordinator.AlarmSelectionListener)1 Category (alma.alarmsystem.Category)1 AlarmCategoryClient (alma.alarmsystem.clients.AlarmCategoryClient)1 SourceClient (alma.alarmsystem.clients.SourceClient)1 AlarmFilter (alma.alarmsystem.clients.alarm.AlarmFilter)1 AlarmListenerForTesting (alma.alarmsystem.clients.test.utils.AlarmListenerForTesting)1 AlrmStatListenerForTesting (alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting)1 CernAlarmServiceUtils (alma.alarmsystem.corbaservice.CernAlarmServiceUtils)1 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)1 AlarmImpl (cern.laser.business.data.AlarmImpl)1