All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sk.seges.acris.reporting.server.service.CustomDataSourceService Maven / Gradle / Ivy

package sk.seges.acris.reporting.server.service;

import java.util.Map;

import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRRuntimeException;
import sk.seges.acris.reporting.server.datasource.CustomDataSource;

import com.jaspersoft.jasperserver.api.metadata.jasperreports.service.ReportDataSourceService;

/**
 * 
 * this service serves only for setting of JRParameter.REPORT_DATA_SOURCE, but
 * is necessary for JasperServer 
* it can be extended if some action with parameters is needed the service is * used in {@link CustomJavaBeanDataSourceFactory} * * @author marta * * @param * type of bean which is used as a row in JasperReport */ public class CustomDataSourceService implements ReportDataSourceService { private CustomDataSource customDataSource; public CustomDataSourceService() {} public CustomDataSourceService(CustomDataSource customDataSource) { super(); this.init(customDataSource); } public void init(CustomDataSource source) { this.customDataSource = source; } /** * method is final because parameter REPORT_DATA_SOURCE must be set * additional parameters can be set via setExtendedReportParameterValues * */ @Override @SuppressWarnings("unchecked") public final void setReportParameterValues(Map parameters) { try { this.setExtendedReportParameterValues(parameters); parameters.put(JRParameter.REPORT_DATA_SOURCE, customDataSource); } catch (Exception ex) { throw new JRRuntimeException("Unable to set report parameter values", ex); } } /** * if this method is overridden, some action with parameters can be * provided, all parameters has to be provided as parameters in jrxml file * and also as input controls in jasperserver repository * * @param Map * of parameters of report */ protected void setExtendedReportParameterValues(Map parameters) throws Exception { return; } @Override public void closeConnection() { // TODO: add connection close support. do not need this... } public void setCustomDataSource(CustomDataSource customDataSource) { this.customDataSource = customDataSource; } public CustomDataSource getCustomDataSource() { return customDataSource; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy