stop a #foreach sentence

Description
martacruzm
Posts: 40
Joined: Mon Jul 13, 2015 7:45 am

stop a #foreach sentence

Postby martacruzm » Mon Feb 27, 2017 9:47 am

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.


martacruzm
Posts: 40
Joined: Mon Jul 13, 2015 7:45 am

Re: stop a #foreach sentence

Postby martacruzm » Tue Mar 14, 2017 2:09 pm

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

GAlexMES
Posts: 2
Joined: Wed Mar 22, 2017 2:05 pm

Re: stop a #foreach sentence

Postby GAlexMES » Wed Mar 22, 2017 2:22 pm

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.

ALMighty
Posts: 80
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

Re: stop a #foreach sentence

Postby ALMighty » Mon Mar 05, 2018 1:40 pm



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.
Attachments
Detailed_Syntax_Help_Velocity_version.png
Polarion version 2016 and its Velocity version.
Detailed_Syntax_Help_Velocity_version.png (194.06 KiB) Viewed 1995 times
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

micdal
Posts: 17
Joined: Thu Feb 09, 2012 6:22 am

Re: stop a #foreach sentence

Postby micdal » Mon Mar 05, 2018 2:37 pm

Hi all,

Polarion 2017 is still using Velocity 1.4 :-(

Regards,
Michael

fbachmann
Posts: 43
Joined: Thu Apr 24, 2014 12:10 pm

Re: stop a #foreach sentence

Postby fbachmann » Tue Mar 06, 2018 9:50 am

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

ALMighty
Posts: 80
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

Re: stop a #foreach sentence

Postby ALMighty » Tue Mar 06, 2018 2:44 pm

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.
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

smarty
Posts: 50
Joined: Fri Jan 18, 2013 4:43 pm
Location: Germany / Frankfurt
Contact:

Re: stop a #foreach sentence

Postby smarty » Thu Mar 22, 2018 12:06 pm

What dou mean with pooling? :lol:

like continuing this thread xwiki velocity script development tipps&tricks?
My environment: Polarion ALM 2016 SR2 on Windows Server 2012,
Polarion-JIRA Connector to JIRA 7.x


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 13 guests