Iterate over contributor list which is a custom attribute
Accepted answer
// provided that you have already retrieved these data...
IProgressMonitor monitor = ...;
IAuditableCommon auditableCommon = ...;
IWorkItem workItem = ...;
IAttribute contributorsCustomAttribute = ...;
List<?> contributors = (List<?>) contributorsCustomAttribute.getValue(auditableCommon, workItem, monitor);
for (Object contributorObj : contributors) {
IContributor contributor = (IContributor) contributorObj;
}
Comments
Thanks for a quick response. But IContributor contributor = (IContributor) contributorObj is throwing the below exception .
com.ibm.team.repository.common.model.impl.ContributorHandleImpl incompatible with com.ibm.team.repository.common.IContributor.
Is there any other way to convert the object into IContributor?
What you got from the getValue method is likely a list of IContributorHandle objects.
Try this way:
AbstractService pluginAbstractService = (AbstractService) this;
IRepositoryItemService repositoryItemService = pluginAbstractService.getService(IRepositoryItemService.class);
for (Object contributorObj : contributors) {
IContributorHandle contributorHandle = (IContributorHandle) contributorObj;
IContributor contributor = (IContributor) repositoryItemService.fetchItem(contributorHandle, IRepositoryItemService.COMPLETE);
}