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)
Nested POJO and scripted datasource
sbhayani
Hi All,
1)I have Employee POJO which contains Address POJO .
I am able to fetch fields of Employee but I can't get fields of Address.
2)Employee POJO contains a list . which I am not able to fetch in ScriptedDataSetEventAdapter.
Please guide me in detail .
Thanks .
Find more posts tagged with
Comments
mwilliams
Take a look at this devShare post. It has an example of using a POJO in a scripted data source.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/255-birt-scripted-datasource-example-design/
sbhayani
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="106947" data-time="1341509111" data-date="05 July 2012 - 10:25 AM"><p>
Take a look at this devShare post. It has an example of using a POJO in a scripted data source.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/255-birt-scripted-datasource-example-design/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/255-birt-scripted-datasource-example-design/</a><br
/></p></blockquote>
<br />
<br />
Hi William,<br />
<br />
I am able to generate report from POJO, when pojo is simple not complex.<br />
I have issue with below,<br />
<br />
public class EmployeePOJO implements Serializable{<br />
private String f_name;<br />
private String l_name;<br />
private String[] phoneNumbers;<br />
private Address address;<br />
}<br />
<br />
I am able to get values of f_name,l_name but I have problem with phoneNumbers field (which is array).<br />
I have issue when one employee has many phone numbers, which should be displayed in report like ,<br />
<br />
FirstName LastName PhoneNumbers<br />
<br />
Sameer Bhayani 9819154626<br />
9998177055<br />
8787878787<br />
0000122100<br />
William William 0070070070<br />
5454545454<br />
4545455445<br />
<br />
<br />
Thanks In advance ......
sbhayani
<blockquote class='ipsBlockquote' data-author="'sbhayani'" data-cid="106965" data-time="1341548591" data-date="05 July 2012 - 09:23 PM"><p>
Hi William,<br />
<br />
I am able to generate report from POJO, when pojo is simple not complex.<br />
I have issue with below,<br />
<br />
public class EmployeePOJO implements Serializable{<br />
private String f_name;<br />
private String l_name;<br />
private String[] phoneNumbers;<br />
private Address address;<br />
}<br />
<br />
I am able to get values of f_name,l_name but I have problem with phoneNumbers field (which is array).<br />
I have issue when one employee has many phone numbers, which should be displayed in report like ,<br />
<br />
FirstName LastName PhoneNumbers<br />
<br />
Sameer Bhayani 9819154626<br />
9998177055<br />
8787878787<br />
0000122100<br />
William William 0070070070<br />
5454545454<br />
4545455445<br />
<br />
<br />
And I am using <strong class='bbc'>ScriptedDataSetEventAdapter</strong> . So please guide for above issue.<br />
Thanks In advance ......<br /></p></blockquote>
mwilliams
One thing you could do with this would be to do a join on the array of phone numbers with a separator of "\n" and place this string into a single string field. When you display this in your report, the phone numbers will all be separated and on different lines within the one row. If you want each number to have its own row, you'll have to do something different. Let me know.
sbhayani
Yes William,
This is fine , but is there any way to get this thing done with Report engine or any automated way to get phonenumbers in different row ?
mwilliams
You can do everything you can do with the designer, with the report engine. Since you're using a scripted dataSet, you could easily step through your array and inner array and flatten it out into rows, in your open script. Or, you could use an extra step variable and checks to step through the inner array in your fetch code. This would be your way to make them into actual separate rows, but then you have to do grouping. If you do the above idea, all you would have to do is in your scripted dataSet, do the join to make the string and assign that to your phonenumber column as the value. It wouldn't be any extra work, since the data element will display the numbers on separate lines because of what you joined them with.