It's all about the answers!

Ask a question

How to use parametrized queries in plain java API


Piotr Aniola (3.7k11738) | asked Mar 26 '14, 7:47 a.m.
Hello,

I created a personal query, that, among other search parameters, has Summary=<provide value at query run> (so the value is not preset, but dynamic.

Assuming I have an IQueryDescriptor that corresponds to this query, how would I go about providing the parameter to run this query?

Comments
sam detweiler commented Mar 26 '14, 7:53 a.m.

I would check Ralph's blog for dynamic query construction. I haven't done this myself.


Ralph Schoon commented Mar 26 '14, 8:10 a.m. | edited Mar 26 '14, 8:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Neither have I. Unfortunately. I would be interested in how it works too.
I have done construction of queries, but I am not sure how parameters are represented and filled.


Piotr Aniola commented Mar 27 '14, 9:03 a.m.

Thank you, you're right that's not a good workaround.


sam detweiler commented Mar 27 '14, 2:09 p.m. | edited Mar 27 '14, 2:11 p.m.

did u see the syntax below? 

 
query ? jsonParameterValues=(attribuedId)??attributeId=(attributeId)??operator(is)??values(value)

so I think you could construct that into the query code in plainjava (the product does)

3 answers



permanent link
Piotr Aniola (3.7k11738) | answered Mar 31 '14, 8:57 a.m.
What I actually did is create a query without the parametrized attribute, cache the results in my program, and perform the search based on the attribute inside the java program.
This is actually ok, as it saves me from running the query over and over again with different parameter values.

permanent link
sam detweiler (12.5k6195201) | answered Mar 26 '14, 9:34 a.m.
edited Mar 26 '14, 9:36 a.m.
I hate it when u make me work to answer a question!!.. but I learn something

so, using the web ui, run the query, then push the print button to get the URL

in my case the query is find the workitem(s) with the old_wi_id field with value=?, in this case the data was '123456'
https://jazz.intranet.xx.com/ccm/resource/itemOid/com.ibm.team.workitem.query.QueryDescriptor/_EG5I8pzfEeOsZYheQqjNwg?_mediaType=text/html&jsonParameterValues=%7B%22com.xx.workitem.attribute.old_wi_id3%22%3A%7B%22attributeId%22%3A%22com.xx.workitem.attribute.old_wi_id%22%2C%22operator%22%3A%22is%22%2C%22values%22%3A%5B123456%5D%7D%7D&nocache=1395840685618

permanent link
Krzysztof Kaźmierczyk (7.5k480103) | answered Mar 27 '14, 9:02 a.m.
I know that this is not good work around, but you can run unparametrized query and iterate over results to fetch work items matching your params.

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.