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

RTC API: how to set a work item modification date to an arbitrary one?

Context: copying work item histories from one repository to another.
When reading a workitem state, I can read when it has been saved to the server:

IWorkItem wi;
Date d;
//...
d = wi.modified();

</pre>

It's all good, I can read when a work item has been updated.

Now, I would like to write a new work item or update a work item and specify a timestamp for the update itself, a different one than the one automatically set by the server. How can I override the default timestamp put by the server and set an arbitrary modification date (my goal is to reflect the original history from the source repository)? Thanks!

EDIT: same thing for the user: I would like to change not only the timestamp of a change, but also the user who did it.

0 votes


Accepted answer

Permanent link

 I am merely speculating here, but I could imagine that lots of things that provide incremental updating and caching functionality depend on no games being played with the modification date, in which case even if you did find some way to do this, you wouldn't want to.   I'd suggest storing some custom property like "original-mod-date" if this info is important to maintain.

Jerome De selected this answer as the correct answer

0 votes

Comments

Yes, I thought the same and it is what I did (https://github.com/jeromede/rtc.pa#workaround-for-work-items-history).

But this limitation makes it impossible to develop a rather exact migration tool using only the API :-(

Thanks!


2 other answers

Permanent link

The return type of date field should be: timestamp. 


So, final return type should be :, 
return new Timestamp(date. GetTime());

0 votes

Comments

Thanks, but it is not helping with my question.


Permanent link

I have tried that and have not been able to change the modified date so far in the Java API, as this seems to be encapsulated in the API and the modification date is set when performing the save operation based on the server system time. I was able to change the creation date and the creator, but not the modification date since IWorkItem does not expose methods to set the values. I looked again today and found some promising methods on the implementation classes for the IWorkItem interface. Any IWorkItem implements the implementation class com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl, so the cast should be ok. So you can try the following (No guarantee that the change does not get overwritten though. I don't have the time to try it out.):

((com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl)workItem).setModifiedBy(null);  

((com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl)workItem).setModified((Timestamp)calculateTimestamp(parameter));

0 votes

Comments

Thanks a lot, Ralph! (And yes, there would also be the person who modifies to override). I tried your suggestion, but, unfortunately, it looks like the save() on the working copy sets the modification time back to the server time... :-(

That was my fear and my current experience as well. 

com.ibm.team.workitem.common.internal.model.WorkItem has the methods as well.

You can search for where the methods are used in the SDK and maybe find a way. I am not very optimistic though. 

Trying to tweak com.ibm.team.workitem.common.internal.model.WorkItem doesn't work either.
I guess the date/user is updated in the save() anyway...
Thanks again.

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,942
× 369

Question asked: Jun 26 '17, 9:04 a.m.

Question was seen: 3,996 times

Last updated: Jul 26 '17, 9:31 a.m.

Confirmation Cancel Confirm