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

How to get previous values (state) of an ITimeSheetEntry?

Hi,

I'm developing an IOperationParticipant that needs to detect the exact change on time tracking.

In order to get previous values of an WorkItem attribute inside an IOperationParticipant, I simply use:


IWorkItem oldWorkItem = (IWorkItem) saveParameter.getOldState();


But as far as I know, ITimeSheetEntry is linked to a WorkItem using endpoint WorkItemEndPoints.WORK_TIME. So my question is: How to get previous states of those linked objects, or what is the extension point to listen to ITimeSheetEntry changes?

I tried this, but obviously didn't work, because it gets the current values of the links:

List<ITimeSheetEntry> listTimeChildren = new ArrayList<ITimeSheetEntry>();

IWorkItemServer service = getService(IWorkItemServer.class);
IWorkItemReferences workItemReferences = service.resolveWorkItemReferences(oldWorkItem , null);
List<IReference> listReferences = workItemReferences.getReferences(WorkItemEndPoints.WORK_TIME);
for (IReference reference : listReferences) {
if (reference.isItemReference()) {
referencedItem = ((IItemReference) reference).getReferencedItem();
if (referencedItem instanceof ITimeSheetEntryHandle) {
timeChild = (ITimeSheetEntry) repositoryItemService.fetchItem(referencedItem, null);
listTimeChildren.add(timeChild);

}
}
}


For new or deleted ITimeSheetEntry, I can use getCreatedReferences and getDeletedReferences. But if the user change a value of an existing entry, I'm unable to find out what entry has been changed.

0 votes

Comments

Any idea?  I have the same question. 



3 answers

Permanent link
 I worked out a workaround that traverse all  ITimeSheetEntry.modified() and get the TimeSheetEntry which modified in last a few seconds in the followup action.  

0 votes


Permanent link

This is an old question, but for anyone that is still wondering, I have a more direct way than looking at the recently modified timesheets.

IWorkItemServer service = getService(IWorkItemServer.class);

ArrayList<IReference> newLinks = new ArrayList<IReference>();

ArrayList<IReference> oldLinks = new ArrayList<IReference>();

IWorkItemReferences newReferences = saveParameter.getNewReferences();

newLinks.addAll(newReferences.getReferences(WorkItemEndPoints.WORK_TIME));

if(saveParameter.getOldState() != null) {

     IWorkItem previousWI = (IWorkItem) (saveParameter.getOldState());

     IWorkItemReferences oldReferences = service.resolveWorkItemReferences((IWorkItemHandle) previousWI.getItemHandl(), monitor);

     oldLinks.addAll(oldReferences.getReferences(WorkItemEndPoints.WORK_TIME));  

}

As usual, remember that if you are using the IWorkItemServer object, you'll need to add the "requiredService" node to the plugin.xml of your MANIFEST.MF file.

0 votes


Permanent link
In general for IAuditables, and ITimeSheetEntry, you can get the two possible predecessors like this:

        IAuditable.getPredecessorState()
        IAuditable.getMergePredecessorState()

Assuming that that history is actually preserved.

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

Question asked: Jul 28 '11, 9:52 a.m.

Question was seen: 4,530 times

Last updated: Apr 02 '15, 9:55 a.m.

Confirmation Cancel Confirm