Search in sources :

Example 36 with FaultFamily

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

the class ACSAlarmDAOImpl method updateFaultFamily.

public void updateFaultFamily(FaultFamily ff) {
    if (conf == null || !conf.isWriteable())
        throw new IllegalStateException("no writable configuration accessor");
    if (ff == null)
        throw new IllegalArgumentException("Null FaultFamily argument");
    StringWriter FFWriter = new StringWriter();
    Marshaller FF_marshaller;
    try {
        FF_marshaller = new Marshaller(FFWriter);
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    FF_marshaller.setValidation(false);
    try {
        FF_marshaller.marshal(ff);
    } catch (MarshalException e) {
        e.printStackTrace();
        return;
    } catch (ValidationException e) {
        e.printStackTrace();
        return;
    }
    String path = ALARM_DEFINITION_PATH + "/" + ff.getName();
    try {
        try {
            conf.getConfiguration(path);
            conf.deleteConfiguration(path);
        } catch (CDBRecordDoesNotExistEx e) {
            //Record does not exist, so we skip removing it.
            throw new IllegalStateException("FaultFamily doesn't exist");
        }
        conf.addConfiguration(path, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
    } catch (IllegalStateException e) {
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    Vector<FaultFamily> ffs = new Vector<FaultFamily>();
    ffs.add(ff);
    removeAlarmsMap(ffs);
    generateAlarmsMap(ffs);
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) IOException(java.io.IOException) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) PatternSyntaxException(java.util.regex.PatternSyntaxException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx) StringWriter(java.io.StringWriter) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector)

Example 37 with FaultFamily

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

the class ACSAlarmDAOImpl method addFaultFamily.

public void addFaultFamily(FaultFamily ff) {
    if (conf == null || !conf.isWriteable())
        throw new IllegalStateException("no writable configuration accessor");
    if (ff == null)
        throw new IllegalArgumentException("Null FaultFamily argument");
    StringWriter FFWriter = new StringWriter();
    Marshaller FF_marshaller;
    try {
        FF_marshaller = new Marshaller(FFWriter);
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    FF_marshaller.setValidation(false);
    try {
        FF_marshaller.marshal(ff);
    } catch (MarshalException e) {
        e.printStackTrace();
        return;
    } catch (ValidationException e) {
        e.printStackTrace();
        return;
    }
    String path = ALARM_DEFINITION_PATH + "/" + ff.getName();
    try {
        conf.addConfiguration(path, FFWriter.toString().replaceFirst("xsi:type=\".*\"", ""));
    } catch (Exception e) {
        throw new IllegalStateException("FaultFamily already exists");
    }
    Vector<FaultFamily> ffs = new Vector<FaultFamily>();
    ffs.add(ff);
    generateAlarmsMap(ffs);
}
Also used : Marshaller(org.exolab.castor.xml.Marshaller) MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) StringWriter(java.io.StringWriter) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) IOException(java.io.IOException) Vector(java.util.Vector) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) PatternSyntaxException(java.util.regex.PatternSyntaxException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 38 with FaultFamily

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

the class ReductionsView method createViewWidgets.

private void createViewWidgets(Composite parent) {
    _addElement = new Listener() {

        public void handleEvent(Event event) {
            TreeItem sel = null;
            TreeItem item = null;
            if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                return;
            sel = _tree.getSelection()[0];
            NodeType type = (NodeType) sel.getData();
            item = sel;
            if (type == NodeType.NODE_REDUCTION_PARENT_DATA || type == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA)
                item = sel.getParentItem();
            type = (NodeType) item.getData();
            java.util.List<FaultFamily> ffs = _alarmManager.getAllAlarms();
            java.util.List<String> ffnames = new ArrayList<String>();
            for (FaultFamily ff : ffs) {
                if (ff.getFaultCodeCount() > 0 && ff.getFaultMemberCount() > 0)
                    ffnames.add(ff.getName());
            }
            Collections.sort(ffnames, IGNORE_CASE_ORDER);
            ListDialog dialog = new ListDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
            dialog.setTitle("Create Reduction Rule");
            dialog.setMessage("Select Parent Fault Family");
            dialog.setBlockOnOpen(true);
            dialog.setInput(ffnames);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.open();
            if (dialog.getReturnCode() == InputDialog.CANCEL)
                return;
            String ffname = (String) dialog.getResult()[0];
            FaultMember[] fms = _alarmManager.getFaultFamily(ffname).getFaultMember();
            java.util.List<String> fmnames = new ArrayList<String>();
            for (FaultMember fm : fms) {
                fmnames.add(fm.getName());
            }
            Collections.sort(ffnames, IGNORE_CASE_ORDER);
            dialog = new ListDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
            dialog.setTitle("Create Reduction Rule");
            dialog.setMessage("Select Parent Fault Member");
            dialog.setBlockOnOpen(true);
            dialog.setInput(fmnames);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.open();
            if (dialog.getReturnCode() == InputDialog.CANCEL)
                return;
            String fmname = (String) dialog.getResult()[0];
            FaultCode[] fcs = _alarmManager.getFaultFamily(ffname).getFaultCode();
            java.util.List<String> fcvalues = new ArrayList<String>();
            for (FaultCode fc : fcs) {
                fcvalues.add(Integer.toString(fc.getValue()));
            }
            Collections.sort(ffnames, IGNORE_CASE_ORDER);
            dialog = new ListDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
            dialog.setTitle("Create Reduction Rule");
            dialog.setMessage("Select Parent Fault Code");
            dialog.setBlockOnOpen(true);
            dialog.setInput(fcvalues);
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setLabelProvider(new LabelProvider());
            dialog.open();
            if (dialog.getReturnCode() == InputDialog.CANCEL)
                return;
            String fcvalue = (String) dialog.getResult()[0];
            ReductionRule parent = null;
            boolean error = false;
            if (type == NodeType.NODE_REDUCTION) {
                parent = _reductionManager.getNRParentByTriplet(ffname, fmname, Integer.parseInt(fcvalue));
                TreeItem[] chs = _tree.getItems()[0].getItems();
                for (TreeItem ch : chs) {
                    if (ch.getText().compareTo("<" + ffname + "," + fmname + "," + fcvalue + ">") == 0)
                        error = true;
                }
            } else if (type == NodeType.MULTIPLICITY_REDUCTION) {
                parent = _reductionManager.getMRParentByTriplet(ffname, fmname, Integer.parseInt(fcvalue));
                TreeItem[] chs = _tree.getItems()[1].getItems();
                for (TreeItem ch : chs) {
                    if (ch.getText().compareTo("<" + ffname + "," + fmname + "," + fcvalue + ">") == 0)
                        error = true;
                }
            }
            if (error || parent != null) {
                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;
            } else
                parent = new ReductionRule(_alarmManager.getAlarm(ffname + ":" + fmname + ":" + fcvalue));
            TreeItem pTree = new TreeItem(item, SWT.NONE);
            pTree.setText("<" + ffname + "," + fmname + "," + fcvalue + ">");
            if (type == NodeType.NODE_REDUCTION) {
                pTree.setData(NodeType.NODE_REDUCTION_PARENT_DATA);
                parent.setIsNodeReduction(true);
            } else if (type == NodeType.MULTIPLICITY_REDUCTION) {
                pTree.setData(NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA);
                parent.setIsNodeReduction(false);
            }
            _tree.setSelection(pTree);
            Event e = new Event();
            _tree.notifyListeners(SWT.Selection, e);
        }
    };
    _addRule = new Listener() {

        public void handleEvent(Event event) {
            Table t = (Table) event.widget;
            if (event.type == SWT.KeyUp)
                if (!(event.keyCode == SWT.CR || event.keyCode == ' '))
                    return;
            if (event.type == SWT.MouseDoubleClick) {
                Point pt = new Point(event.x, event.y);
                if (t.getItem(pt) == null)
                    return;
            }
            boolean isNode;
            if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                return;
            TreeItem tmp1 = _tree.getSelection()[0];
            if ((NodeType) _tree.getSelection()[0].getData() == NodeType.NODE_REDUCTION_PARENT_DATA)
                isNode = true;
            else if ((NodeType) _tree.getSelection()[0].getData() == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA)
                isNode = false;
            else
                return;
            String[] tr = getTriplet(tmp1.getText());
            ReductionRule parent;
            if (isNode)
                parent = _reductionManager.getNRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
            else
                parent = _reductionManager.getMRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
            if (t.getSelection() == null || t.getSelection().length == 0)
                return;
            TableItem item = t.getSelection()[0];
            Alarm p, c;
            if (parent == null) {
                if (isNode)
                    p = _alarmManager.getAlarm(_NRParentFFCombo.getText() + ":" + _NRParentFMCombo.getText() + ":" + _NRParentFCCombo.getText());
                else
                    p = _alarmManager.getAlarm(_MRParentFFCombo.getText() + ":" + _MRParentFMCombo.getText() + ":" + _MRParentFCCombo.getText());
                if (p == null) {
                    if (isNode)
                        _NRParentErrorMessageLabel.setText("Couldn't find parent alarm.");
                    else
                        _MRParentErrorMessageLabel.setText("Couldn't find parent alarm.");
                    return;
                }
                c = null;
            } else {
                p = parent.getParent();
                c = parent.getChild(item.getText());
            }
            if (c == null) {
                //Add child
                c = _alarmManager.getAlarm(item.getText());
                if (c == null) {
                    if (isNode)
                        _NRParentErrorMessageLabel.setText("Couldn't find child alarm.");
                    else
                        _MRParentErrorMessageLabel.setText("Couldn't find child alarm.");
                    return;
                }
                try {
                    if (isNode)
                        _reductionManager.addNodeReductionRule(p, c);
                    else {
                        _reductionManager.addMultiReductionRule(p, c);
                        if (parent == null)
                            _reductionManager.updateMultiThreshold(p, Integer.parseInt(_MRParentThresholdText.getText()));
                    }
                    item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
                    if (parent == null)
                        _tree.getSelection()[0].setText("<" + p.getAlarmId().replace(':', ',') + ">");
                    if (isNode)
                        _NRParentErrorMessageLabel.setText("");
                    else
                        _MRParentErrorMessageLabel.setText("");
                } catch (IllegalOperationException e) {
                    if (isNode)
                        _NRParentErrorMessageLabel.setText(e.getMessage());
                    else
                        _MRParentErrorMessageLabel.setText(e.getMessage());
                }
            } else {
                //Remove child
                try {
                    //ReductionRule rr;
                    if (isNode) {
                        _reductionManager.deleteNodeReductionRule(p, c);
                    //rr = _reductionManager.getNRParentByTriplet(p.getTriplet().getFaultFamily(), p.getTriplet().getFaultMember(), p.getTriplet().getFaultCode());
                    } else {
                        _reductionManager.deleteMultiReductionRule(p, c);
                    //rr = _reductionManager.getMRParentByTriplet(p.getTriplet().getFaultFamily(), p.getTriplet().getFaultMember(), p.getTriplet().getFaultCode());
                    }
                } catch (IllegalOperationException e) {
                    e.printStackTrace();
                }
                item.setImage((org.eclipse.swt.graphics.Image) null);
            }
            fillMRParentChAlarmList(tr[0], tr[1], Integer.parseInt(tr[2]));
            sortReductionRulesList();
            Triplet t2 = p.getTriplet();
            if (isNode)
                selectElementFromTree("<" + t2.getFaultFamily() + "," + t2.getFaultMember() + "," + t2.getFaultCode() + ">", true);
            else
                selectElementFromTree("<" + t2.getFaultFamily() + "," + t2.getFaultMember() + "," + t2.getFaultCode() + ">", false);
        }
    };
    _removeElement = new Listener() {

        public void handleEvent(Event event) {
            boolean choice = MessageDialog.openQuestion(ReductionsView.this.getViewSite().getShell(), "Confirmation", "Are you sure you want to delete this element");
            if (choice == true) {
                TreeItem sel = null;
                if (_tree.getSelection() == null || _tree.getSelection().length == 0)
                    return;
                NodeType type = (NodeType) _tree.getSelection()[0].getData();
                if (type == NodeType.NODE_REDUCTION || type == NodeType.MULTIPLICITY_REDUCTION)
                    return;
                TreeItem item = _tree.getSelection()[0];
                String[] tr = getTriplet(item.getText());
                try {
                    if (type == NodeType.NODE_REDUCTION_PARENT_DATA) {
                        //Remove all the NODE REDUCTION Rules in which this node is parent.
                        ReductionRule rr = _reductionManager.getNRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
                        if (rr != null) {
                            Alarm p = rr.getParent();
                            List<Alarm> chL = rr.getChildren();
                            Alarm[] als = new Alarm[chL.size()];
                            chL.toArray(als);
                            for (int i = 0; i < als.length; i++) _reductionManager.deleteNodeReductionRule(p, als[i]);
                        }
                    } else if (type == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA) {
                        //Remove all the MULTIPLICITY REDUCTION Rules in which this node is a parent.
                        ReductionRule rr = _reductionManager.getMRParentByTriplet(tr[0], tr[1], Integer.parseInt(tr[2]));
                        if (rr != null) {
                            Alarm p = rr.getParent();
                            List<Alarm> chL = rr.getChildren();
                            Alarm[] als = new Alarm[chL.size()];
                            chL.toArray(als);
                            for (int i = 0; i < als.length; i++) _reductionManager.deleteMultiReductionRule(p, als[i]);
                        }
                    }
                } catch (NullPointerException e) {
                    ErrorDialog error = new ErrorDialog(ReductionsView.this.getViewSite().getShell(), "Cannot delete the item", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
                    error.setBlockOnOpen(true);
                    error.open();
                } catch (IllegalOperationException e) {
                    ErrorDialog error = new ErrorDialog(ReductionsView.this.getViewSite().getShell(), "Cannot delete the item", e.getMessage(), new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
                    error.setBlockOnOpen(true);
                    error.open();
                }
                sel = _tree.getSelection()[0].getParentItem();
                _tree.getSelection()[0].dispose();
                _tree.setSelection(sel);
                Event e = new Event();
                _tree.notifyListeners(SWT.Selection, e);
            }
        }
    };
    _sash = new SashForm(parent, SWT.NONE);
    _sash.setLayout(new FillLayout());
    _reductionsComp = new Composite(_sash, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    _reductionsComp.setLayout(layout);
    _treeGroup = new Group(_reductionsComp, SWT.SHADOW_ETCHED_IN);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    _treeGroup.setLayoutData(gd);
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _treeGroup.setLayout(gl);
    _treeGroup.setText("Reduction Rules List");
    _tree = new Tree(_treeGroup, SWT.VIRTUAL | SWT.BORDER);
    gd = new GridData();
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    _tree.setLayoutData(gd);
    Menu treePopUp = new Menu(parent);
    /*
		MenuItem treePopUpDelete = new MenuItem(treePopUp,SWT.PUSH);
		treePopUpDelete.setText("Delete");
		treePopUpDelete.addListener(SWT.Selection, _removeElement);
		MenuItem treePopUpAddRule = new MenuItem(treePopUp,SWT.PUSH);
		treePopUpAddRule.setText("Add Rule");
		treePopUpAddRule.addListener(SWT.Selection, _addElement);
		MenuItem treePopUpAddChildren = new MenuItem(treePopUp,SWT.PUSH);
		treePopUpAddChildren.setText("Add Children");
		//treePopUpAddChildren.addListener(SWT.Selection, _addElement);
		*/
    _tree.setMenu(treePopUp);
    treePopUp.addListener(SWT.Show, new Listener() {

        public void handleEvent(Event e) {
            TreeItem sel = _tree.getSelection()[0];
            NodeType type = (NodeType) sel.getData();
            Menu treePopUp = _tree.getMenu();
            MenuItem[] items = treePopUp.getItems();
            for (int i = 0; i < items.length; i++) items[i].dispose();
            MenuItem mitem;
            switch(type) {
                case NODE_REDUCTION:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Add Node Reduction Rule Parent");
                    mitem.addListener(SWT.Selection, _addElement);
                    break;
                case NODE_REDUCTION_PARENT_DATA:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Delete Node Reduction Rules for this parent");
                    mitem.addListener(SWT.Selection, _removeElement);
                    break;
                case MULTIPLICITY_REDUCTION:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Add Multiplicity Reduction Rule Parent");
                    mitem.addListener(SWT.Selection, _addElement);
                    break;
                case MULTIPLICITY_REDUCTION_PARENT_DATA:
                    mitem = new MenuItem(treePopUp, SWT.PUSH);
                    mitem.setText("Delete Multiplicity Reduction Rules for this parent");
                    mitem.addListener(SWT.Selection, _removeElement);
                    break;
                default:
                    for (int i = 0; i < items.length; i++) items[i].dispose();
                    break;
            }
        }
    });
    _tree.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            TreeItem[] tmp = ((Tree) e.widget).getSelection();
            if (tmp == null || tmp.length == 0)
                return;
            TreeItem item = tmp[0];
            NodeType type = (NodeType) item.getData();
            Control c = _compInitial.getChildren()[0];
            if (c instanceof Label) {
                c.dispose();
                _compInitial.layout();
                c = _compInitial.getChildren()[0];
            }
            if (type == NodeType.NODE_REDUCTION) {
                _NRParentGroup.setVisible(false);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = true;
                _MRParentGroup.setVisible(false);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = true;
            } else if (type == NodeType.NODE_REDUCTION_PARENT_DATA) {
                _NRParentGroup.setVisible(true);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = false;
                _MRParentGroup.setVisible(false);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = true;
                String[] triplet = getTriplet(item.getText());
                fillNRParentWidgets(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
                _NRParentGroup.moveAbove(c);
                _compInitial.layout();
            } else if (type == NodeType.MULTIPLICITY_REDUCTION) {
                _NRParentGroup.setVisible(false);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = true;
                _MRParentGroup.setVisible(false);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = true;
            } else if (type == NodeType.MULTIPLICITY_REDUCTION_PARENT_DATA) {
                _NRParentGroup.setVisible(false);
                ((GridData) _NRParentGroup.getLayoutData()).exclude = true;
                _MRParentGroup.setVisible(true);
                ((GridData) _MRParentGroup.getLayoutData()).exclude = false;
                String[] triplet = getTriplet(item.getText());
                fillMRParentWidgets(triplet[0], triplet[1], Integer.parseInt(triplet[2]));
                _MRParentGroup.moveAbove(c);
                _compInitial.layout();
            }
        }
    });
    /* Top widget of the right side */
    _compInitial = new Composite(_sash, SWT.NONE);
    _compInitial.setLayout(new GridLayout());
    new Label(_compInitial, SWT.NONE).setText("Select a reduction rule");
    /* NR/MR Details */
    createNRParentWidgets();
    createMRParentWidgets();
    _NRParentGroup.setVisible(false);
    _MRParentGroup.setVisible(false);
    _sash.setWeights(new int[] { 3, 5 });
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) Group(org.eclipse.swt.widgets.Group) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) FaultMember(alma.acs.alarmsystem.generated.FaultMember) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Triplet(cern.laser.business.data.Triplet) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) ReductionRule(cl.utfsm.acs.acg.core.ReductionRule) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarm(cern.laser.business.data.Alarm) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ListDialog(org.eclipse.ui.dialogs.ListDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 39 with FaultFamily

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

the class ReductionsView method fillNRParentWidgets.

private void fillNRParentWidgets(String ff, String fm, int fc) {
    //_updateNRParentFF.setEnabled(false);
    ReductionRule nrr = _reductionManager.getNRParentByTriplet(ff, fm, fc);
    Alarm parent = null;
    // This should happen only when creating a new rule...
    if (nrr == null) {
        parent = _alarmManager.getAlarm(ff + ":" + fm + ":" + fc);
        _NRParentErrorMessageLabel.setText("No Reduction Rule for this triplet.");
    } else
        parent = nrr.getParent();
    _NRParentFFCombo.removeAll();
    _NRParentChFFCombo.removeAll();
    _NRParentChFFCombo.add("Any");
    _NRParentChFFCombo.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)
            _NRParentFFCombo.add(fft.getName());
        _NRParentChFFCombo.add(fft.getName());
        if (parent != null && fft.getName().compareTo(parent.getTriplet().getFaultFamily()) == 0) {
            i = _NRParentFFCombo.getItemCount() - 1;
            ffs = fft;
        }
    }
    _NRParentFFCombo.select(i);
    _NRParentFMCombo.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) {
            _NRParentFMCombo.add(fmt.getName());
            if (fmt.getName().compareTo(parent.getTriplet().getFaultMember()) == 0)
                i = _NRParentFMCombo.getItemCount() - 1;
        }
        _NRParentFMCombo.select(i);
    }
    _NRParentFCCombo.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) {
            _NRParentFCCombo.add(Integer.toString(fct.getValue()));
            if (fct.getValue() == parent.getTriplet().getFaultCode())
                i = _NRParentFCCombo.getItemCount() - 1;
        }
        _NRParentFCCombo.select(i);
    }
    _NRParentChFMCombo.removeAll();
    _NRParentChFMCombo.add("Any");
    _NRParentChFMCombo.select(0);
    _NRParentChFCCombo.removeAll();
    _NRParentChFCCombo.add("Any");
    _NRParentChFCCombo.select(0);
    if (ff.isEmpty() && fm.isEmpty() && fc == 0) {
        if (!_NRParentFFCombo.getText().isEmpty() && !_NRParentFMCombo.getText().isEmpty() && !_NRParentFCCombo.getText().isEmpty())
            fillNRParentChAlarmList(_NRParentFFCombo.getText(), _NRParentFMCombo.getText(), Integer.parseInt(_NRParentFCCombo.getText()));
    } else
        fillNRParentChAlarmList(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)

Example 40 with FaultFamily

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

the class AlarmsView method fillFFWidgets.

private void fillFFWidgets(String name) {
    //_ffNameText.removeListener(SWT.Modify, _updateFaultFamily);
    //_ffHelpURLText.removeListener(SWT.Modify, _updateFaultFamily);
    //_ffContactNameText.removeListener(SWT.Modify, _updateFaultFamily);
    //_ffContactMailText.removeListener(SWT.Modify, _updateFaultFamily);
    //_ffContactGSMText.removeListener(SWT.Modify, _updateFaultFamily);
    //_ffSourceCombo.removeListener(SWT.Modify, _updateFaultFamily);
    //_ffCategoryCombo.removeListener(SWT.Modify, updateFaultFamily);
    FaultFamily ff = _alarmManager.getFaultFamily(name);
    // This should never happen anyways...
    if (ff == null)
        return;
    String helpUrl = "";
    String contactName = "";
    String contactEmail = "";
    String contactGsm = "";
    String source = "";
    if (ff.getHelpUrl() != null)
        helpUrl = ff.getHelpUrl().trim();
    if (ff.getContact() != null) {
        if (ff.getContact().getName() != null)
            contactName = ff.getContact().getName().trim();
        if (ff.getContact().getEmail() != null)
            contactEmail = ff.getContact().getEmail().trim();
        if (ff.getContact().getGsm() != null)
            contactGsm = ff.getContact().getGsm().trim();
    }
    _ffSourceCombo.removeAll();
    if (ff.getAlarmSource() != null)
        source = ff.getAlarmSource();
    sortCategoryList(name);
    Source[] _sourceList = _sourceManager.getAllSources();
    for (int i = 0; i < _sourceList.length; i++) {
        _ffSourceCombo.add(_sourceList[i].getName());
    }
    if (_ffSourceCombo.getItemCount() == 0)
        _ffSourceCombo.add("ALARM_SYSTEM_SOURCES");
    _ffNameText.setText(name);
    _ffHelpURLText.setText(helpUrl);
    _ffContactNameText.setText(contactName);
    _ffContactMailText.setText(contactEmail);
    _ffContactGSMText.setText(contactGsm);
    for (int i = 0; i < _ffSourceCombo.getItemCount(); i++) {
        if (_ffSourceCombo.getItem(i).compareTo(source) == 0)
            _ffSourceCombo.select(i);
    }
//_ffNameText.addListener(SWT.Modify, _updateFaultFamily);
//_ffHelpURLText.addListener(SWT.Modify, _updateFaultFamily);
//_ffContactNameText.addListener(SWT.Modify, _updateFaultFamily);
//_ffContactMailText.addListener(SWT.Modify, _updateFaultFamily);
//_ffContactGSMText.addListener(SWT.Modify, _updateFaultFamily);
//_ffSourceCombo.addListener(SWT.Modify, _updateFaultFamily);
//_ffCategoryCombo.addListener(SWT.Modify, _updateFaultFamily);
}
Also used : FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Source(cern.laser.business.data.Source) Point(org.eclipse.swt.graphics.Point)

Aggregations

FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)47 FaultCode (alma.acs.alarmsystem.generated.FaultCode)19 FaultMember (alma.acs.alarmsystem.generated.FaultMember)19 Vector (java.util.Vector)14 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)11 Contact (alma.acs.alarmsystem.generated.Contact)7 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)7 Point (org.eclipse.swt.graphics.Point)7 Alarm (cern.laser.business.data.Alarm)6 MalformedURLException (java.net.MalformedURLException)6 ArrayList (java.util.ArrayList)5 ValidationException (org.exolab.castor.xml.ValidationException)5 Category (alma.acs.alarmsystem.generated.Category)4 Location (alma.acs.alarmsystem.generated.Location)4 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)4 Source (cern.laser.business.data.Source)4 Alarms (alma.acs.alarmsystem.generated.Alarms)3 Triplet (cern.laser.business.data.Triplet)3 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)3