how to restore an old record from the updateReport by a job

One Star

how to restore an old record from the updateReport by a job

hi,
on the MDM interface, it's possible to restore a record using the updateReport by clicking on the line we want and choosing "restore".
Now i try to do the same but i want to do this action in a job.
is it possible to call a webservice or other thing to restore a selected record?
i use Talend MDM 5.3.1 (TIS) with the java 1.7 and windows 7
Employee

Re: how to restore an old record from the updateReport by a job

There is a REST API for getting a snapshot of a record at any point in time, based on the journal. You can then submit that as the new record through tMDMOutput (and this change can itself be rollbacked if it produces yet another journal entry...).
I have a sample somewhere, let me dig it. I'll get back to you on this thread.
One Star

Re: how to restore an old record from the updateReport by a job

thanks for this answer, i'am interested in your sample.
but one disadvantage: with your solution, i have to keep and store all primaryKey of all entities to follow every changes . . . a little bit heavy, isn't it?
i want to restore any line of any entity
for example:
a file inject datas so i have updated lines in an entity with a field called "file_source"
if i delete this source, i want to restore old values of eachl lines of all entities which have "file_source" = my file deleted
Employee

Re: how to restore an old record from the updateReport by a job

I am afraid you will have to implement a 2 step process:
#1 retrieve all record keys based on your criteria with tMDMInput or tMDMViewSearch
#2 for each key invoke the 'rollback' service to restore it to what it was before the change
In fact I am not sure how you will do #2 because the rollback service is time-based, it is a 'time machine', you give it the date/time you want the record to go back to, you can't tell it 'rollback to before file_source changed to x', you must tell it WHEN.
So in 5.3 the API was undocumented but I know it has been used. Problem is, in 5.4 we overlooked it and while the underlying capability is still there, the interface went away. We are putting it back as a documented REST service in the next version. I am considering backporting the feature to 5.4.2 too. Therefore, if you decide to use this, be aware that it is not sustainable, you will have to move to the REST service when you upgrade.
In 5.3:
GET /updatereport/secure/documentHistory?action={current | before | next}&date={java time mills}&dataCluster={container}&dataModel={model}&concept={entity}&key={id}&revision=
action= current | before | next --> create the snapshot as close as possible to the date provided | at the first update before that | at the first update after that
Last time I tried it successfully on my machine I did:
http://localhost:8180/updatereport/secure/documentHistory?action=current&date=1358849980343&dataCluster=Product&dataModel=Product&concept=Product&key=231035935&revision=
In the next version:
GET /datamanager/services/data/container_name/type_name/id
The "swing" value must be one of:
closest: default behavior if swing is unspecified.
before: move to the previous version of the record.
after: move to the next version of the record.
For "before" and "after" if there's no state (i.e. in case you already are at the first state or the last one), MDM returns same as "closest".
Example:
http://localhost:8180/datamanager/services/data/Product/Store/12?datetime=2014-02-27T17:00:00&swing=before
One Star

Re: how to restore an old record from the updateReport by a job

thanks for the information, we try it fastly.
last question: is it possible to do the same but not to restore, only to delete this line in updateReport?
maybe it's not complicated but just one point is difficult:
we have in the updateReport:
Date/Time id old_value new_value
20131225 1 toto titi
20131226 1 titi tata
20131227 1 tata tété
if we want to delete the second line (20131226) the old_value of the third line (20131227) has to be changed in "titi" to keep the logic.
Employee

Re: how to restore an old record from the updateReport by a job

Why would you do that? You don't want to change history, it is a crucial point of a governance product. If you want to restore to 20131226, ask the rollback service for a snapshot of the record at this date and update the record with those values. It will add a new journal entry as well at, say, 20131228. The rollback itself can thus be traced -- and the rollback can be... rollbacked.
Date/Time id old_value new_value
20131225 1 toto titi
20131226 1 titi tata
20131227 1 tata tété
20131228 1 tété tata <--- update with snapshot of 20131226
One Star

Re: how to restore an old record from the updateReport by a job

OK, so it's not a good thing to delete a line, even a restore create a line in updateReport . . .
to come back in the first point, /updatereport/secure/documentHistory doesn't exist:
"ERROR 404 - NOT AVAILABLE"
tREST or a browser return this answer
Employee

Re: how to restore an old record from the updateReport by a job

Like I said it's 5.3 only, it's gone in 5.4 right now, but we'll put it back.
One Star

Re: how to restore an old record from the updateReport by a job

I think there is a misunderstanding
you said that in 5.3 you use "GET /updatereport/secure/documentHistory?action=......"
and in 5.4 you use: "GET /datamanager/services/data/container_name/type_name/id......"
SO, i am in 5.3.1, why can't i see /updatereport/secure/documentHistory ?