Hi,
can you provide me a code snipplet, how to add a user as watcher to a workitem?
Best regards
bschorre
[SOLVED] Adding a Watcher to a Workitem
[SOLVED] Adding a Watcher to a Workitem
Last edited by bschorre on Fri Aug 27, 2010 12:40 pm, edited 1 time in total.
Re: Adding a Watcher to a Workitem
Hi,
I don't know why but this mechanism is really awfull.
First I tried to add the watcher via the workitem, whicvh is from my point of view normal, becuase my focus is on the Workitem.
After analyzing other behavior and storages (e.g. in SVN) I recognized the watches are stored within the users profile. Therefore I tried to add a workitem to the users watchlist. But a function setAsWatcher or addWatcher was not available for class IUser but for a class User.
After thinking around and searching the SDK with a texteditor, I found out, the ITrackerUser has a method called doWatchItem. Now I have to found out how to get access to this and finally it works.
At least this bad documented and implemented feature took me 3h of lifetime. But I spend this time because Polarion Support would have answered in one week ... perhaps. And so long I have no time. But I have started a request to them and I will let you know when I get the feedback.
Best regards
bschorre
I don't know why but this mechanism is really awfull.
First I tried to add the watcher via the workitem, whicvh is from my point of view normal, becuase my focus is on the Workitem.
Code: Select all
this.query = "type:" + this.parentWorkitemType;
Collection< IWorkItem > parentWorkitemList = (Collection< IWorkItem >) trackerService.queryWorkItems(this.query, this.sort );
if( false == parentWorkitemList.isEmpty() )
{
for( final IWorkItem myParentWorkitem : parentWorkitemList )
{
myParentWorkitem .addWatcher();
}
}
After analyzing other behavior and storages (e.g. in SVN) I recognized the watches are stored within the users profile. Therefore I tried to add a workitem to the users watchlist. But a function setAsWatcher or addWatcher was not available for class IUser but for a class User.
After thinking around and searching the SDK with a texteditor, I found out, the ITrackerUser has a method called doWatchItem. Now I have to found out how to get access to this and finally it works.
Code: Select all
ITrackerService trackerService = (ITrackerService) PlatformContext.getPlatform().lookupService( ITrackerService.class );
ITrackerUser trackerUser = (ITrackerUser) trackerService.getTrackerUser( user );
trackerUser.doWatchItem( workItem );
trackerUser.save();
getLogger().info( " Watcher added to Workitem." );
At least this bad documented and implemented feature took me 3h of lifetime. But I spend this time because Polarion Support would have answered in one week ... perhaps. And so long I have no time. But I have started a request to them and I will let you know when I get the feedback.
Best regards
bschorre
Return to “Polarion Application Lifecycle Management (ALM)”
Who is online
Users browsing this forum: Bing [Bot] and 8 guests