Monday, October 12, 2015

Customizing Pentaho Report Web viewer

Hi Friends,

We can customize the Pentaho report Web viewer  (Open .prpt report in New Window  after Publishing)

Usually we will get window something like below for Example:



But the client requested me to customize this viewer with below requirement.

1. By default the panel should be hidden
2. Auto-submit option should be invisible


To customize this viewer, We have to edit a file  called report.html that is available in the installation folder structure:

C:\Pentaho\server\biserver-ee\pentaho-solutions\system\reporting\reportviewer

In the above path we will have a file with name : report.html


Here I did not remove any code that is available in the file and I have just done some trick to achieve mentioned requirements.

We start with second requirement, We can set this at report designer level by selecting Master-Report
and set false to "Auto-submit".

Now to implement the firest requirement I have used below code:

require(['dojo/ready', 'reportviewer/reportviewer-app'], function(ready) {
      ready(function(){
        dojo.addOnLoad(function(){
          require(["dojo/query"], function(query){
            /* function tryHide(isHide){
              var autoComplete = $('#reportControlPanel label.auto-complete-checkbox');

              if(autoComplete.length>0){
                if(isHide)autoComplete.hide();
              }else{
                setTimeout(function(){tryHide(isHide)},100);
              }
            }*/

function loadReportOnLoad() {
if ($('#reportControlPanel .pentaho-button').length > 0) {
$('#reportControlPanel .pentaho-button').click();
                $(".dijitToggleButton>.dijitButtonNode").click();
 } else {
                 setTimeout(function(){loadReportOnLoad();},100);
 }

}
            //tryHide(true);// control hide/show autocomplete
loadReportOnLoad();
          });
        });
      });
    });



After adding the above code to the file, report viewer will looks like below sanp shot:







After Modification, you file should be something like below code:



<!DOCTYPE html>
<html xmlns:pho="http:/www.pentaho.com">
<head>
  <title>Report Web Viewer</title>

  <link rel="shortcut icon" href="images/favicon.ico" />

  <!-- Include CDF styles first to make sure they can be properly overridden -->
  <link rel="stylesheet" href="../../../content/pentaho-cdf/js-legacy/cdf.css" type="text/css" />

  <link rel="stylesheet" type="text/css" href="../../common-ui/resources/web/dojo/dijit/themes/pentaho/pentaho.css"/>

  <script type="text/javascript" src="webcontext.js?context=reporting"></script>

  <link rel="stylesheet" href="../../../content/pentaho-cdf/js-legacy/lib/jdMenu/jquery.jdMenu.css" type="text/css" />
  <link rel="stylesheet" href="../../../content/pentaho-cdf/js-legacy/lib/jdMenu/jquery.jdMenu.slate.css" type="text/css" />
  <link rel="stylesheet" href="../../../content/pentaho-cdf/js-legacy/lib/impromptu/jquery-impromptu.css" type="text/css" />

  <link rel="stylesheet" type="text/css" href="../../../content/common-ui/resources/web/dojo/dijit/themes/pentaho/pentaho.css"/>
  <link rel="stylesheet" href="../../../content/common-ui/resources/web/prompting/pentaho-prompting.css" type="text/css" />
  <link rel="stylesheet" href="../../../content/reporting/reportviewer/reportviewer.css" type="text/css" />

  <style>
  #reportControlPanel label.auto-complete-checkbox {
    display:none;
  }
  </style>

  <script type="text/javascript">

    var _isReportViewer = true;
    var _isTopReportViewer = true;
    try { _isTopReportViewer = ((window.parent === window) || !window.parent._isReportViewer); } catch(ex) { } // Ignore "Same-origin policy" violation in embedded IFrame
   
    var inMobile = false;
    try {
      var ua = navigator.userAgent;
      inMobile = ua.match(/iPhone/i) || ua.match(/iPod/i) || ua.match(/iPad/i) || ua.match(/Android/i);
    } catch(ex) { /*XSS*/ }

    var dojoConfig = {
      parseOnLoad: false,
      isDebug: true,
      disableFlashStorage: true
    };



    /**
     * This is called when a gwt module has been loaded. We depend on these so we'll defer loading of functionality until
     * modules have been loaded.
     */

    var gwtModuleLoaded = function(moduleName) {
      if (moduleName === 'formatter') {
        // Once the GWT JSTextFormatter is loaded we can depend on other modules we need and then load the report viewer

        require(['local'], function(local) {
          local.define('formatter');
        });

      }
    };


    try {
      if(window.top.showLoadingIndicator) {
        window.top.showLoadingIndicator();
      } else if(window.parent.showLoadingIndicator) {
        window.parent.showLoadingIndicator();
      }
    } catch(ex) { } // Ignore "Same-origin policy" violation in embedded IFrame
  </script>
  <script type="text/javascript" src="../../../content/common-ui/resources/web/formatter/formatter.nocache.js"></script>

  <script type="text/javascript">
    // Provide somewhere for cdf/simile/ajax/scripts/json to inject itself into
    var SimileAjax = {};

    var logger, logged;


    require(['dojo/ready', 'reportviewer/reportviewer-app'], function(ready) {
      ready(function(){
        dojo.addOnLoad(function(){
          require(["dojo/query"], function(query){
            /* function tryHide(isHide){
              var autoComplete = $('#reportControlPanel label.auto-complete-checkbox');

              if(autoComplete.length>0){
                if(isHide)autoComplete.hide();
              }else{
                setTimeout(function(){tryHide(isHide)},100);
              }
            }*/

function loadReportOnLoad() {
if ($('#reportControlPanel .pentaho-button').length > 0) {
$('#reportControlPanel .pentaho-button').click();
                $(".dijitToggleButton>.dijitButtonNode").click();
 } else {
                 setTimeout(function(){loadReportOnLoad();},100);
 }

}
            //tryHide(true);// control hide/show autocomplete
loadReportOnLoad();
          });
        });
      });
    });
  </script>
</head>

<body class="tundra body contentHidden">
<div id="toppanel" class="pentaho-transparent hidden">
  <div id="toppanelinner" >
    <div id="toolbarlinner2" class="pentaho-rounded-panel2-shadowed pentaho-padding-sm pentaho-shine pentaho-background">
      <div id="toolbar" data-dojo-type="dijit.Toolbar">
        <div id="pageControl" data-dojo-type="pentaho.common.PageControl" class="dijitInline"></div>
        <span id="toolbar-parameter-separator" data-dojo-type="dijit.ToolbarSeparator"></span>
        <div id="toolbar-parameterToggle" data-dojo-type="dijit.form.ToggleButton" iconClass="dijitEditorIcon dijitEditorIconParameters" showLabel="false">Parameters</div>
      </div>
    </div>
    <script type="text/javascript">
      if(inMobile) {
        document.getElementById('toolbarlinner2').innerHTML =
            '<div id="toolbar" style="display: -webkit-box">' +
                '<div id="toolbar-parameterToggle" data-dojo-type="dijit.form.ToggleButton">Prompts</div>' +
                '<div style="display: -webkit-box; -webkit-box-flex: 1; box-sizing: border-box; -webkit-box-align: center; -webkit-box-pack: center;">' +
                '<div id="pageControl" data-dojo-type="pentaho.common.PageControl" class="dijitInline"></div>' +
                '</div>' +
                '<div style="visibility: hidden" data-dojo-type="dijit.form.ToggleButton">Prompts</div>' + // TODO: What is this? A second button?
                '</div>';
      }
      // document.getElementById('toolbar-parameterToggle');
      var inSchedulerDialog = window.location.pathname.toLowerCase().indexOf('parameterui') >= 0;
      var getParams = function() { return prompt.panel.getParameterValues(); };

      var initSchedulingParams = function(filePath, validParamsCallback) {
        this.file = filePath;
        this.parameterValidityCallback = validParamsCallback;

        // We're not valid until the prompt is refreshed and tells us we are
        if (this.parameterValidityCallback) {
          this.parameterValidityCallback(false);
        }
      };
    </script>
    <div id="reportControlPanel" class="hidden pentaho-rounded-panel-bottom-lr pentaho-shadow">
      <div id="promptPanel" class="pentaho-rounded-panel-bottom-lr"></div>
    </div>
  </div>
</div>

<div id="reportArea" class="pentaho-transparent">
  <div id="reportPageOutline">
    <iframe id="reportContent" frameborder="0"></iframe>
  </div>
</div>

<div id="messageBox" data-dojo-type="pentaho.common.MessageBox" title="" style="width:400px; display:none;">
</div>
<div id="glassPane" data-dojo-type="pentaho.common.GlassPane">
</div>
</body>
</html>





Backing up Pentaho Server during Crash time.

Backing up the files of the Pentaho Suite:

NOTE: You must quit all Pentaho programs and stop all Pentaho-related services (including the BA Server, DI Server, Pentaho Enterprise Console, and the solution database) before creating backups. Do not start the services backup until it is complete

The easiest way to back up a directory is to create a compressed archive of it. 
  •  Generally on a Windows system you would use the Zip or RAR formats through programs like 7-zip or WinRAR.
  • On Linux, BSD, and Solaris, you would use GNU Tar or bsdtar.

No matter which program you use, you should end up with either one single file that encompasses the entire /pentaho/ directory (for graphical installer and archive deployments), or the /pentaho/ directory plus the pentaho.war file from your application server (for manual deployments).

Backing up the Pentaho Repository:

Using whatever tool you choose depending on your DB (Oracle, MySQL, or PostgreSQL).   Run a backup of the 'Hibernate' and 'Quartz' DB's/Schema's.   


If you have a backup of the /pentaho directory and the DB, you should be able to restore your system.   As to a backup schedule, that is completely up to you and your infrastructure requirements.

Backup of Pentaho 5.x
Steps for taking backup of the content
  1. Log in to the operating system of the server machine as the user that installed Pentaho 5.0.0. Using this user is important to avoid any issues with operating system file permissions.
  2. Stop the Business Analytics server.
  3. Take a complete database backup of the quartz, hibernate, and jackrabbit databases. If you're using Postgresql, use the command-line tool pg_dump in the postgresql bin folder. You will need to authenticate as the main database user for each database (jcr_user for jackrabbit, hibuser for hibernate, and pentaho_user for quartz). For example (from the command-line) - for the jackrabbit database:
"C:\Program Files\pentaho\postgresql\bin\pg_dump" -U jcr_user jackrabbit > %TEMP%\jackrabbit.dmp (Windows)
Or
postgresql/bin/pg_dump -U jcr_user jackrabbit > /tmp/jackrabbit.dmp (*nix)
If you're not using Postgresql, please use the tools provided by your database vendor to take full backups of those databases
4. Take a backup of full bi-server directory.
You can also use the import-export utility to backup content only
Follow the link below to Upload and Download from the BA Repository, Using the import-export utility Download the content to backup.

Data cache in Pentaho Report designer.

Hello Friends,

There might be situation where your Data source has been updated and your report still shows old data values.

For this again you need to login to Pentaho enterprise console and manually refreshing "Report Data".


How ever this is not possible every time and End user also not understand this.


So to avoid this, We have to make it fix at report designer level it self.

How we do that:

1. Open your report
2. Select Master Report
3. Go to Attributes and set "False" to   data-cache

Now your report will be able to show updated data from the data source. 

How to read images from database in Pentaho Report designer

Hello Friends,

If you want to display images that are stored in the database, then we have a component called "Image-Field" on existing tool kit at left side of the PRD work space.


Drag "Image-Field" to the work space and navigate to  "Attributes" section and select value for "Field".


If you have multiple images to be display then use the "subreport" concept and drag and drop this image filed to the details section and have multiple images to your report.




Set Dynamic Height to data in the Details Section - Pentaho Report

Hello guys,


If you are facing issues with alignments, here is a simple trick.

select all the fields available in the details section and  go to styles and make height as 100% (Adjust according to your requirement)

Do not forget to add % at the end.

So that if data for a particular field is more than we set before, now height will adjusted automatically with out having breaks on borders.




Passing Dynamic IP address in Pentaho Drill down Reports

Hi Friends,

I am going to explain today about how to specify dynamic IP address in pentaho drill down reports.


For example, I have a Parent-report.prpt and child-report.prpt, Now If I want to create drill down from Parent report to child report. we have to use the drill down function where we manually browse the Child report.

Once you manually browse the child report the drill down function looks like below function:


=DRILLDOWN("remote-sugar"; "http://192.168.10.104:8081/pentaho"; {"country"; [COUNTRY] | "::pentaho-path"; "/public/TEST/sub-report.prpt"})


In the above sample function when ever you try to drill down from parent report to child report, you will definitely redirect to specific path only.

 If you deploy the code on to another server.  And when you drill down from parent report to child report then it will automatically navigate to hard code IP Address. So to avoid this we have to specify environment variables available in the pentaho.

So you have to specify drill down function something like below function:

=DRILLDOWN("remote-sugar"; ["env::pentahoBaseURL"]; {"country"; [COUNTRY] | "::pentaho-path"; "/public/TEST/sub-report.prpt"})



Note:  This is a sample function only.
you have to configure web.xml with proper IP Address.


<context-param>
<param-name>fully-qualified-server-url</param-name>
<param-value>http://192.168.10.104:8080/pentaho/</param-value>
</context-param>

When you use drill down functionality with ["env::pentahoBaseURL"] , it will take URL specified in the web.xml

Wednesday, August 5, 2015

How to start Pentaho server at boot time on Linux server

Hi Friends,

In this post, I would like to give you details on how we start pentaho server at boot time on linux server.

Generally we have two scripts available under below path:

                            installation_directory/pentaho/server/biserver-ee  

start-pentaho.sh & stop-pentaho.sh

How ever we also can start pentaho server through another script called ctlscript.sh which is available in the below path:

                                     installation_directory/pentaho

Now we will see how to start pentaho server at boot time.
STEP1:
Login as a root user and create a init script in the path:  /etc/rc.d/init.d  and give any name to it. In my case I have assigned a name to init script as "pentaho"

STEP2:
Include the below code in the created file to start the server at boot time and to stop the server at OS shut down time.


#!/bin/sh
### BEGIN INIT INFO
# Provides: start-pentaho stop-pentaho
# Required-Start: networking postgresql
# Required-Stop: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Pentaho BA Server
### END INIT INFO

case "$1" in
"start")
su - root -c "cd /opt/Pentaho/ && ./ctlscript.sh start"
#su - pentaho -c "cd /home/pentaho/pentaho/server/enterprise-console && ./start-pec.sh"
;;
"stop")
su - root -c "cd /opt/Pentaho/ && ./ctlscript.sh stop"
#su - pentaho -c "cd /home/pentaho/pentaho/server/enterprise-console && ./stop-pec.sh"
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0

STEP3:
Now save this file and give execution permission by executing the below command.
                     
                                           #chmod +x pentaho
where pentaho is name of the init script.

STEP4:
Now to add init script to default run levels, we have to execute below commands.

chkconfig -add pentaho    --  This command to add our files

NOTE: chkconfig  -  updates  and queries runlevel information for system ser-
       vices


after adding the init script we have set the script to run levels.

 syntax:  chkconfig [--level levels] name <on|off|reset>

chkconfig --level 35 pentaho on     --- This command will set the init script to run at boot time 

Thanks

























Tuesday, August 4, 2015

How to install Pentaho on Linux server

Hi Friends, it is quite easy to install Pentaho on Linux server, before you proceed with downloading of pentaho from Pentaho Corporation. find out your OS type is of 32bit or 64bit.

for this try to execute the below command:

                                                  #uname -a

This command will display the details about your machine and then download the related bin file.
after once you get the installer file go to the folder location where it has downloaded.

Most probably it will be in Downloads Folder, So please navigate to that folder. and try running the installer file by using below syntax.

                   

                     Download#./pentaho-business-analytics-XXX-x64.bin

During installation it will prompts for password details and folder location where to install and proceed with agreement acceptance.

After successful installation, Console page will open for the first time and please log in as  Evaluator.

Refer the below image to get know about details:



How to disable Firewall in Linux server - Pentaho Server access problem

Hi Folks,

If you are facing any issue with accessing of any application that resides on Linux server, Please try to disable firewall and try to reload the page. try to execute the below command.  I have installed pentaho on linux machine and while accessing the Pentaho console remotely I could not able to connect So I just disabled firewall by using the below command.  Hope it will be helpful for you.


                                                   #iptables -F

iptable command: administration tool for IPv4/IPv6 packet filtering and NAT
And try to access the application now.


We use the command      "iptables"   to resolve these kind of issue, before you go directly to disable firewall on linux server better you try to know available options by executing the command

                                             #iptables -help

Monday, August 3, 2015

How to access/list/display files in USB/Flash memory through command prompt in Linux

Hi All, In this section I will be explaining how to access files that are available in USB/pen-drive through UNIX/LINUX command prompt.

First of all login as a root user.

STEP1:
We have to create a mount point, for this execute the below command
                         #mkdir -p /mnt/pen
STEP2:
Now we should mount the disk, for that run the mount command.
                        #mount /dev/sda1  /mnt/pen

This command will mount files to the targeted location.

After that use regular commands to list /mnt/pen

                                       #ls /mnt/pen

Data warehousing Concepts - Slowly changing Dimensions

Hi all,
Here in this section, I will be going to give you a brief explanation on Slowly changing dimension.

Introduction:

As the name represents it, When a dimension changes over time we call it as  a Slowly changing dimension.  We can handle this type of situation in 3 types. these are

SCD type 1
SCD type 2
SCD type 3

Say for example consider the below example.



Customer-id   Customer-name         Address
      12              Kullayappa           Kuala Lampur


Now after some months the customer's adress has been changed to Singapore. and now the data looks like below.

Customer-id   Customer-name         Address
      12              Kullayappa             Singapore

SCD Type 1: 
How SCD type1 approach deals now is, remove the historical data that has been presented and have the updated data only. In this case we could not able to track the historical data.

Example:

Customer-id   Customer-name         Address
      12              Kullayappa             Singapore

SCD Type 2:
SCD type 2 prefers to add a another record for new entry and identify those new records on version.

Example:
Customer-id   Customer-name         Address                 Version
        12              Kullayappa             Kuala Lampur           0
        12              Kullayappa             Singapore                  1

SCD Type 3:
SCD type 3 suggest to add one more column for the new record instead of adding extra record.

Example:

Customer-id   Customer-name         Previous_Address      Current_Address
        12              Kullayappa             Kuala Lampur               Singapore




Folks, I have typed on my own and excuse for my typo errors , I am providing details as per my knowledge.













Sunday, August 2, 2015

How to install pentaho on Linux server - Pre-requisites

Hi All,

In this section, I will be explaining how to install Pentaho on linux server. For this please find the Pre-requisites to be present on your machine.

1.Java should be there on you machine, if not please install the java.
2.Identify the version of your machine and try to download the pentaho files from pentaho corporation. 

Friday, June 5, 2015

Remove Non breaking space in data - Pentaho ETL

We often face a problem called "Non breaking Space" which is a common special character like space and other examples.

We can remove spaces by using TRIM function and in Pentaho ETL we have option to TRIM on both sides as well.

But this non breaking space is different kind of problem where TRIM function will never removes it.

For that we have to use a regular expression to remove "Non breaking space" in the data.

Using "Replace in String" step that is available in Pentaho use    \xA0 as a regular expression and then replace with non. it should be some thing like below image.  And all non breaking spaces in your data will be removed.




MongoDB server Failed to start : Detected unclean shutdown - /var/lib/mongo/mongod.lock is not empty

If you are unable to start the MongoDB server and getting below kind of error then the solution will here.


Simply delete the file mongod.lock that is available in the specified path and try to restart the server by executing the below command:

                                               #sudo service mongod start


Error Code:

2015-06-05T01:54:42.164-0700 I JOURNAL  [journal writer] Journal writer thread started
2015-06-05T01:54:42.552-0700 I NETWORK  [initandlisten] waiting for connections on port 27017
2015-06-05T02:04:07.193-0700 I CONTROL  ***** SERVER RESTARTED *****
2015-06-05T02:04:07.279-0700 E NETWORK  [initandlisten] listen(): bind() failed errno:98 Address already in use for socket:127.0.0.1:27017
2015-06-05T02:04:07.279-0700 E NETWORK  [initandlisten]   addr already in use
2015-06-05T02:04:07.281-0700 W -        [initandlisten] Detected unclean shutdown - /var/lib/mongo/mongod.lock is not empty.
2015-06-05T02:04:09.673-0700 I STORAGE  [initandlisten] exception in initAndListen: 98 Unable to lock file: /var/lib/mongo/mongod.lock errno:11 Resource temporarily unavailable. Is a mongod instance already running?, terminating

Wednesday, June 3, 2015

Data warehouse - Concepts - Part I


Here in this section, I am going to give a very brief explanation about few regular terms. Later I will cover Star schema and snow flake schema and slowly changing dimensions as well.

Dimension:
         Dimensions provide the "Who When What Why How " context in the surroundings of a business process event.

Fact:
        Facts are the measurements that result from a business process event and facts are almost always numeric.

Dimension table:
        Dimension table stores attributes or dimensions that describe the objects in the fact table.

Fact Table:
        Fact table contains the numeric measures produced by an operational measurement event in the real world.
             

Tuesday, June 2, 2015

How to Install MongoDB on CentoOS 6 (Redhat)

                                         STEPS TO INSTALL MONGODB

MongoDB is an open-source document database, and leading NoSQL database. MongoDB is written in C++.

MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.


STEP1:  Add MongoDB Yum Repositiry, to do this enter the below command at your shell terminal.



STEP2: Now add the following content in the file that you just created. If it is 64 bit only.


STEP3:  Now we execute a simple command to install MongoDB on our machine.

                             #  yum install mongodb-org

After installation your window will look like below image.




STEP4: Now to start the server, enter the below command. And do not forget about the owner, file, group permissions. Once you start the server it  should looks like below image.


If your server is not starting means, mostly it would be with file permissions only. Do remember that log files will be located at /var/log/mongod/ folder.

configuration file will be at /etc/mongod.conf

In this file you will also get where dbpath located.

Friday, May 29, 2015

Integrate Pentaho With Hadoop (Cloudera)

STEPS TO INTEGRATE PENTAHO WITH HADOOP

1.Before making changes to the existing configuration file please observe pentaho installation path. Go To the Directory  " \design-tools\data-integration\plugins "

2. In this particular folder, we will have a directory with the name " pentaho-big-data-plugin "

3. Navigate to "pentaho-big-data-plugin" directory and observe the file configuration located here. A file with the name "plugin.properties" existed in this folder.

4.Try to analyse by opening the file, at very beginning of the file there will be a field  with name "active.hadoop.configuration " and it set to to hadoop-20 by default. It some thing like below image.



5. In "pentaho-big-data-plugin" directory there is another  folder available with name "hadoop-configurations". Lets navigate and observe the folder structure.

6.Now in the "plugin.properties" file observe the value set to the filed "active.hadoop.configuration". by default it is set to hadoop-20. If we want to change this to cloudera then there are other folders availble with name "cdh*". So simply in the "plugin.propertes" file change the value accordingly.

7. After modifications done to the file it looks like in below image.Save the file and restart the server in order to reflect changes.


8. Now you can connect to Hadoop eco system from your Pentaho Data Integration.