luni, 15 februarie 2016

Pentaho Saiku CE plugin - Change Asterisk CrossJoin in CrossJoin Classic

Saiku plugin is (maybe) the most used plugin in Pentaho CE. I like this plugin, but in 3.x version the developers, use for CrossJoin the asterisk (*) operator as a shorthand for crossjoin. It's easy, clean, but when i put more then 4 dimensions the query takes to much time against the classic CROSSJOIN().

See http://jira.pentaho.com/browse/MONDRIAN-2284

To achieve old functionality I've modified 2 files in saiku-query library: src/main/java/org/saiku/query/NodeConverter.java and src/main/java/org/saiku/query/Olap4jNodeConverter.java

NodeConverter.java


protected static CallNode generateCrossJoin(List selections, boolean nonEmpty, boolean asterisk) {
 String crossJoinFun = "CrossJoin";
 ParseTreeNode sel1 = selections.remove(0);
 if (sel1 instanceof MemberNode) {
  sel1 = generateSetCall(sel1);
 }
 if (selections.size() == 1) {
  ParseTreeNode sel2 = selections.get(0);
  if (sel2 instanceof MemberNode) {
   sel2 = generateSetCall(sel2);
  }
  return new CallNode(
    null, crossJoinFun, Syntax.Function, sel1, sel2);

 } else {
  return new CallNode(
   null, crossJoinFun, Syntax.Function, sel1,
   generateCrossJoin(selections, nonEmpty,false));
 }
}

Olap4jNodeConverter.java


axisExpression = generateCrossJoin(hierarchies, axis.isNonEmpty(), false);

Surce code: https://github.com/gdudau/saiku-query

vineri, 5 februarie 2016

SmokePing integrate with Observium


Observium is a low-maintenance auto-discovering network monitoring platform supporting a wide range of device types, platforms and operating systems including Cisco, Windows, Linux, HP, Juniper, Dell, FreeBSD, Brocade, Netscaler, NetApp and many more. Observium focuses on providing a beautiful and powerful yet simple and intuitive interface to the health and status of your network.


SmokePing keeps track of your network latency:

  • Best of breed latency visualisation.
  • Interactive graph explorer.
  • Wide range of latency measurement plugins.
  • Master/Slave System for distributed measurement.
  • Highly configurable alerting system.
  • Live Latency Charts with the most 'interesting' graphs.
  • Free and OpenSource Software written in Perl written by Tobi Oetiker, the creator of MRTG and RRDtool

miercuri, 19 august 2015

JsonExport - plugin to generate XLS/XLSX from EXTJS Grid


JsonExport is a helper class who help you to generate data to use with PHPExcel to generate XLS/XLSX files.


Is based on Ext.ux.grid.Printer .

I create this plugin because i needed to export xls/xlsx from a ExtJS grid generated from a json feed.

JsonExport are two parts: client side (JsonExport.js) and server side (export_xls.php)

To setup you must define a button in your with a handler and an url to server-side file (export_xls.php)

Let's start with an example.

1. Setup path to Ext.ux location in your javascript.



Ext.Loader.setConfig({
     enabled: true,
     paths: {
         Ext: '.',   'Ext.ux': '../ux'
    }
 });

2.  Add Ext.Require Before the Grid code.


Ext.require([
      'Ext.ux.grid.JsonExport'
]);


3. Create your grid.


var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        stateful: true,
        stateId: 'stateGrid',
        columns: [
            {text: 'Company',dataIndex: 'company'},
            {text: 'Price',dataIndex: 'price'},
            {text: 'Change',dataIndex: 'change'},
            {text: '% Change',dataIndex: 'pctChange'},
            {text: 'Last Updated',renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    dataIndex: 'lastChange'}
        ],
        height: 350,
        width: 600,
        title: 'Array Grid',
        tbar: [{
            text: 'XLSX',
            iconCls: 'icon-print',
            handler: function () {
                var url = "http://example.com/export.php";
                Ext.ux.grid.JsonExporter.print(grid,url);
            }
        }],
        renderTo: Ext.getBody()
});


4. Export to XLSX (create a handler).



You must define url to your xls exporter. I use php and PHPExcel  which allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML...  
   
handler: function () {
         var url = "http://example.com/export.php";
         Ext.ux.grid.JsonExporter.print(grid,url);
}


Full example of grid.js

Ext.Loader.setConfig({
    enabled: true,
    paths: {
        Ext: '.',
            'Ext.ux': '../ux'
    }
});
Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.ux.grid.JsonExport'
]);
Ext.onReady(function () {
    // sample static data for the store
    var myData = [
        ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'],
        ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'],
        ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'],
        ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'],
        ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'],
        ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'],
        ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'],
        ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'],
        ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'],
        ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'],
        ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'],
        ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'],
        ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am']
    ];


    var store = Ext.create('Ext.data.ArrayStore', {
        fields: [
            {name: 'company'},
            {name: 'price',type: 'float'},
            {name: 'change',type: 'float'},
            {name: 'pctChange',type: 'float'},
            {name: 'lastChange',type: 'date',dateFormat: 'n/j h:ia'}
        ],
        data: myData
    });
    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        stateful: true,
        stateId: 'stateGrid',
        columns: [
            {text: 'Company',dataIndex: 'company'},
            {text: 'Price',dataIndex: 'price'},
            {text: 'Change',dataIndex: 'change'},
            {text: '% Change',dataIndex: 'pctChange'},
            {text: 'Last Updated',renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                   dataIndex: 'lastChange'}
        ],
        height: 350,
        width: 600,
        title: 'Array Grid',
        tbar: [{
            text: 'XLSX',
            iconCls: 'icon-print',
            handler: function () {
                var url = "http://example.com/export.php";
                Ext.ux.grid.JsonExporter.print(grid,url);
            }
        }],
        renderTo: Ext.getBody()
    });
});


... and  export_xls.php

 You can find this on Github (https://github.com/gdudau/JsonExport)


miercuri, 13 mai 2015

Alfresco Add User In Sites with cURL


Sometime you need to add a user or more to one or many site in your Alfresco Share without web interface or without sending invitation.

Every site have some predefined roles:  "SiteManager", "SiteCollaborator", "SiteContributor", "SiteConsumer" .
(http://docs.alfresco.com/community/references/permissions_share.html)

Prerequisites:

1. site ID
2. username(s)
3. role type
4. cURL


I want to add an user test_user in site "My Test Site" with site ID "mytestsite" with Consumer role:

curl -X POST -uadmin:password "http://alfresco:8080/alfresco/service/api/sites/mytestsite/memberships" -H"content-type: application/json" -d "{"role":"SiteConsumer","person":{"userName" : "test_user"}}"


If all is OK the server respond with:

{
        "role": "SiteConsumer",
        "authority":
        {
                "authorityType": "USER",
                "fullName": "test_user",
                "userName": "test_user",
                "firstName": "User",
                "lastName": "Test",
                "jobtitle": "Job Test",
                "organization": "IN TESTing",
                "url": "\/alfresco\/service\/api\/people\/test_user"
        },
        "url": "\/alfresco\/service\/api\/sites\/mytestsite\/memberships\/test_user"
}




vineri, 31 ianuarie 2014

JPivot Deprecation Warning

In this post i'll show you how to hide the JPivot deprecation warning message in Pentaho Community Edition.

For Pentaho CE 4.5 - 4.8 edit [pentaho_path]/biserver-ce/tomcat/webapps/pentaho/jsp/Pivot.jsp

 Find this text:

<div id="deprecatedWarning" style="margin: auto; width: 100%">
  <table width="580px" align="center" style="background-color: #fffdd5; border-style: solid; border-color: #dcb114; border-width= 1px; font: normal .85em Tahoma, 'Trebuchet MS', Arial">
   <tr>
     <td>
       <img src="./jpivot/navi/warning.png"/>
     </td>
     <td>
JPivot has been replaced by Pentaho Analyzer.<br/>
It is provided as a convenience but will no longer be enhanced or offically supported by Pentaho.
     </td>
    </tr>
   </table>
 </div>

Comment or remove. 

For Pentaho 5.x edit [pentaho_path]/biserver-ce/pentaho-solutions/system/pentaho-jpivot-plugin/settings.xml

Find this text:

<show-deprecation-warning>true</show-deprecation-warning>

and change to
<show-deprecation-warning>false</show-deprecation-warning>

Restart Pentaho.

That's all!








 

miercuri, 27 iulie 2011

Extjs 4 TreePanel - PHP - MYSQL (Simple Tutorial)

This article will cover the use of the tree.Panel object with PHP and MySQL. This is a simple tutorial.




 1. MySQL table with examples data
 2. Javascript code for tree
 3. PHP code for take the data from database
 4. HTML