use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl 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");
}
use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl 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");
}
use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl 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);
}
use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl in project ACS by ACS-Community.
the class ReductionManager method loadFromCDB.
/* (non-Javadoc)
* @see cl.utfsm.acs.acg.core.EntityManager#loadFromCDB()
*/
public void loadFromCDB() {
String[] ids = ((ACSAlarmDAOImpl) _alarmDAO).getAllAlarmIDs();
String[] children = null;
Alarm alarm = null;
ReductionRule rr = null;
_nodeReductionRules.clear();
_multiReductionRules.clear();
_objState.clear();
_thrState.clear();
/* Add the reduction rules defined in the CDB */
for (int i = 0; i < ids.length; i++) {
alarm = ((ACSAlarmDAOImpl) _alarmDAO).getAlarm(ids[i]);
/* First the Node Reduction rules */
children = alarm.getNodeChildren();
if (children.length > 0) {
rr = new ReductionRule(alarm);
rr.setIsNodeReduction(true);
}
for (int j = 0; j < children.length; j++) {
rr.addChild(((ACSAlarmDAOImpl) _alarmDAO).getAlarm(children[j]));
_objState.put(new String(ids[i] + "," + children[j] + ",n"), new ObjectState(false));
}
if (children.length > 0)
_nodeReductionRules.add(rr);
/* And the Multiplicity Reduction rules */
children = alarm.getMultiplicityChildren();
if (children.length > 0) {
rr = new ReductionRule(((ACSAlarmDAOImpl) _alarmDAO).getAlarm(ids[i]));
rr.setIsNodeReduction(false);
if (alarm.getMultiplicityThreshold() == null) {
System.out.println("Skipping Multi Reduction Rule: No Threshold set.");
continue;
}
rr.setThreshold(alarm.getMultiplicityThreshold().intValue());
}
for (int j = 0; j < children.length; j++) {
rr.addChild(((ACSAlarmDAOImpl) _alarmDAO).getAlarm(children[j]));
_objState.put(new String(ids[i] + "," + children[j] + ",m"), new ObjectState(false));
_thrState.put(ids[i], new ObjectState(false));
}
if (children.length > 0)
_multiReductionRules.add(rr);
}
}
use of cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl in project ACS by ACS-Community.
the class DAOManager method getSourceDAO.
public SourceDAO getSourceDAO() {
if (_conf == null) {
throw new IllegalStateException("DAOManager not connected to DAL");
}
if (_sourceDAOImpl == null) {
if (_alarmDAOImpl == null)
_alarmDAOImpl = getAlarmDAO();
_sourceDAOImpl = new ACSSourceDAOImpl(_contServ.getLogger(), ((ACSAlarmDAOImpl) _alarmDAOImpl).getSources());
((ACSSourceDAOImpl) _sourceDAOImpl).setConfAccessor(_conf);
}
return _sourceDAOImpl;
}
Aggregations