How to set parent link when creating a work item java client
Hi,
i have created new workitem by plain java client. But when i create workitem i want to add parent link from plain java client. Thanks , Pugazh |
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Mar 28 '12, 4:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,
please see: https://jazz.net/forums/viewtopic.php?p=5489 There are several ways how to do it, important is the link type in WorkItemLinkTypes The code below seems to work also.
|
Hi,
Thanks for your response. I have found the solution.Check my code below. public class WorkItemInitialization extends AbstractWorkItemOperation { private String fSummary; private ICategoryHandle fCategory; private IAttribute iattribute; IWorkItem iparent; IWorkItemHandle target; public WorkItemInitialization(String summary, ICategoryHandle category, IWorkItem parent, IWorkItemHandle parent2, IAttribute ia,IWorkItemClient workItemClient) { super("Initializing Work Item"); fSummary = summary; fCategory = category; iattribute = ia; iparent = parent; target = parent2; this.workItemClient = workItemClient; } protected void execute(WorkItemWorkingCopy workingCopy,IProgressMonitor monitor) throws TeamRepositoryException { IWorkItem workItem = workingCopy.getWorkItem(); workItem.setHTMLSummary(XMLString.createFromPlainText(fSummary)); java.util.Date date= new java.util.Date(); String str_date="08-05-2012"; DateFormat formatter ; Date date1 = null ; formatter = new SimpleDateFormat("dd-M-yy"); try { date1 = (Date)formatter.parse(str_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } java.sql.Timestamp timeStampDate = new Timestamp(date1.getTime()); System.out.println("Today is " +timeStampDate); workItem.setCategory(fCategory); workItem.setDueDate(timeStampDate); IAttribute attr = workItemClient.findAttribute(workingCopy.getWorkItem().getProjectArea(),"Development.Planned_Start_Date", monitor); if (attr != null) { workItem.setValue(attr,timeStampDate); } attr = workItemClient.findAttribute(workingCopy.getWorkItem().getProjectArea(),"Development.Planned_Target_Date", monitor); if (attr != null) { workItem.setValue(attr,timeStampDate); } attr = workItemClient.findAttribute(workingCopy.getWorkItem().getProjectArea(),"Development.parent_dev", monitor); System.out.println("------------------------------"); System.out.println(attr); System.out.println("------------------------------"); if (attr != null) { workItem.setValue(attr,iparent ); } setParent(workingCopy,iparent); } private void setParent(WorkItemWorkingCopy wc, IWorkItem parent) { IEndPointDescriptor referenceType= WorkItemEndPoints.PARENT_WORK_ITEM; IReference reference= WorkItemLinkTypes.createWorkItemReference(parent); wc.getReferences().add(referenceType, reference); } } Thanks Glory |
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.