Thursday, 19 March 2015

NextReports: Iframe new parameters

Starting from NextReports 8.1 iframes will be able to contain in their url some new parameters alongside width, height and report parameters. See this old post about iframe parameters.

Two of them are meaningful for table widgets: tableFontSize and tableCellPadding in points. These can be handy if you want to have an iframe on a big monitor screen and users need to look at it from distance. To show the difference you can compare following two screens:

The second one has tableFontSize=18 and tableCellPadding=10.

Another parameter, adjustableTextFontSize, has a boolean value and by setting it to true the chart from iframe will have texts from title, legends and axis values adjusted in concordance with iframe width. This parameter is automatically set to true on chart Detach action from NextReports Server.

A simple comparison can be seen here:

This example is shown for an iframe with width=800 and height=500 pixels.

Thursday, 12 March 2015

How to access NextReports Server web services in your application

NextReports Server has a number of web services. These can be found in ro.nextreports.server.api. NextReports uses Jersey web services so in any web service class users can see @Path and @QueryParam annotations to know how to create the url. All urls start with:

If users need to access these services using java code, then a client for these services already exists and can be found in ro.nextreports.server.api.client. Inside designer installation folder in lib there is nextreports-server-client-8.0.jar library which can be used. To see how it is used in designer  you can look in ro.nextreports.designer.wizpublish . Here is the code used to publish/download report/charts to/from server. (it involves also how to authenticate, to get list of entities from server, create a folder in server structure and more)

For example to authenticate you have to do the following with the root url previously shown:

WebServiceClient client = new WebServiceClient();   
client.setPassword(new String(passField.getPassword()));
client.setPasswordEncoder(new Md5PasswordEncoder());

boolean authorized = false;
try {
      authorized = client.isAuthorized();            
} catch (Exception e) {
     // connection error
     return false;

To get entities from server:

List<EntityMetaData> entities = client.getEntities(folderPath);

This method sets the server url path by appending to base api url "storage/getEntities/" and then the folder path. There are some root constants used to create folderPath like /reports, /charts, /dataSources.

If you want to call Next web services  from Javascript/JQuery and get reports from a path, you have also to be authenticated. Next example uses two javascript libraries:

Base64 encoder (jquery.base64.js) :
MD5 generation (core-min.js and md5-min.js) :

This example does an ajax get to obtain the list of reports from root /reports path. Request header contains an Authorization object. On success the list of entities (path and type) is shown in a html list.

       <title>NextReports Server JQuery Test</title>
       <script src="jquery-1.10.2.min.js" type="text/javascript"></script>
       <script src="jquery.base64.js" type="text/javascript"></script>
       <script src="core-min.js" type="text/javascript"></script>
       <script src="md5-min.js" type="text/javascript"></script>
             var serverPath = "/reports";   
             var username="admin";
             var password="1";      
             var passwordHash = CryptoJS.MD5("1");
             var base64 = $.base64.encode( username + ":" + passwordHash );               
             $.ajax( {              
                    type: "GET",
                    url : 'http://localhost:8081/nextreports-server/api/storage/getEntities?path=' + serverPath,
                    dataType : "xml",              
                    beforeSend : function(xhr) {           
                            xhr.setRequestHeader('Authorization', 'Basic ' + base64);
                   error : function(xhr, ajaxOptions, thrownError) {
                   success : function(data) {           
                           var paths = data.getElementsByTagName("path");
                           var types = data.getElementsByTagName("type");
                           var root = $("#list");
                           for (var i=0; i<paths.length; i++) {
                                  var type = "";
                                  if (types[i].textContent === "1") {
                                      type = "folder";
                                  } else if (types[i].textContent === "3") {
                                      type = "next-report";
                                  } else if (types[i].textContent === "4") {
                                      type = "jasper-report";
                                  root.append('<li>'+paths[i].textContent+ ' (' + type + ')</li>');
            <span id="title">List of reports from path: </span>
            <ul id="list"></ul>

To be able to run this example you must be in the same domain as server, otherwise a cross domain exception will be seen in console. From NextReports Server 8.1 inside web.xml for jersey.springServlet you can uncomment the following to allow for cross domain testing calls (please be sure to comment it back after you make your tests):


Tuesday, 3 March 2015

NextReports Server: Analysis

NextReports Server 8.0 has a new module (section) called Analysis. To be able to create an analysis, users must run/schedule an ETL (extract transform load) process which gets data from a data source and brings it locally to A NoSQL database. This process is just a run type defined in export property:

Anytime an ETL process is run, all data for it is first cleared and then new data is brought on.

Inside analysis section, users can select from existing "analysis sources" to create new analysis. At the beginning all the columns are selected and users will see the entire set of data.

From this step, users can start to play with data. New columns can be created like string concatenations, mathematical expressions, aggregate functions:

Users can select and order the columns they are interested in:

 Users can sort, group and filter data:

Pagination is mandatory but can be modified to suit users needs:

After obtaining the results, users can save the analysis for future view. This is handy, because if there is a scheduled ETL  process that brings data locally, users are able to see updated data just by entering the analysis section.

Results can be exported as excel and can be frozen. A "freeze" action means the data set is saved as a copy inside NoSql database and no other ETL process can modify it.

Analysis can be shared to other users. If there is no need for it, analysis can be deleted. This process will also delete the data set associated with it if there is no any other analysis linked to that data set.

To find more, you should read the server section manual.