use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultAdminCategoryService method removeCategory.
/**
* {@inheritDoc}
*/
@Override
public void removeCategory(String categoryIdString) {
OnmsCategory category = findCategory(categoryIdString);
CategoryAndMemberNodes cat = getCategory(categoryIdString);
for (OnmsNode adriftNode : cat.getMemberNodes()) {
notifyCategoryChange(adriftNode, new String[0], new String[] { category.getName() });
}
m_categoryDao.delete(category);
}
use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultAdminCategoryService method addNewCategory.
/**
* {@inheritDoc}
*/
@Override
public OnmsCategory addNewCategory(final String name) {
OnmsCategory category = new OnmsCategory();
category.setName(name);
m_categoryDao.save(category);
return category;
}
use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultAdminCategoryService method getCategory.
/**
* {@inheritDoc}
*/
@Override
public CategoryAndMemberNodes getCategory(String categoryIdString) {
if (categoryIdString == null) {
throw new IllegalArgumentException("categoryIdString must not be null");
}
OnmsCategory category = findCategory(categoryIdString);
final List<OnmsNode> memberNodes = new ArrayList<>();
for (final OnmsNode node : getNodeDao().findByCategory(category)) {
if (!OnmsNode.NodeType.DELETED.equals(node.getType())) {
memberNodes.add(node);
}
}
Collections.sort(memberNodes);
return new CategoryAndMemberNodes(category, memberNodes);
}
use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultSiteStatusViewService method getCategoriesForRowDef.
private Set<OnmsCategory> getCategoriesForRowDef(RowDef rowDef) {
Set<OnmsCategory> categories = new LinkedHashSet<>();
// Loop over the defined categories and create model categories (OnmsCategory)
List<Category> cats = rowDef.getCategories();
for (Category cat : cats) {
OnmsCategory category = m_categoryDao.findByName(cat.getName());
if (category == null) {
throw new ObjectRetrievalFailureException(OnmsCategory.class, cat.getName(), "Unable to locate OnmsCategory named: " + cat.getName() + " as specified in the site status view configuration file", null);
}
categories.add(category);
}
return categories;
}
use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.
the class DefaultSiteStatusViewService method getAggregateStatusDefinitionsForView.
private Set<AggregateStatusDefinition> getAggregateStatusDefinitionsForView(View view) {
Set<AggregateStatusDefinition> statusDefs = new LinkedHashSet<>();
// Loop over the defined site status rows
for (RowDef rowDef : view.getRows()) {
AggregateStatusDefinition def = new AggregateStatusDefinition();
def.setName(rowDef.getLabel());
def.setReportCategory(rowDef.getReportCategory());
Set<OnmsCategory> categories = getCategoriesForRowDef(rowDef);
def.setCategories(categories);
statusDefs.add(def);
}
return statusDefs;
}
Aggregations