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

WI queries and Results question

Hello,

I have some questions about the way to get values from a WI.

I customize a WI and i'm trying to do some queries.


After this point:

IQueryResult<IResolvedResult<IWorkItem>> result = queryService.getResolvedExpressionResults(prjAreaHandle, term2, IWorkItem.FULL_PROFILE);

while (result.hasNext(null)){
IWorkItem myWI = result.next(null).getItem();
MyIWorkItem custom = new MyIWorkItem(myWI);
*****
}

****I have a Class (MyIWorkItem) which contains several attributes:
id, appname, owner, etc. I found several values but i still looking for some others.

Is it supposed that "IWorkItem.FULL_PROFILE" above in the method brings all the record for every WI in the result?

Does exists some methods as findAttributeValue(String AttributeName) or similar??? How can i find those values then??


Thanks in advance

0 votes



2 answers

Permanent link
Hi,


First, "IWorkItem.FULL_PROFILE" is used to bring all attributes from an WorkItem.

SMALL_PROFILE < DEFAULT_PROFILE < MEDIUM_PROFILE < LARGE_PROFILE < FULL_PROFILE


Second, there is the method Object getValue(IAttribute attribute), but you need to get an IAttribute object. So, you can use a method like this one:


public Object findAttributeValue(IWorkItem workItem, String attrId) {
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IAttribute attribute;
try {
attribute = workItemServer.findAttribute(workItem.getProjectArea(), attrId, null);
if ((attribute!=null) && (workItem.hasAttribute(attribute))) {
return workItem.getValue(attribute);
};
} catch (TeamRepositoryException e) {
return null;
}
return null;
}



Note that this code works on server side. If you want to use at client side you must access the findAttribute method from IWorkItemClient

0 votes


Permanent link
Hi Eduardo,

I learned a lot of things reading your plug-ins posts a few weeks ago. They are really interesting.

Thanks for your answer.

I used the IWorkItemClient as you suggested and it works very good.

Now i have a similar problem:

In my WI there is a link to the build. In this build, ( IBuildResult object)
I cannot found the person who made the Request.

And i have the same problem with the IBuildDefinitionInstance object and the "Project or Team Area" field.

I have something like this:


if(endPointDesc.getId().equalsIgnoreCase("com.ibm.team.build.common.link.reportedAgainstBuilds")) {
for (int i=0; i < refList.size(); i++) {
try {
IBuildResult buildResultWI =
(IBuildResult) teamRepository.itemManager().fetchCompleteItem(
(BuildResultHandleImpl) refList.get(i).resolve(), ItemManager.DEFAULT, monitor);
builds.add(buildResultWI);
IBuildRequestHandle requestHandle =
(IBuildRequestHandle) buildResultWI.getBuildRequests().get(0);
IBuildRequest request =
(IBuildRequest) teamRepository.itemManager().fetchCompleteItem(requestHandle,
IItemManager.DEFAULT, null);
wid.setBuildDef(request.getBuildDefinitionInstance());
System.out.println("Label:"+buildResultWI.getLabel()+ "------" +
request.getBuildDefinitionInstance().getProperties().size());
_log.info(buildResultWI.getLabel());
}
catch (ItemNotFoundException e)
{
_log.warn(refList.get(i).getComment());
}
} // end for
_log.info("included in builds..." + refList.size());
}




Thanks for your help.

0 votes

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,937

Question asked: Dec 27 '11, 9:36 a.m.

Question was seen: 5,817 times

Last updated: Dec 27 '11, 9:36 a.m.

Confirmation Cancel Confirm