Tuesday, February 25, 2014

NextCharts: Combo Bar Line Charts

NextCharts supports bar and stacked bar combo charts. This means there can be more series inside a chart some bars / stacked bars, some lines.

A simple stacked bar json like:
{
   "type":"stackedbar",
   "style":"glass", 
   "data":[[16,66,24,30,80,52],[48,50,29,60,60,58],[30,40,28,52,34,50]],  
   "labels":["JAN","FEB","MAR","APR","MAY","JUN"], 
   "color":["#004CB3","#A04CB3","#7aa37a"],
   "legend":["2011","2012","2013"],
   "alpha":0.6, 
   "showGridX":true, 
   "showGridY":true, 
   "colorGridX":"rgb(0,198,189)", 
   "colorGridY":"rgb(0,198,189)", 
   "message":"Value #val from #total", 
   "tickCount":4,
   "title":{
        "text":"Financial Analysis",
        "font":{"weight":"bold", "size":16, "family":"sans-serif"},
        "color":"blue",
        "alignment":"center"
   },        
   "xData":{
        "font":{"weight":"bold", "size":14,"family":"sans-serif"},
        "color":"blue"
   },                          
   "yData":{
        "font":{"weight":"bold","size":14,"family":"sans-serif"},
        "color":"blue"
   },
   "xLegend":{
        "text":"Month",
        "font":{"weight":"bold","size":14,"family":"sans-serif"},
        "color":"#993366"
   },"
   "yLegend":{
        "text":"Price",
        "font":{"weight":"bold","size":14,"family":"sans-serif"},
        "color":"#993366"
   }
}
will look like:

To add combo lines (2 lines in this example)  we should add some properties to json object:
{
...
 "lineData":[[31.33, 52, 27, 47.33, 74.66, 53.33],[100, 120, 53, 190, 40, 130]],
 "lineColor":["#270283", "#CC6633"],
 "lineLegend":["Average", "Profit"],
...
}
With these, we obtain a combo chart like:


Friday, February 21, 2014

NextCharts: Styles

Styles are different ways to show a specific kind of charts. These are different for bar and line charts.
For bars these can be normal, glass, cylinder, parallelepiped and dome. For lines these can be  normal, soliddot, hollowdot, anchordot, bowdot, stardot.

Lets take a simple horizontal stacked bar chart:

1. normal
2. glass
3. cylinder
4. parallelepiped
5. dome

A simple line chart:

1. normal
2. soliddot
3. hollowdot
4. anchordot
5. bowdot
6. stardot

Thursday, February 20, 2014

NextCharts: A Developer Perspective

NextCharts is "the new kid in town" for NextReports Suite. It is a simple and nice HTML5 library,  created with Javascript and JQuery, which can be used by developers to show different types of charts.

Charts are drawn on a HTML5 canvas and tooltips are shown on a different canvas. Chart is passed as a JSON object. You can call the chart drawing function using as parameters the json and the ids of the two canvases:
nextChart(json, idCanvas, idTooltipCanvas)
In this case the chart will have the size of the canvas as specified inside CSS/HTML.

You can also specify the width and height in pixels or as percents:
nextChart(json, idCanvas, idTooltipCanvas, canvasWidth, canvasHeight)
A simple HTML page that shows a NextChart can specify (through css) how the tooltip will look. In this example there is a url that serves a json:
<html>
<head>

<title>NextReports Chart</title>

<style type="text/css">
  .tip {
    background-color:white;
    border:1px solid gray;
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    position:absolute;
    left:-200px;
    top:100px;
  }
  
  .canvas {
   border: 1px solid gray;
  }
</style>

<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="js/nextcharts-1.0.min.js" type="text/javascript"></script>
<script>

 $.ajax({
     type: "POST",
     url: "data-html5.json",
     contentType: "application/json; charset=utf-8",
     dataType: "json",    
     success: function(data) {
         console.log(data);
         nextChart(data, 'canvas', 'tip');
     },
     error: function(jqXHR, textStatus, errorThrown) {
         alert("Error: " + textStatus + " errorThrown: " + errorThrown);
     }
});     
</script>
</head>

<body>
    <canvas class="canvas" id="canvas" width="500" height="300"></canvas>
    <canvas class="tip" id="tip" width="1" height="25"></canvas>
</body>

</html>

Following we are taking about Json object structure. As a minimal set of characteristics, only the data and type properties are needed.
{
   "type":"bar",
   "data":[[16,66,24,30,80,52],[48,50,29,60,70,58],[30,40,28,52,74,50]],    
}
This will generate a bar series chart:

Type property can take a value from:  bar, stackedbar, hbar, hstackedbar, line, area, pie.

If you do not specify even type, then by default line is used.

Lets add some labels and change the colors:
{
   "type":"bar",
   "data":[[16,66,24,30,80,52],[48,50,29,60,70,58],[30,40,28,52,74,50]],
   "labels":["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE"],
   "color":["#004CB3","#A04CB3","#7aa37a"]
}
Lets change the style and add some alpha to colors:
{
   "type":"bar",
   "data":[[16,66,24,30,80,52],[48,50,29,60,70,58],[30,40,28,52,74,50]],
   "labels":["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE"],
   "color":["#004CB3","#A04CB3","#7aa37a"],
   "style":"glass",
   "alpha":0.6
}
Style property can have different values for different chart types. For bar charts it can be one of the following: normal, glass, cylinder, dome, parallelepiped. For line charts it can be: normal, soliddot, hollowdot, anchordot, bowdot, stardot.

Lets hide the grid and add a legend:
{
   "type":"bar",
   "data":[[16,66,24,30,80,52],[48,50,29,60,70,58],[30,40,28,52,74,50]],
   "labels":["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE"],
   "color":["#004CB3","#A04CB3","#7aa37a"],
   "style":"glass",
   "alpha":0.6,
   "showGridX":false, 
   "showGridY":false,
   "legend":["2011 First year of work","2012 Second year of work","2013 Third year of work"]
}

Lets change labels fonts and colors and show a title:
{
   "type":"bar",
   "data":[[16,66,24,30,80,52],[48,50,29,60,70,58],[30,40,28,52,74,50]],
   "labels":["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE"],
   "color":["#004CB3","#A04CB3","#7aa37a"],
   "style":"glass",
   "alpha":0.6,
   "showGridX":false, 
   "showGridY":false,
   "legend":["2011 First year of work","2012 Second year of work","2013 Third year of work"],
   "title":{
         "text":"Financial Analysis", 
         "font":{
              "weight":"bold", 
              "size":16, 
              "family":"sans-serif"
         }, 
         "color":"blue"
   },
   "xData":{
           "font":{
              "weight":"bold",
              "size":10,
              "family":"sans-serif"
           }, 
           "color":"blue"
   },
   "yData":{
           "font":{
              "weight":"bold",
              "size":10,
              "family":"sans-serif"
           }, 
           "color":"blue"
   }          
}

There are also other properties like:

tickCount: how many ticks are shown on y axis
message: message format for tooltip
tooltipPattern: a pattern for tooltip
background: background color
labelOrientation: x label orientation (horizontal, vertical, diagonal, halfdiagonal)
onClick: javascript function for click events

Friday, February 14, 2014

NextCharts: a new HTML5 library for NextReports

NextReports will reach a new version soon. A new year, a new major version. When I see 7.0 I have to say I am overwhelmed that NextReports starts its seven year. Looking behind, every release brought something new to make NextReports a tool for everyone. Evolution was not a process to push features just to have them (because others have), but a smooth and natural process to help our users needs.

NextReports 7.0 will bring a new chart library called NextCharts. It is a simple HTML5 library created to fulfill the needs of our open source product. Before it, NextReports used a flash library called OpenFlashCharts. It was a very good free library which served well our purposes. But because flash support is loosing  ground in recent software development, it was time for us to build from scratch a new HTML5 library which also allows for other OS smooth integration like Android systems. It became cumbersome to scratch your head on how to add flash plugin on some Android devices.

NextCharts will support all the features NextReports used in chart layout, no compromises were made. Starting from here, it will also allow us to grow the number of chart types. For version 7.0 you can have horizontal stacked bars, bar-line combos and stacked bar-line combos. Also stacked bars can have now any style as simple bars: normal, glass, cylinder, parallelepiped, dome.


Old flash support was not yet removed, because there are some places where technology is slowly introduced and modern browsers with HTML5 support are not available. That's why if your "dinosaur" browser does not understand HTML5, on NextReports Server you will automatically see a flash chart. (you need to have the flash plugin). That's why in designer you will have both HTML5 and flash previews.

NextCharts will fit as a glove for NextReports Server. From user perspective nothing is changed. Anyway, following is a glimpse on how the new charts look:


Choosing right colors makes the difference. Having just a black background for charts will create something quite different:


When user creates the chart in designer, he can choose to preview as HTML5, flash or image. If browser version is not a problem, users can forget about flash. Newer chart types do not have a correspondence to flash, so if you are stick with flash, you are stick with the old set of chart types.


Stay tuned! NextReports 7.0 is coming soon!

Friday, January 31, 2014

Deploy NextReports Server on JBoss AS 7.1.1

NextReports Server comes bundled with Jetty server as default. If you want to deploy NextReports Server to other web server you should at first read the special section found inside the manual.

For some servers it is very easy to do:
1. put the war in the deployment folder
2. register reports as web context
3. add reports folder to classpath.

For JBoss there are more things to do:

1. You should create a nextreports-server.war folder and unarchive the war file here (Just putting the war file in deployment it won't work)

2. Create an empty file called nextreports-server.war.dodeploy near nextreports-server.war folder (This is needed to inform JBoss to make the deploy of the exploded folder)

3. Add in web.xml from nextreports-server.war\WEB-INF :
   <context-param>      
        <param-name>resteasy.scan</param-name>
        <param-value>false</param-value>
   </context-param>

   <context-param>
         <param-name>resteasy.scan.resources </param-name>
         <param-value>false </param-value>
   </context-param>

   <context-param>
         <param-name>resteasy.scan.providers </param-name>
         <param-value>false </param-value>
   </context-param>
   These are needed because JBoss uses Resteasy as REST library while Next uses Jersey and these two are in conflict. So we deactivate Resteasy.

4. Current version 6.3 of Next uses an older version of Jersey library (1.7) You should use a newer version (1.18) From version 7.0 of Next the needed version of Jersey will be used by default. So replace the jersey jars from nextreports-server.war\WEB-INF\lib

5. Add following ehcache.xml in nextreports-server.war\WEB-INF\classes
<ehcache>
    <diskStore path="java.io.tmpdir"/>

    <cache name="org.hibernate.cache.UpdateTimestampsCache"
           maxElementsInMemory="50000"
           eternal="true"
           overflowToDisk="true"/>

    <cache name="org.hibernate.cache.StandardQueryCache"
           maxElementsInMemory="50000"
           eternal="false"
           timeToIdleSeconds="120"
           timeToLiveSeconds="120"
           overflowToDisk="true"
           diskPersistent="false"
               diskExpiryThreadIntervalSeconds="120"
           memoryStoreEvictionPolicy="LRU"
            />
    <defaultCache
            maxElementsInMemory="50000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            />
</ehcache>

6. In nextreports-server.war\WEB-INF\classes\nextserver.properties modify  nextserver.home property as you wish.

7. In welcome-content folder from JBoss create reports folder (In this way reports is considered a web context). In server settings put this path to reports.home:  ../welcome-content/reports

Monday, January 20, 2014

NextReports Designer: Validate sql in version 7.0

NextReports Designer has a feature (action) which allows to validate queries, reports and charts regarding their query. Till 7.0 version, this validation only showed if something was wrong through a simple message and a warning icon inside browser tree.

From version 7.0, validation process will show as result what is wrong with the query (sql error message). If more queries are invalid, a list with all the errors is shown.


Validation process also takes care about parameters queries and sub-reports queries. This process does not show all errors from a single report (if there are more sql queries to test), but only the first.

This validation process becomes very useful if you have many reports / charts created on some database tables /columns and some table name or column name was changed. By using the replace button, you can automatically do a case sensitive or a case insensitive replace from designer.

Friday, December 13, 2013

NextReports: Creating the report programmatically

NextReports can be used to create a report programmatically. In our company, there was a need to have a report automatically created starting from a sql query and then run it using the engine api. Just think you have a set of data and a simple template which informs about layout properties (fonts, colors, padding and so on) and you want to bypass the process of creating a report using the designer.

To achieve this you have to create a Report object.
  Report report = new Report();
  report.setName("Report File Name"); 
  report.setSql("select ..."); 
  report.setLayout(createLayout(columnNames, "Title"));
The only thing you have to do is to create the ReportLayout:
 public static ReportLayout createLayout(List<String> columnNames, String title) {

        ReportLayout reportLayout = new ReportLayout();
        reportLayout.setReportType(ResultExporter.DEFAULT_TYPE);
        int size = columnNames.size();

        // create a row in header band with a title cell spanned on the entire row
        Band headerBand = reportLayout.getHeaderBand();
        List<BandElement> titleRow = new ArrayList<BandElement>();
        BandElement titleElement = new BandElement(title);
        titleElement.setColSpan(size);
        titleElement.setHorizontalAlign(BandElement.CENTER);
        titleElement.setVerticalAlign(BandElement.MIDDLE);
        titleElement.setPadding(new Padding(1,1,1,1));
        titleRow.add(titleElement);
        for (int i = 0; i < size - 1; i++) {
            titleRow.add(null);
        }
        List<List<BandElement>> headerElements = new ArrayList<List<BandElement>>();
        headerElements.add(titleRow);

        // create two rows in detail band: 
        // first with column names and second with ColumnBandElement cells
        Band detailBand = reportLayout.getDetailBand();
        List<BandElement> headerNamesRow = new ArrayList<BandElement>(size);
        List<bandelement> headerFieldsRow = new ArrayList<BandElement>(size);
        for (String column : columnNames) {
         BandElement he = new BandElement(column);
         he.setPadding(new Padding(1,1,1,1));
            headerNamesRow.add(he);
            BandElement ce = new ColumnBandElement(column);
            ce.setPadding(new Padding(1,1,1,1));
            headerFieldsRow.add(ce);
        }
        List<List<BandElement>> detailElements = new ArrayList<List<BandElement=>>();
        headerElements.add(headerNamesRow);
        detailElements.add(headerFieldsRow);
        
        // create an empty footer row
        Band footerBand = reportLayout.getFooterBand();
        List<List<BandElement>> footerElements = new ArrayList<List<BandElement>>();
        List<BandElement> footerRow = new ArrayList<BandElement>();
        for (int i = 0; i < size; i++) {
         footerRow.add(new BandElement(""));
        }
        footerElements.add(footerRow);

        headerBand.setElements(headerElements);
        detailBand.setElements(detailElements);
        footerBand.setElements(footerElements);               

        return reportLayout;
    }
  
This is the method used by "New Report" action from designer. You can choose any template properties to add on your BandElement cells.

After creating the report you can run it using the engine api or you can save it using  any ro.nextreports.engine.util.ReportUtil save methods.

Tuesday, November 19, 2013

NextReports Designer: View columns that have indexes

Even if NextReports Designer is a reporting tool and not a database tool, users asked to see what columns have indexes so they know if their queries are optimized or not.

From version 6.3 NextReports Designer will show indexed columns as an info icon

similar with those of primary keys and foreign keys. You can see this icon in "View Columns Info" action on any table:


You can also see this icon if you drag and drop a table in designer query perspective:

Monday, November 18, 2013

NextReports: Use reports to create portions of your web application

NextReports Server allows users to integrate charts & reports as iframes inside other applications using an embedded code.

If users do not want to use NextReports Server, there is also the possibility to use the generated reports inside iframes.

NextReports Server is implemented using Wicket framework. In Wicket , a simple document inline frame can be implemented to be used with an iframe tag inside html markup. This makes it very easy to use any Next report to show data from your database inside an application. After you have a NextReportPanel class like the one following, you do not need to write code to get particular data, you just have to create a report! and reuse this panel.

Lets say we want to see some report inside our web application.

The html file will look like:
<html>
    <wicket:panel>
        <iframe height="400px" wicket:id="report"></iframe>
    </wicket:panel>
</html>
Our Wicket component will be just a Wicket Panel. A ByteArrayResource just retrieves the report bytes which can also be cached if we want to. In this example we generate a HTML file:
public class NextReportPanel extends Panel { 
    private String reportName;
       
    // our object model (used to pass parameters to Next report)
    private Model model;
    
    // cache for report data per model
    private static Map<String, byte[]> dataMap = new HashMap<String, byte[]>(); 

    public NextReportPanel(String id, String reportName, IModel<String> model) {
        super(id);        
        this.reportName = reportName; 
        this.model = model;
        setRenderBodyOnly(true);
        add(new DocumentInlineFrame("report", new ReportResource()));
    }
    
    private String getModelId() {
        String id = "";
        if (model.getObject() != null) {
            id = model.getObject().getId();            
        } 
        return id;
    }    

    class ReportResource extends ByteArrayResource {
                
        private static final long serialVersionUID = -6307719094949487807L;
        private byte[] data;

        public ReportResource() {
            super("text/html");                    
        }
        
        @Override
        protected byte[] getData(final Attributes attributes) {            
            String id = getModelId();
            data = dataMap.get(id);            
            if (data == null) {                    
                data = generateReport();                
                dataMap.put(id, data);                
            }     
            return data;
        }                
        
        @Override
        protected void configureResponse(ResourceResponse response, Attributes attributes) {
            response.setCacheDuration(Duration.NONE); 
        }
              
        private byte[] generateReport() {            
            HashMap<String, Object> pValues = new HashMap<String, Object>();
            pValues.put("Id", getModelId());
            ByteArrayOutputStream output;
            Connection connection = null;
            Report report = getReport();
            try {
                output = new ByteArrayOutputStream();
                connection = ConnectionUtil.createConnection();
                FluentReportRunner.report(report).
                    connectTo(connection).
                    withQueryTimeout(60).
                    withParameterValues(pValues).
                    formatAs(ReportRunner.HTML_FORMAT).
                    run(output);                
                return output.toByteArray();
            } catch (Exception e) {
                LOG.error(e.getMessage(), e);
                return new byte[0];
            } finally {
                ConnectionUtil.closeConnection(connection);
            }
        }

        private Report getReport() {
            InputStream is = getClass().getResourceAsStream("/" + reportName);
            try {
                return ReportUtil.loadReport(is);
            } catch (LoadReportException e) {
                e.printStackTrace();
                return null;
            }
        }  
    }        
 }
This panel can be added in any page with different reports. To modify data (if users want to see more / less data) you will just have to modify the report! No source code modification!

Monday, October 21, 2013

NextReports: Search on google

In an older post we described what an External Drill is. What is not told there is that in  "Integration Settings" there is a property called "Drill Url". This is the base url used by all external links.

So we can set it for google web site:

Then, when we define an external  drill, we can put the relative url, in this case a search query for google site:

If no "Drill Url"is set inside "Integration Settings", the full url must be provided.

This means that inside our widget, when we click on second column (Employee):

 we will be redirected to a page with the results from google search:




Friday, October 11, 2013

NextReports: Some new things in 6.2 version

NextReports brings a few improvements in 6.2 version.

Cell formatting conditions allow to format that cell using an arbitrary expression value. Till now, only the value from that cell could be used.

You can see from the image above that user can choose between "Current value" of the cell and "Other value" which allows to enter an expression using any other report layout entities.

Report Layout can contain functions inside headers. Till now, functions could be added only in footers. So a rewritten Timesheet report for our demo will have the following layout :

and PDF result:

Server Alert definition can contain inside mail body the actual value for alarm or indicator. This must be specified through ${val} template string:


Wednesday, October 09, 2013

NextReports in an open source project!

This is a very important moment for NextReports. NextReports became an open source project. Engine and Designer were already free products and now are open source. But now, also, NextReports Server is free and open source.

You can find NextReports engine, designer and server on github. From there you can download sources, build the project and run designer and server.

NextReports Engine is found at https://github.com/nextreports/nextreports-engine. You can read the README to find how to build the engine.

Programmers can use maven now to get NextReports engine in their projects:
   <dependency>
      <groupId>ro.nextreports</groupId>
      <artifactId>nextreports-engine</artifactId>
      <version>6.2</version>
   </dependency>
A change was done in refactoring sources from com.asf.nextreports.* to ro.nextreports.*

NextReports Designer is found at https://github.com/nextreports/nextreports-designer. You can read the README to find how to build and run the designer.

NextReports Server is found at https://github.com/nextreports/nextreports-server. You can read the README to find how to build and run the server.

Server url was changed from http://<host>:<port>/nextserver to http://<host>:<port>/nextreports-server.

Also, when upgrading you must know the following. If you need some older version history for your reports, please keep a copy of your server data before upgrading, to be able to download that version from repository using older NextReports Server. Because refactoring was needed for open source, in the new version you cannot see the older version history of your reports. As a best practice install the new version in other folder and set your server to connect to a copy folder of your repository.

We kept on NextReports site , as always, native installers for Windows and Linux and demo samples for integration.

Friday, October 04, 2013

NextReports Designer: Hidden Gems

Today someone needed to add a line break inside an expression, and to see the result inside different formats like HTML, PDF, RTF, EXCEL.  This means the line break must be considered even if the column width is big enough to fill the entire text on a single row, so "wrap text" property is not useful in such situation.

For HTML , adding a simple <br> tag does the trick. An expression like

$C_First_Name + "< br >" +  $C_Last_Name

will show the expression from a cell with the needed line break:


But for other formats like PDF, RTF and EXCEL the solution was not so obvious. Trying with "\n" had no effect. The needed character was the unicode representation for line feed: "\u000A":

$C_First_Name + "\u000A" + $C_Last_Name 


This works for all three formats:




Monday, September 30, 2013

NextReports Designer: Check for updates

Until version 6.2 , NextReports Designer could be checked for new updates using proprietary Install4J process. This allowed the users to see if a new version was available, to download it and to run the installer immediately.

From version 6.2 we want to make the designer to not depend on such proprietary process. Changing this means the designer has to read the last version from an URI and if this version is new compared to the current version, it gives the user a link to the NextReports download page.


Even this is more minimalistic than the existing wizard in previous versions, the benefits will be seen on a long-term NextReports evolution.

Wednesday, August 21, 2013

NextReports Engine: Integration Demo Hints

After you download nextreports-integration-demo from NextReports Site, you can run some sample code to see how to use engine api.

To make it easily for every java developer, from version 6.2, you can define a DemoDefinition class for your database. You can see such class for a Firebird connection, where you define database name, report /chart name, map of parameters and  database connection:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class FirebirdDemoDefinition implements DemoDefinition {

 @Override
 public String getDatabaseName() {  
  return "Firebird Test";
 }

 @Override
 public String getReportName() {
  return "Projects.report";
 }

 @Override
 public Connection createDemoConnection() throws ClassNotFoundException, SQLException {
  Class.forName("org.firebirdsql.jdbc.FBDriver");
        String url = "jdbc:firebirdsql:192.168.16.32/3050:employee.fdb";
        System.out.println("Connect to '" + url + "'");
        return DriverManager.getConnection(url, "SYSDBA", "sysdba");
 }
 
 @Override
 public Map<String, Object> createDemoParameterValues() {
        Map<String, Object> parameterValues = new HashMap<String, Object>();
        return parameterValues;
 }
 
 @Override
 public String getChartName() {
  return null;
 }

}
You just have to add your definition to DemoDefinitionFactory class and inside DemoUtil class change your NextReports home and your definition:
public static final String NEXTREPORTS_HOME = "D:\\Programs\\NextReports 6.2";
    
public static DemoDefinition def = DemoDefinitionFactory.get(DemoDefinitionFactory.FIREBIRD_DB);
This will help to test faster your JDBC driver compliance with NextReports.

Monday, August 05, 2013

NextReports: add your JDBC driver

Starting from version 6.2 NextReports will allow users to add their own JDBC drivers. We are using Vertica JDBC driver here as example. In version 6.2 Vertica driver will be added by default.

Such process can be resumed by following steps :

1. JDBC jar driver is added inside lib folder (designer and server). From 7.0, designer has a jdbc-drivers folder.

2. Driver must be added in driver_templates.xml which can be found :
  • inside designer in installation folder in \lib\nextreports-designer-6.1.jar 
  • inside server in installation folder in \webapps\nextserver\WEB-INF\classes 

    Vertica
    com.vertica.jdbc.Driver
    jdbc:vertica://<server>:<port>/<database>
    5433    
 
3. You need to create a Dialect class for that type of driver. This dialect does a mapping between database types and java sql types and has some utilities methods.
import java.sql.Types;
import ro.nextreports.engine.util.ProcUtil;

public class VerticaDialect extends AbstractDialect {

    public VerticaDialect() {
     super();
     registerColumnType("binary", Types.BLOB);
     registerColumnType("varbinary", Types.BLOB);
     registerColumnType("bytea", Types.BLOB);
     registerColumnType("raw", Types.BLOB);
     registerColumnType("boolean", Types.BOOLEAN);
     registerColumnType("char", Types.CHAR);
        registerColumnType("varchar", Types.VARCHAR);
        registerColumnType("date", Types.DATE);
        registerColumnType("timestamp", Types.TIMESTAMP);
        registerColumnType("timestamp with timezone", Types.TIMESTAMP);
        registerColumnType("datetime", Types.TIMESTAMP);
        registerColumnType("smalldatetime", Types.TIMESTAMP);
        registerColumnType("double precision", Types.DOUBLE);
        registerColumnType("float", Types.FLOAT);
        registerColumnType("float8", Types.FLOAT);
        registerColumnType("real", Types.DOUBLE);        
        registerColumnType("bigint", Types.BIGINT);
        registerColumnType("smallint", Types.SMALLINT);
        registerColumnType("integer", Types.INTEGER);
        registerColumnType("int", Types.INTEGER);
        registerColumnType("tinyint", Types.INTEGER);
        registerColumnType("int8", Types.INTEGER);
        registerColumnType("decimal", Types.INTEGER);                
        registerColumnType("numeric", Types.NUMERIC);
        registerColumnType("number", Types.NUMERIC);
        registerColumnType("money", Types.NUMERIC);
        registerColumnType("time", Types.TIME);
        registerColumnType("time with timezone", Types.TIME);   
        registerColumnType("interval", Types.TIME);
    }

    public String getCurrentDate() throws DialectException {
        return "current_date";
    }
    
    public String getCurrentTimestamp() throws DialectException {
     return "current_timestamp";
    }
    
    public String getCurrentTime() throws DialectException {
     return "current_time";
    }

    public String getCurrentDateSelect() {
        return "select current_date";
    }

    public String getRecycleBinTablePrefix() {
        return null;
    }

    public String getCursorSqlTypeName() {
        return ProcUtil.REF_CURSOR;
    }

    public int getCursorSqlType() {
        return Types.OTHER;
    }

    public String getSqlChecker() {
        return "select 1";
    }
}
4. You must register the dialect in NextReports. To make this happen in designer and server you have to add some java VM parameters. (nextreports.vmoptions  file from designer and start-nextserver.vmoptions from server)
-Dnext.dialect.database_1="Vertica Database" 
-Dnext.dialect.class_1="mypackage.VerticaDialect"

First parameter must be the name taken from DataBaseMetaData.getDatabaseProductName().

If you need to register more dialects, you use different suffix indexes.

Wednesday, July 17, 2013

NextReports Sight: an Android client for NextReports Server (Part Three)

NextReports Sight can show your widgets one by one by choosing them from a list after a dashboard was previously selected. If "Expand info" setting is selected user will see inside any action some information:
  1. logged user inside dashboards list panel
  2. selected dashboard inside widgets list panel
  3. widget title inside widget view panel
That info can be expanded / collapsed by clicking on it.

For flash charts and drill widgets, users can click to see the value or to go to the next chart or table in the drill chain.

Widgets will auto-size if phone orientation is changed between PORTRAIT and LANDSCAPE.


Previous Parts
Part One
Part Two

Monday, July 15, 2013

NextReports Sight: an Android client for NextReports Server (Part Two)

After NextReports Sight server settings are configured, user can connect to it using his server credentials. The following must be ok:
  1. phone must be able to connect to internet
  2. NextReports Server must be up and running
  3. credentials must be correct
If connection succeeds,  user will be presented with a list of all Dashboards that he has rights to see (personal and shared).

By clicking a dashboard, user will see the list of all widgets inside dashboard. This list does not contain collapsed widgets. Type of widget can be identified by the left icon between table, alarm, chart, indicator, drill and pivot.


Previous Parts
Part One

Wednesday, July 10, 2013

NextReports Sight: an Android client for NextReports Server (Part One)

NextReports Server has a lot of functionality, but most important are dashboards, reporting, monitor and scheduling. Taking the first feature, dashboards, it can be very useful to look at your personal data using a mobile phone. To make it possible, without zooming on the web page inside your browser, a new client application for Android systems was created. This is called NextReports Sight and is a new member inside NextReports Suite applications.

NextReports Sight first version is able to communicate with a NextReports Server in order to bring your widgets to an Android gadget in a more viewable and enjoyable form. When you start the application a login is shown.



User must define inside application settings how to connect to NextReports Server through some server properties like protocol, domain and port. From Menu, users can select Settings and then a new panel is shown.


By default the demo version of NextReports Server is configured. Also inside settings there are two other properties: first will enable sounds inside the application, second will show by default some information expanded or not.

Because we need to communicate  with a server, the api used by the Android client must have a version equal or less than the server version. Required server version can be seen using About action.


Tuesday, June 25, 2013

NextReports: WebService Authentication

NextReports Server offers a web service api to be used by different client applications. To be able to use any web service, users have to login with their credentials, otherwise no calls can be made to the api.

NextReports Server uses Jersey for REST web service implementation and Spring Security for authentication and authorization. To make authentication possible,  Jersey integrates with Spring through a special servlet defined inside web.xml:

        jersey.springServlet
        com.sun.jersey.spi.spring.container.servlet.SpringServlet
        
            com.sun.jersey.config.property.packages
            com.asf.nextserver.api
        
        1



        jersey.springServlet
        /api/*
All web service calls are mapped to a special url pattern /api/*  so to apply security a filter-mapping is added in web.xml:

        spring.securityBasicAuthorizationFilter
        /api/*
Web Service client has a method to authenticate the user:
public boolean isAuthorized() throws WebServiceException
By default, Jersey has a big timeout value after a requests returns if no connection to the server is possible. All client applications need a smaller timeout, so a new method was added for this:
public boolean isAuthorized(int timeout) throws WebServiceException
where timeout is a value in milliseconds.