use of cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl 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 cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl in project ACS by ACS-Community.
the class DAOManager method getCategoryDAO.
public CategoryDAO getCategoryDAO() throws IllegalStateException {
if (_conf == null) {
throw new IllegalStateException("DAOManager not connected to DAL");
}
if (_categoryDAOImpl == null) {
if (_alarmDAOImpl == null)
_alarmDAOImpl = getAlarmDAO();
_categoryDAOImpl = new ACSCategoryDAOImpl(_contServ.getLogger(), (ACSAlarmDAOImpl) _alarmDAOImpl);
((ACSCategoryDAOImpl) _categoryDAOImpl).setConfAccessor(_conf);
}
return _categoryDAOImpl;
}
Aggregations