1)Create connection JDBC or JNDI
Example is for MSsql server using JDBC connection.
------------------------------
<actions>
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>Relational</action-type>
<action-inputs>
<SalesID type="string"/>
</action-inputs>
<action-outputs>
<query-result type="result-set" mapping="query_result_policycontact_city"/>
</action-outputs>
<component-definition>
<!-- make live FALSE if r getting data from Stored Procedure other wise let it be true -->
<live><![CDATA[false]]></live>
<driver><![CDATA[net.sourceforge.jdts.jdbc.Driver]]></driver>
<connection><![CDATA[jdbc:localhost://abhishekConnection:1433/pentaho;instance=policyDB]]></connection>
<user-id><![CDATA[abhishekShankar]]></user-id>
<password><![CDATA[password@password]]></password>
<!-- write your query here -->
<query><![CDATA[execute dbo.policyforallcity 0;]]></query>
</component-definition>
</action-definition>
</actions>
Now under Action Defination define query result name, to get its value in javascript.
example
------------
<action-definition>
<component-name>JavascriptRule</component-name>
<action-type>JavaScript</action-type>
<action-inputs>
<!-- get data from different results set -->
<query_result_policycontact_city type="result-set"/>
<query_result_policycontact_country ="result-set"/>
<query_result_policycontact_local ="result-set"/>
<query_result_policycontact_employee ="result-set"/>
<query_result type="result-set"/>
</action-inputs>
<action-outputs>
<alldata type="string"/>
<rowCount type="integer"/>
<abpolicyCount type="integer"/>
</action-outputs>
<component-definition>
3)define a script component defination
under this u can get data from query.
Example
---------
<component-definition>
<script><![CDATA[alldata ='';
rowCount=query_result.getRowCount();
var abhi=[];
4. Get Values of columns on a variable
<!--
Get Data for cityfrom query_result_policycontact_city query result set .
here city is on 6th column in query result set so its position is (0,5)
-->
var Current_city= query_result_policycontact_city.getValueAt(0,5);
<!--
Get Data for country from query_result_policycontact_city query result set .
here country is on 3rd column in query result set so its position is (0,4)
-->
var previous_country= query_result_policycontact_country.getValueAt(0,4);
Now Create some static Heading for columns under which all data will shown.
abhi.push("<table id='AbhiTable' border='2' ">");
abhi.push('<tr align="Center"><th>CITY</th>');
abhi.push('<th align="Center" !important;>Country</th>');
abhi.push('<th align="Center" !important;>INR</th> </tr>');
Now Start populating data for each column (i.e city country int....)
now create a for loop
for(row=0;row<rowCount;row++)
{
var CITY=query_result_policycontact_city.getValueAt(row,0);
var Country=query_result_policycontact_city(row,1);
var INR=query_result_policycontact_city(row,2);
<!-- now populate country and city column -->
{
abhi.push('<tr><td>'+city_c+' - '+city_c+'</td>');
abhi.push('<td>'+country_t+' - '+country_t+'</td> ');
<!-- number format or currency format in runtime>
abhi.push('<td>'+city+' - $'+parseFloat(total_INR).toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+'k ('+Country+')</td></tr>');
}
}
abh.push('</table>');
alldata=tbl.join('');
]]></script>
</component-definition>
</action-definition>
--------------------------------------------------------------
Kindly post yous comments in case of any issue. Or contact me spectrumon@gmail.com
Example is for MSsql server using JDBC connection.
------------------------------
<actions>
<actions>
<action-definition>
<component-name>SQLLookupRule</component-name>
<action-type>Relational</action-type>
<action-inputs>
<SalesID type="string"/>
</action-inputs>
<action-outputs>
<query-result type="result-set" mapping="query_result_policycontact_city"/>
</action-outputs>
<component-definition>
<!-- make live FALSE if r getting data from Stored Procedure other wise let it be true -->
<live><![CDATA[false]]></live>
<driver><![CDATA[net.sourceforge.jdts.jdbc.Driver]]></driver>
<connection><![CDATA[jdbc:localhost://abhishekConnection:1433/pentaho;instance=policyDB]]></connection>
<user-id><![CDATA[abhishekShankar]]></user-id>
<password><![CDATA[password@password]]></password>
<!-- write your query here -->
<query><![CDATA[execute dbo.policyforallcity 0;]]></query>
</component-definition>
</action-definition>
</actions>
Now under Action Defination define query result name, to get its value in javascript.
example
------------
<action-definition>
<component-name>JavascriptRule</component-name>
<action-type>JavaScript</action-type>
<action-inputs>
<!-- get data from different results set -->
<query_result_policycontact_city type="result-set"/>
<query_result_policycontact_country ="result-set"/>
<query_result_policycontact_local ="result-set"/>
<query_result_policycontact_employee ="result-set"/>
<query_result type="result-set"/>
</action-inputs>
<action-outputs>
<alldata type="string"/>
<rowCount type="integer"/>
<abpolicyCount type="integer"/>
</action-outputs>
<component-definition>
3)define a script component defination
under this u can get data from query.
Example
---------
<component-definition>
<script><![CDATA[alldata ='';
rowCount=query_result.getRowCount();
var abhi=[];
4. Get Values of columns on a variable
<!--
Get Data for cityfrom query_result_policycontact_city query result set .
here city is on 6th column in query result set so its position is (0,5)
-->
var Current_city= query_result_policycontact_city.getValueAt(0,5);
<!--
Get Data for country from query_result_policycontact_city query result set .
here country is on 3rd column in query result set so its position is (0,4)
-->
var previous_country= query_result_policycontact_country.getValueAt(0,4);
Now Create some static Heading for columns under which all data will shown.
abhi.push("<table id='AbhiTable' border='2' ">");
abhi.push('<tr align="Center"><th>CITY</th>');
abhi.push('<th align="Center" !important;>Country</th>');
abhi.push('<th align="Center" !important;>INR</th> </tr>');
Now Start populating data for each column (i.e city country int....)
now create a for loop
for(row=0;row<rowCount;row++)
{
var CITY=query_result_policycontact_city.getValueAt(row,0);
var Country=query_result_policycontact_city(row,1);
var INR=query_result_policycontact_city(row,2);
<!-- now populate country and city column -->
{
abhi.push('<tr><td>'+city_c+' - '+city_c+'</td>');
abhi.push('<td>'+country_t+' - '+country_t+'</td> ');
<!-- number format or currency format in runtime>
abhi.push('<td>'+city+' - $'+parseFloat(total_INR).toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+'k ('+Country+')</td></tr>');
}
}
abh.push('</table>');
alldata=tbl.join('');
]]></script>
</component-definition>
</action-definition>
--------------------------------------------------------------
Kindly post yous comments in case of any issue. Or contact me spectrumon@gmail.com
No comments:
Post a Comment