/** * Return the rule for the specified category. * * @param catlabel * the label for the category whose services list is needed * @return the rule for the specified category, null if the category is not * found */ public String getRule(final String catlabel) { final Category cat = getCategory(catlabel); return (cat == null? null : cat.getRule()); }
@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; }
/** * The default constructor - initializes the values * * @param cat a {@link org.opennms.netmgt.config.categories.Category} object. * @param commonRule a {@link java.lang.String} object. */ public RTCCategory(Category cat, String commonRule) { setLabel(cat.getLabel()); setComment(cat.getComment().orElse(null)); setRule(cat.getRule()); setNormalThreshold(cat.getNormalThreshold()); setWarningThreshold(cat.getWarningThreshold()); setServices(cat.getServices()); m_effectiveRule = "(" + commonRule + ") & (" + cat.getRule() + ")"; }
public void testGetCategory() { Category category = m_catFactory.getCategory(CATLABEL); assertEquals(99,category.getNormalThreshold(),0); assertEquals(97,category.getWarningThreshold(),0); assertTrue(category.getComment().isPresent()); assertEquals(CATCOMMENT,category.getComment().get()); assertEquals(CATRULE,category.getRule()); assertEquals("ICMP",category.getServices().get(0)); assertEquals("SNMP",category.getServices().get(1)); }