use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testGetTitle.
@Test
public void testGetTitle() {
PrefabGraph bits = m_graphs.get("mib2.bits").getObject();
;
assertEquals("getTitle", "Bits In/Out", bits.getTitle());
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class DefaultGraphResultsService method createGraphResultSet.
/**
* <p>createGraphResultSet</p>
*
* @param resourceId a {@link java.lang.String} object.
* @param resource a {@link org.opennms.netmgt.model.OnmsResource} object.
* @param reports an array of {@link java.lang.String} objects.
* @param graphResults a {@link org.opennms.web.svclayer.model.GraphResults} object.
* @return a {@link org.opennms.web.svclayer.model.GraphResults.GraphResultSet}
* object.
*/
private GraphResultSet createGraphResultSet(ResourceId resourceId, OnmsResource resource, String[] reports, GraphResults graphResults) throws IllegalArgumentException {
if (resource == null) {
resource = m_resourceDao.getResourceById(resourceId);
if (resource == null) {
throw new IllegalArgumentException("Could not find resource \"" + resourceId + "\"");
}
}
GraphResultSet rs = graphResults.new GraphResultSet();
rs.setResource(resource);
if (reports.length == 1 && "all".equals(reports[0])) {
PrefabGraph[] queries = m_graphDao.getPrefabGraphsForResource(resource);
List<String> queryNames = new ArrayList<String>(queries.length);
for (PrefabGraph query : queries) {
queryNames.add(query.getName());
}
reports = queryNames.toArray(new String[queryNames.size()]);
}
List<Graph> graphs = new ArrayList<Graph>(reports.length);
List<String> filesToPromote = new LinkedList<String>();
for (String report : reports) {
PrefabGraph prefabGraph = m_graphDao.getPrefabGraph(report);
Graph graph = new Graph(prefabGraph, resource, graphResults.getStart(), graphResults.getEnd());
getAttributeFiles(graph, filesToPromote);
graphs.add(graph);
}
sendEvent(filesToPromote);
/*
* Sort the graphs by their order in the properties file. PrefabGraph
* implements the Comparable interface.
*/
Collections.sort(graphs);
rs.setGraphs(graphs);
return rs;
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class DefaultKscReportService method buildResourceReport.
private static Report buildResourceReport(ResourceService service, OnmsResource parentResource, String title) {
Report report = new Report();
report.setTitle(title);
report.setShowTimespanButton(true);
report.setShowGraphtypeButton(true);
List<OnmsResource> resources = service.findChildResources(parentResource, "interfaceSnmp");
for (OnmsResource resource : resources) {
PrefabGraph[] graphs = service.findPrefabGraphsForResource(resource);
if (graphs.length == 0) {
continue;
}
Graph graph = new Graph();
graph.setTitle("");
graph.setResourceId(resource.getId().toString());
graph.setTimespan("7_day");
graph.setGraphtype(graphs[0].getName());
report.addGraph(graph);
}
return report;
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class GraphResultsControllerTest method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
m_service = EasyMock.createMock(GraphResultsService.class);
PropertiesGraphDao graphDao = new PropertiesGraphDao();
graphDao.loadProperties("performance", new FileSystemResource(new File("src/test/resources/etc/snmp-graph.properties")));
List<PrefabGraph> prefabs = graphDao.getAllPrefabGraphs();
Assert.assertNotNull(prefabs);
Assert.assertFalse(prefabs.isEmpty());
EasyMock.expect(m_service.getAllPrefabGraphs(ResourceId.get("node", "1").resolve("nodeSnmp", ""))).andReturn(prefabs.toArray(new PrefabGraph[prefabs.size()])).anyTimes();
m_controller = new GraphResultsController();
m_controller.setGraphResultsService(m_service);
EasyMock.replay(m_service);
}
use of org.opennms.netmgt.model.PrefabGraph in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testGetPrefabGraphsForResourceWithSuppress.
@Test
public void testGetPrefabGraphsForResourceWithSuppress() {
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interface");
HashSet<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(0);
attributes.add(new RrdGraphAttribute("ifInOctets", "", ""));
attributes.add(new RrdGraphAttribute("ifOutOctets", "", ""));
attributes.add(new RrdGraphAttribute("ifHCInOctets", "", ""));
attributes.add(new RrdGraphAttribute("ifHCOutOctets", "", ""));
attributes.add(new ExternalValueAttribute("ifSpeed", ""));
OnmsResource resource = new OnmsResource("node", "1", resourceType, attributes, ResourcePath.get("foo"));
PrefabGraph[] graphs = m_dao.getPrefabGraphsForResource(resource);
assertEquals("prefab graph array size", 1, graphs.length);
assertEquals("prefab graph[0] name", "mib2.HCbits", graphs[0].getName());
}
Aggregations