Search in sources :

Example 1 with ReportCatalogEntry

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

the class DefaultReportService method createReportCatalogEntry.

private void createReportCatalogEntry(JasperPrint jasperPrint, Report report, String fileName) throws ReportRunException {
    ReportCatalogEntry catalogEntry = new ReportCatalogEntry();
    catalogEntry.setDate(new Date());
    // FIXME Is this correct ?
    catalogEntry.setReportId("reportd_" + report.getReportTemplate());
    catalogEntry.setTitle(report.getReportName());
    catalogEntry.setLocation(fileName);
    try {
        m_reportCatalogDao.save(catalogEntry);
    } catch (Exception e) {
        throw new ReportRunException("Can't save a report catalog entry, " + e.getMessage());
    }
}
Also used : ReportCatalogEntry(org.opennms.netmgt.model.ReportCatalogEntry) Date(java.util.Date) JRException(net.sf.jasperreports.engine.JRException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with ReportCatalogEntry

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

the class ManageDatabaseReportController method listReports.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView listReports(@RequestParam(value = "p", required = false, defaultValue = "0") int page, ModelAndView modelAndView) {
    List<ReportCatalogEntry> reportCatalog = reportStoreService.getAll();
    Map<String, Object> formatMap = reportStoreService.getFormatMap();
    PagedListHolder<ReportCatalogEntry> pagedListHolder = new PagedListHolder<>(reportCatalog);
    pagedListHolder.setPageSize(m_pageSize);
    // strip minus values
    pagedListHolder.setPage(Math.max(page, 0));
    modelAndView.addObject("formatMap", formatMap);
    modelAndView.addObject("pagedListHolder", pagedListHolder);
    modelAndView.addObject("command", new ManageDatabaseReportCommand());
    modelAndView.setViewName("/report/database/manage");
    return modelAndView;
}
Also used : ReportCatalogEntry(org.opennms.netmgt.model.ReportCatalogEntry) PagedListHolder(org.springframework.beans.support.PagedListHolder) ManageDatabaseReportCommand(org.opennms.web.svclayer.model.ManageDatabaseReportCommand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ReportCatalogEntry

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

the class ReportCatalogDaoHibernateIT method testSave.

@Test
@Transactional
public void testSave() {
    Date date = new Date();
    ReportCatalogEntry catalogEntry = new ReportCatalogEntry();
    catalogEntry.setReportId("reportId_1");
    catalogEntry.setLocation("location_1");
    catalogEntry.setTitle("title_1");
    catalogEntry.setDate(date);
    m_reportCatalogDao.save(catalogEntry);
    Integer id = catalogEntry.getId();
    ReportCatalogEntry retrievedEntry = m_reportCatalogDao.get(id);
    assertEquals(catalogEntry.getReportId(), retrievedEntry.getReportId());
    assertEquals(catalogEntry.getTitle(), retrievedEntry.getTitle());
    assertEquals(catalogEntry.getLocation(), retrievedEntry.getLocation());
    assertEquals(0, catalogEntry.getDate().compareTo(retrievedEntry.getDate()));
}
Also used : ReportCatalogEntry(org.opennms.netmgt.model.ReportCatalogEntry) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ReportCatalogEntry

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

the class ReportCatalogDaoHibernateIT method testDelete.

@Test
@Transactional
public void testDelete() {
    Date date = new Date();
    ReportCatalogEntry catalogEntry = new ReportCatalogEntry();
    catalogEntry.setReportId("reportId_2");
    catalogEntry.setLocation("location_2");
    catalogEntry.setTitle("title_2");
    catalogEntry.setDate(date);
    m_reportCatalogDao.save(catalogEntry);
    Integer id = catalogEntry.getId();
    assertNotNull(m_reportCatalogDao.get(id));
    m_reportCatalogDao.delete(id);
    assertNull(m_reportCatalogDao.get(id));
}
Also used : ReportCatalogEntry(org.opennms.netmgt.model.ReportCatalogEntry) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 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