Search in sources :

Example 1 with Graph

use of org.opennms.web.svclayer.model.Graph in project opennms by OpenNMS.

the class DefaultRrdGraphService method getPrefabGraph.

/** {@inheritDoc} */
@Override
public InputStream getPrefabGraph(ResourceId resourceId, String report, long start, long end, Integer width, Integer height) {
    Assert.notNull(resourceId, "resourceId argument cannot be null");
    Assert.notNull(report, "report argument cannot be null");
    Assert.isTrue(end > start, "end time " + end + " must be after start time" + start);
    PrefabGraphType t = m_graphDao.findPrefabGraphTypeByName("performance");
    if (t == null) {
        throw new IllegalArgumentException("graph type \"" + "performance" + "\" is not valid");
    }
    OnmsResource r = m_resourceDao.getResourceById(resourceId);
    Assert.notNull(r, "resource could not be located");
    PrefabGraph prefabGraph = m_graphDao.getPrefabGraph(report);
    Graph graph = new Graph(prefabGraph, r, new Date(start), new Date(end));
    String command = createPrefabCommand(graph, t.getCommandPrefix(), report, width, height);
    return getInputStreamForCommand(command);
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) PrefabGraph(org.opennms.netmgt.model.PrefabGraph) Graph(org.opennms.web.svclayer.model.Graph) PrefabGraph(org.opennms.netmgt.model.PrefabGraph) PrefabGraphType(org.opennms.netmgt.model.PrefabGraphType) Date(java.util.Date)

Example 2 with Graph

use of org.opennms.web.svclayer.model.Graph 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;
}
Also used : PrefabGraph(org.opennms.netmgt.model.PrefabGraph) Graph(org.opennms.web.svclayer.model.Graph) PrefabGraph(org.opennms.netmgt.model.PrefabGraph) ArrayList(java.util.ArrayList) GraphResultSet(org.opennms.web.svclayer.model.GraphResults.GraphResultSet) LinkedList(java.util.LinkedList)

Aggregations

PrefabGraph (org.opennms.netmgt.model.PrefabGraph)2 Graph (org.opennms.web.svclayer.model.Graph)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 PrefabGraphType (org.opennms.netmgt.model.PrefabGraphType)1 GraphResultSet (org.opennms.web.svclayer.model.GraphResults.GraphResultSet)1