Skip to main content



      Home
Home » Archived » BIRT » ArrayLists in scripted data sets(unable to extract the )
ArrayLists in scripted data sets [message #841310] Wed, 11 April 2012 02:32 Go to next message
Eclipse UserFriend
Hello, all:

I was wondering if someone could please give me a hint on how to work with ArrayLists from Java in BIRT. Here is my situation:

I have a very basic java code that creates an ArrayList of an ArrayList ie ArrayList<ArrayList<String>> ie 2d table and stores it as one of the properties of the java class.

This ArrayList is used as a scripted data source to populate the data. In the 'open' section of the scripted data set, I have the following:

importPackage(Packages.com.Portfolio); // does not trigger error
importPackage(Packages.java.util); // does not trigger error
importPackage(Packages.java.lang); // does not trigger error

var myPortfolio = new Portfolio('111'); // does not trigger error
var theDataList = myPortfolio.fakeData; // does not trigger error
totalCount = myPortfolio.fakeData.get(0).size(); // does not trigger error - I get a good number here.
counter=0; // does not trigger error

In the fetch section I have:
if (counter>=totalCount-1){
return(false);} //does not trigger error

var timeLine = new ArrayList(); //does not trigger error - Just declare an ArrayList in Birt
timeLine = theDataList.get(0); //TRIGGERS AN ERROR

//var rorList = theDataList.get(1);
//row["Year"] = timeLine.get(counter);
//row["Ror"] = rorList.get(counter);
counter = counter+1;
return (true);

The error happens at timeLine = theDataList.get(0); theDataList is a 2d table (ArrayList of an ArrayList) so the theDataList.get(0) should return just a 1d ArrayList. BUT IT BREAKS HERE.

What am I doing wrong?

thanks in advance,
Andrew
Re: ArrayLists in scripted data sets [message #841700 is a reply to message #841310] Wed, 11 April 2012 12:31 Go to previous messageGo to next message
Eclipse UserFriend
Andrew,

I am attaching an example that does an arraylist of arraylist. I am
setting the data in the beforeFactory and using it in a scripted dataset.

In your example can your post the error you are getting? Also remove
the keyword var off of this line:

var theDataList = myPortfolio.fakeData;

Jason

On 4/11/2012 2:32 AM, andrew smith wrote:
> Hello, all:
>
> I was wondering if someone could please give me a hint on how to work
> with ArrayLists from Java in BIRT. Here is my situation:
>
> I have a very basic java code that creates an ArrayList of an ArrayList
> ie ArrayList<ArrayList<String>> ie 2d table and stores it as one of the
> properties of the java class.
>
> This ArrayList is used as a scripted data source to populate the data.
> In the 'open' section of the scripted data set, I have the following:
> importPackage(Packages.com.Portfolio); // does not trigger error
> importPackage(Packages.java.util); // does not trigger error
> importPackage(Packages.java.lang); // does not trigger error
>
> var myPortfolio = new Portfolio('111'); // does not trigger error
> var theDataList = myPortfolio.fakeData; // does not trigger error
> totalCount = myPortfolio.fakeData.get(0).size(); // does not trigger
> error - I get a good number here. counter=0; // does not trigger error
>
> In the fetch section I have: if (counter>=totalCount-1){
> return(false);} //does not trigger error
>
> var timeLine = new ArrayList(); //does not trigger error - Just declare
> an ArrayList in Birt
> timeLine = theDataList.get(0); //TRIGGERS AN ERROR
> //var rorList = theDataList.get(1);
> //row["Year"] = timeLine.get(counter);
> //row["Ror"] = rorList.get(counter);
> counter = counter+1;
> return (true);
>
> The error happens at timeLine = theDataList.get(0); theDataList is a 2d
> table (ArrayList of an ArrayList) so the theDataList.get(0) should
> return just a 1d ArrayList. BUT IT BREAKS HERE.
> What am I doing wrong?
> thanks in advance, Andrew
Re: ArrayLists in scripted data sets [message #842107 is a reply to message #841700] Wed, 11 April 2012 22:06 Go to previous messageGo to next message
Eclipse UserFriend
Jason,

Thank you very much for help and an example.
When I removed the var from the line that you suggested, everything started to work. Your example that you attached further solidified my understanding. Thank you.

Just one more quick question on 'var'. I was under impression that I should use 'var' when instantiating an object or a a variable...But it looks like I should not use 'var' when it comes to variables... is that so?

Thanks again,
Andrew
Re: ArrayLists in scripted data sets [message #842728 is a reply to message #842107] Thu, 12 April 2012 11:11 Go to previous messageGo to next message
Eclipse UserFriend
using var will scope it for just that event. Dropping var with make it
available to downstream events.

Jason

On 4/11/2012 10:06 PM, andrew smith wrote:
> Jason,
> Thank you very much for help and an example. When I removed the var from
> the line that you suggested, everything started to work. Your example
> that you attached further solidified my understanding. Thank you.
> Just one more quick question on 'var'. I was under impression that I
> should use 'var' when instantiating an object or a a variable...But it
> looks like I should not use 'var' when it comes to variables... is that so?
> Thanks again,
> Andrew
Re: ArrayLists in scripted data sets [message #843198 is a reply to message #842728] Thu, 12 April 2012 17:12 Go to previous message
Eclipse UserFriend
Thank you so much, Jason!! I did not know about that. What can I say - I am a BIRT newbie, but I am learning!!

Thanks again,
Andrew
Previous Topic:passing a parameter to a jdbc driver
Next Topic:progressive total
Goto Forum:
  


Current Time: Wed Jul 16 14:22:13 EDT 2025

Powered by FUDForum. Page generated in 0.11962 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top