Jump to content
We've recently updated our Privacy Statement, available here ×

oscar16071987

Members
  • Posts

    12
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by oscar16071987

  1. Hi @chanduthedev, Sadly, Finally I used sub-reports and templates for each customer. But @amarco answer has the solution. Check out the answer and give us feedback. Best regards!
  2. Man!, Oh man, Sorry for late response and thanks for your help, I will check out and come back with feedback. Best regards!
  3. Hello hozawa, Thanks for help me ^^ I only have one question: In JasperServer 5.5, There is a way of change a datasource based on a parameter, Maybe creating a JAR?
  4. Hello again, I've following this "tutorial" for creating a dynamic datasource switch. I want to use one report, but each client have their own datasource. http://community.jaspersoft.com/wiki/switching-datasource-based-user I'm using JasperServer 5.5.0 with the installer and iReport 5.5.0 with the installer So, after many searches, finally I got working the jar, but when I run the report on the jasperserver web admin. I got the java.lang.NullPointerException I'm going to attach the files and a screenshot of the error, and, at the bottom the source code. Thanks for your help! Best regards! JasperServerCustomDataSource.java package com.jasperserver.custom.datasource;import java.util.Map;import java.sql.SQLException;import net.sf.jasperreports.engine.JRParameter;import org.springframework.context.i18n.LocaleContextHolder;import com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportDataSource;import com.jaspersoft.jasperserver.api.metadata.jasperreports.service.ReportDataSourceService;import com.jaspersoft.jasperserver.api.common.domain.ExecutionContext;import com.jaspersoft.jasperserver.api.common.service.BeanForInterfaceImplementationFactory;import com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcDataSourceService;import com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory;//import com.jaspersoft.jasperserver.api.engine.jasperreports.util.DataSourceServiceFactory;import com.jaspersoft.jasperserver.war.common.JasperServerUtil;import com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService;public class JasperServerCustomDataSource implements ReportDataSourceService {private JdbcDataSourceService connection;private RepositoryService repositoryService;private BeanForInterfaceImplementationFactory dataSourceServiceFactory;//private DataSourceServiceFactory dataSourceServiceFactory;public JasperServerCustomDataSource(RepositoryService repositoryService, BeanForInterfaceImplementationFactory dsServiceFactory) { super(); this.repositoryService = repositoryService; this.dataSourceServiceFactory = dsServiceFactory;}@SuppressWarnings({ "unchecked", "rawtypes" })public void setReportParameterValues(Map parametersValue) { String ds_name = (String) parametersValue.get("jasper_ds_name"); if( (ds_name == null) || (ds_name.isEmpty()) ) { ds_name = "CUSTOMER_DS1"; } String ds_uri = "/datasources/" + ds_name; connection = getRepositoryDatasource(ds_uri); try { parametersValue.put(JRParameter.REPORT_CONNECTION, connection .getDataSource().getConnection()); } catch (SQLException e) { e.printStackTrace(); }}public JdbcDataSourceService getRepositoryDatasource(String repositoryURI) { ExecutionContext context = JasperServerUtil .getExecutionContext(LocaleContextHolder.getLocale()); ReportDataSource datasource = (ReportDataSource) repositoryService .getResource(context, repositoryURI); JdbcReportDataSourceServiceFactory factory = (JdbcReportDataSourceServiceFactory) dataSourceServiceFactory .getBean(datasource.getClass()); JdbcDataSourceService DSservice = (JdbcDataSourceService) factory .createService(datasource); return DSservice;}@Overridepublic void closeConnection() { if(connection != null) { connection.closeConnection(); }}}[/code]JasperServerCustomDataSourceFactory.java package com.jasperserver.custom.datasource;import com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService;import com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportDataSource;import com.jaspersoft.jasperserver.api.metadata.jasperreports.service.ReportDataSourceService;import com.jaspersoft.jasperserver.api.metadata.jasperreports.service.ReportDataSourceServiceFactory;import com.jaspersoft.jasperserver.api.common.service.BeanForInterfaceImplementationFactory;//import com.jaspersoft.jasperserver.api.engine.jasperreports.util.DataSourceServiceFactory;import com.jasperserver.custom.datasource.JasperServerCustomDataSource;public class JasperServerCustomDataSourceFactory implements ReportDataSourceServiceFactory {private RepositoryService repositoryService;private BeanForInterfaceImplementationFactory dataSourceServiceFactory;public JasperServerCustomDataSourceFactory() {}/* Factory methods */public JasperServerCustomDataSource createDataSourceService() { return new JasperServerCustomDataSource(repositoryService, dataSourceServiceFactory);}@Overridepublic ReportDataSourceService createService(ReportDataSource dataSource) { return new JasperServerCustomDataSource(repositoryService, dataSourceServiceFactory);}/* getters */public RepositoryService getRepositoryService() { return repositoryService;} public BeanForInterfaceImplementationFactory getDataSourceServiceFactory() { return dataSourceServiceFactory;}/* Setters */public void setRepositoryService(RepositoryService repositoryService) { this.repositoryService = repositoryService;}public void setDataSourceServiceFactory(BeanForInterfaceImplementationFactory dataSourceServiceFactory) { this.dataSourceServiceFactory = dataSourceServiceFactory;}}[/code]ApplicationContext-customds.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="JasperServerCustomDataSourceFactory" class="com.jasperserver.custom.datasource.JasperServerCustomDataSourceFactory" > <property name="repositoryService"> <ref bean="repositoryService"/> </property> </bean></beans>[/code]
  5. Hi guys! I don't have experience creating custom libs for JasperServer, I've reading this topic: http://community.jaspersoft.com/wiki/switching-datasource-based-user But the example is not very clear about the files we need in the project. What jasperserver libraries are needed for creating a custom datasource for then add on the project? Thanks for help me Best regards Oscar Romero
  6. Hi guys, Maybe is too late, but maybe some dude get this trouble in a future xD Finally I've found a different solution, Is quite strange. I'm sending a DataSourceID parameter... And In SQL Editor something like this DECLARE @cDBName VARCHAR(100) DECLARE @iDSNumber INTEGER SET @iDSNumber = $P{DataSourceNumber} IF @iDSNumber = 1 SET @cDBName = 'Contoso' ELSE SET @cDBName = 'Fabrikam' EXEC (@cDBName + '.dbo.Procedure ' + '[' + @cCustName + '], ' + @iCountry)
  7. Thanks for help me yurab. Finally I've found a different solution, Is quite strange. I'm sending a DataSourceID parameter... And In SQL Editor something like this DECLARE @cDBName VARCHAR(100) DECLARE @iDSNumber INTEGER SET @iDSNumber = $P{DataSourceNumber} IF @iDSNumber = 1 SET @cDBName = 'Contoso' ELSE SET @cDBName = 'Fabrikam' EXEC (@cDBName + '.dbo.Procedure ' + '[' + @cCustName + '], ' + @iCountry)
  8. Thanks for help me yurab. Currently I have this JasperServer version: Product Version: 4.7.0 Build: 20120815_1737 But the parameter is ignored or something else, We are using the same report for 2 different databases. I'm sending the parameters like this... http:// localhost/doreport.php?uri=/reports/customers/s04&PARAM_dm=0&format=PDF&PARAM_REPORT_CONNECTION=DATA_SOURCE_NAME I'm using a PHP Library and PARAM_XXX is required for this lib. Everything works only the REPORT_CONNECTION it doesn't. Thanks for your help Best regards, Oscar Romero
  9. Hi guys! I have the same issue, How you send the DataSource with parameters? Best regards Oscar Romero
  10. Hi guys!, I'm trying to find the parameter for switch the datasource dynamically, It's possible? Thanks for help me Best regards Oscar Romero
×
×
  • Create New...