Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to copy personal queries to another project area?

 Hi, I'm using RTC3.0.1.3 and our clients do really want to copy their personal queries to other project because they have many personal queries and there are many shared queries in our project area already. It's really inconvenient when they join a new project.

I had looked up to the forum and I found some people might asked the same question as I am asking, but I didn't find the solution. Then I try to write a java application to achieve it. 

Following is my code(Omitted):
IQueryClient queryClient = (IQueryClient)itr.getClientLibrary(IQueryClient.class);
IQueryDescriptorWorkingCopyManager manager = queryClient.getWorkingCopyManager();
List<IQueryDescriptor> queryDesList = queryClient.findPersonalQueries(
projectArea, itr.loggedInContributor(), 
null, IQueryDescriptor.FULL_PROFILE, null);
for (IQueryDescriptor des : queryDesList) {
manager.connect(des, null);
IQueryDescriptorWorkingCopy copy = manager.getWorkingCopy(des);
QueryDescriptor descCopy = (QueryDescriptor) copy.getQueryDescriptor();
descCopy.setProjectArea(targetProjectArea);
copy.saveCopy(des.getName() + "cpy", true, null);
}

After I test the application, I found the query is copied to other project, but after I clicked this query, the result is same as the old project(it mean the query in B project listed the workitems which is belongs to A project). Is any one could give me some advice? 

Thank you.

1

1 vote

Comments

I am in a similar situation; we are basically splitting out some work from an existing project area into a new project area and the team would like to take their queries with them to the new project area.


Is there any UI gesture to move or copy a work item query?

I am using RTC 4.0.1.


Accepted answer

Permanent link
Thanks Millarde for the solution search.

Thank you Di Tang for sharing your code. Perhaps a workaround would be to create a new Query in the new project area, then iterate over the conditions in the old query and add them to the new query. Or extract the xml from the old descriptor and assign it to the new descriptor.  There are some examples of using QueryDescriptor in com.ibm.team.workitem.common.test.QueryDescriptorTest.java which may be helpful (if this is not available to you, please let me know).

@bill: The best workaround may be to write queries that are to be migrated as predefined queries. These are added to the process spec, for example:


&lt;query description="Work items I have created which have been resolved" id="com.ibm.team.workitem.queries.predefined.closedCreated" name="Closed created by me"&gt;
   &lt;select/&gt;
   &lt;where&gt;
       &lt;and&gt;
           &lt;condition operator="is"&gt;
               &lt;attribute name="creator"/&gt;
               &lt;variable type="currentUser"/&gt;
           &lt;/condition&gt;
           &lt;condition operator="is"&gt;
               &lt;attribute name="internalState"/&gt;                &lt;variable arguments="closed" type="state"/&gt;            &lt;/condition&gt;        &lt;/and&gt;
   &lt;/where&gt;
&lt;/query&gt;

These can then be easily migrated using the Process Spec xml configuration.


Regards,

Larry


Di Tang selected this answer as the correct answer

0 votes

Comments

Hope that didn't spam you all... the forum ate my answer (and the comment box) so I had to handcraft the html back into submission. 

Thank you Larry for your advice! I'm waiting for the solution for a while, I will check the QueryDescriptorTest.java later and try again.


One other answer

Permanent link
In answer to @bill, there is no gesture for this. There have been several requests for this capability (see work items 37198, 65750 and 210655). Enhancement 210655 included an RFE which was rejected earlier this year. The underlying issue is that the query could reference attributes and values that are not available in the target project area, making a reliable move/copy operation difficult or dependent on having exactly the same process spec in the target.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,944
× 457
× 201

Question asked: Mar 06 '13, 2:14 a.m.

Question was seen: 8,366 times

Last updated: May 03 '13, 8:49 p.m.

Confirmation Cancel Confirm