Why getOrigin() returns null on the server side
Hello!
I can not go through an initial problem getting a reference to current repository object. I need it to get the additional libraries which could help me to work with workitem attributes. I try to get the repository object in this way: ...IWorkItem wi... ITeamRepository repo = (ITeamRepository) wi.getOrigin(); I tried next services as prerequisites in plugin.xml: <prerequisites> <requiredService interface="com.ibm.team.workitem.service.IWorkItemServer"/> <requiredService interface="com.ibm.team.repository.service.IRepositoryItemService"/> <requiredService interface="com.ibm.team.repository.common.service.IContributorService"/> <requiredService interface="com.ibm.team.workitem.common.IAuditableCommon"/> <requiredService interface="com.ibm.team.process.service.IProcessServerService"/> <requiredService interface="com.ibm.team.workitem.service.IWorkItemServer"/> <requiredService interface="com.ibm.team.repository.common.service.IQueryService"/> </prerequisites> But every time, I get null instead of an existing object! And the question is, which service could be declared to get non null repository object? Thank you in advance! |
Accepted answer
because your plugin extends AbstractSerivce you have access to methods to load other libraries
fWorkItemServer = getService(IWorkItemServer.class);
fAuditableCommon = getService(IAuditableCommon.class);
fcontributorService = getService(IContributorService.class);
fProcessServerService = getService(IProcessServerService.class);
fQueryService = getService(IQueryService.class);
fItemService = getService(IRepositoryItemService.class);
Dmitry A. Lesin selected this answer as the correct answer
Comments
Dmitry A. Lesin
commented Apr 01 '14, 10:33 a.m.
Thank you!
It's possible that the origin wasn't set for the item. The documentation states it can return null if the origin is unknown.
sam detweiler
commented Apr 01 '14, 10:49 a.m.
Also, why do you need it? you have access to all the service you could want, as you are running IN the repository The plugin is an RTC follow-up action trigger which is called on saving a workitem. As for me, I need only to get a "FoundIn" attribute for a typical defect from Scrum process. I'm investigating a way like this:
1
doesn't work the same in server side.
private IWorkItemServer fWorkItemServer = getService(IWorkItemServer.class);
fWorkItemServer.findAttribute(projectArea, IWorkItem.FOUND_IN_PROPERTY, monitor);
Thank you very much! It really works. Finally produced code with getting the value for "FoundIn" attribute is next:
showing 5 of 6
show 1 more comments
|
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.