It's all about the answers!

Ask a question

Programatically querying using Category property of workitem


Ramya Gopalan (3141) | asked Jun 18 '10, 7:52 a.m.
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



permanent link
Patrick Streule (4.9k21) | answered Jun 18 '10, 1:03 p.m.
JAZZ DEVELOPER
On 6/18/10 1:53 PM, ramya wrote:
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.


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

permanent link
Ramya Gopalan (3141) | answered Jun 18 '10, 4:07 p.m.
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,

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.


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

permanent link
Patrick Streule (4.9k21) | answered Jun 19 '10, 5:41 a.m.
JAZZ DEVELOPER
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.

You modify your existing category expression to look like this:

AttributeExpression categoryExpression = new
AttributeExpression(categoryAttribute, AttributeOperation.EQUALS,
categoryHandle);

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Ramya Gopalan (3141) | answered Jun 21 '10, 12:46 a.m.
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
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.

You modify your existing category expression to look like this:

AttributeExpression categoryExpression = new
AttributeExpression(categoryAttribute, AttributeOperation.EQUALS,
categoryHandle);

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Priscila Medrano (1) | answered Jul 19 '12, 3:21 p.m.
JAZZ DEVELOPER
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


Register or to post your answer.