Search in sources :

Example 1 with RemoteReportSDO

use of org.opennms.features.reporting.sdo.RemoteReportSDO 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;
}
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 2 with RemoteReportSDO

use of org.opennms.features.reporting.sdo.RemoteReportSDO 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 3 with RemoteReportSDO

use of org.opennms.features.reporting.sdo.RemoteReportSDO 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)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ArrayList (java.util.ArrayList)3 BasicReportDefinition (org.opennms.features.reporting.model.basicreport.BasicReportDefinition)3 RemoteReportSDO (org.opennms.features.reporting.sdo.RemoteReportSDO)3 WebTarget (javax.ws.rs.client.WebTarget)2 GenericType (javax.ws.rs.core.GenericType)2 SimpleJasperReportDefinition (org.opennms.features.reporting.model.jasperreport.SimpleJasperReportDefinition)1