How to query defects for a secified iteration in Java Client
![]()
I want to query defects from RTC with a specific "planned For" (Iteration).
Below my code that i tried. But with that code i got an Exception. I'm using RTC 4 based clients. AttributeExpression defectFilter = new AttributeExpression(getQueryableAttribute(IWorkItem.TYPE_PROPERTY), AttributeOperation.EQUALS, "defect"); AttributeExpression targetFilter = new AttributeExpression(getQueryableAttribute(IWorkItem.TARGET_PROPERTY),AttributeOperation.EQUALS,plannedForToBeFiltered ); Term term_List = new Term(Operator.AND); term_List.add(defectFilter); term_List.add(targetFilter); Term term = new Term(Operator.AND); term.add(term_List); IQueryResult<IResolvedResult<IWorkItem>> result = mQueryClient.getResolvedExpressionResults(mProcessArea.getProjectArea(), term, IWorkItem.FULL_PROFILE); java.lang.IllegalArgumentException: Argument must be an instance of IAuditableHandle at com.ibm.team.workitem.common.internal.model.SetAttributeType.toString(SetAttributeType.java:73) 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:174) at com.ibm.team.workitem.common.expression.AttributeExpression.saveState(AttributeExpression.java:164) at com.ibm.team.workitem.common.expression.Term.saveState(Term.java:209) at com.ibm.team.workitem.common.expression.Term.saveState(Term.java:209) at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:137) at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:56) at com.ibm.team.workitem.common.internal.query.impl.QueryDescriptorCustomImpl.setExpression(QueryDescriptorCustomImpl.java:56) at com.ibm.team.workitem.common.internal.query.QueryCommon.createQuery(QueryCommon.java:268) at com.ibm.team.workitem.common.internal.query.QueryCommon.getResolvedExpressionResults(QueryCommon.java:123) at RTCHandler.getServiceRequests(RTCHandler.java:256) at PTFClosingInfo.main(PTFClosingInfo.java:40) |
Accepted answer
![]()
Solved .
We used some of the code from the link above to find the correct iteration and use the iterationhandle as input for the AttributeExpression. IIterationHandle iterationHandle = findIteration (mProcessArea.getProjectArea(), l, RTCHandler.BYNAME); if (iterationHandle != null) { AttributeExpression targetFilter = new AttributeExpression(getQueryableAttribute(IWorkItem.TARGET_PROPERTY),AttributeOperation.EQUALS,iterationHandle ); term_List.add(targetFilter); } Ralph Schoon selected this answer as the correct answer
Comments Glad you got it working!
Hi Thomos,
I am also facing java.lang.IllegalArgumentException: Argument must be an instance of IAuditableHandle .
Please provide the solution. Hope you Solved above exception .
in below your code
IIterationHandle iterationHandle = findIteration (mProcessArea.getProjectArea(), l, RTCHandler.BYNAME);
Please copy the findIteration method as well.
and what is l , RTCHandler.BYNAME you are passing to that method.
Hope, that you found it useful.
|
One other answer
|
Comments
Hi Thomas,
Which line is causing the exception to be thrown? If it's the second one, how are you getting plannedForToBeFiltered? I'm wondering if you need to get the plannedForToBeFiltered in a different way. http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/ has a lot of information about the planned for attribute and may be helpful to you.
The Exception is thrown during call of :
IQueryResult<iresolvedresult<iworkitem>> result =
mQueryClient.getResolvedExpressionResults(mProcessArea.getProjectArea(), term, IWorkItem.FULL_PROFILE);
plannedForToBeFiltered is a usual java string and it's a parameter of the java program.
The Link was very useful, but don't hit my problem, because i don't want to read or set the iteration.
I want to filter defects by iteration.
I'm not sure what the problem is. Perhaps something in this forum post will trigger an idea for you: https://jazz.net/forum/questions/56227/how-to-programmatically-retrieve-work-items-owned-by-a-user. When someone was hitting the same error you are while querying based on contributor, Martin wrote, "The owner attribute is of type 'Contributor'. So you can compare the attribute against a string, but need to pass in a object of Contributor." Maybe you need to pass in an object of type Iteration?
Thomas, I think Lauren has identified the problem for you..