Wednesday, August 24, 2011

Moving around with widgets

Version 4.1 of NextReports was out. We are looking now to the following 4.2 release.

A small, but important new feature will be the possibility to copy or move a widget from a dashboard to other dashboard. Do you have some nice dashboards with cool widgets and you want to make another dashboard and share it to other users? Now this task will be easier.

A new action "Copy / Move" can be found in the widget toolbar, before "Delete" :


This action allows to select your action (copy or move) and to execute it for the selected dashboard :


Wednesday, August 03, 2011

JColorChooser History

JColorChooser in java can be used to select a color from "Swatches", "HSB", "RGB" panels.  But only "Swatches" tab has a history of recent used colors. We want to have a global history for selected colors.

For that we have to add another panel in a JColorChooser (like ExcelPalette).  In java you have to create a new class which extends AbstractColorChooserPanel:
public class HistoryColorChooserPanel extends AbstractColorChooserPanel {          
         @Override
         protected void buildChooser() {    
                //  here you add your UI components
         }
}
To use it:
AbstractColorChooserPanel[] panels = chooser.getChooserPanels() ;
// create a new array of panels containing also your panel
chooser.setChooserPanels(newPanels);


Anytime a color is selected from any tab except "Color History", that color is added to history as the top-left color from the matrix, and all the other colors are moved by a cell to the right.

At first glance it does not seem a "big" functionality, but when you think you want to use a number of colors to make your reports and charts look alike, this will help you a lot of time instead of entering again and again the same colors.

Friday, July 29, 2011

NextReports : Use hidden parameter inside another parameter

NextReports has a powerful support for parameters. You can have simple parameters, hidden parameters, chained parameters, procedure parameters. Parameters with values selected from table columns or from manual sources will have their type automatically selected. Parameters can have single or multiple selection. All of these will define how the user interface is created, what UI components will be used for selection.

Till version 4.1 only parameters used inside the main query had a meaning and were taken into account. New version will bring also a new feature regarding parameters usage.

A hidden parameter can now be used inside the source of another parameter without of being used inside the main query. Let's take a simple example.

We have a PROJECTS and a USERS tables. We want to select one or more projects for the user logged inside a NextReports Server, those projects which have the current user as project manager.

NextReports Designer has a special parameter __USER__ which has to be declared as following :


Value is passed to this parameter on the server and it means the name of the current logged user.
This parameter is defined as 'hidden', so it cannot be selected / modified from the UI.

We have to define our Project parameter and to use __USER__ parameter inside its source:


So, now we have a Project parameter which will filter data regarding to the logged user on the server. We design our report and we will use the Project parameter as a criteria :


The automatically created query inside the editor looks like this :
SELECT
    S1.PROJECT_ID,
    S1.NAME,
    S2.USER_NAME
FROM
    ANYTIME.SPP_PROJECTS S1,
    ANYTIME.SYS_USERS S2
WHERE
    S1.PROJECT_MANAGER_ID = S2.USER_ID AND
    S1.PROJECT_ID IN ${Project}
ORDER BY
    S1.PROJECT_ID 



Wednesday, June 22, 2011

Study Case : NextReports - A Real Time Exchange Rates Chart

From a developer's perspective, to have a real time chart, you need to have a database with real time data. We create a simple mysql database with only one table where we will insert currency values for every day (regarding our national currency RON).
create database currencies;

DROP TABLE IF EXISTS ron_values;
CREATE TABLE ron_values (
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    code varchar(3) NOT NULL,
    value decimal(10,4),
    exchange_date datetime    
);

First step to think of is where you get your data. We have this data offered in an xml file here: http://www.bnr.ro/nbrfxrates.xml. This file is changed every day except weekends and holidays.
The algorithm is pretty straightforward :
if (data_read_successfully) {
    get_list_of_currency_objects
    if (today_is_weekend_or_holiday) {
         // the currencies values will be the same like in previous day
         change_date_for_all_read_currencies_to_today
     }
     if (currencies_not_already_inserted_into_database) {
        insert_currencies_into_database
     }
}

We test if currencies were already inserted, because we do not want to depend on the date time when the xml file is updated, so our process can run lets say every hour or every minute.

After we have our real time data, we need to create our Next chart. First we define a currency parameter to see only exchange rates for a specific currency :



Parameter values are taken from a source sql which gives us all currency codes. We also have to put a default value for this parameter because our chart will be used inside a dashboard.



We want to see data for last 15 days and mysql query is :
Select DATE(RV.EXCHANGE_DATE) as EXCHANGE_DATE,
           RV.code,
           RV.value
From ron_values RV
Where RV.EXCHANGE_DATE Between DATE_ADD(CURDATE(), INTERVAL -14 DAY) And CURDATE()
and ${P_Currency} = RV.code
order by RV.EXCHANGE_DATE
We see how our defined parameter is used between curly brackets ${P_Currency}.
If we run the query we will be asked to select the value for currency parameter :



Result will show us all desired values :



After we have the query we will create a new chart. We will select EXCHANGE_DATE column for X_AXIS and VALUE column for Y_AXIS. We will select all properties we want like chart type, labels, colors, fonts, patterns, legends:


We can preview the chart inside designer to see how it looks like :


Then we can publish the chart to a server and we can add it to a dashboard. You can see this chart on our demo server http://demo.next-reports.com/nextserver on the NextSite dashboard.

Wicket Ajax Callback and FileUploadField

NextReports Server has an Upload action for different kind of reports.  Besides selecting report files and images, user has to enter a name for the report. We wanted to automatically set the name after selecting file (for lazy people), but this approach proved to be incorrect.

We had something like in the following snippet:
uploadField.add(new AjaxEventBehavior("onchange") {
               
     protected void onEvent(AjaxRequestTarget target) {
         Request request = RequestCycle.get().getRequest();
         String filename = request.getParameter("filename");
         String text = getModel().getObject().getName();
         if ((text == null) || "".equals(text.trim())) {
            int index = filename.lastIndexOf(".");
            if (index > 0) {
               filename = filename.substring(0,  index);
            } 
            getModel().getObject().setName(filename);                        
         }                    
         target.addComponent(name);
     }

     public CharSequence getCallbackUrl(boolean onlyTargetActivePage) {
         CharSequence callBackUrl = super.getCallbackUrl(onlyTargetActivePage);
         return callBackUrl + "&filename=' + this.value + '";
     }

}); 

Starting from IE8 and also in Chrome, but not yet in Firefox,  according to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is c:\fakepath.

So, we have to give up using this functionality.

Monday, May 23, 2011

NextReports Server : Drill Down Table Reports

Starting from version 4.1, NextReports Server will be able to define drill down process for table reports. The number of levels to drill down is infinite.

To link two table reports you need to have a link parameter and to specify the column position whose value will be pass to the next report in the drill process.


All values from the column will be represented as links and the drill-down will happen just by clicking one of them.




The path (shown as  the first column in the drill-down reports) will be composed from all the values clicked by user.

Tuesday, April 26, 2011

Friday, April 22, 2011

NextReports : empty elements in designer

Till version 4.1 of designer when a new report was created all new empty cells from  new rows or new columns were 'null'. That means when we select an empty cell no properties are seen in corresponding panel. Secondly, to merge one or more cells, only one cell must be not-empty and all the others must be null.

These facts make it harder to accomplish layout formatting for your reports.

Starting with 4.1 version, when new empty cells are created, they will be by default text-based with an empty string. The only case in which a band element is null  is in a cell span.


The most important advantage is that we can start to format the cell immediately, we do not need a previous step of inserting an empty string. Practically the following business was modified :
  1. merge algorithm allows to merge cells with empty string
  2. insert row & insert column actions from layout and from tree will insert band elements with empty strings
  3. merge action will nullify all cells without data (empty strings)
  4. unmerge action will insert empty band elements inside the 'null' ones
  5. add group action will insert empty band elements in header & footer
  6. new report action will insert empty band elements in footer row

    Monday, April 04, 2011

    NextReports Server - Single Sign On

    NextReports Server allows integration with all your applications through Single Sign On using CAS.

    To make this possible, NextReports defines a process which first brings the users into the content repository. A simple xml configuration will define synchronization process. You must specify your data source and your queries to get users names and users attributes (which allows to map any fields you may have to NextServer repository):
    <bean id="syncService" class="com.asf.nextserver.security.DatabaseExternalUsersService">
            <property name="dataSource" ref="syncDataSource"/>
            <property name="userNamesQuery">
                <value>SELECT USER_NAME FROM USERS</value>          
            </property>       
            <property name="userQuery">
                <value>SELECT * FROM USERS WHERE USER_NAME = ?</value>
            </property>
            <property name="mapping">
                <map>
                    <!--  required -->
                    <entry key="user.username" value="USER_NAME"/>
                    .......
                </map>
            </property>
    </bean> 
    
    
    To define your CAS , a validation ticket must be written which will inform about cas login and cas logout urls:
    <bean id="tValidator" class="com.asf.nextserver.web.security.cas.CasServiceTicketValidator">
            <constructor-arg index="0" value="https://myurl:myport/cas"/>
            <property name="loginUrl" value="https://myurl:myport/cas/login"/>
            <property name="logoutUrl" value="https://myurl:myport/cas/logout"/>
    </bean> 

    Monday, March 28, 2011

    Remote JDBC driver in NextReports 4.0

    NextReports 4.0 has been released.

    From this version, both designer and server will have the same major number. One of the new functionality from designer is the possibility to create a data source of type NextReports Server.

    This means designer will use a driver found on the server. You do not need the driver on your computer. This JDBC driver is implemented using Web Services.


    Driver's url has a special form jdbc:nextreports:@<server url>;<server data source>. When you edit the url you will have to select a NextReports Server and then you can browse the data sources tree on the server:


    To be able to browse the data sources, the user and password entered for driver connection will be used.

    This functionality is very important for companies which do not want to expose their databases.

    Friday, March 18, 2011

    NextReports Server : Profile Configuration

    NextReports Server uses a profile concept which is attached to users that are not administrators.

    A profile specifies two things :

    1. what sections can be seen by users with such profile

    NextReports Server has 7 sections : dashboards, reports, charts, data sources, monitor, scheduler and security. Any defined profile can contain one or more sections. By default , NextReports Server uses following profiles :

    ·         Analyst : all sections
    ·         Business user : Dashboards, Reports, Monitor sections
    ·         Reports : Reports and Monitor sections
    ·         Dashboards : Dashboards section

    2. what actions need to be hidden  for users with such profile

    Even if the actions are shown regarding the permissions on a specific entity (report, chart, data source and so on), some of them must be hidden for a profile.

    Configuration may be done in an xml file like this :
    <bean id="reportsProfile" class="com.asf.nextserver.security.Profile">
       <property name="name" value="reports"/>
       <property name="displayName" value="Reports"/>
       <property name="sectionIds">
          <list>                                 
            <value>section_class</value>
            . . .            
          </list>
       </property>
       <property name="hiddenActionContributorIds">
          <list>
       <value>contributor_class</value>
             . . .  
          </list>
       </property>
    </bean>    
    In this way it is very easy to add new profiles with your desired sections and visible actions making NextReports Server integration with your application as easy as possible.

    Tuesday, March 15, 2011

    NextReports Server : search for invalid sqls

    As inside NextReports Designer, NextReports Server 4.0 allows to look for reports or charts with invalid sqls.
    This is done from search action and it is the best way to find all such sqls  from a folder.

    Tuesday, March 08, 2011

    NextReports Server : Embedded Widgets revisited

    For generated iframe tag a width and a height parameters can be entered. They are passed to the open flash chart to draw at specified size.

    Thursday, March 03, 2011

    NextReports: check your sqls

    A needed feature to come in NextReports is sql validation.

    If some columns, tables or views where deleted or renamed, you can see a warning. Every query, report or chart can be checked without open it. But the real plus is when you do a bulk check on all your queries, reports or charts. In this way you can see very fast what sqls are not running anymore. And then you can open those, if any, and resolve the problem.

    'Validate Sql' action can be found inside explorer tree on one of the following nodes:
    1. any query, report or chart node
    2. queries root
    3. reports root
    4. charts root
    5. any folder found inside queries, reports or charts root
      All queries, reports and charts which are invalid will be seen inside explorer tree with warning bullets over their icons.

      Thursday, January 27, 2011

      NextReports : new page addon

      For pdf, rtf, excel exporters, a new page option is very important. NextReports allows to specify that after every group, a new page (sheet for excel) will start :


      From version 4.0, every row from layout has an action 'New page' :


      When you select this property, a small '+' bullet will be shown over row icon :

      NextReports : charts inside reports.

      Till version 4.0 charts could be exported only as flash, needing an internal server to allow for previewing. Because a chart image could not be created programatically, a chart could not be inserted inside a report.

      From 4.0 a chart can be also exported as a jpg image. Using this exporter, now it is possible to insert a chart inside a report (to be seen in HTML, PDF, RTF, EXCEL or saved in XML)  :


      A pdf result  (for chart data analysis part) looks like :


      A chart element is similar to an image  element, the only difference is that for chart the image is dynamically generated. So, a chart element can be resized similar to an image element.

      Tuesday, January 11, 2011

      NextReports : French Internationalization

      From version 4.0 NextReports will be also internationalized in french. N'hésitez pas à l'essayer.

      NextReports : Text Flat File with fixed-length columns

      NextReports 4.0 will bring a new type of file export, a simple text flat file. But instead of already existing csv and tsv types , this new "To Txt" exporter will allow to have fixed-length in characters for columns.

      To specify size in characters for columns a new action was created which is similar with size in pixels.


      Horizontal alignment property makes the text to be left-padded (for RIGHT value) or right-padded (for LEFT value). For CENTER value, text will be right-padded.

      Result will be like this (for left-padded values) :

      Wednesday, December 15, 2010

      NextReports : History Pagination

      NextReports Server has a Monitor panel where user can see all processes that are running and all scheduled processes that are active. Also , here it can be seen a history of all executed processes and if they finished successfully or not.

      History data has security permissions, meaning a user will see only history for those reports he has rights to.

      Problem: Because security is done using @Secured spring annotation :
      @Transactional(readOnly = true)
      @Secured("AFTER_ACL_COLLECTION_READ")
      public List getRunHistory() {... } 

      our data provider  has to load all history data , which will become time consuming soon enough. Pagination is used, but in this case it is only a mode to show less data at a time.

      Solution: History will be load only for the current day. A day filter is added to our history panel to allow for seeing history for any other previous day.

      Monday, November 15, 2010

      NextReports Server : Embedded Widgets

      NextReports Server 2.5 widgets have a new action called "Embedded Code". This action shows inside a panel an html code that can be inserted in any other web site page to view the corresponding widget. To accomplish that an iframe is used :

      NextReports Server : Widgets Cache

      NextReports Server allows from version 2.5 to define cache settings for all entities that can be added to dashboards : charts, table reports, alarm reports.


      Reports are represented with different icons to know which ones can be cached. In next picture, besides simple reports, we can spot alarms and tables.


      User can set an expiration time in minutes, if cache is used:


      So only on the first load, a widget will do a database call. Any refresh inside dashboards done for all widgets created from a dashbordable entity, will take the result from cache until it will expire, then it will hit the database and again for next calls result will be taken from cache until cache will expire again.

      Wicket, Open Flash Chart, HTTPS and Internet Explorer

      NextReports Server uses Open Flash Chart to present charts inside dashboards.

      After setting a https server, on Internet Explorer all the flash widgets showed a #2032 Error. Firefox was working as expected. This was obviously an Internet Explorer bug and the solution to it was to add two response headers : "Pragma" and "Cache-Control".

      Testing again, everything was ok, except refresh action. A refresh on IE wouldn't load the chart. The problem was IE cache. Also no drill down was possible because of this. The cache mechanism in Internet Explorer is different from that used by other browsers like Firefox. So we need to force IE to not cache flash. We add another response header "Expires" and set it to -1, and also we used "no-store" value  for "Cache-Control".

      Final solution was to use in our WebResource the following :
      protected void setHeaders(WebResponse response) {
          response.setHeader("Pragma", "public");
          response.setHeader("Cache-Control", "no-store, must-revalidate");
          response.setHeader("Expires", "-1");           
      }     

      Wednesday, November 03, 2010

      NextReports Designer : Choose Borders

      For previous versions, user can select for a cell which borders to see (top, left, right, bottom). All borders had the same thickness (thin, medium, thick) and were black.

      Starting with 3.5 version, border chooser was improved  :
      • user can select a different thickness for every type of border
      • user can select a different color for every type of border

      Exports in HTML, EXCEL, PDF and RTF can generate now colored borders.

      Monday, October 25, 2010

      NextReports : Alarms

      NextReports Server dashboards can contain charts and tables. Tables are a specific type of reports with a column header and data. In next release, dashboards will contain also alarms.

      An alarm is also a specific type of report created with NextReports Designer. Such report they must have two cells in the detail band:

       
      • First cell is a column (status) with formatting conditions for background color.
      • Second cell is an expression "if .. else .." which returns a different message for every known status (column value)
      On the server, first cell is drawn as a status led which will have the color the same with cell background color. The message will be shown next to the image.

      For example, the formatting conditions for the first cell can be :



      This image shows that for a value <= 0 , background color is red, otherwise background color is green. Expression in the second cell is defined as :
      if ( $C_NUMBER_PC <= 0 ) {
          "Alarm!";
      } else {
          "Ok";
      } 

      On the server, the result will be like this :


      To publish a report to server as an alarm, a new property called 'alarm' was added.


      NextReports : Report Distribution

      For versions until 2.4 , NextReports Server  allows only mail distribution. Generated reports can be sent through mail to a list of recipients. Mails can contain a link to generated report or the entire report as an attachment.

      For upcoming  version, a report can be distributed to one or more destinations. Mail destination is like in previous versions :


      User can see now a list of all configured destinations :


      Other destinations that can be created are FTP, SSH, Windows Share and WebDAV. Configuration for FTP and SSH is similar :


      For WebDAV, user can also specify if connection uses https. For Windows Share, in addition to FTP, user can  optionally enter a domain property. Destinations also have a Test button to see if they are valid.

      Tuesday, September 21, 2010

      NextReports Drill Down Charts

      NextReports Server is able to show drill down charts inside dashboards. The number of levels to drill down is infinite.

      To create drill down charts use "Drill Down" action on chart entities. This action is visible if the user has write permission on that chart :


      If a chart has at least one drill down chart , the chart icon will show this through a "link" bullet.

      For our example we have a chart which shows the projects (x axis) and number of hours for every project (y axis). First drill down chart will show the number of hours worked by each employee. To create this first drill we add the chart with a "project" link parameter which contains the project name x axis value.


      Second drill down chart will show the number of hours for each workcode for selected project and employee. To create it we add a chart with an "employee" link parameter which contains the employee name x axis value.


      For every drill down level all selected parent parameters will be passed. In our example, for second drill down chart, the project name will be also passed along with employee parameter.

      The drill down chart panel shows all the added charts:


      From here we can also delete drill down charts.

      When we add the ProjectHoursBar chart to a dashboard, we won't see any difference to a simple chart.


      But because this chart was created with a 2-level drill down functionality, we can select one project with the mouse and the next drill down chart will be shown :


      Here, under the toolbar, a link called "Up" is visible allowing for returning to the parent chart. We can select now an employee and we will see the workcode hours for that employee working in previously selected project :


      You can view this on the online demo.

      Wednesday, September 01, 2010

      NextReports Layout Zoom

      Version 3.4 of NextReports Designer makes use of moving to Java 1.6 and brings a wanted feature.

      Report Layout can be zoomed between 50% and 300%. Values outside this range were not considered suited for designer. A zoom can be done with the spinner in the top right corner or with the CTRL + mouse wheel, same way as browsers zooming.


      This feature is most useful if font size for a cell is too small. If that cell also contains a database column , the user interface combobox popup will have items which cannot be understand. By zooming the layout, this is not true anymore and user can see what he is doing.