Search in sources :

Example 36 with Alarm

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

the class ReductionsView method createMRParentWidgets.

private void createMRParentWidgets() {
    _updateMRParentFF = new Listener() {

        public void handleEvent(Event event) {
            _MRParentFMCombo.removeAll();
            FaultMember[] fml = _alarmManager.getFaultFamily(_MRParentFFCombo.getText()).getFaultMember();
            for (int j = 0; j < fml.length; j++) {
                _MRParentFMCombo.add(fml[j].getName());
            }
            _MRParentFCCombo.removeAll();
            FaultCode[] fcl = _alarmManager.getFaultFamily(_MRParentFFCombo.getText()).getFaultCode();
            for (int j = 0; j < fcl.length; j++) {
                _MRParentFCCombo.add(String.valueOf(fcl[j].getValue()));
            }
            //_MRParentThresholdText.setText("");
            _MRParentErrorMessageLabel.setText("Please choose a Fault Member and a Fault Code.");
        }
    };
    _updateMRParent = new Listener() {

        public void handleEvent(Event event) {
            if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                return;
            NodeType type = (NodeType) _tree.getSelection()[0].getData();
            if (type != NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA)
                return;
            if (_MRParentFMCombo.getText().isEmpty()) {
                _MRParentErrorMessageLabel.setText("Please choose a Fault Member.");
                return;
            }
            if (_MRParentFCCombo.getText().isEmpty()) {
                _MRParentErrorMessageLabel.setText("Please choose a Fault Code.");
                return;
            }
            if (_MRParentThresholdText.getText().isEmpty()) {
                _MRParentErrorMessageLabel.setText("Please set a Threshold value.");
                return;
            }
            int thr;
            try {
                thr = Integer.parseInt(_MRParentThresholdText.getText());
            } catch (NumberFormatException e) {
                _MRParentErrorMessageLabel.setText("Incorrect Threshold. A number is required.");
                return;
            }
            String[] tr = getTriplet(_tree.getSelection()[0].getText());
            ReductionRule mrr = _reductionManager.getMRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
            ReductionRule mrr2 = _reductionManager.getMRParentByTriplet(_MRParentFFCombo.getText(), _MRParentFMCombo.getText(), Integer.parseInt(_MRParentFCCombo.getText()));
            Alarm parent = null;
            Alarm mParent;
            fillMRParentChAlarmList(_MRParentFFCombo.getText(), _MRParentFMCombo.getText(), Integer.parseInt(_MRParentFCCombo.getText()));
            if (mrr == null) {
                _MRParentErrorMessageLabel.setText("There's no Reduction Rule (no children) for the selected Alarm.");
                return;
            } else
                parent = mrr.getParent();
            if (mrr2 == null)
                mParent = _alarmManager.getAlarm(new String(_MRParentFFCombo.getText() + ":" + _MRParentFMCombo.getText() + ":" + _MRParentFCCombo.getText()));
            else {
                mParent = mrr2.getParent();
                if (mrr != mrr2) {
                    ErrorDialog edialog = new ErrorDialog(ReductionsView.this.getViewSite().getShell(), "Reduction Rule Already Exists", "The reduction rule you are trying to create already exists", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", "The reduction rule parent already exists"), IStatus.ERROR);
                    edialog.setBlockOnOpen(true);
                    edialog.open();
                    return;
                }
            }
            if (parent != null) {
                String[] ch = parent.getMultiplicityChildren();
                //Remove all Children from mrr and add them to mrr2.
                try {
                    for (int i = 0; i < ch.length; i++) {
                        Alarm aCh = _alarmManager.getAlarm(ch[i]);
                        if (aCh != null) {
                            if (!_reductionManager.deleteMultiReductionRule(parent, aCh)) {
                                _MRParentErrorMessageLabel.setText("One or more children alarms didn't exist.");
                                continue;
                            }
                            _reductionManager.addMultiReductionRule(mParent, aCh);
                        }
                    }
                    _reductionManager.updateMultiThreshold(mParent, thr);
                } catch (IllegalOperationException e) {
                    _MRParentErrorMessageLabel.setText("The parent alarm didn't exist.");
                }
                _tree.getSelection()[0].setText("<" + mParent.getAlarmId().replace(':', ',') + ">");
                _MRParentErrorMessageLabel.setText("");
            }
            if (mrr != null && mrr.getChildrenCount() < mrr.getThreshold()) {
                _MRParentErrorMessageLabel.setText("You need to have at least threshold (" + mrr.getThreshold() + ") childs for this triplet.");
                return;
            }
            if (tr[0].compareTo(_MRParentFFCombo.getText()) != 0 || tr[1].compareTo(_MRParentFMCombo.getText()) != 0 || tr[2].compareTo(_MRParentFCCombo.getText()) != 0) {
                sortReductionRulesList();
                Triplet t = mParent.getTriplet();
                selectElementFromTree("<" + t.getFaultFamily() + "," + t.getFaultMember() + "," + t.getFaultCode() + ">", false);
            }
        }
    };
    _updateMRParentChFF = new Listener() {

        public void handleEvent(Event event) {
            _MRParentChFMCombo.removeAll();
            _MRParentChFMCombo.add("Any");
            if (_MRParentChFFCombo.getText().compareTo("Any") != 0) {
                FaultMember[] fml = _alarmManager.getFaultFamily(_MRParentChFFCombo.getText()).getFaultMember();
                for (int j = 0; j < fml.length; j++) {
                    _MRParentChFMCombo.add(fml[j].getName());
                }
            }
            _MRParentChFMCombo.select(0);
            _MRParentChFCCombo.removeAll();
            _MRParentChFCCombo.add("Any");
            if (_MRParentChFFCombo.getText().compareTo("Any") != 0) {
                FaultCode[] fcl = _alarmManager.getFaultFamily(_MRParentChFFCombo.getText()).getFaultCode();
                for (int j = 0; j < fcl.length; j++) {
                    _MRParentChFCCombo.add(String.valueOf(fcl[j].getValue()));
                }
            }
            _MRParentChFCCombo.select(0);
            TreeItem[] tmp = _tree.getSelection();
            if (tmp == null || tmp.length == 0)
                return;
            TreeItem item = tmp[0];
            String[] triplet = getTriplet(item.getText());
            fillMRParentChAlarmList(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
        }
    };
    _updateMRParentCh = new Listener() {

        public void handleEvent(Event event) {
            TreeItem[] tmp = _tree.getSelection();
            if (tmp == null || tmp.length == 0)
                return;
            TreeItem item = tmp[0];
            String[] triplet = getTriplet(item.getText());
            fillMRParentChAlarmList(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
        }
    };
    _MRParentGroup = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    _MRParentGroup.setLayout(gl);
    _MRParentGroup.setLayoutData(gd);
    _MRParentFtGroup = new Group(_MRParentGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 2;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFtGroup.setLayout(gl);
    _MRParentFtGroup.setLayoutData(gd);
    _MRParentFtGroup.setText("Primary Alarm");
    _MRParentFFLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentFFLabel.setText("Fault Family:");
    _MRParentFFCombo = new Combo(_MRParentFtGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFFCombo.setLayoutData(gd);
    _MRParentFFCombo.addListener(SWT.Selection, _updateMRParentFF);
    _MRParentFMLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentFMLabel.setText("Fault Member:");
    _MRParentFMCombo = new Combo(_MRParentFtGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFMCombo.setLayoutData(gd);
    _MRParentFMCombo.addListener(SWT.Selection, _updateMRParent);
    _MRParentFCLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentFCLabel.setText("Fault Code:");
    _MRParentFCCombo = new Combo(_MRParentFtGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentFCCombo.setLayoutData(gd);
    _MRParentFCCombo.addListener(SWT.Selection, _updateMRParent);
    _MRParentThresholdLabel = new Label(_MRParentFtGroup, SWT.NONE);
    _MRParentThresholdLabel.setText("Threshold:");
    _MRParentThresholdText = new Text(_MRParentFtGroup, SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentThresholdText.setLayoutData(gd);
    _MRParentThresholdText.addListener(SWT.Modify, _updateMRParent);
    //
    _MRParentChGroup = new Group(_MRParentGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 1;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    _MRParentChGroup.setLayout(gl);
    _MRParentChGroup.setLayoutData(gd);
    _MRParentChGroup.setText("Alarms to Ignore");
    _MRParentChFilterGroup = new Group(_MRParentChGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 2;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFilterGroup.setLayout(gl);
    _MRParentChFilterGroup.setLayoutData(gd);
    _MRParentChFilterGroup.setText("Filter Options");
    _MRParentChFilterLevelGroup = new Group(_MRParentChFilterGroup, SWT.SHADOW_ETCHED_IN);
    gl = new GridLayout();
    gl.numColumns = 3;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFilterLevelGroup.setLayout(gl);
    _MRParentChFilterLevelGroup.setLayoutData(gd);
    _MRParentChFilterLevelGroup.setText("Show");
    _MRParentChAllRadio = new Button(_MRParentChFilterLevelGroup, SWT.RADIO);
    _MRParentChAllRadio.setText("All");
    _MRParentChAllRadio.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChSelectedRadio = new Button(_MRParentChFilterLevelGroup, SWT.RADIO);
    _MRParentChSelectedRadio.setText("Selected");
    _MRParentChSelectedRadio.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChUnselectedRadio = new Button(_MRParentChFilterLevelGroup, SWT.RADIO);
    _MRParentChUnselectedRadio.setText("Unselected");
    _MRParentChUnselectedRadio.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChFFLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFFLabel.setText("Fault Family:");
    _MRParentChFFCombo = new Combo(_MRParentChFilterGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFFCombo.setLayoutData(gd);
    _MRParentChFFCombo.addListener(SWT.Selection, _updateMRParentChFF);
    _MRParentChFMLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFMLabel.setText("Fault Member:");
    _MRParentChFMCombo = new Combo(_MRParentChFilterGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFMCombo.setLayoutData(gd);
    _MRParentChFMCombo.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChFCLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFCLabel.setText("Fault Code:");
    _MRParentChFCCombo = new Combo(_MRParentChFilterGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFCCombo.setLayoutData(gd);
    _MRParentChFCCombo.addListener(SWT.Selection, _updateMRParentCh);
    _MRParentChFilterLabel = new Label(_MRParentChFilterGroup, SWT.NONE);
    _MRParentChFilterLabel.setText("Filter RegEx:");
    _MRParentChFilterText = new Text(_MRParentChFilterGroup, SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _MRParentChFilterText.setLayoutData(gd);
    _MRParentChFilterText.addListener(SWT.Modify, _updateMRParentCh);
    _MRParentChAlarmList = new Table(_MRParentChGroup, SWT.BORDER);
    gd = new GridData();
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    _MRParentChAlarmList.setLayoutData(gd);
    _MRParentChAlarmList.addListener(SWT.KeyUp, _addRule);
    _MRParentChAlarmList.addListener(SWT.MouseDoubleClick, _addRule);
    _MRParentErrorMessageLabel = new Label(_MRParentGroup, SWT.NONE);
    _MRParentErrorMessageLabel.setText("");
    _MRParentErrorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    _MRParentErrorMessageLabel.setLayoutData(gd);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Group(org.eclipse.swt.widgets.Group) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) Table(org.eclipse.swt.widgets.Table) TreeItem(org.eclipse.swt.widgets.TreeItem) Triplet(cern.laser.business.data.Triplet) Label(org.eclipse.swt.widgets.Label) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) ReductionRule(cl.utfsm.acs.acg.core.ReductionRule) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) Alarm(cern.laser.business.data.Alarm) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 37 with Alarm

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

the class ACSCategoryDAOImpl method flushCategory.

public void flushCategory() {
    if (conf == null || !conf.isWriteable())
        throw new IllegalStateException("no writable configuration accessor");
    CategoryDefinitions acds = new CategoryDefinitions();
    CategoryDefinitionListType ctc = new CategoryDefinitionListType();
    acds.setCategoriesToCreate(ctc);
    AlarmCategoryDefinitions linksTop = new AlarmCategoryDefinitions();
    AlarmCategoryLinkDefinitionListType cltc = new AlarmCategoryLinkDefinitionListType();
    linksTop.setCategoryLinksToCreate(cltc);
    Iterator<Category> i = catPathToCategory.values().iterator();
    while (i.hasNext()) {
        CategoryDefinition cd = new CategoryDefinition();
        CategoryImpl ci = (CategoryImpl) i.next();
        cd.setDescription(ci.getDescription());
        cd.setPath(ci.getPath());
        ctc.addCategoryDefinition(cd);
        Iterator<?> aidsi = ci.getAlarmIds().iterator();
        while (aidsi.hasNext()) {
            String aid = (String) aidsi.next();
            Alarm a = alarmDao.getAlarm(aid);
            if (a == null)
                throw new RuntimeException("Category has a link to a non-existent alarm");
            AlarmCategoryLinkType link = new AlarmCategoryLinkType();
            alma.alarmsystem.alarmmessage.generated.Alarm linkAlarm = new alma.alarmsystem.alarmmessage.generated.Alarm();
            alma.alarmsystem.alarmmessage.generated.Category linkCat = new alma.alarmsystem.alarmmessage.generated.Category();
            link.setAlarm(linkAlarm);
            link.setCategory(linkCat);
            AlarmDefinition linkAlarmDef = new AlarmDefinition();
            CategoryDefinition linkCatDef = new CategoryDefinition();
            linkAlarm.setAlarmDefinition(linkAlarmDef);
            linkCat.setCategoryDefinition(linkCatDef);
            linkAlarmDef.setFaultCode(a.getTriplet().getFaultCode().intValue());
            linkAlarmDef.setFaultFamily(a.getTriplet().getFaultFamily());
            linkAlarmDef.setFaultMember(a.getTriplet().getFaultMember());
            linkCatDef.setPath(ci.getPath());
            cltc.addAlarmCategoryLink(link);
        }
    }
    StringWriter catList = new StringWriter();
    try {
        acds.marshal(catList);
    } catch (Exception e) {
        throw new RuntimeException("Failed to encode categories", e);
    }
    StringWriter linkList = new StringWriter();
    try {
        acds.marshal(linkList);
    } catch (Exception e) {
        throw new RuntimeException("Failed to encode link", e);
    }
    try {
        conf.setConfiguration(CATEGORY_DEFINITION_PATH, catList.toString());
        conf.setConfiguration(ALARM_CATEGORY_DEFINITION_PATH, linkList.toString());
    } catch (Exception e) {
        throw new RuntimeException("Failed to store configuration", e);
    }
}
Also used : Category(cern.laser.business.data.Category) AlarmDefinition(alma.alarmsystem.alarmmessage.generated.AlarmDefinition) AlarmCategoryLinkType(alma.alarmsystem.alarmmessage.generated.AlarmCategoryLinkType) CategoryDefinitions(alma.alarmsystem.alarmmessage.generated.CategoryDefinitions) AlarmCategoryDefinitions(alma.alarmsystem.alarmmessage.generated.AlarmCategoryDefinitions) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) CategoryImpl(cern.laser.business.data.CategoryImpl) StringWriter(java.io.StringWriter) Alarm(cern.laser.business.data.Alarm) AlarmCategoryLinkDefinitionListType(alma.alarmsystem.alarmmessage.generated.AlarmCategoryLinkDefinitionListType) CategoryDefinitionListType(alma.alarmsystem.alarmmessage.generated.CategoryDefinitionListType) AlarmCategoryDefinitions(alma.alarmsystem.alarmmessage.generated.AlarmCategoryDefinitions) CategoryDefinition(alma.alarmsystem.alarmmessage.generated.CategoryDefinition)

Example 38 with Alarm

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

the class ACSCategoryDAOImpl method linkWithAlarms.

public void linkWithAlarms() {
    if (conf == null)
        throw new IllegalStateException("null configuration accessor");
    if (alarmDao == null)
        throw new IllegalStateException("missing alarm DAO");
    String path = ALARM_CATEGORY_DEFINITION_PATH;
    String xml;
    try {
        xml = conf.getConfiguration(path);
    } catch (Exception e) {
        throw new RuntimeException("Failed to read " + path);
    }
    AlarmCategoryDefinitions acds;
    try {
        acds = (AlarmCategoryDefinitions) AlarmCategoryDefinitions.unmarshalAlarmCategoryDefinitions(new StringReader(xml));
    } catch (Exception e) {
        throw new RuntimeException("Failed to parse " + path);
    }
    AlarmCategoryLinkDefinitionListType cltc = acds.getCategoryLinksToCreate();
    if (cltc == null)
        throw new RuntimeException("Missing category-links-to-create in " + path);
    AlarmCategoryLinkType[] links = cltc.getAlarmCategoryLink();
    for (int a = 0; a < links.length; a++) {
        AlarmCategoryLinkType l = links[a];
        alma.alarmsystem.alarmmessage.generated.Alarm linkAlarm = l.getAlarm();
        alma.alarmsystem.alarmmessage.generated.Category linkCat = l.getCategory();
        if (linkAlarm == null || linkCat == null)
            throw new RuntimeException("Missing alarm or category in a link in " + path);
        AlarmDefinition ad = linkAlarm.getAlarmDefinition();
        CategoryDefinition cd = linkCat.getCategoryDefinition();
        if (ad == null || cd == null)
            throw new RuntimeException("Missing alarm-definition or category-definition in " + path);
        String lff = ad.getFaultFamily();
        String lfm = ad.getFaultMember();
        if (lff == null || lfm == null)
            throw new RuntimeException("Missing fault-family or fault-member in " + path);
        String alarmId = Triplet.toIdentifier(lff, lfm, new Integer(ad.getFaultCode()));
        String catPath = cd.getPath();
        if (catPath == null)
            throw new RuntimeException("Missing category path in " + path);
        Alarm alarm = alarmDao.getAlarm(alarmId);
        Category cat = getCategoryByPath(catPath);
        if (alarm == null)
            throw new RuntimeException("Missing alarm with ID " + alarmId);
        if (cat == null)
            throw new RuntimeException("Missing category with path " + catPath);
        cat.addAlarm(alarm);
    }
    Iterator<Category> i = catPathToCategory.values().iterator();
    while (i.hasNext()) {
        Category ci = i.next();
        String cPath = ci.getPath();
        int lastcolon = cPath.lastIndexOf(':');
        if (lastcolon >= 0) {
            String parentCPath = cPath.substring(0, lastcolon);
            CategoryImpl cp = (CategoryImpl) catPathToCategory.get(parentCPath);
            if (cp != null) {
                cp.addChildCategory(ci);
            }
        }
    }
}
Also used : Category(cern.laser.business.data.Category) AlarmDefinition(alma.alarmsystem.alarmmessage.generated.AlarmDefinition) AlarmCategoryLinkType(alma.alarmsystem.alarmmessage.generated.AlarmCategoryLinkType) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) CategoryImpl(cern.laser.business.data.CategoryImpl) Alarm(cern.laser.business.data.Alarm) StringReader(java.io.StringReader) AlarmCategoryLinkDefinitionListType(alma.alarmsystem.alarmmessage.generated.AlarmCategoryLinkDefinitionListType) AlarmCategoryDefinitions(alma.alarmsystem.alarmmessage.generated.AlarmCategoryDefinitions) CategoryDefinition(alma.alarmsystem.alarmmessage.generated.CategoryDefinition)

Example 39 with Alarm

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

the class ACSSourceDAOImpl method getAlarms.

public String[] getAlarms(String sourceId) {
    if (alarmDAO == null) {
        throw new IllegalStateException("alarmDAO not set");
    }
    if (!(alarmDAO instanceof ACSAlarmDAOImpl))
        throw new UnsupportedOperationException();
    String[] aids = ((ACSAlarmDAOImpl) alarmDAO).getAllAlarmIDs();
    ArrayList result = new ArrayList();
    for (int a = 0; a < aids.length; a++) {
        Alarm al = alarmDAO.getAlarm(aids[a]);
        if (al.getSource().getSourceId().equals(sourceId))
            result.add(aids[a]);
    }
    String[] rids = new String[result.size()];
    result.toArray(rids);
    return rids;
}
Also used : Alarm(cern.laser.business.data.Alarm) ArrayList(java.util.ArrayList)

Example 40 with Alarm

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

the class TestAlarmDAO method testFindAlarm.

/**
	 * Find alarm is like getAlarm but throws an exception
	 * if the alarm is not found
	 * 
	 * @throws Exception
	 */
public void testFindAlarm() throws Exception {
    // Get an alarm that exist
    Alarm alarm = alarmDAO.findAlarm(AlarmTriplets.TEST_TM2_1.ID);
    assertNotNull(alarm);
    assertEquals(AlarmTriplets.TEST_TM2_1.ID, alarm.getAlarmId());
    // Get an unknown alarm ==> thorws an exception
    Alarm alarm2 = null;
    try {
        alarm2 = alarmDAO.findAlarm("A:b:1");
        // Should not be executed
        alarm2 = alarm;
    } catch (Exception e) {
    // Ok
    }
    assertNull(alarm2);
}
Also used : Alarm(cern.laser.business.data.Alarm)

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