Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Complex algorithm for generating a BIRT table
mstaniloiu
Hello everyone,
I have a birt dataset containing the following columns, sorted by 'time':
devicename String
operatorname String
time Date Time
action String
info String
'action' can have one of four possible values:
MAINTENANCE_START
DEVICE_DEFECT
DEVICE_REPAIRED
MAINTENANCE_STOP
I want to generate a table in my report using this data. I should have a table entry for each row of the dataset where action has the value 'MAINTENANCE_STOP'. My table should have the following columns:
Time
Operator
Status
Duration
Maintenance_Info
* 'Time' should take its value from the 'time' column of the last 'MAINTENANCE_START' before the current 'MAINTENANCE_STOP'
* 'Operator' should be the operator who performed the 'MAINTENANCE_START'
* 'Status' - if between the last 'MAINTENANCE_START' and the current 'MAINTENANCE_STOP' there was either a 'DEVICE_DEFECT' or 'DEVICE_REPAIRED' event, this should have the value 'Device not available' else it should be 'Device available'.
* 'Duration' - should be the difference (interval) between the 'MAINTENANCE_STOP' and the last 'MAINTENANCE_START'
* 'Maintenance_Info' - should be a concatenation of all the 'info' strings between the last 'MAINTENANCE_START' and the current 'MAINTENANCE_STOP'.
This was originally done in a java bean for a web application. In java it wasn't so hard to do, however, in BIRT I am not sure it is even possible. Can you give me any advice on how I can do something like this?
Find more posts tagged with
Comments
mstaniloiu
No replies at all? So it's impossible then?
CBR
I don't think that it's impossible. The only thing that makes it kind of hard is that you require a lot of manual javaScript code to remember last values for operator and date time columns (you have to reference values from previous columns).
I ll build a sample report for you if you provide me some sample data in a csv file.
johnw
Yes, its totally possible. In fact, you can probably use the same beans that you used in your application in your BIRT report by using a Scripted Data Source, and just instantiate your classes in there.
Remember, with BIRT, any Java class that is in your classpath can be used in your report. Check the document section and the DevShare for information and examples on how to use a scripted data source, and check under the Windows/Show View/Report And Chart/Report Designs for a Scripted Data Source example report.
If you still have questions, feel free to post some example data, and I can work up a quick example.
John
mstaniloiu
I've attached some data in a csv file (well, txt actually. I am apparently not allowed to attach csv files). Unfortunately I don't have a clue about how to use the java classes doing the computation and don't think I am even allowed to. I'll have to look into the issue further.
CBR
Please find sample report attached.
I had to change the file extension of my utils.js to utils.txt, please rename it back to utils.js.
You have to save report and the js file in a single eclipse project. The csv file should be in the root folder of your eclipse installation (where you can find the eclipse.exe). But you can easily change it by changing the csv folder of the datasource.
hope this helps.
If you are interested i can explain how i build the report.
The difference of start and end time are in hours. It's possible to change it to minutes, days, seconds by just replacing the BirtDateTime.diffHour to another method.
mstaniloiu
Thank you for the report, it's what I wanted except for one thing: I should only show the rows where the action is 'MAINTENANCE_STOP' (even though I also use the others for the computations). How can I do this?
CBR
You have to set a visibility condition on the detail row.
The condition has to be set to
row["action"] Not Equals to "MAINTENENCE_STOP"
I can update my sample report and reupload it tomorrow if it helps.
mstaniloiu
Not necessary, I did it myself. Thanks!
mstaniloiu
Is there any way to do debugging on the javascript file while generating the report? The date returned by getLastDate seems to always be the one of the first MAINTENANCE_START action, and I would like to see why this happens.