Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to programmatically retrieve work items owned by a user?

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?

0 votes



4 answers

Permanent link

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

0 votes


Permanent link
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.

0 votes


Permanent link

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?

0 votes

Comments

Did you ever find an answer to this question?


Permanent link
 I'm convinced we'll never find a useful answer on this forum.  Nearly a complete waste of time.

0 votes

Comments

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..

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.

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.

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.

:-)   Completely understand.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: May 30 '11, 2:16 a.m.

Question was seen: 9,649 times

Last updated: Feb 12 '17, 6:43 p.m.

Confirmation Cancel Confirm