It's all about the answers!

Ask a question

How to copy personal queries to another project area?


1
1
Di Tang (341713) | asked Mar 06 '13, 2:14 a.m.
edited Mar 06 '13, 2:16 a.m.
 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.

Comments
Bill Higgins commented May 02 '13, 3:48 p.m. | edited May 02 '13, 3:49 p.m.
JAZZ DEVELOPER

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
Lawrence Smith (3764) | answered May 03 '13, 4:07 p.m.
JAZZ DEVELOPER
edited May 03 '13, 4:30 p.m.
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

Comments
Lawrence Smith commented May 03 '13, 4:16 p.m. | edited May 03 '13, 4:24 p.m.
JAZZ DEVELOPER


Lawrence Smith commented May 03 '13, 4:43 p.m.
JAZZ DEVELOPER

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. 


Di Tang commented May 03 '13, 8:49 p.m.

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
Millard Ellingsworth (2.5k12431) | answered May 03 '13, 2:28 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER
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.

Your answer


Register or to post your answer.