Search in sources :

Example 71 with OnmsResource

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

the class DefaultResourceService method findDomainChildResources.

/**
 * {@inheritDoc}
 */
@Override
public List<OnmsResource> findDomainChildResources(String domain) {
    List<OnmsResource> resources = new ArrayList<>();
    OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("domain", domain));
    if (resource != null) {
        resources = resource.getChildResources();
        // Get the size to force the list to be loaded
        resources.size();
    }
    return resources;
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ArrayList(java.util.ArrayList)

Example 72 with OnmsResource

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

the class DefaultResourceService method findNodeSourceChildResources.

/**
 * {@inheritDoc}
 */
@Override
public List<OnmsResource> findNodeSourceChildResources(String nodeSource) {
    List<OnmsResource> resources = new ArrayList<>();
    OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("nodeSource", nodeSource));
    if (resource != null) {
        resources = resource.getChildResources();
        // Get the size to force the list to be loaded
        resources.size();
    }
    return resources;
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ArrayList(java.util.ArrayList)

Example 73 with OnmsResource

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

the class DefaultResourceService method findNodeChildResources.

/**
 * {@inheritDoc}
 */
public List<OnmsResource> findNodeChildResources(int nodeId) {
    List<OnmsResource> resources = new ArrayList<>();
    OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("node", Integer.toString(nodeId)));
    if (resource != null) {
        resources = resource.getChildResources();
        // Get the size to force the list to be loaded
        resources.size();
    }
    return resources;
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ArrayList(java.util.ArrayList)

Example 74 with OnmsResource

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

the class DefaultRrdGraphService method getAdhocGraph.

/**
 * {@inheritDoc}
 */
@Override
public InputStream getAdhocGraph(ResourceId resourceId, String title, String[] dataSources, String[] aggregateFunctions, String[] colors, String[] dataSourceTitles, String[] styles, long start, long end) {
    Assert.notNull(resourceId, "resourceId argument cannot be null");
    Assert.notNull(title, "title argument cannot be null");
    Assert.notNull(dataSources, "dataSources argument cannot be null");
    Assert.notNull(aggregateFunctions, "aggregateFunctions argument cannot be null");
    Assert.notNull(colors, "colors argument cannot be null");
    Assert.notNull(dataSourceTitles, "dataSourceTitles argument cannot be null");
    Assert.notNull(styles, "styles argument cannot be null");
    Assert.isTrue(end > start, "end time must be after start time");
    AdhocGraphType t = m_graphDao.findAdhocGraphTypeByName("performance");
    OnmsResource r = m_resourceDao.getResourceById(resourceId);
    Assert.notNull(r, "resource \"" + resourceId + "\" could not be located");
    String command = createAdHocCommand(t, r, start, end, title, dataSources, aggregateFunctions, colors, dataSourceTitles, styles);
    return getInputStreamForCommand(command);
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) AdhocGraphType(org.opennms.netmgt.model.AdhocGraphType)

Example 75 with OnmsResource

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

the class ResourceTreeWalkerTest method testWalkChildren.

public void testWalkChildren() {
    ResourceTreeWalker walker = new ResourceTreeWalker();
    walker.setResourceDao(m_resourceDao);
    walker.setVisitor(m_visitor);
    m_mocks.replayAll();
    walker.afterPropertiesSet();
    m_mocks.verifyAll();
    MockResourceType resourceType = new MockResourceType();
    OnmsResource childResource = new OnmsResource("eth0", "Interface eth0", resourceType, new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
    OnmsResource topResource = new OnmsResource("1", "Node One", resourceType, new HashSet<OnmsAttribute>(0), Collections.singletonList(childResource), new ResourcePath("foo"));
    expect(m_resourceDao.findTopLevelResources()).andReturn(Collections.singletonList(topResource));
    m_visitor.visit(topResource);
    m_visitor.visit(childResource);
    m_mocks.replayAll();
    walker.walk();
    m_mocks.verifyAll();
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) MockResourceType(org.opennms.netmgt.mock.MockResourceType)

Aggregations

OnmsResource (org.opennms.netmgt.model.OnmsResource)143 Test (org.junit.Test)54 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)40 MockResourceType (org.opennms.netmgt.mock.MockResourceType)31 OnmsNode (org.opennms.netmgt.model.OnmsNode)28 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)23 File (java.io.File)22 ResourcePath (org.opennms.netmgt.model.ResourcePath)19 ArrayList (java.util.ArrayList)14 HashSet (java.util.HashSet)14 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)12 HashMap (java.util.HashMap)11 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)11 ResourceId (org.opennms.netmgt.model.ResourceId)11 Date (java.util.Date)10 Source (org.opennms.netmgt.measurements.model.Source)8 LinkedList (java.util.LinkedList)7 FetchResults (org.opennms.netmgt.measurements.api.FetchResults)7 ExternalValueAttribute (org.opennms.netmgt.model.ExternalValueAttribute)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7