It's all about the answers!

Ask a question

Programmatically created query runs over all project areas instead over the requested one! Why?


praveen hanchinamani (27312) | asked Jun 08 '17, 7:48 a.m.
edited Jun 08 '17, 10:30 a.m.

Hi,

I am trying to deserialize the query definition xml file to expression with the following JAVA API -
    XMLExpressionSerializer serializer = new XMLExpressionSerializer();
    Expression expression = serializer.deserialize(queryString,
            new WorkItemQuerySerializationContext("com.ibm.team.workitem.workItemType", projectArea));

Where "WorkItemQuerySerializationContext" extends the "AbstractSerializationContext" and provides the -
       "com.ibm.team.workitem.workItemType" as a type and
       projectArea instance as the origin/context of query execution.

But we have problem here, is - Once the expression has been constructed out of the query, I can't find the "Term" which explains about the context(Where to execute the query - project area) of the execution. (I am intended to execute the query expression in the defined/provided project area).

With this constructed expression, I am deriving the "IQueryDescripor" instance as below -
       IQueryDescriptor queryFromExpression =
            queryClient.createQuery(projectArea, "com.ibm.team.workitem.workItemType", queryName,
             expression);
But - though i have provided the "projectArea" instance, to create the IQueryDescriptor, the execution of the same as below will result in the execution of the query descriptor over all the project areas of repository instead of intended one.
       IQueryResult<IResolvedResult<IWorkItem>> resolvedResults =
            queryClient.getResolvedQueryResults(queryFromExpression, loadProfile);
Later I am resolving the results to work items.

Questions -
1) Is the understanding of the context (WorkItemQuerySerializationContext) is correct?
2) Is there a problem in code?
3) Or am I missing anything else?

Please let me know if anyone knows about the issue.
Thank you in advane.


Comments
Ralph Schoon commented Jun 08 '17, 10:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The tagging is supposed to provide additional information such as the product and what this is about. Adding tons of irrelevant tags like Jazz.net and so on does not help. 


If you want to learn what a good question should contain, please have a look at:  How should I ask a question in the Forum if I want to receive useful answers?


Ralph Schoon commented Jun 08 '17, 10:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The interesting question here would be, what the code is supposed to achieve. AbstractSerializationContext is only used in internal classes. My information on how to run Expressions and Queries is here: 


praveen hanchinamani commented Jun 08 '17, 10:22 a.m.

Hello Ralph,

The goal of the above question is -
I have query definition in xml file(Only with conditions and no context(where to execute)). Provided this file and the repository and project area, I wish to execute this query over the defined context.

Hope the usecase is clear.

I have already seen the above mentioned links and there I can see someusefull info about -
1) Create a complete query using "Expression" and then the IQueryDescriptor for the desired results.
2) Fetching IQueryDescriptor from the stored(Personal, Shared or private queries) server queries to get the desired results.

In both the cases, the context where to execute the query is clear.

But in my case, I am trying to define the context in runtime, so that I can re-use the same conditions over desired multiple project areas.




Ralph Schoon commented Jun 08 '17, 10:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Makes a lot more sense now. Consider to open com.ibm.team.workitem.common.internal.expression.AbstractSerializationContext as a type, then on the object run the references search. Look at the code how it is used.


E.g. com.ibm.team.workitem.service.tests.query.ExpressionSerializerTest.TestSerializationContext 


Marko Tomljenovic commented Jun 08 '17, 11:01 a.m.

Hi Ralph,
let's phrase the question differently:  When a created Expression object is invoked using

queryClient.getExpressionResults(projectArea, expression);

and the expression does not contain any condition that defines the project area then the query is executed over all project areas.

For what reason do I then need to provide the project area parameter in the above mentioned method call?
This does not make too much sense to me.

Be the first one to answer this question!


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.