Programatically querying using Category property of workitem
Hi all,
I am trying to extract workitems that belong to only a particular category. For this I am modified the query to extract a particular type as follows: IQueryableAttribute categoryAttribute= findAttribute(projectArea, auditableClient, IWorkItem.CATEGORY_PROPERTY, null); AttributeExpression categoryExpression = new AttributeExpression(categoryAttribute, AttributeOperation.STARTS_WITH, "Agile"); Term term= new Term(Operator.AND); term.add(categoryExpression); return queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE); But I get the following exception: Argument must be an instance of IAuditableHandle at com.ibm.team.workitem.common.internal.model.SetAttributeType.toString(SetAttributeType.java:69) at com.ibm.team.workitem.common.internal.expression.AttributeValueFactory$ConstantValue.saveState(AttributeValueFactory.java:58) at com.ibm.team.workitem.common.expression.AttributeExpression.saveValueProxy(AttributeExpression.java:165) at com.ibm.team.workitem.common.expression.AttributeExpression.saveState(AttributeExpression.java:155) at com.ibm.team.workitem.common.expression.Term.saveState(Term.java:189) at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:132) at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:57) at com.ibm.team.workitem.common.internal.query.impl.QueryDescriptorCustomImpl.setExpression(QueryDescriptorCustomImpl.java:40) at com.ibm.team.workitem.common.internal.query.QueryCommon.createQuery(QueryCommon.java:258) at com.ibm.team.workitem.common.internal.query.QueryCommon.getResolvedExpressionResults(QueryCommon.java:123) I am guessing that the implementation of Now when I execute this I get the following IllegalArgumentException: Argument must be an instance of IAuditableHandle at com.ibm.team.workitem.common.internal.model.SetAttributeType.toString(SetAttributeType.java:69) at com.ibm.team.workitem.common.internal.expression.AttributeValueFactory$ConstantValue.saveState(AttributeValueFactory.java:58) at com.ibm.team.workitem.common.expression.AttributeExpression.saveValueProxy(AttributeExpression.java:165) at com.ibm.team.workitem.common.expression.AttributeExpression.saveState(AttributeExpression.java:155) at com.ibm.team.workitem.common.expression.Term.saveState(Term.java:189) at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:132) at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:57) at com.ibm.team.workitem.common.internal.query.impl.QueryDescriptorCustomImpl.setExpression(QueryDescriptorCustomImpl.java:40) at com.ibm.team.workitem.common.internal.query.QueryCommon.createQuery(QueryCommon.java:258) at com.ibm.team.workitem.common.internal.query.QueryCommon.getResolvedExpressionResults(QueryCommon.java:123) I think that though CATEGORY_PROPERTY and TYPE_PROPERTY return the same type, their implementaiton is different. Is there any other way that I can query with the category type? Thanks, Ramya. |
5 answers
On 6/18/10 1:53 PM, ramya wrote:
Hi all, Categories are items (as opposed to the work item type which is a string), so you must pass in the ICategoryHandle for the desired category. -- Regards, Patrick Jazz Work Item Team |
Hi Patrick,
Thanks for your reply. Can you also tell me where I should pass the ICategoryHandle? I have created the ICategoryHandle as follows: IWorkItemClient workItemClient = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class); ICategoryHandle categoryHandle = workItemClient.findCategoryByNamePath(projectArea, path, null); I am not sure on where how I should add this ICategoryHandle to my Term. Thanks, Ramya. On 6/18/10 1:53 PM, ramya wrote: Hi all, Categories are items (as opposed to the work item type which is a string), so you must pass in the ICategoryHandle for the desired category. -- Regards, Patrick Jazz Work Item Team |
Thanks for your reply. Can you also tell me where I should pass the You modify your existing category expression to look like this: AttributeExpression categoryExpression = new AttributeExpression(categoryAttribute, AttributeOperation.EQUALS, categoryHandle); -- Regards, Patrick Jazz Work Item Team |
That works! Thank you very much, Patrick!
Appreciate your help. Ramya. Thanks for your reply. Can you also tell me where I should pass the You modify your existing category expression to look like this: AttributeExpression categoryExpression = new AttributeExpression(categoryAttribute, AttributeOperation.EQUALS, categoryHandle); -- Regards, Patrick Jazz Work Item Team |
I'm trying to do exactly this, but seeing your code:
workItemClient.findCategoryByNamePath(projectArea, path, null); I'm not quite sure what path is or how to do it in the documentation says it is a List of string but I don't know what should be in it Any advice? |
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.