It's all about the answers!

Ask a question

How to get attachment history with JAVA SDK ?


David MICHEL (1471638) | asked Apr 12 '16, 10:24 a.m.
edited Apr 12 '16, 10:26 a.m.
Hello,
I work on history of my workitems with Java SDK.
I get all information saved in the past on a workitem with this code :
IAuditableHandle auditableHandle = (IAuditableHandle) iWorkItem.getStateHandle();
List<IWorkItemHandle> handleList = this.teamRepository.itemManager().fetchAllStateHandles(auditableHandle, monitor);
for (IWorkItemHandle wiHandle : handleList) {
IWorkItem wi = (IWorkItem) this.teamRepository.itemManager().fetchCompleteState((IAuditableHandle) wiHandle, monitor); System.out.println(wi.modified());
}
I obtain without problem the history of my workitems
Now I add to my code this methods to get informations about attachments :

IWorkItemCommon common = (IWorkItemCommon) teamRepository.getClientLibrary(IWorkItemCommon.class);
IAuditableClient auditableClient = (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
IWorkItemReferences workitemReferences = common.resolveWorkItemReferences(wi, monitor);
List<IReference> referencesList = workitemReferences.getReferences(WorkItemEndPoints.ATTACHMENT);
for (IReference iReference : referencesList) {
   IAttachmentHandle attachHandle = (IAttachmentHandle) iReference.resolve();

   IAttachment attachment = (IAttachment)
auditableClient.resolveAuditable((IAttachmentHandle) attachHandle,IAttachment.DEFAULT_PROFILE, null);

System.out.println(attachment.getName());
}
Problem : I get attachments information only on the current state of my workitem.
Is it possible to obtain past informations about attachments (Attachment added or deleted)

Thanks for your help
Regards

Mathieu

Comments
Mathieu Defianas commented Apr 13 '16, 5:20 a.m.

Hello,
I have the same problem to the links.
In fact, I cannot get informations in history about attachments (if an attachment is added ? when ? if an attachment is removed ...)
I have the same problem with links.
Whereas, I have no problem to get past informations on Workitems : Find the value of a specific field 3 weeks ago, is not a problem for me
Thanks for your help
Mathieu


Arun K Sriramaiah commented Apr 28 '16, 11:41 a.m.

Please let us know any comments or  updates for the question


Mathieu Defianas commented May 02 '16, 5:36 a.m.

Is it possible to obtain past informations about references ie attachments or links (References added or deleted)?

Accepted answer


permanent link
Ralph Schoon (57.1k23642) | answered Apr 12 '17, 5:58 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

  From reading the interface documentation the interface 


com.ibm.team.repository.common.IAuditable 

provides the methods

com.ibm.team.repository.common.IAuditable.getPredecessorState() 

and 

com.ibm.team.repository.common.IAuditable.getMergePredecessorState() 

which you should be able to use to get to the history items. I have no example code for it. If you have such a state, you resolve it like you do above. Then you should be able to access the history. I don't know how the information for attachments is managed this way.

Ralph Schoon selected this answer as the correct answer

Comments
Ralph Schoon commented Apr 12 '17, 7:02 a.m. | edited Apr 12 '17, 7:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No worries. Just note that you could have avoided this by 


2. You can in general comment on questions and answers and you can answer questions, try to get yourself used to the difference and don't answer with a new question (a comment might be appropriate)

PS: I accepted the solution converted to an answer based on your comment that it is working for you. If you want to post your code here, feel free to do so. 

One other answer



permanent link
Song Jie (362) | answered Apr 12 '17, 6:29 a.m.
edited Apr 12 '17, 6:39 a.m.

 Hello, Ralph, plesae don't ban me. I'll delete this msg asap if it's inappropriate. I have to input as an answer as it doesn't allow me to comment or whisper to you. I'll just delete it later.


I read your reply about getting the workitem history. It works. Sorry for not replying my thanks earlier, as there wasn't a comment button, and I thought reply "thank you" as a second answer is inappropriate.

The comment you just input above is about getting the workitem history, but this question is about getting a history of attachments, which isn't included in a previous state of the workitem, and IReference doesn't extend IAuditable, which makes it impossible to getPredecessorState().

I sincerely don't have the intention to flood any forum anywhere, because of which I'm replying to this old question, as my question is exactly the same and unanswered. I can ask a new question and move everything there if necessary.

Finally my sincere apologies if my previous behavior annoyed you. I've deleted all my previous posts, if necessary this one too. Your advice is mostly welcome.


Your answer


Register or to post your answer.