use of org.opennms.netmgt.model.ReportCatalogEntry in project opennms by OpenNMS.
the class AvailabilityCalculatorImpl method writeLocateableXML.
/* (non-Javadoc)
* @see org.opennms.reporting.availability.AvailabilityCalculator#writeLocateableXML(java.lang.String)
*/
/**
* {@inheritDoc}
*/
@Override
public String writeLocateableXML(String id) throws AvailabilityCalculationException {
try {
LOG.debug("Writing the XML");
// Create a file name of type Category-monthFormat-startDate.xml
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
String catFileName = m_categoryName.replace(' ', '-');
m_outputFileName = catFileName + "-" + m_monthFormat + fmt.format(m_periodEndDate) + ".xml";
LOG.debug("Report Store XML file: {}", m_outputFileName);
File reportFile = new File(m_baseDir, m_outputFileName);
// marshal the XML into the file.
marshal(reportFile);
// save to reportStore
ReportCatalogEntry catalogEntry = new ReportCatalogEntry();
catalogEntry.setReportId(id);
catalogEntry.setTitle(m_monthFormat + " " + m_categoryName);
catalogEntry.setLocation(reportFile.getAbsolutePath());
catalogEntry.setDate(new Date());
m_reportStoreService.save(catalogEntry);
} catch (AvailabilityCalculationException e) {
LOG.error("Unable to marshal report as XML");
throw new AvailabilityCalculationException(e);
}
return m_outputFileName;
}
use of org.opennms.netmgt.model.ReportCatalogEntry in project opennms by OpenNMS.
the class DefaultReportStoreServiceTest method testSave.
@Test
public void testSave() {
ReportCatalogEntry reportCatalogEntry = new ReportCatalogEntry();
m_reportCatalogDao.save(reportCatalogEntry);
m_reportCatalogDao.flush();
replay(m_reportCatalogDao);
m_reportStoreService.save(reportCatalogEntry);
verify(m_reportCatalogDao);
}
Aggregations