Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get attachment history with JAVA SDK ?

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

1 vote

Comments

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

Please let us know any comments or  updates for the question

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


Accepted answer

Permanent link

  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

0 votes

Comments

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

 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.


0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937
× 67
× 51

Question asked: Apr 12 '16, 10:24 a.m.

Question was seen: 3,998 times

Last updated: Apr 12 '17, 4:37 p.m.

Confirmation Cancel Confirm