use of org.opennms.features.reporting.model.basicreport.BasicReportDefinition 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;
}
use of org.opennms.features.reporting.model.basicreport.BasicReportDefinition in project opennms by OpenNMS.
the class DefaultRemoteRepository method getReports.
/**
* {@inheritDoc}
*/
@Override
public List<BasicReportDefinition> getReports() {
List<BasicReportDefinition> resultReports = new ArrayList<>();
if (isConfigOk()) {
WebTarget target = getTarget(m_remoteRepositoryDefintion.getURI() + "reports" + "/" + m_jasperReportsVersion);
List<RemoteReportSDO> webCallResult = new ArrayList<>();
try {
webCallResult = getBuilder(target).get(new GenericType<List<RemoteReportSDO>>() {
});
} catch (Exception e) {
logger.error("Error requesting report template from repository. Error message: '{}' Uri was: '{}'", e.getMessage(), target.getUri());
e.printStackTrace();
}
logger.debug("getReports got '{}' RemoteReportSDOs from uri '{}'", webCallResult.size(), target.getUri());
resultReports = this.mapSDOListToBasicReportList(webCallResult);
}
return resultReports;
}
use of org.opennms.features.reporting.model.basicreport.BasicReportDefinition 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());
}
use of org.opennms.features.reporting.model.basicreport.BasicReportDefinition in project opennms by OpenNMS.
the class DefaultDatabaseReportListService method getAll.
/**
* <p>
* getAll Reports from all Repositories
* </p>
*
* @return a {@link java.util.List} object.
*/
@Deprecated
@Override
public List<DatabaseReportDescription> getAll() {
List<DatabaseReportDescription> allReports = new ArrayList<>();
for (ReportRepository globalRepository : m_globalReportRepository.getRepositoryList()) {
for (BasicReportDefinition report : globalRepository.getReports()) {
DatabaseReportDescription summary = new DatabaseReportDescription();
summary.setRepositoryId(globalRepository.getRepositoryId());
summary.setId(report.getId());
summary.setDisplayName(report.getDisplayName());
summary.setDescription(report.getDescription());
summary.setIsOnline(report.getOnline());
summary.setAllowAccess(report.getAllowAccess());
allReports.add(summary);
}
}
return allReports;
}
use of org.opennms.features.reporting.model.basicreport.BasicReportDefinition in project opennms by OpenNMS.
the class DefaultRemoteRepositoryTest method reportIdsWithRepoIdgetMappedToRemoteReportTest.
@Test
public void reportIdsWithRepoIdgetMappedToRemoteReportTest() {
List<BasicReportDefinition> reports = m_defaultRemoteRepository.getReports();
for (BasicReportDefinition report : reports) {
assertTrue(m_defaultRemoteRepository.getDisplayName(report.getId()).length() > 0);
logger.debug("'{}' \t '{}'", report.getId(), m_defaultRemoteRepository.getDisplayName(report.getId()));
}
}
Aggregations