Search in sources :

Example 1 with LegacyLocalReportDefinition

use of org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition in project opennms by OpenNMS.

the class LegacyLocalReportRepository method getReports.

/**
 * {@inheritDoc}
 */
@Override
public List<BasicReportDefinition> getReports() {
    List<BasicReportDefinition> resultList = new ArrayList<>();
    for (BasicReportDefinition report : m_localReportsDao.getReports()) {
        BasicReportDefinition resultReport = new LegacyLocalReportDefinition();
        try {
            BeanUtils.copyProperties(resultReport, report);
            resultReport.setId(REPOSITORY_ID + "_" + report.getId());
            // Community reports are allowed by default, no permission restriction
            resultReport.setAllowAccess(true);
        } catch (IllegalAccessException e) {
            logger.error("IllegalAccessException during BeanUtils.copyProperties for BasicReportDefinion '{}'", e.getMessage());
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            logger.error("InvocationTargetException during BeanUtils.copyProperties for BasicReportDefinion '{}'", e.getMessage());
            e.printStackTrace();
        }
        resultList.add(resultReport);
    }
    return resultList;
}
Also used : LegacyLocalReportDefinition(org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition) ArrayList(java.util.ArrayList) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with LegacyLocalReportDefinition

use of org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition in project opennms by OpenNMS.

the class LegacyLocalReportRepositoryTest method setUp.

/**
 * <p>setUp</p>
 * <p/>
 * Initialize and mockup the LegacyLocalReportRepository
 *
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    // Mocked report list as a result from DAOs
    List<BasicReportDefinition> reports = new ArrayList<>();
    List<BasicReportDefinition> onlineReports = new ArrayList<>();
    reports.add(new LegacyLocalReportDefinition());
    reports.add(new LegacyLocalReportDefinition());
    onlineReports.add(new LegacyLocalReportDefinition());
    // Mock DAOs for the local repository test
    LocalReportsDao m_localReportsDao = EasyMock.createMock(LocalReportsDao.class);
    LocalJasperReportsDao m_localJasperReportsDao = EasyMock.createMock(LocalJasperReportsDao.class);
    // TODO indigo: Mockup an InputStream with EasyMock is not trivial, InputStream isn't an interface
    // InputStream jrTemplateStream = EasyMock.createMock(InputStream.class);
    // EasyMock.expect(m_localJasperReportsDao.getTemplateStream("sample-report")).andReturn(jrTemplateStream);
    // Initialize the local report repository to provide reports from database-reports.xml and jasper-reports.xml
    m_legacyLocalReportRepository = new LegacyLocalReportRepository(m_localReportsDao, m_localJasperReportsDao);
    m_legacyLocalReportRepository.setLocalReportsDao(m_localReportsDao);
    m_legacyLocalReportRepository.setLocalJasperReportsDao(m_localJasperReportsDao);
    EasyMock.expect(m_localReportsDao.getOnlineReports()).andReturn(onlineReports);
    EasyMock.expect(m_localReportsDao.getDisplayName("sample-report")).andReturn("displayNameMockup");
    EasyMock.expect(m_localReportsDao.getReports()).andReturn(reports);
    EasyMock.expect(m_localReportsDao.getOnlineReports()).andReturn(onlineReports);
    EasyMock.expect(m_localReportsDao.getReportService("sample-report")).andReturn("jasperReportServiceMockup");
    EasyMock.expect(m_localJasperReportsDao.getTemplateLocation("sample-report")).andReturn("mocked-jdbc");
    EasyMock.expect(m_localJasperReportsDao.getEngine("sample-report")).andReturn("mocked-jdbc");
    EasyMock.replay(m_localReportsDao);
    EasyMock.replay(m_localJasperReportsDao);
    // Sanitycheck
    assertNotNull("Test if mocked DAO for database-reports.xml is not null", m_legacyLocalReportRepository.getLocalReportsDao());
    assertNotNull("Test if mocked DAo for jasper-reports.xml is not null", m_legacyLocalReportRepository.getLocalJasperReportsDao());
}
Also used : LegacyLocalReportDefinition(org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition) ArrayList(java.util.ArrayList) LocalJasperReportsDao(org.opennms.features.reporting.dao.jasper.LocalJasperReportsDao) LocalReportsDao(org.opennms.features.reporting.dao.LocalReportsDao) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition) Before(org.junit.Before)

Example 3 with LegacyLocalReportDefinition

use of org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition in project opennms by OpenNMS.

the class LegacyLocalReportRepository method getOnlineReports.

/**
 * {@inheritDoc}
 */
@Override
public List<BasicReportDefinition> getOnlineReports() {
    List<BasicReportDefinition> resultList = new ArrayList<>();
    for (BasicReportDefinition report : m_localReportsDao.getOnlineReports()) {
        BasicReportDefinition resultReport = new LegacyLocalReportDefinition();
        try {
            BeanUtils.copyProperties(resultReport, report);
            resultReport.setId(REPOSITORY_ID + "_" + report.getId());
            // Community reports are allowed by default, no permission restriction
            resultReport.setAllowAccess(true);
        } catch (IllegalAccessException e) {
            logger.error("IllegalAccessException during BeanUtils.copyProperties for BasicReportDefinion '{}'", e.getMessage());
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            logger.error("InvocationTargetException during BeanUtils.copyProperties for BasicReportDefinion '{}'", e.getMessage());
            e.printStackTrace();
        }
        resultList.add(resultReport);
    }
    return resultList;
}
Also used : LegacyLocalReportDefinition(org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition) ArrayList(java.util.ArrayList) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ArrayList (java.util.ArrayList)3 BasicReportDefinition (org.opennms.features.reporting.model.basicreport.BasicReportDefinition)3 LegacyLocalReportDefinition (org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Before (org.junit.Before)1 LocalReportsDao (org.opennms.features.reporting.dao.LocalReportsDao)1 LocalJasperReportsDao (org.opennms.features.reporting.dao.jasper.LocalJasperReportsDao)1