Search in sources :

Example 6 with ACSAlarmDAOImpl

use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl in project ACS by ACS-Community.

the class AlarmManager method addFaultCode.

/**
	 * Adds a new Fault Code to a given Fault Family.
	 * @param ff The Fault Family to which the Fault Code will be added
	 * @param fm The Fault Code to be added
	 * @throws NullPointerException If the given Fault Family (or its name),
	 * the given Fault Code or both are null
	 * @throws IllegalOperationException If the Fault Code already exists
	 * or the Fault Family doesn't exist
	 */
public void addFaultCode(FaultFamily ff, FaultCode fc) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) to which the Fault Code will be added is null");
    if (fc == null)
        throw new NullPointerException("The Fault Code 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) {
            for (Iterator<FaultCode> iterator2 = Arrays.asList(fft.getFaultCode()).iterator(); iterator2.hasNext(); ) {
                FaultCode fct = (FaultCode) iterator2.next();
                if (fct.getValue() == fc.getValue()) {
                    throw new IllegalOperationException("The Fault Code " + fc.getValue() + " already exists");
                }
            }
            fft.addFaultCode(fc);
            ObjectState os = _objState.get(fft.getName());
            if (os == null)
                throw new IllegalOperationException("There is no ObjectState associated with the given Fault Family");
            os.update();
            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 : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Example 7 with ACSAlarmDAOImpl

use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl in project ACS by ACS-Community.

the class AlarmManager method updateFaultCode.

/**
	 * Modifies a Fault Code of a given Fault Family.
	 * @param ff The Fault Family to which belongs the Fault Code to be changed
	 * @param fc The Fault Code to be changed
	 * @param fci The Fault Code with the new values
	 * @throws NullPointerException If any (or both) of the given Fault Codes
	 * or the Fault Family (or its name) or both are null
	 * @throws IllegalOperationException If the Fault Family doesn't exists
	 */
public void updateFaultCode(FaultFamily ff, FaultCode fc, FaultCode fci) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) is null");
    if (fc == null)
        throw new NullPointerException("The Fault Code to be changed is null");
    if (fci == null)
        throw new NullPointerException("The Fault Code 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<FaultCode> iterator2 = Arrays.asList(fft.getFaultCode()).iterator(); iterator2.hasNext(); ) {
                FaultCode fct = (FaultCode) iterator2.next();
                if (fct.getValue() == fci.getValue()) {
                    if (fc.getValue() == fci.getValue())
                        continue;
                    throw new IllegalOperationException("The Fault Code " + fci.getValue() + " already exists");
                }
            }
            for (Iterator<FaultCode> iterator2 = Arrays.asList(fft.getFaultCode()).iterator(); iterator2.hasNext(); ) {
                FaultCode fct = (FaultCode) iterator2.next();
                if (fct.getValue() == fc.getValue()) {
                    int value = fc.getValue();
                    fct.setValue(fci.getValue());
                    fct.setPriority(fci.getPriority());
                    fct.setCause(fci.getCause());
                    fct.setAction(fci.getAction());
                    fct.setConsequence(fci.getConsequence());
                    fct.setProblemDescription(fci.getProblemDescription());
                    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 (value != fci.getValue()) {
                        Vector<FaultFamily> ffs = new Vector<FaultFamily>();
                        ffs.add(ff);
                        ((ACSAlarmDAOImpl) _alarmDAO).removeAlarmsMap(ffs);
                        ((ACSAlarmDAOImpl) _alarmDAO).generateAlarmsMap(ffs);
                    }
                    return;
                }
            }
            throw new IllegalOperationException("The Fault Value " + fc.getValue() + " doesn't exists");
        }
    }
    throw new IllegalOperationException("The Fault Family " + ff.getName() + " doesn't exists");
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Example 8 with ACSAlarmDAOImpl

use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl 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 9 with ACSAlarmDAOImpl

use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl in project ACS by ACS-Community.

the class AlarmManager method deleteFaultCode.

/**
	 * Deletes a Fault Code of a given Fault Family. The Fault Code 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 of the Fault Code to be deleted
	 * @param fc The Fault Code to be deleted
	 * @return True if it deletes the given Fault Code, false otherwise
	 * @throws NullPointerException If the given Fault Family or Fault Code 
	 * is null
	 * @throws IllegalOperationException If the Fault Code is part of an 
	 * existing Reduction Rule
	 */
public boolean deleteFaultCode(FaultFamily ff, FaultCode fc) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) owner of the Fault Code to be deleted is null");
    if (fc == null)
        throw new NullPointerException("The Fault Code to be deleted is null");
    List<ReductionRule> rrL = _reductionManager.getNodeReductionRules();
    for (ReductionRule rr : rrL) {
        String[] tr = rr.getParent().getAlarmId().split(":");
        if (tr[0].compareTo(ff.getName()) == 0 && Integer.parseInt(tr[2]) == fc.getValue())
            throw new IllegalOperationException("The Fault Code is currently associated to a Reduction Rule");
    }
    for (Iterator<FaultFamily> iterator = _ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = (FaultFamily) iterator.next();
        if (fft.getName().compareTo(ff.getName()) == 0) {
            for (Iterator<FaultCode> iterator2 = Arrays.asList(fft.getFaultCode()).iterator(); iterator2.hasNext(); ) {
                FaultCode fct = (FaultCode) iterator2.next();
                if (fct.getValue() == fc.getValue()) {
                    fft.removeFaultCode(fc);
                    ObjectState os = _objState.get(fft.getName());
                    if (os == null)
                        throw new IllegalOperationException("There is no ObjectState associated with the given Fault Family");
                    os.update();
                    Vector<FaultFamily> ffs = new Vector<FaultFamily>();
                    ffs.add(ff);
                    ((ACSAlarmDAOImpl) _alarmDAO).removeAlarmsMap(ffs);
                    ((ACSAlarmDAOImpl) _alarmDAO).generateAlarmsMap(ffs);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Example 10 with ACSAlarmDAOImpl

use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl in project ACS by ACS-Community.

the class AlarmManager method setFaultMemberDefault.

public boolean setFaultMemberDefault(FaultFamily ff, FaultMemberDefault fmd) throws NullPointerException, IllegalOperationException {
    if (ff == null || ff.getName() == null)
        throw new NullPointerException("The Fault Family (or its name) owner of the Fault Member to be deleted is null");
    List<ReductionRule> rrL = _reductionManager.getNodeReductionRules();
    for (ReductionRule rr : rrL) {
        String[] tr = rr.getParent().getAlarmId().split(":");
        if (tr[0].compareTo(ff.getName()) == 0 && tr[1].compareTo("*") == 0)
            throw new IllegalOperationException("The Fault Member is currently associated to a Reduction Rule");
    }
    for (Iterator<FaultFamily> iterator = _ffList.iterator(); iterator.hasNext(); ) {
        FaultFamily fft = (FaultFamily) iterator.next();
        if (fft.getName().compareTo(ff.getName()) == 0) {
            FaultMemberDefault tfmd = fft.getFaultMemberDefault();
            fft.setFaultMemberDefault(fmd);
            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 ((tfmd == null && fmd != null) || (tfmd != null && fmd == null)) {
                Vector<FaultFamily> ffs = new Vector<FaultFamily>();
                ffs.add(ff);
                ((ACSAlarmDAOImpl) _alarmDAO).removeAlarmsMap(ffs);
                ((ACSAlarmDAOImpl) _alarmDAO).generateAlarmsMap(ffs);
            }
            return true;
        }
    }
    return false;
}
Also used : FaultMemberDefault(alma.acs.alarmsystem.generated.FaultMemberDefault) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Vector(java.util.Vector) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Aggregations

ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)16 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)11 Vector (java.util.Vector)10 FaultCode (alma.acs.alarmsystem.generated.FaultCode)3 FaultMember (alma.acs.alarmsystem.generated.FaultMember)3 Alarms (alma.acs.alarmsystem.generated.Alarms)2 Category (alma.acs.alarmsystem.generated.Category)2 Alarm (cern.laser.business.data.Alarm)2 ValidationException (org.exolab.castor.xml.ValidationException)2 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)1 AlarmDefinition (alma.alarmsystem.alarmmessage.generated.AlarmDefinition)1 Child (alma.alarmsystem.alarmmessage.generated.Child)1 Parent (alma.alarmsystem.alarmmessage.generated.Parent)1 ReductionDefinitions (alma.alarmsystem.alarmmessage.generated.ReductionDefinitions)1 ReductionLinkType (alma.alarmsystem.alarmmessage.generated.ReductionLinkType)1 Threshold (alma.alarmsystem.alarmmessage.generated.Threshold)1 ACSCategoryDAOImpl (cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl)1 ACSSourceDAOImpl (cl.utfsm.acs.acg.dao.ACSSourceDAOImpl)1