Page 1 of 1

stop a #foreach sentence

Posted: Mon Feb 27, 2017 9:47 am
by martacruzm
Hi

I have a workitem with many linkedworkitems. I would like to find one specific linkedwork with an specific role.
Is it possible to stop the loop once i've found the item that i want?

I would like to optimize it because there are a lot of linked items, this way I do not have to go over all the items.

Re: stop a #foreach sentence

Posted: Tue Mar 14, 2017 1:57 pm
by fbachmann

Re: stop a #foreach sentence

Posted: Tue Mar 14, 2017 2:09 pm
by martacruzm
thanks for your reply, but,
have you test it in a wiki page?
i've tested it and doesn't work

Re: stop a #foreach sentence

Posted: Wed Mar 22, 2017 2:22 pm
by GAlexMES
Instead of get the linked work items by the method .getLinkedWorkItems you can create a query for that.

Possible Query:
linkedWorkItems:implements=ITEM-123

"implements" is the Role and ITEM-123 the ID of your Item. If you use ITrackerService.queryWorkItems() this will return you a List of linked WorkItems, that have the role implements to the ITEM-123.

Re: stop a #foreach sentence

Posted: Mon Mar 05, 2018 1:40 pm
by ALMighty


The break command defeinitely not work if the thread requester is using Polarion 2016 or below.
As you can see in my attached screenshot, the 2016 version of Polarion still refers to
the 1.4 version of the Velocity language in its detailed syntax help, the break command
is not available in version 1.4., see here: https://velocity.apache.org/engine/1.4/user-guide.html

The Stackoverflow reply you have linked refers to Velocity version 1.6 in which the break command was alread a feature.

I would not recommend what the marked answer in that thread is recommending: Modifying the internal sources because when you upgrade your Polarion version, these changes must be taken into account.

To be honest I don't know if Polarion 2017 is using a later version of Velocity already but
when using Polarion 2016 it is save to say that you have to abstain from a break command.

martacruzm wrote:thanks for your reply, but,
have you test it in a wiki page?
i've tested it and doesn't work


What version are you using? If you use Polarion 2016 like me then a break command for going out of the foreach loop is definitely not possible like I mentioned in the paragraph before.

I would also follow the approach GAlexMES mentioned: Try to reduce the huge number of work items upfront with a elaborate query.

Re: stop a #foreach sentence

Posted: Mon Mar 05, 2018 2:37 pm
by micdal
Hi all,

Polarion 2017 is still using Velocity 1.4 :-(

Regards,
Michael

Re: stop a #foreach sentence

Posted: Tue Mar 06, 2018 9:50 am
by fbachmann
And they will not move to a later Velocity version, they're pushing the widgets technology and just keeping Wiki pages as tolerated-but-not-actively-maintained-legacy :(

Looks like we need to pool the Wiki know-how among users. Who's in?

Fran├žois

Re: stop a #foreach sentence

Posted: Tue Mar 06, 2018 2:44 pm
by ALMighty
fbachmann wrote:Looks like we need to pool the Wiki know-how among users. Who's in?


What dou mean with pooling? :lol:

If you mean that we all should help together, I willingly provide my gathered knowledge in Polarion of course.

Re: stop a #foreach sentence

Posted: Thu Mar 22, 2018 12:06 pm
by smarty
What dou mean with pooling? :lol:

like continuing this thread xwiki velocity script development tipps&tricks?