Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » rool back on resource creation
rool back on resource creation [message #415510] Wed, 19 December 2007 13:26 Go to next message
Eclipse UserFriend
Originally posted by: laurent.legoff.geensy.com

Hello,
I'm about to integrate transaction plugin into our tool. To learn this
new api, I read the documentation and I write some test code to
manipulate the api. I wonder why a resource is not remove from
resourceset after a rollback, in the transaction I just create a
resource in a resource and add content in this resource. Is is anyone
know why this is done like this?
see the code below, the last assert is not what I'm waiting.

thanks

public void testAbortTransaction()
{
final int [] ntimes = new int[]{0};
ResourceSetListenerImpl resourceSetListener = new ResourceSetListenerImpl(){
public Command transactionAboutToCommit(ResourceSetChangeEvent
event) throws RollbackException {
ntimes[0]++;
assertTrue(event.getNotifications().size() >= 1);
throw new
RollbackException(PlatformExceptionUtil.createErrorStatus("Roll back"));
};
};
editingDomain.addResourceSetListener(resourceSetListener);
final Resource [] resource = new Resource[1];
RecordingCommand command = new RecordingCommand(editingDomain,
"Test Recording Transaction", "Test Recording Transaction") {
@Override
protected void doExecute()
{
resource[0] = createResource();
Person person = PeopleFactory.eINSTANCE.createPerson();
resource[0].getContents().add(person);
assertFalse(resource[0].getContents().isEmpty());
}
};
editingDomain.getCommandStack().execute(command);
editingDomain.removeResourceSetListener(resourceSetListener) ;
assertEquals(ntimes[0], 1);
// the transaction has been aborted and resource have to be empty
assertTrue(resource[0].getContents().isEmpty());
// the resource set is not empty !!
assertTrue(editingDomain.getResourceSet().getResources().isE mpty());
}
Re: rool back on resource creation [message #415514 is a reply to message #415510] Wed, 19 December 2007 14:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Laurent,

Chris can best answer this but because proxy resolves can cause
resources to be added you generally can't expect proxies to be
unresolved as part of undo...


Laurent Le Goff wrote:
> Hello,
> I'm about to integrate transaction plugin into our tool. To learn this
> new api, I read the documentation and I write some test code to
> manipulate the api. I wonder why a resource is not remove from
> resourceset after a rollback, in the transaction I just create a
> resource in a resource and add content in this resource. Is is anyone
> know why this is done like this?
> see the code below, the last assert is not what I'm waiting.
>
> thanks
>
> public void testAbortTransaction()
> {
> final int [] ntimes = new int[]{0};
> ResourceSetListenerImpl resourceSetListener = new
> ResourceSetListenerImpl(){
> public Command transactionAboutToCommit(ResourceSetChangeEvent
> event) throws RollbackException {
> ntimes[0]++;
> assertTrue(event.getNotifications().size() >= 1);
> throw new
> RollbackException(PlatformExceptionUtil.createErrorStatus("Roll back"));
> };
> };
> editingDomain.addResourceSetListener(resourceSetListener);
> final Resource [] resource = new Resource[1];
> RecordingCommand command = new RecordingCommand(editingDomain,
> "Test Recording Transaction", "Test Recording Transaction") {
> @Override
> protected void doExecute()
> {
> resource[0] = createResource();
> Person person = PeopleFactory.eINSTANCE.createPerson();
> resource[0].getContents().add(person);
> assertFalse(resource[0].getContents().isEmpty());
> }
> };
> editingDomain.getCommandStack().execute(command);
> editingDomain.removeResourceSetListener(resourceSetListener) ;
> assertEquals(ntimes[0], 1);
> // the transaction has been aborted and resource have to be empty
> assertTrue(resource[0].getContents().isEmpty());
> // the resource set is not empty !!
> assertTrue(editingDomain.getResourceSet().getResources().isE mpty());
> }


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: rool back on resource creation [message #415515 is a reply to message #415514] Wed, 19 December 2007 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: laurent.legoff.geensy.com

Thank you,
But I don't understand why object cannot be reverted to proxy if there's
an undo. This is not a real "RollBack" or "Undo".
This is a feature or a bug?

thank you for being so quick to answer ;-)

Laurent

Ed Merks a écrit :
> Laurent,
>
> Chris can best answer this but because proxy resolves can cause
> resources to be added you generally can't expect proxies to be
> unresolved as part of undo...
>
>
> Laurent Le Goff wrote:
>> Hello,
>> I'm about to integrate transaction plugin into our tool. To learn this
>> new api, I read the documentation and I write some test code to
>> manipulate the api. I wonder why a resource is not remove from
>> resourceset after a rollback, in the transaction I just create a
>> resource in a resource and add content in this resource. Is is anyone
>> know why this is done like this?
>> see the code below, the last assert is not what I'm waiting.
>>
>> thanks
>>
>> public void testAbortTransaction()
>> {
>> final int [] ntimes = new int[]{0};
>> ResourceSetListenerImpl resourceSetListener = new
>> ResourceSetListenerImpl(){
>> public Command transactionAboutToCommit(ResourceSetChangeEvent
>> event) throws RollbackException {
>> ntimes[0]++;
>> assertTrue(event.getNotifications().size() >= 1);
>> throw new
>> RollbackException(PlatformExceptionUtil.createErrorStatus("Roll back"));
>> };
>> };
>> editingDomain.addResourceSetListener(resourceSetListener);
>> final Resource [] resource = new Resource[1];
>> RecordingCommand command = new RecordingCommand(editingDomain,
>> "Test Recording Transaction", "Test Recording Transaction") {
>> @Override
>> protected void doExecute()
>> {
>> resource[0] = createResource();
>> Person person = PeopleFactory.eINSTANCE.createPerson();
>> resource[0].getContents().add(person);
>> assertFalse(resource[0].getContents().isEmpty());
>> }
>> };
>> editingDomain.getCommandStack().execute(command);
>> editingDomain.removeResourceSetListener(resourceSetListener) ;
>> assertEquals(ntimes[0], 1);
>> // the transaction has been aborted and resource have to be empty
>> assertTrue(resource[0].getContents().isEmpty());
>> // the resource set is not empty !!
>> assertTrue(editingDomain.getResourceSet().getResources().isE mpty());
>> }
Re: rool back on resource creation [message #415516 is a reply to message #415514] Wed, 19 December 2007 15:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Ed,

Did you mean Christian?

In any case, rollback and undo only revert changes to the resource contents.
The Transaction API treats the entire resource set as an interconnected
data set, and the resources as meta-data in the classic sense of "data
about data." Transactions record and manage only changes to the data,
which includes changes to the existence of objects (as members of resource
contents lists).

You should find that the contents that you added to the new resource are not
present after a rollback, but the resource will still exist and will still
be loaded.

HTH,

Christian

Ed Merks wrote:

> Laurent,
>
> Chris can best answer this but because proxy resolves can cause
> resources to be added you generally can't expect proxies to be
> unresolved as part of undo...
>
>
> Laurent Le Goff wrote:
>> Hello,
>> I'm about to integrate transaction plugin into our tool. To learn this
>> new api, I read the documentation and I write some test code to
>> manipulate the api. I wonder why a resource is not remove from
>> resourceset after a rollback, in the transaction I just create a
>> resource in a resource and add content in this resource. Is is anyone
>> know why this is done like this?
>> see the code below, the last assert is not what I'm waiting.
>>
>> thanks

-----8<-----
Re: rool back on resource creation [message #415519 is a reply to message #415515] Wed, 19 December 2007 15:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Laurent,

This behaviour is the designed intent, so I suppose it would be classified
as a "feature."

Resolving a proxy or loading a resource doesn't change any data (or, more
specifically, the *abstract state* of any objects) so why would you unload
it?

cW

Laurent Le Goff wrote:

> Thank you,
> But I don't understand why object cannot be reverted to proxy if there's
> an undo. This is not a real "RollBack" or "Undo".
> This is a feature or a bug?
>
> thank you for being so quick to answer ;-)
>
> Laurent

-----8<-----
Re: rool back on resource creation [message #415521 is a reply to message #415516] Wed, 19 December 2007 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: laurent.legoff.geensy.com

Thank you. Your response satisfy my curiosity.

Laurent

Christian W. Damus a écrit :
> Hi, Ed,
>
> Did you mean Christian?
>
> In any case, rollback and undo only revert changes to the resource contents.
> The Transaction API treats the entire resource set as an interconnected
> data set, and the resources as meta-data in the classic sense of "data
> about data." Transactions record and manage only changes to the data,
> which includes changes to the existence of objects (as members of resource
> contents lists).
>
> You should find that the contents that you added to the new resource are not
> present after a rollback, but the resource will still exist and will still
> be loaded.
>
> HTH,
>
> Christian
>
> Ed Merks wrote:
>
>> Laurent,
>>
>> Chris can best answer this but because proxy resolves can cause
>> resources to be added you generally can't expect proxies to be
>> unresolved as part of undo...
>>
>>
>> Laurent Le Goff wrote:
>>> Hello,
>>> I'm about to integrate transaction plugin into our tool. To learn this
>>> new api, I read the documentation and I write some test code to
>>> manipulate the api. I wonder why a resource is not remove from
>>> resourceset after a rollback, in the transaction I just create a
>>> resource in a resource and add content in this resource. Is is anyone
>>> know why this is done like this?
>>> see the code below, the last assert is not what I'm waiting.
>>>
>>> thanks
>
> -----8<-----
Re: rool back on resource creation [message #415523 is a reply to message #415516] Wed, 19 December 2007 17:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090906010407080006010607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Christian,

Sorry. Today is just not my day. I just had a car accident too. :'(
If only people would use those handy signals and wouldn't feel the need
to turn right and then left in icy conditions.


Christian W. Damus wrote:
> Hi, Ed,
>
> Did you mean Christian?
>
> In any case, rollback and undo only revert changes to the resource contents.
> The Transaction API treats the entire resource set as an interconnected
> data set, and the resources as meta-data in the classic sense of "data
> about data." Transactions record and manage only changes to the data,
> which includes changes to the existence of objects (as members of resource
> contents lists).
>
> You should find that the contents that you added to the new resource are not
> present after a rollback, but the resource will still exist and will still
> be loaded.
>
> HTH,
>
> Christian
>
> Ed Merks wrote:
>
>
>> Laurent,
>>
>> Chris can best answer this but because proxy resolves can cause
>> resources to be added you generally can't expect proxies to be
>> unresolved as part of undo...
>>
>>
>> Laurent Le Goff wrote:
>>
>>> Hello,
>>> I'm about to integrate transaction plugin into our tool. To learn this
>>> new api, I read the documentation and I write some test code to
>>> manipulate the api. I wonder why a resource is not remove from
>>> resourceset after a rollback, in the transaction I just create a
>>> resource in a resource and add content in this resource. Is is anyone
>>> know why this is done like this?
>>> see the code below, the last assert is not what I'm waiting.
>>>
>>> thanks
>>>
>
> -----8<-----
>


--------------090906010407080006010607
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Christian,<br>
<br>
Sorry.&nbsp; Today is just not my day.&nbsp; I just had a car accident too.&nbsp;<span
class="moz-smiley-s15"><span> :'( </span></span>&nbsp; If only people
would use those handy signals and wouldn't feel the need to turn right
and then left in icy conditions.<br>
<br>
<br>
Christian W. Damus wrote:
<blockquote cite="mid:fkbdpd$38n$1@build.eclipse.org" type="cite">
<pre wrap="">Hi, Ed,

Did you mean Christian?

In any case, rollback and undo only revert changes to the resource contents.
The Transaction API treats the entire resource set as an interconnected
data set, and the resources as meta-data in the classic sense of "data
about data." Transactions record and manage only changes to the data,
which includes changes to the existence of objects (as members of resource
contents lists).

You should find that the contents that you added to the new resource are not
present after a rollback, but the resource will still exist and will still
be loaded.

HTH,

Christian

Ed Merks wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Laurent,

Chris can best answer this but because proxy resolves can cause
resources to be added you generally can't expect proxies to be
unresolved as part of undo...


Laurent Le Goff wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
I'm about to integrate transaction plugin into our tool. To learn this
new api, I read the documentation and I write some test code to
manipulate the api. I wonder why a resource is not remove from
resourceset after a rollback, in the transaction I just create a
resource in a resource and add content in this resource. Is is anyone
know why this is done like this?
see the code below, the last assert is not what I'm waiting.

thanks
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
-----8&lt;-----
</pre>
</blockquote>
<br>
</body>
</html>

--------------090906010407080006010607--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Inhibiting EMF Lazy Loading For Manual Proxy URI Update
Next Topic:EOpposite for multiple children
Goto Forum:
  


Current Time: Fri Apr 19 22:55:44 GMT 2024

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

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

Back to the top