Wednesday, January 27, 2010

Monday, January 25, 2010

Scripted Data sets in BIRT

Why/when do you need a Scripted data set in a BIRT report?
Existing tables in your database will not provide data in the way you need them in a report. You might have to query more than one table to get all the data, or you may want to do some computation which requires going through one table data more than once.

What scripting language can be used?
Javascript is the primary language to be used in BIRT. BIRT also uses the Mozilla Rhino JavaScript engine which provides excellent integration with Java, hence you can use Java libraries as well but with a Javascript like syntax.

How to do it?
- Create a global variable: declare the variable in the initialize event of the report
For example:
importPackage(Packages.java.util.*);
globalVarMap = new java.util.HashMap();
globalVarList = new java.util.ArrayList();

- Populate this variable with required data: Typically you would read a simple dataset and dump all the data in this global map with the primary key (or maybe some other value) of the table being the key of the hashmap. The necessary code goes in 'onFetch' event (method) of the dataset, and a table column is referred to as 'row["CUSTOMER_ID"]'. The onFetch event is called once per each table record, hence you get access to table data one record at a time.
For example:
var list = globalVarMap.get(row["CUSTOMER_ID"]);;
if(list == null) {
list = new java.util.ArrayList();
}

var data={};
data.customer_name = row["CUSTOMER_NAME"];
data.product_bought = row["PRODUCT_BOUGHT"];
data.price = row["PRICE"];

list.add(data);
globalVarMap.put(row["CUSTOMER_ID"], list);

Here the CUSTOMER_ID is not the primary key, and we are just sorting of various items bought by each customer.

- Create a scripted data set: The final step is to create a scripted data set with the required columns and use global variables like the one above to populate this data set. Since you have the necessary data in a bunch of global variables, you can do pretty much what you want. The necessary code goes in 'fetch' event (method) of the dataset.
if(customerCount < globalVarList.size()){
 var data = globalVarList.get(customerCount);

 row["CUSTOMER_ID"] = data.customer_id;
 row["CUSTOMER_NAME"] = data.customer_name;
 row["PRODUCT_ID"] =data.product_id;
 row["TOTAL_PURCHASE"] = data.total_purchase;
 row["QUARTER"] = data.quarter;
 row["COUNTRY"] = data.country;

 customerCount++;
 return true;
}

return false;

Here, we have the necessary data in a global list variable and we just have to populate the scripted data set. In the fetch method we return true to indicate that there is more data coming, and false to indicate that we are done.

Additional Info
BIRT/FAQ/Scripting
BIRT Java Reporting

Wednesday, January 20, 2010

Monitoring and Allocating Users Across Projects in Rational Team Concert

Most views and reports in Rational Team Concert (RTC) are project centric. They give information about a particular project, its members and their utilization and various other facades. So far so good. But what if you wanted to maximize your resource (user) utilization across projects from within RTC. Who should the project manager pick up to assign to a new task?

Few custom reports can be created to provide a resource centric view of RTC.

Resource Assignment
This report gives how various resources are assigned to various projects. Essentially this report gives the overall 'Load' (as defined in the User admin page of RTC) for all users across all projects.


Resource Utilization
This report gives you how the users are utilized across projects. It shows one value for a user by doing a weighted average, with the weights being the user assignment in percentage.

Resource Utilization for a user for one project = Work Assigned (Hrs) in the project/ Total time (Hrs) available for the project



Resource Utilization per User
This will give a breakdown of resource utilization of a particular user.
Task Card
Users can use this Task card to see all their workitems across all projects.

Discussion and Downloads
The detailed discussion on these is captured in an RTC workitem on Jazz.net. The report designs can also be downloaded from there.
Create a report to see user utilization across all projects in the repository (100997)

Note:
  • These reports also deal with massive amounts of data and hence can be a bit slow.
  • They also span across multiple project areas which can have different timelines, hence the reports may or may not suit your needs. If the timelines are aligned, then these reports should work without problems.
  • These have been tested with RTC 2.0.0.1

Thursday, January 14, 2010

Asking questions the smart way

The industry standard on this : http://catb.org/~esr/faqs/smart-questions.html

While this is a fairly long piece the following steps should work in most cases
-RTFM
-STFW
-While asking your question provide enough information so that no one needs to come back to you for clarification or more information, as no one will.
- And use general common sense ;-)

Saturday, January 9, 2010

Some Misc Eclipse Links

Eclipse and Java for total beginners. These are some nice video tutorials.
  • http://eclipsetutorial.sourceforge.net/totalbeginner.html
  • http://eclipsetutorial.sourceforge.net/workbench.html
  • http://eclipsetutorial.sourceforge.net/persistence.html
  • http://eclipsetutorial.sourceforge.net/debugger.html
Eclipse Webinars and Podcasts
  • http://live.eclipse.org/