Search in sources :

Example 31 with FaultFamily

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

Example 32 with FaultFamily

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

the class AlarmManager method loadFromCDB.

public void loadFromCDB() {
    try {
        _ffList = ((ACSAlarmDAOImpl) _alarmDAO).loadAlarms();
        _objState.clear();
        for (FaultFamily ff : _ffList) _objState.put(ff.getName(), new ObjectState(false));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) MalformedURIException(org.apache.xerces.util.URI.MalformedURIException) ValidationException(org.exolab.castor.xml.ValidationException)

Example 33 with FaultFamily

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

the class AlarmManager method updateFaultMember.

/**
	 * Modifies a Fault Member of a given Fault Family.
	 * @param ff The Fault Family to which belongs the Fault Member to be changed
	 * @param fm The Fault Member to be changed
	 * @param fmi The Fault Member with the new values
	 * @throws NullPointerException If any (or both) of the given Fault Members (or their names)
	 * or the Fault Family (or its name) or both are null
	 * @throws IllegalOperationException If the Fault Family doesn't exists
	 */
public void updateFaultMember(FaultFamily ff, FaultMember fm, FaultMember fmi) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) is null");
    if (fm == null || fm.getName() == null)
        throw new NullPointerException("The Fault Member (or its name) to be changed is null");
    if (fmi == null || fmi.getName() == null)
        throw new NullPointerException("The Fault Member (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(ff.getName()) == 0) {
            for (Iterator<FaultMember> iterator2 = Arrays.asList(fft.getFaultMember()).iterator(); iterator2.hasNext(); ) {
                FaultMember fmt = (FaultMember) iterator2.next();
                if (fmt.getName().compareTo(fmi.getName()) == 0) {
                    if (fm.getName().compareTo(fmi.getName()) == 0)
                        continue;
                    throw new IllegalOperationException("The Fault Member " + fmi.getName() + " already exists");
                }
            }
            for (Iterator<FaultMember> iterator2 = Arrays.asList(fft.getFaultMember()).iterator(); iterator2.hasNext(); ) {
                FaultMember fmt = (FaultMember) iterator2.next();
                if (fmt.getName().compareTo(fm.getName()) == 0) {
                    String name = fm.getName();
                    fmt.setName(fmi.getName());
                    fmt.setLocation(fmi.getLocation());
                    ObjectState os = _objState.get(fft.getName());
                    if (os == null)
                        throw new IllegalOperationException("There is no ObjectState associated with the given Fault Family");
                    os.update();
                    if (name.compareTo(fmi.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 Member " + fm.getName() + " doesn't exists");
        }
    }
    throw new IllegalOperationException("The Fault Family " + ff.getName() + " doesn't exists");
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Example 34 with FaultFamily

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

the class AlarmManager method checkCDB.

public String checkCDB() {
    List<FaultFamily> ffs = _ffList;
    String error = "";
    for (FaultFamily ff : ffs) {
        if (ff.getName() == null || ff.getName().length() == 0)
            error += "Fault Family " + ff.getName() + " doesn't have a name.\n";
        try {
            new URI(ff.getHelpUrl());
        } catch (MalformedURIException e1) {
            error += "Fault Family " + ff.getName() + " has malformed URL.\n";
        }
        if (ff.getContact() == null)
            error += "Fault Family " + ff.getName() + " doesn't define Contact entity.\n";
        if (ff.getContact().getName() == null || ff.getContact().getName().length() == 0)
            error += "Fault Family " + ff.getName() + " doesn't define Contact name.\n";
        if (ff.getAlarmSource().compareTo("ALARM_SYSTEM_SOURCES") != 0)
            error += "Fault Family " + ff.getName() + " has wrong Source defined.\n";
        if (ff.getFaultMemberCount() == 0 && ff.getFaultMemberDefault() == null)
            error += "Fault Family " + ff.getName() + " doesn't define any Fault Member and doesn't have a Default Fault Member.\n";
        FaultMember[] fms = ff.getFaultMember();
        for (FaultMember fm : fms) {
            if (fm.getName() == null || fm.getName().length() == 0)
                error += "Fault Member " + fm.getName() + " defined in Fault Family " + ff.getName() + " doesn't have a name.\n";
        }
        FaultCode[] fcs = ff.getFaultCode();
        for (FaultCode fc : fcs) {
            if (fc.getValue() <= 0)
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " has an invalid value (Must be > 0).\n";
            if (!fc.hasPriority())
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " doesn't define a priority.\n";
            if (fc.getPriority() < 0 || fc.getPriority() > 3)
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " has an invalid a priority (Must be in [0;3]).\n";
            if (fc.getProblemDescription() == null || fc.getProblemDescription().length() == 0)
                error += "Fault Code " + fc.getValue() + " defined in Fault Family " + ff.getName() + " doesn't define a problem description.\n";
        }
    }
    return error;
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultCode(alma.acs.alarmsystem.generated.FaultCode) MalformedURIException(org.apache.xerces.util.URI.MalformedURIException) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) URI(org.apache.xerces.util.URI)

Example 35 with FaultFamily

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

the class AlarmManager method addFaultFamily.

/**
	 * Adds a new Fault Family.
	 * @param ff The Fault Family to be added
	 * @throws NullPointerException If the given Fault Family (or its name)
	 * is null
	 * @throws IllegalOperationException If the Fault Family already exists
	 */
public void addFaultFamily(FaultFamily ff) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) to be added is null");
    for (Iterator<FaultFamily> iterator = _ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = (FaultFamily) iterator.next();
        if (fft.getName().compareTo(ff.getName()) == 0) {
            throw new IllegalOperationException("The Fault Family " + ff.getName() + " already exists");
        }
    }
    _ffList.add(ff);
    ObjectState os = _objState.get(ff.getName());
    if (os == null) {
        os = new ObjectState(true);
        os.create();
        _objState.put(ff.getName(), os);
    } else
        os.update();
    Vector<FaultFamily> ffs = new Vector<FaultFamily>();
    ffs.add(ff);
    ((ACSAlarmDAOImpl) _alarmDAO).generateAlarmsMap(ffs);
}
Also used : FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

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