Search in sources :

Example 1 with AdhocGraphType

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

the class PropertiesGraphDao method loadAdhocProperties.

/**
 * <p>
 * loadAdhocProperties
 * </p>
 *
 * @param type
 *            a {@link java.lang.String} object.
 * @param in
 *            a {@link java.io.InputStream} object.
 * @throws java.io.IOException
 *             if any.
 */
public void loadAdhocProperties(String type, InputStream in) throws IOException {
    AdhocGraphType t = createAdhocGraphType(type, in);
    m_adhocTypes.put(t.getName(), new FileReloadContainer<AdhocGraphType>(t));
}
Also used : AdhocGraphType(org.opennms.netmgt.model.AdhocGraphType)

Example 2 with AdhocGraphType

use of org.opennms.netmgt.model.AdhocGraphType 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 3 with AdhocGraphType

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

the class PropertiesGraphDao method createAdhocGraphType.

/**
 * <p>
 * createAdhocGraphType
 * </p>
 *
 * @param type
 *            a {@link java.lang.String} object.
 * @param in
 *            a {@link java.io.InputStream} object.
 * @return a {@link org.opennms.netmgt.model.AdhocGraphType} object.
 * @throws java.io.IOException
 *             if any.
 */
private AdhocGraphType createAdhocGraphType(String type, InputStream in) throws IOException {
    Properties properties = new Properties();
    properties.load(in);
    AdhocGraphType t = new AdhocGraphType();
    t.setName(type);
    t.setCommandPrefix(getProperty(properties, "command.prefix"));
    t.setOutputMimeType(getProperty(properties, "output.mime"));
    t.setTitleTemplate(getProperty(properties, "adhoc.command.title"));
    t.setDataSourceTemplate(getProperty(properties, "adhoc.command.ds"));
    t.setGraphLineTemplate(getProperty(properties, "adhoc.command.graphline"));
    return t;
}
Also used : AdhocGraphType(org.opennms.netmgt.model.AdhocGraphType) Properties(java.util.Properties)

Example 4 with AdhocGraphType

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

the class PropertiesGraphDao method loadAdhocProperties.

/**
 * <p>createPrefabGraphType
 * loadAdhocProperties
 * </p>
 *
 * @param type
 *            a {@link java.lang.String} object.
 * @param resource
 *            a {@link org.springframework.core.io.Resource} object.
 * @throws java.io.IOException
 *             if any.
 */
public void loadAdhocProperties(String type, Resource resource) throws IOException {
    InputStream in = resource.getInputStream();
    AdhocGraphType t;
    try {
        t = createAdhocGraphType(type, in);
    } finally {
        IOUtils.closeQuietly(in);
    }
    m_adhocTypes.put(t.getName(), new FileReloadContainer<AdhocGraphType>(t, resource, m_adhocCallback));
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) AdhocGraphType(org.opennms.netmgt.model.AdhocGraphType)

Aggregations

AdhocGraphType (org.opennms.netmgt.model.AdhocGraphType)4 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1