It's all about the answers!

Ask a question

Generate a List for a date range using the BF Java API


Randall Beck (22413) | asked Sep 24 '15, 5:33 p.m.
Hi,

I am a builder, not a Java developer, so please forgive this simple question.

Using the Build Forge Java API, what is the best way to generate a List<Build> where the members of that list fall between a startDate and an endDate?

I know I can use the BF Java API to get a list of all projects like this:
List<Project> projList = Project.findAll(conn);
	
And for each Project returned, I can then ask for a list of all its Builds in a foreach loop:
List<Build> buildList = proj.getBuilds();
	
I also know the Build object supports a findBetween() method, but I think that would necessitate a second List<Build> using the findBetween() method to interrogate the first List<Build>.

Is there a better way to generate a list of Build Forge Builds that fall between a Date range?

Accepted answer


permanent link
Joshua Keefe (1011) | answered Oct 09 '15, 1:16 p.m.
Is the goal to list every build that was running around a specific time window, or to further filter/sort the results to by the build's parent project?

The Build method findBetween() should be sufficient to gather all the builds between a certain time window.

But to filter the resulted list, you would need to generate the List of Projects to make the comparison to.

Otherwise, if you are attempting to use one of the list generated "on-the-fly" to compared to the other created list object, this may be considered inefficient.

As you would be calling Build Forge for the on-the-fly List object (whether it be Project or Build) to perform the comparison, instead of generating a variable to cache the data first.
Randall Beck selected this answer as the correct answer

Comments
Randall Beck commented Oct 09 '15, 2:59 p.m.

Hi Josh,

Thanks for your reply; I was beginning to give up hope :-)

To answer your question, the first week of every month my manager asks me to generate a list of all builds run through BF the preceding month.  For example, today, October 9th, I would like to generate a list of all September, 2015 builds (Sept. 1 -> Sept. 30).

As you know, I can't wait too long to run the proj.getBuilds() because the BF built-in Class will start to purge results from the database.

Nevertheless, you have provided me with the direction in which I need to go.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.