How to fetch workitem Approvals through Jazz API
Hi,
I developed a java client to retrieve a workitem base on several criteria. Now I tried to retrieve the Approvals associated with this workitem and retrieve the Reviewer/submitter of the Approvals: IApprovals approvals = searchWorkItem.getApprovals(); java.util.List<IApproval> approval = approvals.getContents() ; From the JavaDoc the object com.ibm.team.workitem.common.model.IApprovals has the following method: IContributorHandle getApprover() -> Returns the contributor that is asked for approval. IApprovalDescriptor getDescriptor() -> Returns the approval descriptor this approval belongs to. I tried to retrieve both IContributorHandle and IApprovalDescriptor objects but have no luck here. Could someone please help here? Thanks. |
13 answers
Thanks. I think my question is regarding on this method:
findLinksByTarget(java.lang.String[] linkTypeIds, IReference target, IProgressMonitor monitor) From the sample code : linkManager.findLinksByTarget("com.ibm.team.filesystem.workitems.change_set", workItemReference, monitor); The target is set to com.ibm.team.filesystem.workitems.change_set. The method returns the link of the changeset associated with the workitem. My question is if I want to retrieve the link of the related worktitem assoicated to the original workitem (parent, children, related, etc), I would expect we have to set the target to one of the following: public static final String RELATED_WORK_ITEM= "com.ibm.team.workitem.linktype.relatedworkitem"; //$NON-NLS-1$ public static final String DUPLICATE_WORK_ITEM= "com.ibm.team.workitem.linktype.duplicateworkitem"; //$NON-NLS-1$ public static final String COPIED_WORK_ITEM= "com.ibm.team.workitem.linktype.copiedworkitem"; //$NON-NLS-1$ public static final String RELATED_ARTIFACT= "com.ibm.team.workitem.linktype.relatedartifact"; //$NON-NLS-1$ public static final String ATTACHMENT= "com.ibm.team.workitem.linktype.attachment"; //$NON-NLS-1$ public static final String BLOCKS_WORK_ITEM= "com.ibm.team.workitem.linktype.blocksworkitem"; //$NON-NLS-1$ public static final String PARENT_WORK_ITEM= "com.ibm.team.workitem.linktype.parentworkitem"; //$NON-NLS-1$ Thanks. I'm not sure I understand the question: |
Nick,
I tried to run the following code. By running in the debug mode: There is an object returned by this method: linkQueryPage = linkManager.findLinksByTarget("com.ibm.team.workitem.common.model.WorkItemLinkTypes.RELATED_WORK_ITEM", workItemReference, monitor); Now when the code proceeds on this method it returns null. ILinkCollection linkCollection = linkQueryPage.getAllLinksFromHereOn(); There are two different workitems (APAR workitem 54, APAR subTask 55) and I set the Related link between 54 and 55. Any advise? public void getRelatedWorkItem(IWorkItem workItem, IProgressMonitor monitor) throws TeamRepositoryException{ System.out.println("getRelatedWorkItem starts"); ILinkManager linkManager = (ILinkManager) teamRepository.getClientLibrary(ILinkManager.class); IReferenceFactory referenceFactory = linkManager.referenceFactory(); IReference workItemReference = referenceFactory.createReferenceToItem(workItem.getItemHandle()); //Find all ILinks which attach a change set to the work item. ILinkQueryPage linkQueryPage = null; try { linkQueryPage = linkManager.findLinksByTarget("com.ibm.team.workitem.common.model.WorkItemLinkTypes.RELATED_WORK_ITEM", workItemReference, monitor); } catch (TeamRepositoryException e) { // TODO Auto-generated catch block e.printStackTrace(); } ILinkCollection linkCollection = linkQueryPage.getAllLinksFromHereOn(); //Put the ILinks in a list. List<ILink> linksById = (List<ILink>)linkCollection.getLinksById("com.ibm.team.workitem.common.model.WorkItemLinkTypes.RELATED_WORK_ITEM"); List <IItemHandle> temp21 = new ArrayList<IItemHandle>(); for (ILink link : linksById){ IReference ref = link.getTargetRef();// or getTargetReference() if (ref.isItemReference()) { IItemReference itemRef = (IItemReference) ref; IItemHandle itemHandle = itemRef.getReferencedItem(); IWorkItemHandle iworkitemHandle = (IWorkItemHandle)itemHandle; temp21.add(0, iworkitemHandle); } IItemManager itemManager = teamRepository.itemManager(); IFetchResult temp100 = itemManager.fetchCompleteItemsPermissionAware(temp21, 0, monitor); List <com> temp200 = null; temp200 = temp100.getRetrievedItems(); if (temp200!=null){ System.out.println ("temp200 is not null"); for (int i=0; i < temp200.size(); i++){ com.ibm.team.workitem.common.model.IWorkItem _iworkItem = (com.ibm.team.workitem.common.model.IWorkItem) temp200.get(i); System.out.println("_iworkItem: "+ _iworkItem.getId()); } } /* //List<ILink> changeSetLinks = linksById; System.out.println("********************"+ linksById.size()); //ALWAYS getting size 0 List<IReference> changeSetReferences = new ArrayList<IReference>(); for (ILink link : changeSetLinks) { IChangeSetHandle changeSetHandle = (IChangeSetHandle)link.getSourceRef().resolve(); ItemId<IChangeSet> changeSetItemId = ChangeSetUtil.getChangeSet(changeSetHandle); */ } } |
You're passing "com.ibm.team.workitem.common.model.WorkItemLinkTypes.RELATED_WORK_ITEM" as a literal string. Try using the constant instead:
com.ibm.team.workitem.common.model.WorkItemLinkTypes.RELATED_WORK_ITEM (i.e. without quotes) Its value is: "com.ibm.team.workitem.linktype.relatedworkitem". |
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.