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

How to identify the Associated work item type of a Change set using Event handler?

hi,

I need to restrict the Change set to be associated with ONE PARTICULAR WORK ITEM TYPE. Else, error message should be thrown.

I started to build event handler thru server side plugin project. But I don't know the exact APIs to be used.

Guide me with some samples or workshops for event handler.

0 votes

Comments

I am using RTC 3.0.1.2 and hence I dont have the Predefined precondition in Deliever (Server) for querying work items.



4 answers

Permanent link
OK, here goes, I have taken an hour to get the answer for you guys. I shall make it a blog entry soon, but for now....

Please carefully look at

com.ibm.team.filesystem.service.internal.ServerRequireWorkItemAdvisor
com.ibm.team.filesystem.service.internal.ServerRequireWorkItemAdvisor.ServerRequireWorkItemAdvisor

You will notice the constructor that passes the providerfactory in the first advisor that instanciates the second one.

Please also note that the first extends AbstractScmService. Based on that and closely looking at what it does....

You need to extend AbstractScmService, then the code below gets you the work items.

        IRepositoryItemService itemService = getService(IRepositoryItemService.class);   
        ProviderFactory providerFactory = new ServerProviderFactory(this, itemService);
       
        for (IChangeSetHandle iChangeSetHandle : changeSetHandles) {
           
            List<ILink> links= ChangeSetLinks.findLinks(providerFactory, iChangeSetHandle, new String[] { ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID }, monitor);
            for (ILink link : links) {
                Object resolved = link.getTargetRef().resolve();
                if (resolved instanceof IWorkItemHandle) {
                    IWorkItemHandle wiHandle = (IWorkItemHandle) resolved;
                    IWorkItem workItem = (IWorkItem) workItemServer.getAuditableCommon().resolveAuditable(wiHandle, IWorkItem.FULL_PROFILE, monitor);
                    IWorkItem workingCopy= (IWorkItem) workItem.getWorkingCopy();
                    System.out.println(" Linked to: " + workItem.getId());
                }
            }

Please note you are calling internal API here!

I needed these prerequisites.

               <prerequisites>
                        <requiredService interface="com.ibm.team.workitem.service.IWorkItemServer" />
                          <requiredService interface="com.ibm.team.workitem.common.IWorkItemCommon" />
                          <requiredService interface="com.ibm.team.links.common.service.ILinkService" />
                          <requiredService interface="com.ibm.team.workitem.common.IAuditableCommon" />
                          <requiredService interface="com.ibm.team.repository.service.IRepositoryItemService" />   
                          <requiredService interface="com.ibm.team.scm.common.IScmService" />   
                          <requiredService interface="com.ibm.team.process.service.IProcessServerService" />   
                                
               </prerequisites>

This code is for an Advisor.


1 vote


Permanent link
Hi,

I have developed a advisor for Source control Deliver (Server) operation.
I got the change set content. But I don't know the API to read associated work item details

Any clues now?

0 votes


Permanent link
I have posted a bunch of work item related api examples hrere: https://rsjazz.wordpress.com/

0 votes

Comments

Many thanks ralph for starting this million dollar blog. But sorry what I am looking for is not in the page.


Permanent link
I would assume you have to follow a link. https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ talks about links.

You are looking for a reference or related item at the change set with endpoint         IEndPointDescriptor changeSet= ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.CHANGE_SET).getTargetEndPointDescriptor();

instead of the parent. That's what I have to get you started at the moment. Maybe someone has more details.

Here is a post from recently that talks about creating that link. I assume you should be able to figure out how to detect there is one of this type from the change set.

0 votes

Comments

Ralph, The above code is to get the Change Set from given work item. But what I want is the reverse. that is to get the associated work item from the given change set. so that I will verify the work item type of the associated work item during the Deliver operation.

Anybody?

I am looking for the same calls.  I need to enforce that the change set is linked (either directly or indirectly) to a particular work item type.  So far, I have not found a way to go from a change set to a work item.  Have you had any luck?

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,938
× 411

Question asked: Aug 23 '12, 1:18 a.m.

Question was seen: 7,045 times

Last updated: Oct 30 '12, 12:46 p.m.

Confirmation Cancel Confirm