Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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!

0 votes


Accepted answer

Permanent link
 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

1 vote

Comments

Thank you!
But in this case, is there a way to get non null team repository object with some another library? How can I get not null getOrigin?

It's possible that the origin wasn't set for the item. The documentation states it can return null if the origin is unknown.

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:

IWorkItemClient client = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
if (projectArea != null) {
        IAttribute filedAgainst = client.findAttribute(projectArea, IWorkItem.FOUND_IN_PROPERTY, monitor);
}

But client variable requires repo parameter which I can not get now. May be my way is wrong, isn't it?  :(

I tried getOrigin() for current workitem and process area. Everywhere, it's null! But how can it be null, if I already connected to the repository?  :( :( :(

doesn't work the same in server side. 


private IWorkItemServer fWorkItemServer = getService(IWorkItemServer.class);
fWorkItemServer.findAttribute(projectArea, IWorkItem.FOUND_IN_PROPERTY, monitor); 

1 vote

Thank you very much! It really works. Finally produced code with getting the value for "FoundIn" attribute is next:

        ...IWorkItem wi...

        IWorkItemServer fWorkItemServer = getService(IWorkItemServer.class);
        IAttribute attr_foundIn = fWorkItemServer.findAttribute(projectArea,
                IWorkItem.FOUND_IN_PROPERTY, monitor);
        IDeliverableHandle wi_foundIn = (IDeliverableHandle) wi.getValue(attr_foundIn);
        IDeliverable foundIn = (IDeliverable) itemService.fetchItem(wi_foundIn,
                IRepositoryItemService.COMPLETE);
        ... = foundIn.getName();

showing 5 of 6 show 1 more comments

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Apr 01 '14, 9:34 a.m.

Question was seen: 2,956 times

Last updated: Apr 01 '14, 11:52 a.m.

Confirmation Cancel Confirm