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;
}
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;
}
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;
}
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);
}
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();
}
Aggregations