Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Question about CDO notification and RevisionManage
[CDO] Question about CDO notification and RevisionManage [message #430918] Wed, 17 June 2009 16:51 Go to next message
Eclipse UserFriend
Originally posted by: adomas.greicius.nomagic.com

Hello,

I would like to ask same questions about RevisionManager. Is there any
documentation of RevisionManager?

While handling remove object notification, I do not get old object. If I
try to get Object from revisionManager using version from notification,
got null. . If I decrease version by one and then try to get revision it is
ok. Is it a bug?

public void notifyChanged(Notification msg) {


if (msg instanceof CDODeltaNotification) {

CDODeltaNotification cdoDeltaNotification = (CDODeltaNotification) msg;

int version = cdoDeltaNotification.getRevisionDelta().getOriginVersion();

CDORevision revision =
cTransaction.getSession().getRevisionManager().getRevisionBy Version(
locksContainer.cdoID(), 0, version - 1);

Object o = revision.data().get(XXXX.Literals.XXXX, msg.getPosition());

}

}

Same times I get exception IndexOutOfBoundsException, when I try to get
data from revision. Should I decrease position?

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

revision.data().get(XXXX.Literals.XXXX, msg.getPosition());

If I handle removed object notification in remote client, I do not get
oldObject (It is null). What is the best way to get OldObject?
Re: [CDO] Question about CDO notification and RevisionManage [message #430929 is a reply to message #430918] Thu, 18 June 2009 01:06 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hi Adomas,

Adomas Greicius wrote:
> Hello,
>
> I would like to ask same questions about RevisionManager. Is there any
> documentation of RevisionManager?
>
> While handling remove object notification, I do not get old object. If I
> try to get Object from revisionManager using version from notification,
> got null. . If I decrease version by one and then try to get revision it is
> ok. Is it a bug?
>
Don't know yet! :-)

> public void notifyChanged(Notification msg) {
>
>
> if (msg instanceof CDODeltaNotification) {
>
> CDODeltaNotification cdoDeltaNotification = (CDODeltaNotification) msg;
>
> int version = cdoDeltaNotification.getRevisionDelta().getOriginVersion();
>
> CDORevision revision =
> cTransaction.getSession().getRevisionManager().getRevisionBy Version(
> locksContainer.cdoID(), 0, version - 1);
>
Why you take locksCOntainer.cdoID ? Why not
cdoDeltaNotification.getRevisionDelta().getID() ? (Since I don't know
whichs objects it is... I'm not sure where locksCOntainer came from).

> Object o = revision.data().get(XXXX.Literals.XXXX, msg.getPosition());
Is it a one-to-many relationship ? or one to one ? (Not related to the
problem... just a question)
Why you don't use EStructuralFeature feature =
(EStructuralFeature)cdoDeltaNotification .getFeature();
Since you don't know which feature changed... how can you use the
msg.getPosition ?

Be careful when you play with position... you can use it in the old
revision only if it is not a ADD (Like in Standard EMF).

Ex:
object.getElements().size(); // size == 4
object.getElements().add(newObject); //

The notification received would be :
msg.getPosition() == 4
It will not make sense for ADD notification to go to the previous
version and do the following:
object.getElements().get(4); // INDEX OUT OF BOUND

But if you are saying it was a Remove... then you can do it. It really
depends of the kind of notification.. and you should add a test in your
adapter.

>
> }
>
> }
>
> Same times I get exception IndexOutOfBoundsException, when I try to get
> data from revision. Should I decrease position?
>
> java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
>
> revision.data().get(XXXX.Literals.XXXX, msg.getPosition());
>
> If I handle removed object notification in remote client, I do not get
> oldObject (It is null). What is the best way to get OldObject?
>
>
I did a small case
- I used .getOriginVersion() and notification.getFeature().


if (notification instanceof CDODeltaNotification)
{

CDODeltaNotification cdoDeltaNotification =
(CDODeltaNotification)notification;

int version =
cdoDeltaNotification.getRevisionDelta().getOriginVersion();

CDORevision revision =
tx2.getSession().getRevisionManager().getRevisionByVersion(
cdoDeltaNotification.getRevisionDelta().getID(), 0, version);
EStructuralFeature feature =
(EStructuralFeature)notification.getFeature();
Object o = revision.data().get(feature,
notification.getPosition());
System.out.println(o);
}

All worked very nicely.

By the way which Back-end are you using? (Mysql? MEM ? Others? )


Simon
>
>
>
>
>
>
>
>
>
>
>
>
>
Re: [CDO] Question about CDO notification and RevisionManage [message #430952 is a reply to message #430929] Fri, 19 June 2009 14:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adomas.greicius.nomagic.com

Thanks Simon for your example. It helped a lot.
We are using DBStore. Same times we use with MySQL and same time with Derby.

"Simon McDuff" <smcduff@hotmail.com> wrote in message
news:h1c3qq$iig$1@build.eclipse.org...
> Hi Adomas,
>
> Adomas Greicius wrote:
>> Hello,
>>
>> I would like to ask same questions about RevisionManager. Is there any
>> documentation of RevisionManager?
>>
>> While handling remove object notification, I do not get old object. If I
>> try to get Object from revisionManager using version from notification,
>> got null. . If I decrease version by one and then try to get revision it
>> is ok. Is it a bug?
>>
> Don't know yet! :-)
>
>> public void notifyChanged(Notification msg) {
>>
>>
>> if (msg instanceof CDODeltaNotification) {
>>
>> CDODeltaNotification cdoDeltaNotification = (CDODeltaNotification) msg;
>>
>> int version = cdoDeltaNotification.getRevisionDelta().getOriginVersion();
>>
>> CDORevision revision =
>> cTransaction.getSession().getRevisionManager().getRevisionBy Version(
>> locksContainer.cdoID(), 0, version - 1);
>>
> Why you take locksCOntainer.cdoID ? Why not
> cdoDeltaNotification.getRevisionDelta().getID() ? (Since I don't know
> whichs objects it is... I'm not sure where locksCOntainer came from).
>
>> Object o = revision.data().get(XXXX.Literals.XXXX, msg.getPosition());
> Is it a one-to-many relationship ? or one to one ? (Not related to the
> problem... just a question)
> Why you don't use EStructuralFeature feature =
> (EStructuralFeature)cdoDeltaNotification .getFeature();
> Since you don't know which feature changed... how can you use the
> msg.getPosition ?
>
> Be careful when you play with position... you can use it in the old
> revision only if it is not a ADD (Like in Standard EMF).
>
> Ex:
> object.getElements().size(); // size == 4
> object.getElements().add(newObject); //
>
> The notification received would be :
> msg.getPosition() == 4
> It will not make sense for ADD notification to go to the previous version
> and do the following:
> object.getElements().get(4); // INDEX OUT OF BOUND
>
> But if you are saying it was a Remove... then you can do it. It really
> depends of the kind of notification.. and you should add a test in your
> adapter.
>
>>
>> }
>>
>> }
>>
>> Same times I get exception IndexOutOfBoundsException, when I try to get
>> data from revision. Should I decrease position?
>>
>> java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
>>
>> revision.data().get(XXXX.Literals.XXXX, msg.getPosition());
>>
>> If I handle removed object notification in remote client, I do not get
>> oldObject (It is null). What is the best way to get OldObject?
>>
>>
> I did a small case
> - I used .getOriginVersion() and notification.getFeature().
>
>
> if (notification instanceof CDODeltaNotification)
> {
>
> CDODeltaNotification cdoDeltaNotification =
> (CDODeltaNotification)notification;
>
> int version =
> cdoDeltaNotification.getRevisionDelta().getOriginVersion();
>
> CDORevision revision =
> tx2.getSession().getRevisionManager().getRevisionByVersion(
> cdoDeltaNotification.getRevisionDelta().getID(), 0,
> version);
> EStructuralFeature feature =
> (EStructuralFeature)notification.getFeature();
> Object o = revision.data().get(feature,
> notification.getPosition());
> System.out.println(o);
> }
>
> All worked very nicely.
>
> By the way which Back-end are you using? (Mysql? MEM ? Others? )
>
>
> Simon
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
Re: [CDO] Question about CDO notification and RevisionManage [message #430953 is a reply to message #430952] Fri, 19 June 2009 14:39 Go to previous message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
You are welcome.

Let me know if you still think it doesn`t behave correctly.

Simon
Previous Topic:Loading unique reference
Next Topic:Get domain model file in RPC Editor
Goto Forum:
  


Current Time: Fri Apr 26 18:07:09 GMT 2024

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

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

Back to the top