use of org.opennms.netmgt.config.statsd.model.PackageReport in project opennms by OpenNMS.
the class ReportDefinitionBuilder method buildReportDefinitions.
/**
* Builds and schedules all reports enabled in the statsd-configuration.
* This method has the capability to throw a ton of exceptions, just generically throwing <code>Exception</code>
*
* @return a <code>Collection</code> of enabled reports from the statsd-configuration.
* @throws java.lang.Exception if any.
*/
public Collection<ReportDefinition> buildReportDefinitions() throws Exception {
Set<ReportDefinition> reportDefinitions = new HashSet<ReportDefinition>();
for (StatsdPackage pkg : m_statsdConfigDao.getPackages()) {
for (PackageReport packageReport : pkg.getReports()) {
Report report = packageReport.getReport();
if (!packageReport.isEnabled()) {
LOG.debug("skipping report '{}' in package '{}' because the report is not enabled", report.getName(), pkg.getName());
continue;
}
Class<? extends AttributeStatisticVisitorWithResults> clazz;
try {
clazz = createClassForReport(report);
} catch (ClassNotFoundException e) {
throw new DataAccessResourceFailureException("Could not find class '" + report.getClassName() + "'; nested exception: " + e, e);
}
Assert.isAssignable(AttributeStatisticVisitorWithResults.class, clazz, "the class specified by class-name in the '" + report.getName() + "' report does not implement the interface " + AttributeStatisticVisitorWithResults.class.getName() + "; ");
ReportDefinition reportDef = new ReportDefinition();
reportDef.setReport(packageReport);
reportDef.setReportClass(clazz);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(reportDef);
try {
bw.setPropertyValues(packageReport.getAggregateParameters());
} catch (BeansException e) {
LOG.error("Could not set properties on report definition: {}", e.getMessage(), e);
}
reportDef.afterPropertiesSet();
reportDefinitions.add(reportDef);
}
}
return reportDefinitions;
}
use of org.opennms.netmgt.config.statsd.model.PackageReport in project opennms by OpenNMS.
the class ReportDefinitionTest method createPackageReport.
private static PackageReport createPackageReport() {
PackageReport packageReport;
packageReport = new PackageReport();
packageReport.setDescription("a package!");
packageReport.setEnabled(true);
packageReport.setPackage(new StatsdPackage());
packageReport.setReport(null);
packageReport.setRetainInterval(Long.valueOf(86400 * 1000));
packageReport.setSchedule("hmm");
return packageReport;
}
Aggregations