Latest features available in JasperReport Server 6.4

Latest features available in JasperReport Server 6.4

 
Following are the different features available in JasperReport Server 6.4
 
1. Export options for organization admins.
 
In JasperReport Server 6.3 only ROLE_SUPERUSER has export options but in JasperReport Server 6.4 export option is available for organization admins which is the User with ROLE as ROLE_ADMINISTRATOR.Now ROLE_ADMINISTRATOR have option to export.
 
1
 
2. Superusers have new option to export resources and folders with full resource path.
 
In JasperReport Server 6.4 superusers have new option to export resources and folders with full resource path.We have option to check/uncheck option for full source path while export.You can see the folder structure with check/uncheck full resource path after export shown below :

For example : If we export Adhoc Component with full resource path the folder sturcture will be :

C:\Users\helical010\Desktop\test\resources\organizations\Helical\adhoc\topics\

Without full resource path, in export will get path as below :

Capture

 
3. Organizational admins have access to include/exclude dependencies.
 
In JasperReport server 6.4 for Organizational admins, we have option to include/exclude dependency option while export this will help us if you dont want to override the previous resource changes while import.Let us assume
if you have your own datasource and you want to import same Resource having its own datasource which you dont want to override in such cases this will help you.
 
Capture

 
4. Dashlets have hyperlink control.
 
In JasperServer 6.4 dashboard , new functionality of hyperlink is provided for each dashlet shown below :
 
You use hyperlink control for dashlet we need to enable the hyperlink control
 
1
 
Hyperlink control provides different actions :
1. Update Page : On dashlet hyperlink(click), dashlet will get update.
 
Picture2
 
2. Open new page : On dashlet click, hyperlinked report/resource get open in new page.
 
Picture1
 

3. Replace page : On dashlet hyperlink click , dashlet get replace with another hyperlinked report.
 
Picture3
 
5. Undo-Redo action buttons changes in input control values.
 
In JasperServer 6.4 dashboard , undo-redo action buttons changes to input control values which we have set in dashboard input control.
 

 
6. More formatting options for text dashlets.
 
In JasperServer 6.4 dashboard , text dashlets have more formatting options.You can change the font type ,font size, alignments etc for text dashlets shown below :
 
1
 
We can set hyperlinks on text dashlets.To set hyperlink on text dashlet we need to enable the hyperlink as shown below :
 
1
 
In this way , we can do more formatting changes for text dashlets.
 
7. Include theme option while import option.
 
In JasperReport Server 6.4 include theme option is provided while import , if user dont want to include the theme he/she can uncheck the include theme option as shown below :
 
1
 
Hope it helps ūüôā
 

Thanks ,
Sayali | Helical IT Solutions

Hide logout option for externally authenticated users in JasperReport Server

Hide logout option for externally authenticated users in Jasper Report Server

  • An external user is a user outside of an organization who does not directly login to Jasper Reports Server.
  • JasperReports Server does not store the passwords of external users, and is not impacted by changes to user passwords or user password policies on the external authority only the login name is stored in an external user account.
  • In¬†JasperReports Server if you want to hide logout option for externally authenticated users, following are the steps to achieve it :



Used Jasper Report Server Version : 6.4.0

  1. Goto to path : \WEB-INF\decorators\
  2. Open the decorator.jsp file
  3. Comment below code :
  4.         <authz:authorize ifNotGranted="ROLE_ANONYMOUS">
            <li id="main_logOut" class="last" role="menuitem">
            <a id="main_logOut_link" tabindex="-1">
            <spring:message code="menu.logout"/>
            </a>
            </li>
            </authz:authorize>
         


  5. Add below code before commented code which check for externally authenticated user and hides the logout option for it :

  6. <c:set var="isExternallyDefinedUser" value="<%= ((com.jaspersoft.jasperserver.api.metadata.user.domain.User)SecurityContextHolder.getContext().getAuthentication().getPrincipal()).isExternallyDefined()%>"/>
    
    <c:if test="${!isExternallyDefinedUser}">
    
    <authz:authorize ifNotGranted="ROLE_ANONYMOUS">
    
    <li id="main_logOut" class="last" role="menuitem">
    
    <a id="main_logOut_link" tabindex="-1">
    
    <spring:message code="menu.logout"/>
    
    </a>
    
    </li>
    
    </authz:authorize>
    
    </c:if>
    


  7. Save decorator.jsp file

To test hide logout option for externally authenticated user :

  1. Custom authentication
  2. Manually update ‚Äúexternallydefined‚ÄĚ flag in database and test.

We can test hide logout option for externally authenticated user by second mentioned way :

  1. Connect to Jasperserver postgres database.
  2. Check users present in jasperserver by executing below query :

Select * from jiuser;

  1. You will get all users details which are present in jasper server , check the id of user to which you want to make it as externally defined user.
  2. Let us assume if you want to make testuser as externally defined user and its id is 65874 then to make is as externally defined user execute below query which set the ‚Äúexternallydefined‚ÄĚ flag/value to ‚Äút‚ÄĚ.

Verify the set flag value by executing Select * from jiuser;

  1. Now restart the jasperserver and its repository(postgres).
  2. Login to jasper server with superuser access through browser.
  3. Goto->Mange->Users and select testuser.
  4. Click on Login as User button.



Picture1

9.You will directly logged with testuser which don’t having the logout option .

 

Picture2

 

Thanks,

Sayali Mahale | Helical IT Solutions

Grouping in Jasper Report/Table

Grouping in Jasper Report/Table

Grouping in a canned report which can be developed in Jasper Studio is easily done in Cross-tab. Cross-tab can be used when a measure has to be calculated on more than one dimension and in that case it is simpler to use cross-tab. Limitation of using Cross-tab is that it has fixed lay-out and customization of look and feel gets complex. One can use grouping available in reports and tables in special cases like.

1. Displaying the groups in new page every time
2. when Header/ Footers need customization

Grouping in table


1.Right click on the dataset and click on add group

Capture1


Capture2

2. create variables and store calculated measure by aggregating(sum, count, etc…,) and set the property to ResetType as the Group created.

Capture3

3. Add row in the Group Header of the table.

Capture4

If required we can group the cells and make a single cell of the group as shown in the following

Capture5

4. Add row in the Group Footer of the table, drag and drop the variables in to respective cells.

Capture6

Grouping in Report


1.Right click on the report and click on add group, create group by giving the expression or selecting the fields.
NOTE: fields must be pulled in the main dataset query

Capture7

Capture10

2. create variables and store calculated measure by aggregating(sum, count, etc…,) and set the property to ResetType as the page.

Capture8


3. Add row in the Group Footer of the table, drag and drop the variables in to respective cells.

Capture9

Displaying the groups in new page every time

1. add the table into Page Header

Capture11

2. Set the property Start New Page

Capture12

Visualize.js ‚Äď Hyperlinks API

Visualize.js ‚Äď Hyperlinks

In the post, we will discuss how we can handle hyperlink execution in jaspersoft reports that are embedded using visualize.js.

If you have not worked on rendering reports through visualize js , this post may not be the best place to start. You may check this one out.

As we all know, jasper hyperlink’s are of various types – report execution, reference, local / remote anchor or pages. We will look into what information do we get about the hyperlinks in the embedded reports when we click on them and how we can utilize this information to take appropriate action on the event.

As an example, we will take one of the sample report from the jasper samples that come with the installation – SalesByMonthReport. I have made a small change to this report and added a hyperlink in the page footer of the type “reference” which opens “http://helicaltech.com/” webpage.

RenderedReport1

Below is the HTML and the Java Script Code for embedding the report using Visualize JS with hyperlink handling –
—- HTML —–

<!----- JQuery,underscore js is required for this code, has been included from external resources in jsfiddle--->
<script type='text/javascript' src="http://192.168.2.141:8082/jasperserver-pro/client/visualize.js"></script>
<div id="container"> Main report Appears here</div>
<div id="container2">Drilldown Appears here</div>

 I have created 2 place holder divisions, “container” to render the “SalesByMonthReport” report. This report has a drilldown report which opens when we click on any of the months in the table. When user clicks on any of these hyperlinks, we will display the drilldown report in “container2”

— Java Script —

var reportUri = "/public/Samples/Reports/SalesByMonthReport"
visualize({
    auth: {
        name: "superuser",
        password: "superuser"
    }
}, function (v) {
   var report = v.report({ 
        resource: reportUri, 
        container: "#container", 
        params:{"startMonth": ['1'],"endMonth": ['12']},  //defaults
        linkOptions: {
       	   beforeRender: function (linkToElemPairs) {
                linkToElemPairs.forEach(showCursor);
            },
            events: {
                "click": function(ev, link){
                    console.log(link);
                  if(link.type == 'ReportExecution'){
                  		v("#container2").report({
                            resource: link.parameters._report,
                            params: {
                                monthNumber: [link.parameters.monthNumber]
                            }, 
                        });     
                  }
                  else if(link.type == 'Reference'){
                  	window.open(link.href);
                  }
                }
            }    
        },
        success:function () {
            alert('Report rendered successfully');
        },
        error: function (err) {
            alert(err.message);
        }  
    });
    
   function showCursor(pair){
           var elink = pair.element;
               elink.style.cursor = "pointer";
    }
});

  Let’s concentrate on the “linkOptions” portion of the call to the Report API. It allows you to control the behaviour of the Hyperlinks.

beforeRender: function (linkToElemPairs) {
    linkToElemPairs.forEach(showCursor);
}

  In “beforeRender”, we are just trying to change the cursor type when mouse moves over the element which has the hyperlink. I am not going into details of this code. However, we can see that there is a way to add any logic that might be required before the links are rendered.

events: {
            "click": function(ev, link){
				console.log(link);
				if(link.type == 'ReportExecution'){
					v("#container2").report({
						resource: link.parameters._report,
						params: {
							monthNumber: [link.parameters.monthNumber]
						}, 
					});     
				}
				else if(link.type == 'Reference'){
					window.open(link.href);
				}
			}
	}

  In “events”, we can define the behaviour in case of various events, mainly the click event. Inside the click event callback function, we get access to the definition of the hyperlink on which click has happened. You basically get access to all the hyperlink properties that we define at design time.
In our example, we have 2 types of hyperlinks – report execution & reference. Lets see what we get for each of these types and what action we have taken on them using the information.

Report Execution : When user would click on the link on months in the table –

Hyperlink-Reference-report

Below is the JSON we get in the “link” parameter of the click callback (“click”: function(ev, link))

Hyperlink-ReportExecution

As you see, in our code, we check for “link.type” value and then in case it is “ReportExecution”, we use “link.parameters._report” & “link.parameters.monthNumber” values to call the Report API again and display the drilldown report in “container2”.

Reference : When user would click on the hyperlink in the page footer –

Hyperlink-ReportExecution-report

Below is the JSON we get in the “link” parameter of the click callback (“click”: function(ev, link))

Hyperlink-Reference

As you see, in our code, we check for “link.type” value and then in case it is “Reference”, we use “link.href” to open the hyperlink in a new window.

So, with this, we have successfully handled 2 different types of Hyperlinks that we come across in reports. Similarly, you can also write your logic to handle the other types as per your requirement.

JS fiddle of the example : http://jsfiddle.net/b42ax3m2/63/

You may also check the below blog links for learning about – authentication, report rendering, input controls API of visualize JS.
First encounter with Visualise.js
Visualize.js ‚Äď The Input Controls API

References:
Visualize JS API reference

– Shraddha
Helical IT Solutions

How to resolve mixed active blocked contents in error when configuring SSL

How to resolve mixed active blocked contents error when configuring SSL

What is Mixed Active Blocked contents ?

When anyone hits a page served over HTTP, their connection is open for eavesdropping and man-in-the-middle attacks. When a user visits a page served over HTTPS, their connection with the web server is authenticated and encrypted with SSL and hence safeguarded from eavesdroppers and MITM attacks. When an HTTPS page includes HTTP content, the HTTP portion can be read or modified by attackers, even though the main page is served over HTTPS. When an HTTPS page has HTTP content, we call that content ‚Äúmixed‚ÄĚ. The webpage that the user is visiting is only partially encrypted, since some of the content is retrieved unencrypted over HTTP.
The Mixed Content Blocker blocks certain HTTP requests on HTTPS pages.

How to avoid ?
The best strategy to avoid mixed content blocking is to serve all the content as HTTPS instead of HTTP.

So whenever there is a need of enabling SSL in webapplication , it should be properly handshaked with application server. Below is an example of Tomcat Server and steps –

1. Take backup of server.xml present in the below location –
<Tomcat_Home>/conf/

2. Add scheme and proxyPort attributes in the below tag –
<Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″
URIEncoding=”UTF-8″ scheme=”https” proxyPort=”443″/>

3. Restart Tomcat

Thanks,
Rupam Bhardwaj

Using Multi-select parameter in Jasper


Using Multi-select parameter in Jasper

Parameters can be the filter conditions which can be applied in the data-visualizations. This bog gives steps wise description of creating a multi-select parameter while developing report.

There are 2 different types of Parameters
1. Single select
2. Multi-Select

creating Parameter in Jasper Studio:

For Example there are employees in a department and a report generates the employee details department-wise. If the user wants to view employees from more than 1 department user can create multi-select parameter in that case.

Following are steps to create a parameter

step1: In the outline to the left side of the jasper studio we can find parameters. Right-clcik and create a new parameter.for eg: lets create a parameter with name “dept” and in the class definition we must give “java.util.Collection”, we can also give default values it is optional.

Capture1

step2: In case we are using sub-report or the table component we need to pass the same paraeter with same name to the sub-report/table. In the above example we are using table. Click on table in the table component and in the properties pane select dataset table u will find the following

Capture2

step3: Then add the parameter from main report to the table/subreport.
and click on finish.
Capture3

step4: Using the parameter in the query. following is the syntax for using multi-select parameter in a query.

where $X{IN,d.department_id,dept}
Capture4

Thanks
Asha Bidiyasar

Neo4j : Graph Database

Neo4j : Graph Database

  • NoSQL graph database
  • Usecases : include matchmaking, network management, software analytics, scientific research, routing, organizational and project management, recommendations, social networks, and more.
  • Neo4j implements the Property Graph Model efficiently down to the storage level.
  • Neo4j provides full database characteristics including ACID transaction compliance, cluster support, and runtime failover, making it suitable to use graph data in¬†production scenarios.
  • Used for connected DB
  • Easy traversing of data(¬†Ex.Google+ , Facebook linkedin etc)
  • These applications contain lots of structured, semi-structured and unstructured connected data. It is not easy to represent this kind of unstructured connected data in RDBMS Databases.
  • Graph DBMS stores this kind of more connected data very easily. It stores each Profile data as a Node internally, it’s connected Nodes with adjacent nodes and they connect each other with Relationships.

 

Property Graph Model in Graph Database

  • The property graph contains connected entities (the¬†nodes) which can hold any number of attributes (key-value-pairs). Nodes can be tagged with labels representing their different roles in your domain. In addition to contextualizing node and relationship properties, labels may also serve to attach metadata‚ÄĒindex or constraint information‚ÄĒto certain nodes.
  • Relationships¬†provide directed, named semantically relevant connections between two node-entities. A relationship always has a direction, a type, a¬†start node, and an¬†end node.
  • Relationships have quantitative properties, such as weights, costs, distances, ratings, time intervals, or strengths.

 

Graph entities in Neo4j :

Nodes              : Acts as row

Label                : Acts as table

Relationships     : Acts as joins

Properties          : Acts as column name

Note : Nodes are directed but relationships can be navigated.

 

Properties of Graph database:

  • No broken links
  • A relationship always has a start and end node, you can‚Äôt delete a node without also deleting its associated relationships.
  • You can also always assume that an existing relationship will never point to a non-existing endpoint.

 

Installation steps of neo4j  for windows:

  • Download .exe or .zip file.
  • Install Neo4j from official website.
  • Run its exe file.
  • Set DB location for neo4j and start server.
  • You can access neo4j in browser using link : http://localhost:7474/browser/¬†with default
  • ¬†User and Password:neo4j

 

Note : You need to set new password and then again you can connect to Neo4j.

 

To install neo4j  on ubuntu refer below links :

https://www.digitalocean.com/community/tutorials/how-to-install-neo4j-on-an-ubuntu-vps

 

http://www.codiply.com/blog/standalone-neo4j-server-setup-on-ubuntu-14-04/

 

Following are some Cipher Query Language syntax used in Neo4j :

Capture3

                                                Figure:1

Following are some neo4j cypher queries compared with mysql queries for better understanding :

Capture1
Capture2

                                                                 Figure : 2

Hope you will get how cypher queries differs from mysql.

 

 

Thanks ,

Sayali.

 

Create A Custom Table Report using Helical Insight (Dynamically Picking the Columns Names and Data)

Create A Custom Table Report using HI (Dynamically Picking the Columns Names and Data)

If you have already had a Hands-On experience on the Helical Insight Tool [HI tool] then this blog would be helpful

For a creating a report there are 4 files required
1. EFW
2. HTML
3. EFWD
4. EFWVF

the Report Layout lies on the HTML page, the SQL queries lies within the EFWD file and the visualization lies in the EFWVF File.
Hence once the Query is fired it comes to the visualization file to create a table as that’s our goal. With the help of the following code below it can be created with ease.

The below code here is a template of our EFWVF looks like
<Charts>
<Chart id=”1″>
<prop>
<name>Table</name>
<type>Custom</type>
<DataSource>1</DataSource>
<script>

//Your Visualization Code Goes Here

</script>
</prop>
</Chart>
</Charts>

Chart ID here is 1 which is unique
Type is of custom
DataSource 1 is the Unique ID defined in the EFWVF File. ie (<DataMap id=”1″ )
Now within the <script> </script>
we Paste the following:

<![CDATA[
//The If Block Does Return A Message NO Data when there is No Data
if(data.length == 0)
{
$(‘#chart_1′).html(“<div ><h4 style=’text-align:CENTER;color:black; padding-top:60px;’>No Data Available For Current Selection</h4></div>”);
return;
}
//The Else Block Returns The Table if there is a Table
else
{
//Here the funtion Tabluate Returns the Data in Tabular Form
function tabulate(elem, data, columns)
//Function Start
{
var table = d3.select(elem).append(“table”)
.attr(“class”,” table display compact width:100%;cellspacing:1 “)
.attr(“id”,”table”)
thead = table.append(“thead”),
tbody = table.append(“tbody”);

//Append the header row
thead.append(“tr”)
.selectAll(“th”)
.data(columns)
.enter()
.append(“th”)
.text(function(column) { return column; })
.attr(‘class’, function(d, i){ return “colH_” + i; })
.style(‘background-color’,’#ededed’)
.style(‘color’,’black’)
.style(‘@media print’,’display:none’)
.style(‘padding-left’,’25px’);

// create a row for each object in the data
var rows = tbody.selectAll(“tr”)
.data(data)
.enter()
.append(“tr”);

// create a cell in each row for each column
var cells = rows.selectAll(“td”)
.data(function(row) {
return columns.map(function(column) {
return {column: column, value: row[column]};
});
})
.enter()
.append(“td”)
.text(function(d) { return d.value; })
.attr(‘class’, function(d, i){ return “col_” + i; })
.attr(‘align’, ‘left’)
return table;
//Function END
}

//Render the table
//Object.keys(data[0]) is the Data to fetch the Column Header
//data has the data of the Table
console.log(Object.keys(data[0]));
var subjectTable = tabulate( ‘#chart_1’, data, Object.keys(data[0]));
}
]]>
Save it in the same Directory with rest of the file

Run your report on HI and you get a table.

Keep in mind you can change the query and still get the new columns from the new query.

Thanks
Sohail Izebhijie

Change Hive metastore from derby to MySQL

 

Change Hive metastore from derby to MySQL

 

Machine : UBUNTU-14.04 |  Hive :  HIve 1.2.1

To change Hive Metastore from Derby to MySQL we need to follow these 8 simple steps,

 

Step-1 :

First we need to install Mysql and its dependencies on system.

Command-1 : sudo apt-get install mysql-server

Note: Click Next > Next and set the password for MySQL.

Command-2 :  sudo apt-get install libmysql-java

 

Step-2 :

Create soft-link for connector in Hive lib directory.

Command-1 : ln -s /usr/share/java/mysql-connector-java.jar $HIVE_HOME/lib/mysql-connector-java.jar

 

Step-3 :

Access your MySQL and create one new database metastore for hive,

Command : $ mysql -u root -p

Enter password:

mysql> CREATE DATABASE metastore;

 

Step-4 :

Then we need one MySQL account for Hive to access the metastore. It is very important to prevent this user account from any type of change in schema.

Command :

mysql> CREATE USER ‘hive’@’%’¬†IDENTIFIED BY ‘password’;

mysql> GRANT all on *.* to ‘hive’@localhost¬†identified by ‘password’;

mysql>  flush privileges;

 

Step-5 :

Now we need to configure Hive to access MySQL metastore, for this we need to update hive-site.xml file(If file does not exist then create a new one)

<configuration>

<property>

<name>javax.jdo.option.ConnectionURL</name>

<value>jdbc:mysql://192.168.8.99/metastore?createDatabaseIfNotExist=true</value>

<description>metadata is stored in a MySQL server</description>

</property>

<property>

<name>javax.jdo.option.ConnectionDriverName</name>

<value>com.mysql.jdbc.Driver</value>

<description>MySQL JDBC driver class</description>

</property>

<property>

<name>javax.jdo.option.ConnectionUserName</name>

<value>hive</value>

<description>user name for connecting to mysql server</description>

</property>

<property>

<name>javax.jdo.option.ConnectionPassword</name>

<value>password</value>

<description>password for connecting to mysql server</description>

</property>

</configuration>

 

Note: While updating please take all properties-tag only.

 

Step-6 :

Now we need to run the Hive schematool to initialization MySQL metastore.

For this we need to go to $HIVE_HOME>bin> folder

Command-1 : schematool -initSchema -dbType mysql

Note : When you have found that your metastore is corrupted, then we need to update metastore.

  • Before you run hive for the first time, run

Command : schematool -initSchema -dbType mysql

  • If you already ran hive and then tried to initSchema and if it’s failing:

Command : mv metastore_db metastore_db.tmp

You find your metasore_db file at $HIVE_HOME location.

  • Re run

 

Step-7 :

Start your Hive and access your tables.

 

Step-8 :

To validate it ,

Connect and open your hive

hive>

Then create a table in it and insert one record.

hive> create table saurzcode(id int, name string);

hive> insert into¬†saurzcode(1, ‚ÄúHelical‚ÄĚ);

Later access your MySQL and open metastore database

mysql -u root -p

Enter password:

mysql> use metastore;

And see your table as a record in TBLS table of metastore database.

mysql> show tables ;

mysql> select * from TBLS;

 

Hurray, Completed !!!!

 

Thanks for visiting , Have a great day.

PUSHPRAJ KUMAR 

LATERAL JOIN

LATERAL JOIN

Lateral join is a very incredible feature in Postgres (Postgres 9.3+) .The LATERAL key word can precede a sub-SELECT FROM item.  It allows the sub-SELECT to point to the  columns of FROM items that appear before it in the FROM list.  We can say it’s used for cross-referencing.It basically allows sub queries in the right-hand-side of the join to reference columns defined in the left-hand-side of the join.

It can be explained from a simple example :

Suppose there is a business scenario where you want to just check whether a set of people belong in one subclass or not. And accordingly we have do the manipulations in the outer query.

Select * from
(Select ¬†empid , case when ¬†x.flag = ‚Äė1‚Äôthen ‚ÄėYES‚Äô else ‚ÄėNO‚Äô end as check from getempdata (‚Äė04/03/2017‚Äô))base¬†¬† —– getempdata is the function

left join lateral

(select¬†case¬†when¬†pbe.benefitsubclass in¬†(‘6Z’,’6Y’) then¬†‘1’¬†end¬†as¬†flag , pbe.personid , pbe.benefitsubclass,pbe.monthlyamount as¬†amt1, pbe.monthlyemployeramount as¬†amt2

from person_bene_election pbe

where  base.empid = pbe.personid

and current_timestamp between pbe.createts and pbe.endts

and¬†to_date(’04/03/2017′, ‘mm/dd/yyyy’) between¬†pbe.effectivedate and¬†¬†pbe.enddate

and¬†pbe.benefitelection in¬†(‘E’,’T’)

and¬†pbe.benefitsubclass in¬†(‘6Z’)

)x on x.personid = base.empid

Left join lateral allows us to use the empid from the function in left side of the lateral join to be used for reference in the right side.
Also with the left join lateral returns multiple rows , and also the flag column used in select  of lateral join is  used in the main FROM CLAUSE.

In a gist, lateral  allows you to perform a sub-query in the FROM clause and reference column values from other records in the query. It is similar to a correlated subquery in that it can reference values from another query.

It has some advantages over the the correlated subquery , it can return multiple rows and can be used in the From clause.