Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Creating diffs & Storing revisions also at Resource level
[CDO] Creating diffs & Storing revisions also at Resource level [message #1831721] Thu, 27 August 2020 13:24 Go to next message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 21
Registered: January 2018
Junior Member
Hi all,

I'm creating a REST API for CDO. When I upload an already existing resource, I use EMFCompare to calculate the differences between the repo version and the uploaded XMI-based version. I then copy the differences to the repo version and commit the transaction.

I've got two questions regarding this approach:


  1. Does CDO have a similar compare functionality that I could use, or is that only for comparing CDO-based resources? I recently found EMFDiffMerge, how does that compare to EMFCompare? Anybody any experiences?
  2. When you commit changes to an attribute of an eObject in a resource, you can only see the revisions of this change at the eObject level. Is it possible to also see these changes at the resource-level?
    Users can then quickly see what changes are done to a single resource.


Thanks in advance!
Ewoud
Re: [CDO] Creating diffs & Storing revisions also at Resource level [message #1831738 is a reply to message #1831721] Thu, 27 August 2020 17:39 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6556
Registered: July 2009
Senior Member
Ewoud Werkman wrote on Thu, 27 August 2020 15:24
Does CDO have a similar compare functionality that I could use, or is that only for comparing CDO-based resources? I recently found EMFDiffMerge, how does that compare to EMFCompare? Anybody any experiences?


No, CDO only has a scalable compare functionality to compare an entire CDO repository between two branch points.

Personally, I have no experiences with EMFDiffMerge.

Ewoud Werkman wrote on Thu, 27 August 2020 15:24
When you commit changes to an attribute of an eObject in a resource, you can only see the revisions of this change at the eObject level. Is it possible to also see these changes at the resource-level?
Users can then quickly see what changes are done to a single resource.


What do you mean by "you can only see the revisions of this change"? Are you referring to the History view of Eclipse? If so, then no, there's currently no "aggregation" of changes implemented, except for the entire repository.


Re: [CDO] Creating diffs & Storing revisions also at Resource level [message #1831771 is a reply to message #1831738] Fri, 28 August 2020 14:01 Go to previous messageGo to next message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 21
Registered: January 2018
Junior Member
Eike Stepper wrote on Thu, 27 August 2020 17:39
What do you mean by "you can only see the revisions of this change"? Are you referring to the History view of Eclipse? If so, then no, there's currently no "aggregation" of changes implemented, except for the entire repository.

Hi Eike,

Thanks for your reply.

Indeed, the history view of Eclipse is my reference, but I am not tied to that view.
What I want to do is present a list of all the changes applied to a specific resource and its containing eObjects to a user.

Can I do this programatically? E.g. could I do something like a
CDOResource.setModified(true)
on the resource, so the resource also gets a revision when a change is made to an EObject somewhere in the resource and is committed? What does setTrackingModification(true) do?

Should I do this by iterating through all its containing EObjects and query their history and create such an aggregation myself?
Or can I iterate through the history of the entire repo and somehow filter if it concerns my specific resource?
Any better ideas?

Thanks!
Ewoud
Re: [CDO] Creating diffs & Storing revisions also at Resource level [message #1831790 is a reply to message #1831771] Sat, 29 August 2020 06:05 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6556
Registered: July 2009
Senior Member
The Resource::modified attribute is transient, so you can't use it to create a new revision of the resource.

Resource.setTrackingModification(true) attaches a CDOModificationTrackingAdapter to the resource and all its contents. This adapter automatically maintains the transient Resource::modified attribute with the help of a CDOLazyContentAdapter. I don't think it's suitable for your purpose, but you could have a look at
org.eclipse.emf.cdo.util.CDOModificationTrackingAdapter to see how changes can be collected for subtrees.

Quote:
Should I do this by iterating through all its containing EObjects and query their history and create such an aggregation myself?


Then you would miss the deltas of objects that used to be in the resource but are currently not in it.

Quote:
Or can I iterate through the history of the entire repo and somehow filter if it concerns my specific resource?


That sounds more like the solution you want. But of course it's a very time consuming. That's also the reason why CDO doesn't offer an out-of-the-box functionality to create aggregates of changes of subtrees. If you really opt for this approach I would recommend to create the aggregate on the server-side. Otherwise you'd probably load the entire history of the entire repository on the client-side; again for each resource the user selects.


Re: [CDO] Creating diffs & Storing revisions also at Resource level [message #1831910 is a reply to message #1831790] Wed, 02 September 2020 12:21 Go to previous messageGo to next message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 21
Registered: January 2018
Junior Member
Hi Eike,

Thanks for your explanation. I need to find time to find out how to create such an aggregate on the server-side (e.g. SQL query).
Until then my plan is to update the root element's version attribute (which happens to be part of the model) everytime there are changes to be commited (set it to cdoRevision().getVersion()+1). That way I only have to query the root elements' revisions to see who and what has changed in the model itself.


Re: [CDO] Creating diffs & Storing revisions also at Resource level [message #1831915 is a reply to message #1831910] Wed, 02 September 2020 14:53 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6556
Registered: July 2009
Senior Member
You can not change a revision's version directly, there's no public setter. And you must not call the internal setter. You can only change the version by modifying a modeled feature of the root element and successfully committing the change. Frequently locking/changing the same single object can reduce concurrency dramatically.

Re: [CDO] Creating diffs & Storing revisions also at Resource level [message #1832040 is a reply to message #1831915] Mon, 07 September 2020 10:20 Go to previous message
Ewoud Werkman is currently offline Ewoud WerkmanFriend
Messages: 21
Registered: January 2018
Junior Member
Quote:
You can only change the version by modifying a modeled feature of the root element and successfully committing the change. Frequently locking/changing the same single object can reduce concurrency dramatically.

That is exactly what I am doing, for now. The amount of updates will be low for the current use case.
A future version requires, as you said, a solution at the server side. But I don't know yet how to approach that and what kind of effort that would take. I didn't play with SQL or OCL queries yet (I assume that is what you meant) and need to know more about the internals of CDO before I can do that.
Previous Topic:emf adoption
Next Topic:Test
Goto Forum:
  


Current Time: Sun Apr 18 09:42:30 GMT 2021

Powered by FUDForum. Page generated in 0.01460 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top