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

ramonc

Members
  • Posts

    6
  • 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 ramonc

  1. Follow this thread even though its a little late. https://community.jaspersoft.com//questions/1064821/pass-paramaters-using-jasperserver-api-datasource-invoked-report
  2. For console logging usniig jasper studio follow this thread. https://community.jaspersoft.com/jaspersoft-studio/issues/3622 You should be seeing system.println("") logging on the jss console.
  3. I managed to solve this by folowing this thread using part of the code written in the comments: "look at this for source code example" I will resume this in basic steps: 1) Create a java class that implements JRDatasource 2) Create a java class that implements JRDatasourceProvider 3) Create a java class that extends AbstractQueryExecuterFactory 4) From the overriden createQueryExecuter method process whatever is needed to then return an instance of your JRDatasourceProvider Class, make sure to pass the report and report's parameter mapping. 5) In your provider class setup what you need to connect and pass paramenters to the JRDatasource class implemeted (I assume here is where you will access any source and compile the necessary data to fill out the fields of the report) 6) Create a data adapter that uses "java class which implements the JRDataSourceProvider interface" 7) Add the data adapter created to the report and set to read from the query executer created (the custom query executer must be imported into jasperstudio look at here). This is done opening the query and dataset dialog. 8) Should be ready to go NOTE: create the parameters in the report design view, and the parameter map that the method recieves in the query executer should appear. NOTE2: If report has sub datasets that also read from custom data source, a repetition of these steps should be used (I did some bad practice therefore not publishing the actual source code, basically create a boolean parameter inside the subset and read it in the executer and instantiate whatever needed to get to the sub data set data source :] ) TROUBLESHOOTING - If you are having problems with null pointers, enable the jss console in the settings and start printing to system.out, should help figure out whats going on. - If empty document, check your datasource to see if it actually is returning data or that the query executer was imported correctly
  4. If rendered as a web page and consumed using the REST_V2 API, then you could set the content-type header=application/pdf; content-dispostion=inline; you have a problem downloading it
  5. Hi all, At the moment I'm not sure how to proceed since I have created a custom datasource that connects with a RESTful service that provides a JSON document that is parsed and displayed on the report. The service needs to send some parameters to obtain the document wanted. I find no way of extracting these parameters, getting and using their value. Here is my datasource code: package dataSources;import com.eqb.utilities.HttpRestClient;import java.io.IOException;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Paths;import java.util.ArrayList;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;import java.util.Set;import org.apache.commons.lang.ArrayUtils;import org.json.JSONException;import org.json.JSONObject;import com.fasterxml.jackson.core.JsonParseException;import com.fasterxml.jackson.core.type.TypeReference;import com.fasterxml.jackson.databind.JsonMappingException;import com.fasterxml.jackson.databind.ObjectMapper;import net.sf.jasperreports.engine.JRDataSource;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRField;import net.sf.jasperreports.engine.JasperReport;public class AnnualStatementDataSource implements JRDataSource { private Integer counter = -1; private String jsonText = ""; @Override public boolean next() throws JRException { if(counter < 0) return true; return false; } @Override public Object getFieldValue(JRField jrField) throws JRException { HttpRestClient http = new HttpRestClient(); String fieldValue = ""; counter++; jsonText = http.sendPostRequest("some_url", "jasper_parameter"); fieldValue = getFieldValueFromJson(jsonText,jrField.getName()); return fieldValue; } public static JRDataSource StatementDataSource(){ return new StatementDataSource(); } }[/code] IMPORTANT NOTE: The report instantiates this datasource using a data adapter that invokes this datasource. If anyone could point me into the right direction, thank you and please.
×
×
  • Create New...