Search in sources :

Example 1 with Alarms

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

the class ACSCategoryDAOImplTest method testUpdateCategory.

public void testUpdateCategory() {
    //boolean exception;
    Category c1;
    c1 = new Category();
    c1.setPath("Foobar");
    c1.setDescription("Foobar Category2");
    c1.setIsDefault(false);
    Alarms alarms = new Alarms();
    alarms.addFaultFamily("ffTest");
    c1.setAlarms(alarms);
    Categories cats = _categoryDAO.getCategories();
    _categoryDAO.updateCategory(cats, c1);
}
Also used : Category(alma.acs.alarmsystem.generated.Category) Categories(alma.acs.alarmsystem.generated.Categories) Alarms(alma.acs.alarmsystem.generated.Alarms)

Example 2 with Alarms

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

the class ACSCategoryDAOImplTest method testDeleteCategory.

public void testDeleteCategory() {
    //boolean exception;
    Category c1;
    c1 = new Category();
    c1.setPath("Foobar");
    c1.setDescription("Foobar Category2");
    c1.setIsDefault(false);
    Alarms alarms = new Alarms();
    alarms.addFaultFamily("ffTest");
    c1.setAlarms(alarms);
    Categories cats = _categoryDAO.getCategories();
    _categoryDAO.deleteCategory(cats, c1);
}
Also used : Category(alma.acs.alarmsystem.generated.Category) Categories(alma.acs.alarmsystem.generated.Categories) Alarms(alma.acs.alarmsystem.generated.Alarms)

Example 3 with Alarms

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

the class AlarmsView method createFFWidgets.

private void createFFWidgets() {
    _updateFaultFamily = new Listener() {

        public void handleEvent(Event event) {
            TreeItem tmp = _tree.getSelection()[0];
            String ff = tmp.getText();
            FaultFamily fft = new FaultFamily();
            //TODO: Error icon or something similar
            if (_ffNameText.getText().isEmpty()) {
                _ffErrorMessageLabel.setText("FaultFamily Name Missing!");
                return;
            }
            if (_ffNameText.getText().contains(" ")) {
                _ffErrorMessageLabel.setText("Invalid FaultFamily Name. No spaces allowed.");
                return;
            }
            fft.setName(_ffNameText.getText());
            if (!_ffHelpURLText.getText().isEmpty()) {
                URI hurl;
                try {
                    hurl = new URI(_ffHelpURLText.getText());
                } catch (MalformedURIException e1) {
                    _ffErrorMessageLabel.setText("Malformed URL!");
                    return;
                }
                fft.setHelpUrl(hurl.toString());
            }
            fft.setAlarmSource(_ffSourceCombo.getText());
            Contact ct = new Contact();
            if (_ffContactNameText.getText().isEmpty()) {
                _ffErrorMessageLabel.setText("Contact Name Missing!");
                return;
            }
            ct.setName(_ffContactNameText.getText());
            if (!_ffContactMailText.getText().isEmpty())
                ct.setEmail(_ffContactMailText.getText());
            if (!_ffContactGSMText.getText().isEmpty())
                ct.setGsm(_ffContactGSMText.getText());
            fft.setContact(ct);
            _ffErrorMessageLabel.setText("");
            try {
                _alarmManager.updateFaultFamily(_alarmManager.getFaultFamily(ff), fft);
                tmp.setText(_ffNameText.getText());
                IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
                IViewReference[] views = _window.getActivePage().getViewReferences();
                IMyViewPart view = ((IMyViewPart) views[2].getView(false));
                view.fillWidgets();
                if (ff.compareTo(fft.getName()) != 0) {
                    sortFaultFamilyList();
                    selectElementFromTree(fft.getName(), null, null);
                }
            } catch (IllegalOperationException e) {
                _ffErrorMessageLabel.setText(e.getMessage());
            } catch (NullPointerException e) {
                e.printStackTrace();
                _ffErrorMessageLabel.setText(e.getMessage());
            }
        }
    };
    _addCategory = new Listener() {

        public void handleEvent(Event event) {
            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 (_ffCategoryList.getItem(pt) == null)
                    return;
            }
            TreeItem[] tmp1 = _tree.getSelection();
            if (tmp1 == null || tmp1.length == 0)
                return;
            String ff = tmp1[0].getText();
            TableItem[] tmp2 = _ffCategoryList.getSelection();
            if (tmp2 == null || tmp2.length == 0)
                return;
            TableItem item = tmp2[0];
            Category c = _categoryManager.getCategoryByPath(item.getText());
            try {
                String[] ffs = c.getAlarms().getFaultFamily();
                for (int i = 0; i < ffs.length; i++) {
                    if (ff.compareTo(ffs[i]) == 0) {
                        c.getAlarms().removeFaultFamily(ff);
                        item.setImage((org.eclipse.swt.graphics.Image) null);
                        IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
                        IViewReference[] views = _window.getActivePage().getViewReferences();
                        IMyViewPart view = ((IMyViewPart) views[2].getView(false));
                        view.fillWidgets();
                        return;
                    }
                }
                c.getAlarms().addFaultFamily(ff);
                item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
            } catch (NullPointerException e) {
                item.setImage((org.eclipse.swt.graphics.Image) null);
                Alarms alarms = new Alarms();
                alarms.addFaultFamily(ff.toString());
                alarms.setFaultFamily(0, ff.toString());
                c.setAlarms(alarms);
                item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
            }
            IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
            IViewReference[] views = _window.getActivePage().getViewReferences();
            IMyViewPart view = ((IMyViewPart) views[2].getView(false));
            view.fillWidgets();
        }
    };
    _FFgroup = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
    _FFgroup.setText("Fault Family details");
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    _FFgroup.setLayoutData(gd);
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;
    _FFgroup.setLayout(gl);
    _ffNameLabel = new Label(_FFgroup, SWT.NONE);
    _ffNameLabel.setText("Fault Family name");
    _ffNameText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _ffNameText.setLayoutData(gd);
    _ffNameText.addListener(SWT.Modify, _updateFaultFamily);
    _ffHelpURLLabel = new Label(_FFgroup, SWT.NONE);
    _ffHelpURLLabel.setText("Help URL");
    _ffHelpURLText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _ffHelpURLText.setLayoutData(gd);
    _ffHelpURLText.addListener(SWT.Modify, _updateFaultFamily);
    _ffContactNameLabel = new Label(_FFgroup, SWT.NONE);
    _ffContactNameLabel.setText("Contact name");
    _ffContactNameText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _ffContactNameText.setLayoutData(gd);
    _ffContactNameText.addListener(SWT.Modify, _updateFaultFamily);
    _ffContactMailLabel = new Label(_FFgroup, SWT.NONE);
    _ffContactMailLabel.setText("Contact e-mail");
    _ffContactMailText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _ffContactMailText.setLayoutData(gd);
    _ffContactMailText.addListener(SWT.Modify, _updateFaultFamily);
    _ffContactGSMLabel = new Label(_FFgroup, SWT.NONE);
    _ffContactGSMLabel.setText("Contact GSM");
    _ffContactGSMText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _ffContactGSMText.setLayoutData(gd);
    _ffContactGSMText.addListener(SWT.Modify, _updateFaultFamily);
    _ffSourceLabel = new Label(_FFgroup, SWT.NONE);
    _ffSourceLabel.setText("Source");
    _ffSourceCombo = new Combo(_FFgroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    _ffSourceCombo.setLayoutData(gd);
    _ffSourceCombo.setEnabled(false);
    _ffSourceCombo.addListener(SWT.Modify, _updateFaultFamily);
    _ffCategoryLabel = new Label(_FFgroup, SWT.NONE);
    _ffCategoryLabel.setText("Categories:");
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    _ffCategoryLabel.setLayoutData(gd);
    _ffCategoryList = new Table(_FFgroup, SWT.BORDER);
    gd = new GridData();
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    _ffCategoryList.setLayoutData(gd);
    _ffCategoryList.addListener(SWT.KeyUp, _addCategory);
    _ffCategoryList.addListener(SWT.MouseDoubleClick, _addCategory);
    Menu categoryPopUp = new Menu(_ffCategoryList);
    _ffCategoryList.setMenu(categoryPopUp);
    categoryPopUp.addListener(SWT.Show, new Listener() {

        public void handleEvent(Event e) {
            TableItem[] sel = _ffCategoryList.getSelection();
            Menu categoryPopUp = _ffCategoryList.getMenu();
            MenuItem[] items = categoryPopUp.getItems();
            for (int i = 0; i < items.length; i++) items[i].dispose();
            if (sel == null || sel.length == 0)
                return;
            MenuItem mitem;
            mitem = new MenuItem(categoryPopUp, SWT.PUSH);
            if (sel[0].getImage() == null) {
                mitem.setText("Add to Category");
                mitem.addListener(SWT.Selection, _addCategory);
            } else {
                mitem.setText("Remove from Category");
                mitem.addListener(SWT.Selection, _addCategory);
            }
        }
    });
    _ffErrorMessageLabel = new Label(_FFgroup, SWT.NONE);
    _ffErrorMessageLabel.setText("");
    _ffErrorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    _ffErrorMessageLabel.setLayoutData(gd);
}
Also used : Group(org.eclipse.swt.widgets.Group) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) MalformedURIException(org.apache.xerces.util.URI.MalformedURIException) Category(alma.acs.alarmsystem.generated.Category) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) URI(org.apache.xerces.util.URI) GridLayout(org.eclipse.swt.layout.GridLayout) Menu(org.eclipse.swt.widgets.Menu) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Table(org.eclipse.swt.widgets.Table) Alarms(alma.acs.alarmsystem.generated.Alarms) Text(org.eclipse.swt.widgets.Text) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) Contact(alma.acs.alarmsystem.generated.Contact) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 4 with Alarms

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

the class AlarmManager method deleteFaultFamily.

/**
	 * Deletes a Fault Family. The Fault Family to be deleted is checked 
	 * against the existing Reduction Rules in order to preserve the 
	 * consistency of the application (i.e., a Fault Code cannot be 
	 * deleted if it is currently present in a Reduction Rule).
	 * @param ff The Fault Family to be deleted
	 * @return True if it deletes the given Fault Family, false otherwise
	 * @throws NullPointerException If the given Fault Family (or its name)
	 * is null
	 * @throws IllegalOperationException If the Fault Family is part of an 
	 * existing Reduction Rule
	 */
public boolean deleteFaultFamily(FaultFamily ff) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) to be deleted is null");
    //Check Reduction Rules
    List<ReductionRule> rrL = _reductionManager.getNodeReductionRules();
    for (ReductionRule rr : rrL) {
        String[] tr = rr.getParent().getAlarmId().split(":");
        if (tr[0].compareTo(ff.getName()) == 0)
            throw new IllegalOperationException("The Fault Family is currently associated to a Reduction Rule");
    }
    //Check Categories
    List<Category> catL = _categoryManager.getAllCategories();
    for (Category c : catL) {
        String[] sFFL = c.getAlarms().getFaultFamily();
        if (sFFL.length > 1)
            continue;
        for (String sFF : sFFL) {
            if (sFF.compareTo(ff.getName()) == 0)
                throw new IllegalOperationException("There is a category that only has this FaultFamily");
        }
    }
    for (Iterator<FaultFamily> iterator = _ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = (FaultFamily) iterator.next();
        if (fft.getName().compareTo(ff.getName()) == 0) {
            iterator.remove();
            ObjectState os = _objState.get(fft.getName());
            if (os == null)
                throw new IllegalOperationException("There is no ObjectState associated with the given Fault Family");
            os.delete();
            for (Category c : catL) {
                Alarms als = c.getAlarms();
                if (als.removeFaultFamily(ff.getName())) {
                    c.setAlarms(als);
                    _categoryManager.updateCategory(c, c);
                }
            }
            Vector<FaultFamily> ffs = new Vector<FaultFamily>();
            ffs.add(ff);
            ((ACSAlarmDAOImpl) _alarmDAO).removeAlarmsMap(ffs);
            return true;
        }
    }
    return false;
}
Also used : Category(alma.acs.alarmsystem.generated.Category) Alarms(alma.acs.alarmsystem.generated.Alarms) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Example 5 with Alarms

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

the class CategoryManager method checkCDB.

public String checkCDB() {
    String error = "";
    List<Category> cats = _categoryList;
    for (Category c : cats) {
        if (c.getPath() == null || c.getPath().length() == 0)
            error += "Category " + c.getPath() + " doesn't have a path.\n";
        if (!c.hasIsDefault())
            error += "Category " + c.getPath() + " doesn't define isDefault value.\n";
        Alarms als = c.getAlarms();
        if (als != null) {
            String[] ffs = als.getFaultFamily();
            for (String ff : ffs) {
                if (_alarmManager.getFaultFamily(ff) == null)
                    error += "FaultFamily " + ff + " defined in category " + c.getPath() + " doesn't exist.\n";
            }
        }
    }
    return error;
}
Also used : Category(alma.acs.alarmsystem.generated.Category) Alarms(alma.acs.alarmsystem.generated.Alarms)

Aggregations

Alarms (alma.acs.alarmsystem.generated.Alarms)8 Category (alma.acs.alarmsystem.generated.Category)8 Categories (alma.acs.alarmsystem.generated.Categories)3 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)3 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)2 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)2 Vector (java.util.Vector)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Event (org.eclipse.swt.widgets.Event)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Listener (org.eclipse.swt.widgets.Listener)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 Text (org.eclipse.swt.widgets.Text)2 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)2 Contact (alma.acs.alarmsystem.generated.Contact)1