[SOLVED] Adding a Watcher to a Workitem

Description
bschorre
Posts: 25
Joined: Mon Aug 14, 2006 10:20 am
Location: Loehne, Germany

[SOLVED] Adding a Watcher to a Workitem

Postby bschorre » Fri Aug 27, 2010 10:05 am

Hi,

can you provide me a code snipplet, how to add a user as watcher to a workitem?


Best regards
bschorre
Last edited by bschorre on Fri Aug 27, 2010 12:40 pm, edited 1 time in total.

bschorre
Posts: 25
Joined: Mon Aug 14, 2006 10:20 am
Location: Loehne, Germany

Re: Adding a Watcher to a Workitem

Postby bschorre » Fri Aug 27, 2010 12:40 pm

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.

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: No registered users and 7 guests