How to create an Approval Descriptor using java api?
Akshata Kulkarni (37●3●20)
| asked Jul 15 '16, 2:43 a.m.
edited Jul 15 '16, 3:22 a.m. by Ralph Schoon (63.5k●3●36●46)
Hello,
I am using java apis to create a descrioptor object and search it in IApprovals. To create a descriptor Object i used the IBM provided code snippet: .. IApprovals approvals = workItem.getApprovals(); IApprovalDescriptor descriptor= approvals.createDescriptor(WorkItemApprovals.REVIEW_TYPE.getIdentifier(), fApprovalName); but when i get the object as ... |
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Jul 15 '16, 3:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see https://rsjazz.wordpress.com/2012/10/01/adding-approvals-to-work-items-using-the-plain-java-client-libraries/ or https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/
Ralph Schoon selected this answer as the correct answer
Comments
Akshata Kulkarni
commented Jul 26 '16, 3:39 a.m.
Thanks for the response.
Akshata Kulkarni
commented Sep 02 '16, 12:54 a.m.
Could anyone please give me an update on the question i mentioned above?
Thanks in advance!
Obviously you would retrieve all the approvals and then have to go through these. As far as I can tell, the only information you can use to compare are type and name.
|
One other answer
Ralph Schoon (63.5k●3●36●46)
| answered Sep 14 '16, 7:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Some example code:
/** * Tries to find a an approval from the approval data and deletes it if it * can be found Removes only the first instance found that matches. * * @param approvalData * @return */ private boolean updateRemoveApproval(ApprovalInputData approvalData) { IApprovals approvals = getWorkItem().getApprovals(); List<IApproval> approvalContent = approvals.getContents(); for (IApproval anApproval : approvalContent) { IApprovalDescriptor descriptor = anApproval.getDescriptor(); if (descriptor.getTypeIdentifier().equals( approvalData.getApprovalType()) && descriptor.getName().equals( approvalData.getApprovalName())) { approvals.remove(anApproval); approvals.remove(descriptor); return true; } } return false; } Comments
Akshata Kulkarni
commented Sep 23 '16, 9:00 a.m.
I have used the similar code as mentioned above. I wanted to eliminate the loops and make a quick search using java comparator.That is the reason i created an approval object and set its name and type to proper values and then used java 's comparator function to search the particular object.Comparator function required the attributes to compare.Therefore when tried to fetch the approval's name using :
Ralph Schoon
commented Sep 23 '16, 10:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I think something similar is in the links: Please see https://rsjazz.wordpress.com/2012/10/01/adding-approvals-to-work-items-using-the-plain-java-client-libraries/ or https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ That I provided above already. IApprovalDescriptor descriptor = approvals.createDescriptor( WorkItemApprovals.REVIEW_TYPE.getIdentifier(), fApprovalName); for (IContributorHandle reviewer : reviewers) { IApproval approval = approvals.createApproval(descriptor, reviewer); approvals.add(approval); } |
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.
Comments
Could anyone please give me an update on the question i mentioned above?