use of org.opennms.netmgt.config.categories.CategoryGroup in project opennms by OpenNMS.
the class DefaultCategoryConfigDao method findAll.
/**
* <p>findAll</p>
*
* @return a {@link java.util.Collection} object.
*/
@Override
public Collection<Category> findAll() {
List<Category> catList = new ArrayList<Category>();
Catinfo catInfo = CategoryFactory.getInstance().getConfig();
List<CategoryGroup> catGroupList = catInfo.getCategoryGroups();
if (catGroupList != null) {
for (final CategoryGroup cg : catGroupList) {
catList.addAll(cg.getCategories());
}
}
return catList;
}
use of org.opennms.netmgt.config.categories.CategoryGroup in project opennms by OpenNMS.
the class RTCUtils method createCategoriesMap.
/**
* 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;
}
use of org.opennms.netmgt.config.categories.CategoryGroup in project opennms by OpenNMS.
the class CategoryFactory method replaceCategoryGroup.
/**
* 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;
}
Aggregations