Search in sources :

Example 1 with ACSCategoryDAOImpl

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();
    }
}
Also used : Category(alma.acs.alarmsystem.generated.Category) ValidationException(org.exolab.castor.xml.ValidationException) Categories(alma.acs.alarmsystem.generated.Categories) ACSCategoryDAOImpl(cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl)

Example 2 with ACSCategoryDAOImpl

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;
}
Also used : ACSCategoryDAOImpl(cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl) ACSAlarmDAOImpl(cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)

Aggregations

ACSCategoryDAOImpl (cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl)2 Categories (alma.acs.alarmsystem.generated.Categories)1 Category (alma.acs.alarmsystem.generated.Category)1 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)1 ValidationException (org.exolab.castor.xml.ValidationException)1