use of org.opennms.netmgt.config.api.CatFactory 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;
}
Aggregations