@Override public synchronized Category getCategory(final String name) { for (final CategoryGroup cg : m_config.getCategoryGroups()) { for (final Category cat : cg.getCategories()) { if (cat.getLabel().equals(name)) { return cat; } } } return null; }
/** * Add a categorygroup. * * @param group * category group to be added */ public void addCategoryGroup(final CategoryGroup group) { try { getWriteLock().lock(); m_config.addCategoryGroup(group); } finally { getWriteLock().unlock(); } }
/** * Delete a categorygroup. * * @param groupname * category group to be removed * @return true if categorygroup is successfully deleted */ public boolean deleteCategoryGroup(final String groupname) { try { getWriteLock().lock(); return m_config.removeCategoryGroup(groupname); } finally { getWriteLock().unlock(); } }
/** * Replace category in a categorygroup. * * @param groupname * category group to which category is to be added * @param cat * category to be replaced * @return true if category is successfully replaced in the specified * category group */ public boolean replaceCategory(final String groupname, final Category cat) { try { getWriteLock().lock(); m_config.replaceCategoryInGroup(groupname, cat); } finally { getWriteLock().unlock(); } return false; }
/** * Replace categorygroup. * * @param group * category group to be replaced * @return true if categorygroup is successfully replaced */ public boolean replaceCategoryGroup(final CategoryGroup group) { try { getWriteLock().lock(); final String groupname = group.getName(); for (int i = 0; i < m_config.getCategoryGroups().size(); i++) { final int index1 = i; final CategoryGroup oldCg = m_config.getCategoryGroups().get(index1); if (oldCg.getName().equals(groupname)) { final int index = i; m_config.getCategoryGroups().set(index, group); return true; } } } finally { getWriteLock().unlock(); } return false; }
/** * Delete a categorygroup. * * @param group * category group to be removed * @return true if categorygroup is successfully deleted */ public boolean deleteCategoryGroup(final CategoryGroup group) { try { getWriteLock().lock(); return m_config.removeCategoryGroup(group); } finally { getWriteLock().unlock(); } }
/** * <p>findAll</p> * * @return a {@link java.util.Collection} object. */ @Override public Collection<Category> findAll() { List<Category> catList = new ArrayList<>(); Catinfo catInfo = CategoryFactory.getInstance().getConfig(); List<CategoryGroup> catGroupList = catInfo.getCategoryGroups(); if (catGroupList != null) { for (final CategoryGroup cg : catGroupList) { catList.addAll(cg.getCategories()); } } return catList; } }
/** * <p>findAll</p> * * @return a {@link java.util.Collection} object. */ @Override public Collection<Category> findAll() { List<Category> catList = new ArrayList<>(); Catinfo catInfo = CategoryFactory.getInstance().getConfig(); List<CategoryGroup> catGroupList = catInfo.getCategoryGroups(); if (catGroupList != null) { for (final CategoryGroup cg : catGroupList) { catList.addAll(cg.getCategories()); } } return catList; } }
/** * {@inheritDoc} * * Return the category specified by name. */ @Override public Category getCategory(final String name) { try { getReadLock().lock(); for (final CategoryGroup cg: m_config.getCategoryGroups()) { for (final Category cat : cg.getCategories()) { if (cat.getLabel().equals(name)) { return cat; } } } } finally { getReadLock().unlock(); } return null; }
/** * Add category to a categorygroup. * * @param groupname * category group to which category is to be added * @param cat * category to be added * @return true if category is successfully added to the specified category * group */ public boolean addCategory(final String groupname, final Category cat) { try { getWriteLock().lock(); for (final CategoryGroup cg : m_config.getCategoryGroups()) { if (cg.getName().equals(groupname)) { cg.addCategory(cat); return true; } } } finally { getWriteLock().unlock(); } return false; }
/** * Delete category from a categorygroup. * * @param groupname * category group from which category is to be removed * @param catlabel * label of the category to be deleted * @return true if category is successfully deleted from the specified * category group */ public boolean deleteCategory(final String groupname, final String catlabel) { try { getWriteLock().lock(); for (final CategoryGroup cg : m_config.getCategoryGroups()) { if (cg.getName().equals(groupname)) { cg.removeCategory(catlabel); } } } finally { getWriteLock().unlock(); } return false; }
/** * Delete category from a categorygroup. * * @param groupname * category group from which category is to be removed * @param cat * category to be deleted * @return true if category is successfully deleted from the specified * category group */ public boolean deleteCategory(final String groupname, final Category cat) { try { getWriteLock().lock(); for (final CategoryGroup cg : m_config.getCategoryGroups()) { if (cg.getName().equals(groupname)) { cg.removeCategory(cat); return true; } } } finally { getWriteLock().unlock(); } return false; }
@Override public synchronized String getEffectiveRule(final String catlabel) { for (final CategoryGroup cg : m_config.getCategoryGroups()) { for (final Category cat : cg.getCategories()) { if (cat.getLabel().equals(catlabel)) { return "(" + cg.getCommon().getRule() + ") & (" + cat.getRule() + ")"; } } } return null; }
LOG.debug("catCount {}", catCount); for(final CategoryGroup cg : config.getCategoryGroups()) {
LOG.debug("catCount {}", catCount); for(final CategoryGroup cg : config.getCategoryGroups()) {
/** * {@inheritDoc} * * Return the effective rule for the specified category. The category rule * ANDed with the rule of the category group that the category belongs to. */ @Override public String getEffectiveRule(final String catlabel) { try { getReadLock().lock(); for (final CategoryGroup cg : m_config.getCategoryGroups()) { for (final Category cat : cg.getCategories()) { if (cat.getLabel().equals(catlabel)) { return "(" + cg.getCommon().getRule() + ") & (" + cat.getRule() + ")"; } } } } finally { getReadLock().unlock(); } return null; }
/** * Creates the categories map. Reads the categories from the categories.xml * and creates the 'RTCCategory's map */ public static HashMap<String, RTCCategory> createCategoriesMap() { CatFactory cFactory = null; try { CategoryFactory.init(); cFactory = CategoryFactory.getInstance(); } catch (IOException ex) { LOG.error("Failed to load categories information", ex); throw new UndeclaredThrowableException(ex); } HashMap<String, RTCCategory> retval = new HashMap<String, RTCCategory>(); cFactory.getReadLock().lock(); try { for (CategoryGroup cg : cFactory.getConfig().getCategoryGroups()) { final String commonRule = cg.getCommon().getRule(); for (final org.opennms.netmgt.config.categories.Category cat : cg.getCategories()) { RTCCategory rtcCat = new RTCCategory(cat, commonRule); retval.put(rtcCat.getLabel(), rtcCat); } } } finally { cFactory.getReadLock().unlock(); } return retval; }