use of alma.acs.alarmsystem.generated.Categories in project ACS by ACS-Community.
the class CategoryManager method saveToCDB.
public void saveToCDB() {
Set<String> keyset = _objState.keySet();
String[] objs = new String[keyset.size()];
keyset.toArray(objs);
Categories cats = ((ACSCategoryDAOImpl) _categoryDAO).getCategories();
boolean flush = false;
try {
for (int i = 0; i < objs.length; i++) {
ObjectState os = _objState.get(objs[i]);
Category c = getCategoryByPath(objs[i]);
if (c != null)
c.validate();
switch(os.getAction()) {
case //Error, no state assigned.
-1:
break;
case 0:
break;
case 1:
((ACSCategoryDAOImpl) _categoryDAO).addCategory(cats, c);
flush = true;
break;
case 2:
((ACSCategoryDAOImpl) _categoryDAO).updateCategory(cats, c);
flush = true;
break;
case 3:
c = new Category();
c.setPath(objs[i]);
((ACSCategoryDAOImpl) _categoryDAO).deleteCategory(cats, c);
flush = true;
break;
default:
//Shouldn't happen.
break;
}
}
_objState.clear();
if (flush)
((ACSCategoryDAOImpl) _categoryDAO).flushCategories(cats);
for (Category c : _categoryList) _objState.put(c.getPath(), new ObjectState(false));
} catch (ValidationException e) {
e.printStackTrace();
}
}
use of alma.acs.alarmsystem.generated.Categories in project ACS by ACS-Community.
the class ACSCategoryDAOImplTest method testSaveCategory.
public void testSaveCategory() {
//boolean exception;
Category c1;
c1 = new Category();
c1.setPath("Foobar");
c1.setDescription("Foobar Category");
c1.setIsDefault(false);
Alarms alarms = new Alarms();
alarms.addFaultFamily("ffTest");
c1.setAlarms(alarms);
Categories cats = _categoryDAO.getCategories();
_categoryDAO.addCategory(cats, c1);
}
Aggregations