use of cern.laser.business.data.Category in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method updateCategory.
public void updateCategory(Category category) {
Integer id = category.getCategoryId();
if (id == null)
throw new IllegalStateException();
Category previous = categories.get(id);
// path may have changed
catPathToCategory.values().remove(previous);
categories.put(id, category);
if (category.getPath() != null)
catPathToCategory.put(category.getPath(), category);
}
use of cern.laser.business.data.Category in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method assignCategoryOfCoreAlarms.
/**
* Assign core alarms to the root category.
*
* @see LaserCoreAlarms
* @see LaserCoreFaultState
* @see LaserCoreFaultCodes
*/
private void assignCategoryOfCoreAlarms() {
String[] coreIds = LaserCoreFaultState.getCoreAlarmIds();
Category rootCategory = getCategoryByPath("ROOT");
assignCategoryToAlarms(rootCategory, LaserCoreFaultState.FaultFamily);
}
use of cern.laser.business.data.Category in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method getChildren.
public Integer[] getChildren(Integer parentId) {
int pid = parentId.intValue();
CategoryImpl cat = (CategoryImpl) getCategory(parentId);
if (cat == null)
return null;
ArrayList<Integer> result = new ArrayList<Integer>();
Iterator<Category> i = categories.values().iterator();
while (i.hasNext()) {
Category c = i.next();
// root categories have null parentId
if (c.getParentId() != null && c.getParentId().intValue() == pid)
result.add(c.getCategoryId());
}
Integer[] out = new Integer[result.size()];
result.toArray(out);
return out;
}
use of cern.laser.business.data.Category in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method assignCategoryToAlarms.
/**
* Assign the category to the all the alarms of a given FaultFamily.
*
* In the CDB each category has a list (eventually empty) of FaultFamily.
* If a FaultFamily appear in the definition of a Category then add
* such category to all the alarms of such FF.
*
* @param category The category to assign to the alarms
* @param FF The fault family of the alarms to assign the category to
*/
private void assignCategoryToAlarms(Category category, String FF) {
if (category == null) {
throw new IllegalArgumentException("Invalid null category");
}
if (FF == null) {
throw new IllegalArgumentException("Invalid null fault family");
}
String[] alarmIDs = ((ACSAlarmDAOImpl) alarmDao).getAllAlarmIDs();
for (String id : alarmIDs) {
Alarm alarm = alarmDao.getAlarm(id);
if (alarm == null) {
logger.log(AcsLogLevel.WARNING, "Got a null alarm for ID=" + id);
continue;
}
if (alarm.getTriplet().getFaultFamily().equals(FF)) {
Collection<Category> alarmCategories = alarm.getCategories();
if (!alarmCategories.contains(category)) {
alarmCategories.add(category);
logger.log(AcsLogLevel.DEBUG, "Category " + category.getName() + " assigned to alarm " + alarm.getAlarmId());
}
}
}
}
use of cern.laser.business.data.Category in project ACS by ACS-Community.
the class ACSCategoryDAOImpl method deleteCategory.
public void deleteCategory(Category category) {
Integer id = category.getCategoryId();
if (id == null)
throw new IllegalStateException();
Category previous = categories.get(id);
categories.remove(id);
// this one was in catPath, so remove that one instead
// have to use values(), because the path may have changed,
// but mapping didn't
catPathToCategory.values().remove(previous);
}
Aggregations