It's all about the answers!

Ask a question

How to programmatically retrieve work items owned by a user?


Kamal Suruguchi (15112114) | asked May 30 '11, 2:16 a.m.
I have tried the following to retrieve work items owned by a particular user in a project area from a plain Java client.

//------------------------------------------------------------------------------------
IQueryableAttribute projectAreaAttribute= findAttribute(projectArea, auditableClient, IWorkItem.PROJECT_AREA_PROPERTY, null);
AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea);

IQueryableAttribute assignedToAttribute= findAttribute(projectArea, auditableClient, IWorkItem.OWNER_PROPERTY, null);
AttributeExpression assignedToExpression= new AttributeExpression(assignedToAttribute, AttributeOperation.EQUALS, "test");

Term term= new Term(Operator.AND);
term.add(projectAreaExpression);
term.add(assignedToExpression);

return queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.SMALL_PROFILE);
//------------------------------------------------------------------------------------

I get the following error while retrieving results:

Exception in thread "main" java.lang.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)


Can someone help?

4 answers



permanent link
Kamal Suruguchi (15112114) | answered May 31 '11, 11:58 a.m.
edited Feb 12 '17, 6:42 p.m. by Geoffrey Clemm (30.1k33035)

Full source code of a similar class (with no query on OWNER_PROPERTY) is available here: https://jazz.net/wiki/pub/Main/QueryDevGuide/DupeFinder.java

This works fine without any exception. But adding the query on OWNER_PROPERTY throws the exception!

Created a work item for this problem here: https://jazz.net/jazz/web/projects/Jazz%20Foundation#action=com.ibm.team.workitem.viewWorkItem&id=167710


permanent link
Martin Aeschlimann (911) | answered Jun 01 '11, 9:13 a.m.
JAZZ DEVELOPER
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.

Use ITeamRepository.contributorManager() to get a hold of contributors.

permanent link
Kamal Suruguchi (15112114) | answered Jun 10 '11, 10:27 a.m.
edited Feb 12 '17, 6:43 p.m. by Geoffrey Clemm (30.1k33035)

I have now tried the following:
// ---------------------------------------------------------------
IContributor user = repository.contributorManager().fetchContributorByUserId("myuser", null);

IQueryableAttribute assignedToAttribute= findAttribute(projectArea, auditableClient, IWorkItem.OWNER_PROPERTY, null);
AttributeExpression assignedToExpression= new AttributeExpression(assignedToAttribute, AttributeOperation.EQUALS, user);

Term term= new Term(Operator.AND);
term.add(projectAreaExpression);
term.add(typeExpression);
term.add(assignedToExpression);
// ---------------------------------------------------------------
Now I do not get an exception but the search does not result in any results (even though there are!). I have also tried to use the following:
// ---------------------------------------------------------------
AttributeExpression assignedToExpression= new AttributeExpression(assignedToAttribute, AttributeOperation.EQUALS, repository.loggedInContributor());
// ---------------------------------------------------------------

But still, it does not work. What am I missing here?


Comments
Bryan Miller - Integration Developer commented Jun 14 '12, 7:04 p.m.

Did you ever find an answer to this question?


permanent link
Abraham Ayorinde (1113) | answered Aug 02 '16, 8:43 a.m.
 I'm convinced we'll never find a useful answer on this forum.  Nearly a complete waste of time.

Comments
sam detweiler commented Aug 02 '16, 9:12 a.m.

this is not a forum for programming help. many of the folks that contribute here, like me,  do it because we can, and like to.. but we might not have direct experience with the exact scenario you are attempting.

there are samples of all kinds of code in Ralph's blog.. but we assume that you all have taking the developer assistance workshops, so you get started with the debugging and setup skills.

but there is NO training on using this object oriented system..  there is a lot of thinking that must be done to understand how the objects need to be structured..
at least for me..


Ralph Schoon commented Aug 02 '16, 9:18 a.m. | edited Aug 02 '16, 9:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You will not find an answer unless you follow my hints and set up your environment for debugging. If you want to do this you need development skills and you need to setup your environment as hinted. Otherwise you will stumble around and get nowhere. This is complex stuff and you can't just take it lightly. If you can't see the source and debug in your environment, again, follow https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ and get that working first.

You can also not complain that others don't do the work for users that ask and publish that.

I published https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/ as a good starting point (that you can debug if you know how). But it will not be the exact solution for what you search.

Hint: you can search the SDK for Expressions with users as example.


Bryan Miller - Integration Developer commented Aug 02 '16, 2:25 p.m.

Abraham, I empathize with your situation.  Not a lot of developers frequent the forums so responses can be sporadic.  I have seen excellent responses and dialog on occasion which have proven helpful.  I recommend reading Ralph's page and a few of the other good web pages on development for RTC and the Jazz Platform in general.


Abraham Ayorinde commented Aug 02 '16, 2:40 p.m.

Guys.  Please don't mind me.  I was simply frustrated and irritated.  I'm swamped with 4 coding projects all in different languages, with this one being perhaps the most importance with the least amount of work to be able to do what I ultimately want to be able to do.

You guys have been great.  Thanks again.


Bryan Miller - Integration Developer commented Aug 02 '16, 3:37 p.m.

:-)   Completely understand.

Your answer


Register or to post 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.