Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain
[CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain [message #1749470] Wed, 07 December 2016 07:02 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
using CDO together with a TransactionalEditingDomain (e.g. when running CDO with Papyrus) we have the following issue:

The CDOId of an object that is re-attached by a redo is changed if the transaction was comitted between the undo and redo.

The following test case fails:
 public void testCdoIdInUndoRedoCommitScenario() throws Exception
  {
    TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
    ResourceSet resourceSet = domain.getResourceSet();

    Company company = getModel1Factory().createCompany();

    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction(resourceSet);
    CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));

    resource.getContents().add(company);
    resource.save(null);

    PurchaseOrder order = getModel1Factory().createPurchaseOrder();

    domain.getCommandStack().execute(AddCommand.create(domain, company,
        company.eClass().getEStructuralFeature(Model1Package.COMPANY__PURCHASE_ORDERS), Collections.singleton(order)));

    resource.save(null);

    CDOID cdoId1 = CDOUtil.getCDOObject(order).cdoID();

    domain.getCommandStack().undo();

    resource.save(null);

    CDOID cdoId2 = CDOUtil.getCDOObject(order).cdoID();

    Assert.assertTrue(cdoId2 == null);

    domain.getCommandStack().redo();

    resource.save(null);

    CDOID cdoId3 = CDOUtil.getCDOObject(order).cdoID();

    // Since order is still the same object the same ID is expected
    Assert.assertTrue(CDOIDUtil.equals(cdoId1, cdoId3));

  }


I understand that the commit removes all information in the transaction regarding the order object. Thus from a CDO perspective the undo looks just like adding a new object therefore the new ID. But from a user perspective it is still the same order. In an audit mode the new ID extinguishes the history of the object. I am wondering if there is something we could do in this case. I think I could somehow save the ID of the object so that it could be available upon undo but I am not sure how to recover the state of the object in the repository.

Regards,
Thorsten

Re: [CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain [message #1749472 is a reply to message #1749470] Wed, 07 December 2016 07:32 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Yes, that is expected behavior. Once the CDOTransaction is committed you can not expect a higher-level transaction to roll back CDO-internal data. I suggest you flush the undo stack of the EMFTransaction whenever you commit the lower-level CDOTransaction.

Re: [CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain [message #1749473 is a reply to message #1749472] Wed, 07 December 2016 07:43 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
As I am auto comitting every command execution this would completely disable undo\redo.
Re: [CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain [message #1749475 is a reply to message #1749473] Wed, 07 December 2016 07:50 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Yes.

Re: [CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain [message #1749505 is a reply to message #1749470] Wed, 07 December 2016 13:50 Go to previous messageGo to next message
Pavel Vlasov is currently offline Pavel VlasovFriend
Messages: 23
Registered: December 2015
Junior Member
How about hiding the order from the user by setting some flag instead of deleting?
Then actually deleting hidden objects at some later point of time when the undo commands are already gone, e.g. when the user closes the application or the editor.
Re: [CDO] Object changes it's CDOID in an Undo\Redo Scenario using TransactionalEditingDomain [message #1749534 is a reply to message #1749505] Wed, 07 December 2016 20:48 Go to previous message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Thanks for our input but the point is that if you run CDO in audit mode then deletion of an objects already results in flagging the revision in the database as being deleted. So there is no real deletion. An undo would necesserily mean to reset this flag. Appart from the fact that the information about the object being part of the object tree is gone after the commit there is currently no functionality to reset the deletion in the database. Instead a new object is created with a new primary key. My problem is that I have some other functionality that uses this object key as a foreign key which now points to a different object after undo.
Previous Topic:[CDO] First pass through resource contents slow?
Next Topic:Runtime exception: Feature 'owner' is not a valid changeable feature
Goto Forum:
  


Current Time: Tue Apr 23 17:15:06 GMT 2024

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

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

Back to the top