Search in sources :

Example 41 with OnmsCategory

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);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory)

Example 42 with OnmsCategory

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;
}
Also used : OnmsCategory(org.opennms.netmgt.model.OnmsCategory)

Example 43 with OnmsCategory

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);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) ArrayList(java.util.ArrayList)

Example 44 with OnmsCategory

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) Category(org.opennms.netmgt.config.siteStatusViews.Category) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) ObjectRetrievalFailureException(org.springframework.orm.ObjectRetrievalFailureException)

Example 45 with OnmsCategory

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) AggregateStatusDefinition(org.opennms.netmgt.model.AggregateStatusDefinition) RowDef(org.opennms.netmgt.config.siteStatusViews.RowDef)

Aggregations

OnmsCategory (org.opennms.netmgt.model.OnmsCategory)63 OnmsNode (org.opennms.netmgt.model.OnmsNode)29 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)9 Path (javax.ws.rs.Path)7 LinkedHashSet (java.util.LinkedHashSet)6 HashSet (java.util.HashSet)5 AggregateStatusDefinition (org.opennms.netmgt.model.AggregateStatusDefinition)4 AggregateStatusView (org.opennms.netmgt.model.AggregateStatusView)4 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)4 Transactional (org.springframework.transaction.annotation.Transactional)4 GET (javax.ws.rs.GET)3 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)3 SearchResult (org.opennms.features.topology.api.topo.SearchResult)3 RowDef (org.opennms.netmgt.config.siteStatusViews.RowDef)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 OnmsAssetRecord (org.opennms.netmgt.model.OnmsAssetRecord)3 OnmsGeolocation (org.opennms.netmgt.model.OnmsGeolocation)3 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)3 AggregateStatus (org.opennms.web.svclayer.model.AggregateStatus)3