Search in sources :

Example 6 with ReportCatalogEntry

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;
}
Also used : ReportCatalogEntry(org.opennms.netmgt.model.ReportCatalogEntry) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date)

Example 7 with ReportCatalogEntry

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);
}
Also used : ReportCatalogEntry(org.opennms.netmgt.model.ReportCatalogEntry) Test(org.junit.Test)

Aggregations

ReportCatalogEntry (org.opennms.netmgt.model.ReportCatalogEntry)7 Date (java.util.Date)4 Test (org.junit.Test)3 Transactional (org.springframework.transaction.annotation.Transactional)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 JRException (net.sf.jasperreports.engine.JRException)1 ManageDatabaseReportCommand (org.opennms.web.svclayer.model.ManageDatabaseReportCommand)1 PagedListHolder (org.springframework.beans.support.PagedListHolder)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1