Modifying and saving work item
I try to modify a work item that was previously added in jazz. I get IWorkItem object with work item data. Than I would like to modify description, state, attachments and comments.
I use WorkItemInitialization object to modify and save work item:
WorkItemInitialization operation= new WorkItemInitialization(incomingWorkItem, category);
//modifying operation object data
addMissingData(incomingWorkItem, workItem, teamRepository, operation);
IWorkItemHandle handle= operation.run(workItemType, null);
IWorkItem workItem2= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);
System.out.println("Work item " + workItem2.getId() + " modified.");
private static class WorkItemInitialization extends WorkItemOperation {
//incoming data
private IWorkItem fWorkItem;
//changes
private String fDescription;
private String fState;
private ArrayList<File> fAttachments;
private ArrayList<String> fComments;
public WorkItemInitialization(IWorkItem workItem, ICategoryHandle category) {
super("Initializing Work Item");
this.fWorkItem = workItem;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {
IWorkItem workItem= workingCopy.getWorkItem();
workItem = this.fWorkItem;
IWorkItem itemCopy = (IWorkItem) workItem.getWorkingCopy();
itemCopy.setHTMLDescription(XMLString.createFromPlainText(fDescription));
workItem = itemCopy;
....
....
workingCopy.save(null);
}
....
}
I get an exception while executing:
auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null)
com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215I Item not found: com.ibm.team.workitem.common.internal.model.impl.WorkItemHandleImpl@5c925c92 (stateId: <unset>, itemId: , origin: com.ibm.team.repository.client.internal.TeamRepository@743e743e, immutable: <unset>)
at com.ibm.team.repository.client.internal.ItemManager.internalFetchItem(ItemManager.java:1581)
at com.ibm.team.repository.client.internal.ItemManager.access$0(ItemManager.java:1538)
Am I doing something wrong while changing work item data or changed work item schould be saved in different way?
I use WorkItemInitialization object to modify and save work item:
WorkItemInitialization operation= new WorkItemInitialization(incomingWorkItem, category);
//modifying operation object data
addMissingData(incomingWorkItem, workItem, teamRepository, operation);
IWorkItemHandle handle= operation.run(workItemType, null);
IWorkItem workItem2= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);
System.out.println("Work item " + workItem2.getId() + " modified.");
private static class WorkItemInitialization extends WorkItemOperation {
//incoming data
private IWorkItem fWorkItem;
//changes
private String fDescription;
private String fState;
private ArrayList<File> fAttachments;
private ArrayList<String> fComments;
public WorkItemInitialization(IWorkItem workItem, ICategoryHandle category) {
super("Initializing Work Item");
this.fWorkItem = workItem;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {
IWorkItem workItem= workingCopy.getWorkItem();
workItem = this.fWorkItem;
IWorkItem itemCopy = (IWorkItem) workItem.getWorkingCopy();
itemCopy.setHTMLDescription(XMLString.createFromPlainText(fDescription));
workItem = itemCopy;
....
....
workingCopy.save(null);
}
....
}
I get an exception while executing:
auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null)
com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215I Item not found: com.ibm.team.workitem.common.internal.model.impl.WorkItemHandleImpl@5c925c92 (stateId: <unset>, itemId: , origin: com.ibm.team.repository.client.internal.TeamRepository@743e743e, immutable: <unset>)
at com.ibm.team.repository.client.internal.ItemManager.internalFetchItem(ItemManager.java:1581)
at com.ibm.team.repository.client.internal.ItemManager.access$0(ItemManager.java:1538)
Am I doing something wrong while changing work item data or changed work item schould be saved in different way?