@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; }
/** * {@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; }