/** * createGraphResultSet * * @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( String 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; }
@Override public PrefabGraph[] getAllPrefabGraphs(String resourceId) { OnmsResource resource = m_resourceDao.getResourceById(resourceId); return m_graphDao.getPrefabGraphsForResource(resource); }