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
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
2 answers
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 methodObject getValue(IAttribute attribute) , but you need to get an IAttribute object. So, you can use a method like this one:
Note that this code works on server side. If you want to use at client side you must access the findAttribute method from IWorkItemClient
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
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
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:
Thanks for your help.
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.