Search in sources :

Example 16 with BasicReportDefinition

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

the class DefaultRemoteRepository method getOnlineReports.

/**
 * {@inheritDoc}
 */
@Override
public List<BasicReportDefinition> getOnlineReports() {
    List<BasicReportDefinition> resultReports = new ArrayList<>();
    List<RemoteReportSDO> webCallResult = new ArrayList<>();
    if (isConfigOk()) {
        WebTarget target = getTarget(m_remoteRepositoryDefintion.getURI() + "onlineReports" + "/" + m_jasperReportsVersion);
        try {
            webCallResult = getBuilder(target).get(new GenericType<List<RemoteReportSDO>>() {
            });
        } catch (Exception e) {
            logger.error("Error requesting online reports. Error message: '{}' URI was: '{}'", e.getMessage(), target.getUri());
            e.printStackTrace();
        }
        logger.debug("getOnlineReports got '{}' RemoteReportSDOs from uri '{}'", webCallResult.size(), target.getUri());
        resultReports = this.mapSDOListToBasicReportList(webCallResult);
    }
    return resultReports;
}
Also used : RemoteReportSDO(org.opennms.features.reporting.sdo.RemoteReportSDO) GenericType(javax.ws.rs.core.GenericType) ArrayList(java.util.ArrayList) WebTarget(javax.ws.rs.client.WebTarget) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 17 with BasicReportDefinition

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

the class DefaultRemoteRepository method mapSDOListToBasicReportList.

private List<BasicReportDefinition> mapSDOListToBasicReportList(List<RemoteReportSDO> remoteReportSDOList) {
    List<BasicReportDefinition> resultList = new ArrayList<>();
    for (RemoteReportSDO report : remoteReportSDOList) {
        SimpleJasperReportDefinition result = new SimpleJasperReportDefinition();
        try {
            BeanUtils.copyProperties(result, report);
            result.setId(m_remoteRepositoryDefintion.getRepositoryId() + "_" + result.getId());
        } catch (IllegalAccessException e) {
            logger.debug("SDO to BasicReport mapping IllegalAssessException while copyProperties from '{}' to '{}' with exception.", report, result);
            logger.error("SDO to BasicReport mapping IllegalAssessException while copyProperties '{}' RepositoryURI: '{}'", e, m_remoteRepositoryDefintion.getURI());
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            logger.debug("SDO to BasicReport mapping InvocationTargetException while copyProperties from '{}' to '{}' with exception.", report, result);
            logger.error("SDO to BasicReport mapping InvocationTargetException while copyProperties '{}' RepositoryURI: '{}'", e, m_remoteRepositoryDefintion.getURI());
            e.printStackTrace();
        }
        logger.debug("SDO to BasicReport mapping got: '{}'", report.toString());
        resultList.add(result);
    }
    logger.debug("SDO to BasicReport mapping returns resultList: '{}'", resultList.toString());
    return resultList;
}
Also used : RemoteReportSDO(org.opennms.features.reporting.sdo.RemoteReportSDO) ArrayList(java.util.ArrayList) SimpleJasperReportDefinition(org.opennms.features.reporting.model.jasperreport.SimpleJasperReportDefinition) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 18 with BasicReportDefinition

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

the class DefaultDatabaseReportListService method getReportsByRepositoryId.

@Override
public List<DatabaseReportDescription> getReportsByRepositoryId(String repositoryId) {
    List<DatabaseReportDescription> reportList = new ArrayList<>();
    for (BasicReportDefinition reportDefinition : m_globalReportRepository.getRepositoryById(repositoryId).getReports()) {
        DatabaseReportDescription summary = new DatabaseReportDescription();
        summary.setRepositoryId(reportDefinition.getRepositoryId());
        summary.setId(reportDefinition.getId());
        summary.setDisplayName(reportDefinition.getDisplayName());
        summary.setDescription(reportDefinition.getDescription());
        summary.setIsOnline(reportDefinition.getOnline());
        summary.setAllowAccess(reportDefinition.getAllowAccess());
        reportList.add(summary);
    }
    return reportList;
}
Also used : DatabaseReportDescription(org.opennms.web.svclayer.model.DatabaseReportDescription) ArrayList(java.util.ArrayList) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition)

Example 19 with BasicReportDefinition

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

the class DefaultDatabaseReportListService method getAllOnline.

/**
 * <p>
 * getAll Reports from all Repositories
 * </p>
 *
 * @return a {@link java.util.List} object.
 */
@Deprecated
@Override
public List<DatabaseReportDescription> getAllOnline() {
    List<DatabaseReportDescription> onlineReports = new ArrayList<>();
    for (ReportRepository m_repo : m_globalReportRepository.getRepositoryList()) {
        for (BasicReportDefinition report : m_repo.getOnlineReports()) {
            DatabaseReportDescription summary = new DatabaseReportDescription();
            summary.setRepositoryId(m_repo.getRepositoryId());
            summary.setId(report.getId());
            summary.setDisplayName(report.getDisplayName());
            summary.setDescription(report.getDescription());
            summary.setIsOnline(report.getOnline());
            summary.setAllowAccess(report.getAllowAccess());
            onlineReports.add(summary);
        }
    }
    return onlineReports;
}
Also used : DatabaseReportDescription(org.opennms.web.svclayer.model.DatabaseReportDescription) ArrayList(java.util.ArrayList) GlobalReportRepository(org.opennms.features.reporting.repository.global.GlobalReportRepository) ReportRepository(org.opennms.features.reporting.repository.ReportRepository) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition)

Example 20 with BasicReportDefinition

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

the class DefaultDatabaseReportListService method getOnlineReportsByRepositoryId.

@Override
public List<DatabaseReportDescription> getOnlineReportsByRepositoryId(String repositoryId) {
    List<DatabaseReportDescription> onlineReportList = new ArrayList<>();
    for (BasicReportDefinition reportDefinition : m_globalReportRepository.getRepositoryById(repositoryId).getOnlineReports()) {
        DatabaseReportDescription summary = new DatabaseReportDescription();
        summary.setRepositoryId(reportDefinition.getRepositoryId());
        summary.setId(reportDefinition.getId());
        summary.setDisplayName(reportDefinition.getDisplayName());
        summary.setDescription(reportDefinition.getDescription());
        summary.setIsOnline(reportDefinition.getOnline());
        summary.setAllowAccess(reportDefinition.getAllowAccess());
        onlineReportList.add(summary);
    }
    return onlineReportList;
}
Also used : DatabaseReportDescription(org.opennms.web.svclayer.model.DatabaseReportDescription) ArrayList(java.util.ArrayList) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition)

Aggregations

BasicReportDefinition (org.opennms.features.reporting.model.basicreport.BasicReportDefinition)20 ArrayList (java.util.ArrayList)14 ReportRepository (org.opennms.features.reporting.repository.ReportRepository)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Test (org.junit.Test)4 DatabaseReportDescription (org.opennms.web.svclayer.model.DatabaseReportDescription)4 LegacyLocalReportDefinition (org.opennms.features.reporting.model.basicreport.LegacyLocalReportDefinition)3 GlobalReportRepository (org.opennms.features.reporting.repository.global.GlobalReportRepository)3 RemoteReportSDO (org.opennms.features.reporting.sdo.RemoteReportSDO)3 WebTarget (javax.ws.rs.client.WebTarget)2 GenericType (javax.ws.rs.core.GenericType)2 Before (org.junit.Before)2 HashMap (java.util.HashMap)1 ReportFormat (org.opennms.api.reporting.ReportFormat)1 LocalReportsDao (org.opennms.features.reporting.dao.LocalReportsDao)1 LocalJasperReportsDao (org.opennms.features.reporting.dao.jasper.LocalJasperReportsDao)1 SimpleJasperReportDefinition (org.opennms.features.reporting.model.jasperreport.SimpleJasperReportDefinition)1 DefaultDatabaseReportListService (org.opennms.web.svclayer.support.DefaultDatabaseReportListService)1