Search in sources :

Example 11 with Category

use of alma.acs.alarmsystem.generated.Category 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 12 with Category

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

the class CategoryManager method deleteCategory.

/**
	 * Deletes a category. The category to be deleted is checked against the existing
	 * Fault Families in order to preserve the consistency of the application
	 * (i.e., a category cannot be deleted if it currently being used
	 *  by a Fault Family). 
	 * @param c The category to be deleted
	 * @return True if it deletes the given category, false otherwise
	 * @throws NullPointerException If the given category is null
	 * @throws IllegalOperationException If the category is part of a existing Fault Family
	 */
public boolean deleteCategory(Category c) throws NullPointerException, IllegalOperationException {
    if (c == null || c.getPath() == null)
        throw new NullPointerException("The category to be deleted (or its name) is null");
    // Check the category FFs with the existing FFs
    AlarmManager alarmManager = AlarmSystemManager.getInstance().getAlarmManager();
    List<FaultFamily> ffList = alarmManager.getAllAlarms();
    if (c.getAlarms() != null) {
        String[] categoryFFs = c.getAlarms().getFaultFamily();
        for (FaultFamily ff : ffList) for (int i = 0; i != categoryFFs.length; i++) if (categoryFFs[i].compareTo(ff.getName()) == 0)
            throw new IllegalOperationException("The Category can't be removed since it has a FaultFamily assigned");
    }
    for (Iterator<Category> iterator = _categoryList.iterator(); iterator.hasNext(); ) {
        Category ct = (Category) iterator.next();
        if (ct.getPath().compareTo(c.getPath()) == 0) {
            iterator.remove();
            ObjectState os = _objState.get(c.getPath());
            if (os == null)
                throw new IllegalOperationException("There is no ObjectState associated with the given Category");
            os.delete();
            return true;
        }
    }
    return false;
}
Also used : Category(alma.acs.alarmsystem.generated.Category) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 13 with Category

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

the class CategoryManager method loadFromCDB.

public void loadFromCDB() {
    _alarmManager = AlarmSystemManager.getInstance().getAlarmManager();
    try {
        _categoryList = new ArrayList<Category>(Arrays.asList(((ACSCategoryDAOImpl) _categoryDAO).loadCategories()));
        _objState.clear();
        for (Category ctg : _categoryList) _objState.put(ctg.getPath(), new ObjectState(false));
    } catch (Exception e) {
        // The category list is empty
        _categoryList = new ArrayList<Category>();
    }
}
Also used : Category(alma.acs.alarmsystem.generated.Category) ArrayList(java.util.ArrayList) ValidationException(org.exolab.castor.xml.ValidationException)

Example 14 with Category

use of alma.acs.alarmsystem.generated.Category 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)

Example 15 with Category

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

the class AlarmManager method updateFaultFamily.

/**
	 * Modifies a Fault Family.
	 * @param ff The Fault Family to be changed
	 * @param ffi The Fault Family with the new values
	 * @throws NullPointerException If any (or both) of the given Fault Families (or their names)
	 * are null
	 * @throws IllegalOperationException If the Fault Family doesn't exists
	 */
public void updateFaultFamily(FaultFamily ff, FaultFamily ffi) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) to be changed is null");
    if (ffi == null || ffi.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) with the new values is null");
    for (Iterator<FaultFamily> iterator = _ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = (FaultFamily) iterator.next();
        if (fft.getName().compareTo(ffi.getName()) == 0) {
            if (ff.getName().compareTo(ffi.getName()) == 0)
                continue;
            throw new IllegalOperationException("The Fault Family " + ffi.getName() + " already exists");
        }
    }
    for (Iterator<FaultFamily> iterator = _ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = (FaultFamily) iterator.next();
        if (fft.getName().compareTo(ff.getName()) == 0) {
            ObjectState os = _objState.get(ff.getName());
            if (os == null)
                throw new IllegalOperationException("There is no ObjectState associated with the given Fault Family");
            if (ff.getName().compareTo(ffi.getName()) == 0)
                os.update();
            else {
                os.delete();
                os = _objState.get(ffi.getName());
                if (os == null) {
                    os = new ObjectState(true);
                    os.create();
                    _objState.put(ffi.getName(), os);
                } else
                    os.update();
                List<Category> catL = _categoryManager.getAllCategories();
                for (Category c : catL) {
                    Alarms als = c.getAlarms();
                    if (als.removeFaultFamily(ff.getName())) {
                        c.setAlarms(als);
                        als.addFaultFamily(ffi.getName());
                        _categoryManager.updateCategory(c, c);
                    }
                }
            }
            String name = ff.getName();
            fft.setName(ffi.getName());
            fft.setAlarmSource(ffi.getAlarmSource());
            fft.setHelpUrl(ffi.getHelpUrl());
            fft.setContact(ffi.getContact());
            if (name.compareTo(ffi.getName()) != 0) {
                Vector<FaultFamily> ffs = new Vector<FaultFamily>();
                ffs.add(ff);
                ((ACSAlarmDAOImpl) _alarmDAO).removeAlarmsMap(ffs);
                ((ACSAlarmDAOImpl) _alarmDAO).generateAlarmsMap(ffs);
            }
            return;
        }
    }
    throw new IllegalOperationException("The Fault Family " + ff.getName() + " doesn't exists");
}
Also used : Category(alma.acs.alarmsystem.generated.Category) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarms(alma.acs.alarmsystem.generated.Alarms) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Aggregations

Category (alma.acs.alarmsystem.generated.Category)22 Alarms (alma.acs.alarmsystem.generated.Alarms)8 ArrayList (java.util.ArrayList)5 Categories (alma.acs.alarmsystem.generated.Categories)4 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)4 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 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 Point (org.eclipse.swt.graphics.Point)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