Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
POJOs as Datasource
joesie75
Hello,
I'm a newbie with BIRT. I would like generate a dynamic report with values from a java object structure. The POJOs are:
public class WeeklyReport{
private String customerName;
private List<Location> locations;
private Date from;
private Date to;
...
public class Location {
private String name;
private List<Sensor> sensors;
...
public class Sensor {
private String name;
private String unit;
private List<Data> data;
...
public class Data {
private final Date timestamp;
private final Double average;
private final Double max;
...
I create a scripted Data Source with follow Dataset fetch:
if( currentlocation >= totalLocations ){
return( false );
}
var location = locations.get(currentlocation);
var sensors = location.getSensors();
dataSetRow["Customer"] = weekData.getCustomerName();
dataSetRow["FromDate"] = weekData.getFrom();
dataSetRow["ToDate"] = weekData.getTo();
row["LocationName"]=location.getName();
var sensor = sensors.get(currentsensor);
row["SensorName"]=sensor.getName();
if(currentData < sensor.getData().size() ){
var data = sensor.getData().get(currentData);
currentData ++;
row["DataTimestamp"]=data.getTimestamp();
row["average"]=data.getAverage();
row["max"]=data.getMax();
return true;
}
currentData = 0;
currentsensor++;
if( currentsensor >= sensors.size() ){
currentlocation ++;
currentsensor = 0;
return( true );
}
return true;
So, the preview results on this dataset looks pretty.
In the Report I need a new page for every sensor. In my example I have 1 customer with 2 locations. Every location has 2 senors and every sensor has 7 dataobjects.
In the generated report, the data from the different sensors are attached to every sensors. For example: the data array from first sensor ar attached to all sensors in the report and so on.
My question: Have I mistakes in my dataset? And how I can design my report to attached the data correctly. The quantity of locations, sensors and data can be different.
Thanks for your help
Find more posts tagged with
Comments
mwilliams
What is your report setup like? Are you grouping a single table or embedding one table into another?