Search in sources :

Example 61 with OnmsCategory

use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.

the class NodeRestService method getCategoryForNode.

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{nodeCriteria}/categories/{categoryName}")
public OnmsCategory getCategoryForNode(@PathParam("nodeCriteria") String nodeCriteria, @PathParam("categoryName") String categoryName) {
    OnmsNode node = m_nodeDao.get(nodeCriteria);
    if (node == null) {
        throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
    }
    final OnmsCategory cat = getCategory(node, categoryName);
    if (cat == null) {
        throw getException(Status.NOT_FOUND, "Can't find category {} for node {}.", categoryName, nodeCriteria);
    }
    return cat;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 62 with OnmsCategory

use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.

the class DefaultGroupService method getAuthorizedCategoriesAsString.

@Override
public List<String> getAuthorizedCategoriesAsString(String groupName) {
    List<OnmsCategory> categories = getAuthorizedCategories(groupName);
    List<String> categoryNames = new ArrayList<String>(categories.size());
    for (OnmsCategory category : categories) {
        categoryNames.add(category.getName());
    }
    return categoryNames;
}
Also used : OnmsCategory(org.opennms.netmgt.model.OnmsCategory) ArrayList(java.util.ArrayList)

Example 63 with OnmsCategory

use of org.opennms.netmgt.model.OnmsCategory in project opennms by OpenNMS.

the class DefaultSiteStatusServiceIT method createOutageForNodeInCategory.

private void createOutageForNodeInCategory(String categoryName) {
    OnmsCategory category = m_categoryDao.findByName(categoryName);
    Collection<OnmsNode> nodes = m_nodeDao.findByCategory(category);
    assertNotNull(nodes);
    assertFalse(nodes.isEmpty());
    /*
         * There should only be 1 node per category based on the set of
         * default nodes that are stored in {@link DatabasePopulator}
         */
    assertEquals(1, nodes.size());
    OnmsNode node = nodes.iterator().next();
    node.visit(new AbstractEntityVisitor() {

        @Override
        public void visitMonitoredService(OnmsMonitoredService monSvc) {
            createOutageForService(monSvc);
        }
    });
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) AbstractEntityVisitor(org.opennms.netmgt.model.AbstractEntityVisitor) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

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