Search in sources :

Example 6 with Categories

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();
    }
}
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 7 with Categories

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);
}
Also used : Category(alma.acs.alarmsystem.generated.Category) Categories(alma.acs.alarmsystem.generated.Categories) Alarms(alma.acs.alarmsystem.generated.Alarms)

Aggregations

Categories (alma.acs.alarmsystem.generated.Categories)7 Category (alma.acs.alarmsystem.generated.Category)4 Alarms (alma.acs.alarmsystem.generated.Alarms)3 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)3 StringReader (java.io.StringReader)3 Unmarshaller (org.exolab.castor.xml.Unmarshaller)3 ValidationException (org.exolab.castor.xml.ValidationException)3 CategoryDefinition (alma.alarmsystem.alarmmessage.generated.CategoryDefinition)2 Category (cern.laser.business.data.Category)2 CategoryImpl (cern.laser.business.data.CategoryImpl)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 MarshalException (org.exolab.castor.xml.MarshalException)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 InputSource (org.xml.sax.InputSource)2 CDBRecordDoesNotExistEx (alma.cdbErrType.CDBRecordDoesNotExistEx)1