Thursday, December 13, 2012

BizTalk Server 12th Birthday


Happy Birthday BizTalk Server 12/12/2012 Born on 12/12/2000
A Many more returns of the day for BizTalk Server ... The first version of the product "Microsoft BizTalk Server 2000" was released back in 12/12/2000

BizTalk Summit 2012 is happening in Redmond, Seattle on 10th and 11th of December 2012 .The main objective of the event is to show the roadmap, future direction of BizTalk and to highlight what’s coming in the upcoming BizTalk Server 2013 version and improvement that’s happening on the integration side in Windows Azure.

Some good news about BizTalk Server. In Scott Guthrie, Vice President, Microsoft developer division key note, he has mentioned that the "Microsoft is heavily investing on BizTalk Server".
But I did not get, What is the roadmap for BizTalk server beyond 2013

More about the summit please read here . 

But where Microsoft is investing ???

Wednesday, December 05, 2012

Business Intelligence - Part 1 - Date/Time Dimensions, Table Design for periodic aggregate reports

Introduction


Often we end in scratching our head for writing SQLs for a report, where we finally end up writing few SQL in the loop and make a final report. There are age old techniques to achieve that, while we miss the view in doing that.

Sometimes single query could solve our issue in much faster approach than the queries in loop.

Going in search of knowledge of such options I have ended up in learning Data Warehouse and Business Intelligence. The primary approach would be to take baby steps one by one and to reach the destination.

Problem:

What we have:

It is a small store with sales data, what we have is just products, sales invoice and invoice items.


What we need:

Simple intelligence reports

  1. Sales per day of the provided month
  2. Sales per day of the provided week
  3. Sales per quarter of the provided year
  4. Sales per year overall
  5. and more if possible

Solution

Introduce date and time dimensions


Add new dimension tables as above, these tables help to give more business related information like weekday name like Monday, Tuesday, or the quarter of the year Q1, Q2,Q3,Q4 etc.,

The date dimension should have the date_key as long value like 20091125 to map a 2009, November 25th.
Having this as a numeric field like long will help the joins to be faster. Each other table columns are expected to repeat the values in detail. year as 2009, month as 11, day_of_month as 25 etc. We could add more columns as much as needed to provide the business reports.

The time would have a fixed 24 x 60 entries of 1440. If in case we need a second based match, we may need to have 86400 records, but better to avoid second level reporting as it is not required for the store management.

Introduce dimension mapping columns

Add the dimension mapping columns in the invoice for the invoice date, which will have invoice_date_key and invoice_date_time_key.

Both would have numeric values like 20091125 and 1429.

Write the queries.

1. Sales per day of the provided month

SELECT dd.day_of_month, SUM(invoice.total_amount) FROM invoice
RIGHT OUTER JOIN dim_date  dd ON dd.date_key = invoice.invoice_date_key
AND invoice.invoice_date BETWEEN 'x' AND 'y'
GROUP BY dd.day_of_month
ORDER BY dd.day_of_month

The above would result something like
1 $100
2 $90
3 $2000
4 $1200
5 $600
etc...

1.1 Sales per day of the per month, for provided year



SELECT dd.month_short_name_en, dd.day_of_month, SUM(invoice.total_amount) FROM invoice
RIGHT OUTER JOIN dim_date  dd ON dd.date_key = invoice.invoice_date_key
AND invoice.invoice_date BETWEEN 'x' AND 'y'
GROUP BY dd.month, dd.day_of_month
ORDER BY dd.month, dd.day_of_month



The above would result something like
Jan 1 $100
Jan 2 $90
Jan 3 $2000
...

Feb 1 $110
Feb 2 $20
Feb 3 $1000

Feb 4 $1200
Feb 5 $600
etc...


The join with the dimension can be varied and more grouping and aggregation can be done to form variety of reports in a single query, which could impress the business.


    Tuesday, December 04, 2012

    J2EE Web Application Deployment setup for Development in JBoss AS 7.1

    Deploying a J2EE web application is very easy in JBoss AS 7.1.x server. Make your J2EE application as a war file, login to JBoss admin console, in Manage Deployments area, you can upload the war file and Enable it to make it deployed. But, is it possible to keep the deployment process like this while you are developing an application? Certainly not. This process will consume lot of time to see the development changes working.

    This post will help you to setup the deployment process for development in JBoss.

    Instead of deploying the application as a war file, we are going to deploy it as a exploded war directory under <JBoss Home>/standalone/deployments/. This is called exploded deployment, which helps development in greater extent. Follow the steps to get the exploded deployment working,


    • Create a directory with .war suffixed with your application name under   <JBoss Home>/standalone/deployments/ directory.
    • In <JBoss Home>/standalone/configuration/standalone.xml, add auto-deploy-exploded="true"  attribute to deployment-scanner node under deployment-scanner subsystem. 
    • You can also set scan-interval (scan-interval="5000") attribute and set your an interval to the  deployment-scanner node. For example,
                <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-exploded="true" deployment-timeout="1200"/>
    • If the above are done, you have to get the J2EE application contents placed in the deployment directory we have created. It is better to link the output folders to the deployment directory, if you are using an Eclipse based IDE. JBoss will redeploy the application when it finds a change in the code. So all you have to do while development is, do a build when you want to see the code changes working.


    When I was running the application successfully, I noticed that all the cookies from the application is suffixed with . undefined . For example, 

    Ur1bLe3UDdWJ9xm0ZDbMfZvJ.undefined

    this is a bug in JBoss 7.1x and as a workaround, you have to set instance-id attribute in jboss:domain:web subsystem in standalone.xml. For example,

    <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false" instance-id="myDomain">

    This is not a serious issue, but include the above configuration changes as a good practice. 



    Monday, December 03, 2012

    Dojo + AngluarJS a powerful combination

    For years impressed with Dojo for its complete suite. It was quite sometimg, I started to fall in love with AngularJS for its plain way of working in DOM.

    Dojo's modular code now supports the AMD, which is quite compliant with all the other libraries.

    Normal Dojo page

    <!doctype html>
    <html>

    <head>
        <script src="path/to/dojo/1.7.x/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: true"></script>
        <script type="text/javascript">
            require(['dijit/form/DateTextBox']);
        </script>
    </head>
    <body>
    <input id="dateBox" data-dojo-widget="dijit/form/DateTextBox"  />
    </body>
    </html>


    AngularJS page



    <!doctype html>
    <html data-ng-app>
    <head>
        <script src="http://code.angularjs.org/1.0.1/angular-1.0.1.js"></script>
        <script type="text/javascript">
            function TestController($scope) {
        $scope.date = new Date();
        $scope.alert = function(msg) {
        $scope.text = msg;
        };
        };
        </script>
    </head>
    <body data-ng-controller="TestController">
          <input id="dateBox" data-ng-model="date2" data-ng-change="alert(date2)" />
          <span id="text">{{text}}</span>
    </body>
    </html>





    Dojo + AngularJS page

    <!doctype html>
    <html data-ng-app="angular-dojo-test">
    <head>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dijit/themes/claro/claro.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js" type="text/javascript"></script>
              <script src="http://code.angularjs.org/1.0.1/angular-1.0.1.js" type="text/javascript"></script>
            <script src="angular-dojo.js" type="text/javascript"></script>
        <script>
       
        function TestController($scope) {
         $scope.date = new Date();
        $scope.alert = function(msg) {
        $scope.date = msg;
        };
        };

        var module = angular.module("angular-dojo-test", ['angular-dojo']);

        </script>
    </head>
        <body class="claro" data-ng-controller="TestController">
        <div>
        <input id="dateBox" data-dojo-widget="dijit/form/DateTextBox" data-ng-model="date" data-ng-change="alert(date)" />
       </div>
       <h1>Date 1: {{date}} </h1>
        </body>
    </html>




    The angular-dojo.js can be found in the github.
    An amazing way to do the JS works

    Saturday, December 01, 2012

    Building JS Graphs, jQuery, Dojo Charts, Google Charts, ExtJS Charts

    Recently in few of the projects there were needs to use Graphs.

    Plenty of them were in race. jQuery jqplot, dojo, extjs.

    jqPlot


    Dojo Charts

    ExtJS



    While the above were good to start with am quite impressed with Google Graphs, Their documentations and simple access to the APIs without complexities.
    Google Charts 

    Google charts is simple easy and quite good with its look and feel and behaviour for applications where we don't need much modifications but just to show data.



    PHP 5.3+ Doctrine2 Schema update script

    I have been working more than 3 years with doctrine, and now started to play with Doctrine 2 for few of my new projects, Its almost a year with Doctrine 2. Here is what it helps the team in development.

    The command line tool to update tables and dump SQLs for upgrades.


    The app uses ZendFramework and Doctrine, here is the small snippet that helps me to run the doctrine commands

    $env = getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development';
    define('APPLICATION_ENV', $env);
     
    define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
    
    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../library'),
        realpath(APPLICATION_PATH . '/models/entity'),
        realpath(APPLICATION_PATH . '/util'),
        realpath(APPLICATION_PATH . '/models'),  
        get_include_path(),
    )));
    
    // Doctrine and Symfony Classes
    require_once 'Doctrine/Common/ClassLoader.php';
    require_once 'BaseEntity.php';
    
    $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
    $classLoader->register();
    $classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
    $classLoader->register();
    $classLoader = new \Doctrine\Common\ClassLoader('Entities', APPLICATION_PATH . '/models');
    $classLoader->setNamespaceSeparator('_');
    $classLoader->register();
    
    // Zend Components
    require_once 'Zend/Application.php';
     
    // Create application
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini'
    );
    
    // bootstrap doctrine
    $application->getBootstrap()->bootstrap('doctrine');
    $em = $application->getBootstrap()->getResource('doctrine');
    
    // generate the Doctrine HelperSet
    $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
        'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
        'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
    ));
    
    \Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);
    
    The above PHP snippet was saved as doctrine.php And the following commands can be used against the database migrations

    > php doctrine.php orm:schema-tool:create
    > php doctrine.php orm:schema-tool:update --force
    > php doctrine.php orm:schema-tool:update --dump-sql
    Trying the following command gives list of other options to perform
    >php doctrine.php