Search in sources :

Example 6 with Category

use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.

the class CategoryManager method addCategory.

/**
	 * Add a new Category. If there is a Category with the same name that the given Category, the new Category cannot be added 
	 * @param c The Category to be added
	 * @return True If the Category is added , False otherwise 
	 * @throws IllegalOperationException If the Category to add already exists
	 * @throws NullPointerException If the Category is null 
	 */
public boolean addCategory(Category c) throws IllegalOperationException, NullPointerException {
    if (c == null || c.getPath() == null)
        throw new NullPointerException("The category to be added (or its name) is null");
    for (Category ctg : _categoryList) if (ctg.getPath().compareTo(c.getPath()) == 0)
        throw new IllegalOperationException("The Category already exists");
    c.setIsDefault(false);
    _categoryList.add(c);
    ObjectState os = _objState.get(c.getPath());
    if (os == null) {
        os = new ObjectState(true);
        os.create();
        _objState.put(c.getPath(), os);
    } else
        os.update();
    return true;
}
Also used : Category(alma.acs.alarmsystem.generated.Category)

Example 7 with Category

use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.

the class CategoryManagerTest method testAddCategory.

public void testAddCategory() throws IllegalOperationException {
    List<Category> categories1 = cm.getAllCategories();
    assertNotNull(categories1);
    Category c = new Category();
    c.setPath("NEW CATEGORY");
    cm.addCategory(c);
    List<Category> categories2 = cm.getAllCategories();
    assertNotNull(categories2);
    assertEquals(categories1.size(), categories2.size());
    boolean check = false;
    for (Iterator<Category> iterator = categories2.iterator(); iterator.hasNext(); ) {
        Category ctg = (Category) iterator.next();
        if (ctg.getPath().compareTo("NEW CATEGORY") == 0) {
            check = true;
        }
    }
    assertTrue(check);
    check = false;
    try {
        cm.addCategory(c);
    } catch (IllegalOperationException e) {
        check = true;
    }
    assertTrue(check);
}
Also used : Category(alma.acs.alarmsystem.generated.Category)

Example 8 with Category

use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.

the class CategoryManagerTest method testGetAllCategories.

public void testGetAllCategories() {
    CategoryManager cm = _alarmSystemManager.getCategoryManager();
    assertNotNull(cm);
    cm.loadFromCDB();
    List<Category> categories = cm.getAllCategories();
    assertNotNull(categories);
    for (Category category : categories) assertNotNull(category);
}
Also used : Category(alma.acs.alarmsystem.generated.Category)

Example 9 with Category

use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.

the class CategoryManagerTest method testGetCategoryByPath.

public void testGetCategoryByPath() {
    CategoryManager cm = _alarmSystemManager.getCategoryManager();
    cm.loadFromCDB();
    List<Category> categories = cm.getAllCategories();
    Category category2 = null;
    for (Category category : categories) {
        category2 = cm.getCategoryByPath(category.getPath());
        assertNotNull(category2);
        assertEquals(category, category2);
    }
}
Also used : Category(alma.acs.alarmsystem.generated.Category)

Example 10 with Category

use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.

the class ACSCategoryDAOImplTest method testUpdateCategory.

public void testUpdateCategory() {
    //boolean exception;
    Category c1;
    c1 = new Category();
    c1.setPath("Foobar");
    c1.setDescription("Foobar Category2");
    c1.setIsDefault(false);
    Alarms alarms = new Alarms();
    alarms.addFaultFamily("ffTest");
    c1.setAlarms(alarms);
    Categories cats = _categoryDAO.getCategories();
    _categoryDAO.updateCategory(cats, c1);
}
Also used : Category(alma.acs.alarmsystem.generated.Category) Categories(alma.acs.alarmsystem.generated.Categories) Alarms(alma.acs.alarmsystem.generated.Alarms)

Aggregations

Category (alma.acs.alarmsystem.generated.Category)22 Alarms (alma.acs.alarmsystem.generated.Alarms)8 ArrayList (java.util.ArrayList)5 Categories (alma.acs.alarmsystem.generated.Categories)4 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)4 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)2 Vector (java.util.Vector)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 Point (org.eclipse.swt.graphics.Point)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Event (org.eclipse.swt.widgets.Event)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Listener (org.eclipse.swt.widgets.Listener)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2