[plain java] Adding Work Item type to query?
Bryan Miller - Integration Developer (449●35●31)
| asked Jun 18 '12, 3:54 p.m.
retagged Nov 13 '12, 4:02 a.m. by Morten Madsen (305●32●50)
I have a Work Item query that works well but I wish to add an expression to my existing query to filter by Work Item type (defect, task, etc). I am not seeing any methods that will take my type string (i.e. "Defect") and return a type ID to add to my existing query.
Any thoughts? BTW, I have read the excellent Developer's Guide to Querying Work Items and it doesn't cover this use case. |
2 answers
here is something that i use, key is to get a queryable reference to the workitem type property and compare it with the specific workitem type ID.
//Create the Term Term queryTerm = new Term(Operator.AND); //work item type ID to be used to filter var mWorkitemType = "workitemtypeID"; // gather a queryable reference to the Workitem Type property for this ProjectArea IQueryableAttribute workItemTypeAttribute = factory.findAttribute(mProjectArea, IWorkItem.TYPE_PROPERTY, mAuditableClient, mMonitor); //build the attribute expression using the queryable reference to type property and the filter workitemtype ID AttributeExpression exprnWorkItemType = new AttributeExpression(workItemTypeAttribute, AttributeOperation.EQUALS, mWorkitemtype); // add the expression to your query term queryTerm.add(exprnWorkItemType); // run the query and capture the results IQueryResult<IResolvedResult<IWorkItem>> queryResult = mQueryClient.getResolvedExpressionResults(mProjectArea, queryTerm, IWorkItem.FULL_PROFILE); Comments
Bryan Miller - Integration Developer
commented Jun 19 '12, 9:59 a.m.
Thank you Dinesh. I may not have asked the question as clearly as I should have. I am trying to figure out how to get the contents of workitemtypeID from a display value (e.g. Defect). Is there a method call (or series of method calls more likely) which will take a string display value (.e.g Defect) and return an type ID for that project? |
Use the ID from the process configuration Work Item Type editor as String. For instance, for a defect:
//following the code from "Developer's Guide to Querying Work Items"... new AttributeExpression( findAttribute(projectArea, auditableClient, IWorkItem.TYPE_PROPERTY, null), AttributeOperation.EQUALS, "defect" ); -- Gabriel Enriquez, IBM Rational, Tracking & Planning Comments
Bryan Miller - Integration Developer
commented Jun 19 '12, 1:26 p.m.
Much obliged Gabriel. I had the correct code but was capitalising "defect" as "Defect" and that apparently doesn't match anything...
Morten Madsen
commented Nov 13 '12, 3:58 a.m.
Hi Gabriel, do you have a link to this "Developer's Guide" ....?
Here is a link to the Query Dev Guide.
|
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.