[CDO] - CDOResource [message #1780928] |
Tue, 30 January 2018 01:41  |
Eclipse User |
|
|
|
Hello Team,
1] The first question is about the CDO's Virtual File system (aka ResourceTree).
Right now, our client presents the users with a browser where we can create/load/save the model elements in XMI format. We would like to list down the contents of a CDO repository in the same way. The idea is to have our model elements organized into files and folders which facilitate an easy access. I would be glad if you can help me with a graceful way of creating and working with files and folders.
I read the documentation and the available online and created an unbaked version of CDOResourceFolder and added a CDO resource into it.
cdoTransaction = openTransaction();
CDOResourceFolder resourceFolder = cdoTransaction.createResourceFolder(folderName);
resourceFolder.addResource(resourceName);
CDOResource resource = cdoTransaction.createResource("/" + folderName + "/" +resourceName);
commitTransaction(cdoTransaction);
I am pretty sure I am missing something here or have interpreted the implementation wrongly. If I create an Online Transactional copy, I find the resourceFolder to be created and it contains the resource. However, I end up getting the Error (Please find attached Error.txt) printed in the console.
2] The second question is regarding the transactions. I happen to use one transaction to create the resource. I commit and close the transaction right after.
In order to work on the resource, I first open the transaction and get the resource, add the object to the resource content, commit and close the transaction. Please correct me if I am wrong. Right now, I am using:
CDOResource resource = transaction.getResource("/path/to/resource");
resource.getContents().add(UserDefinedbject);
However, I will have to find the resourcePath dynamically and not hard-code this. I can obtain the ResourceSet using the EditingDomain. I couldn't find any way to obtain the resourcePath. Is there anything that could be done about it?
Attachment: Error.txt
(Size: 3.24KB, Downloaded 94 times)
|
|
|
|
Re: [CDO] - CDOResource [message #1781135 is a reply to message #1781068] |
Thu, 01 February 2018 13:41   |
Eclipse User |
|
|
|
Hello Eike,
Thank you very much for the prompt reply. I can confirm that it did answer both of my questions.
I have another question regarding the objects that have been altered. Our application makes use of EMF Edit (EditingDomain, CommandStack).
As of now, I am trying to open a new transaction before and after this to capture the changes. However, to persist the changes, I will have to do something like,
CDOTransaction transaction = SessionManager.openTransaction();
CDOResource resource = transaction.getRootResource();
editingDomain.getCommandStack().execute(command);
resource.getContents().add(<Not sure what to add here>);
transaction.commit();
One of the ways I tried to do this is to use: command.getAffectedObjects() This returns me a Collection<?> of objects.
I am not sure if that's the best way to tackle this issue. In short, I would like to know if there is a way to easily keep track of all the changes that the objects underwent and then persist them? I humbly request you to guide me on this.
Regards,
Nirmal
[Updated on: Thu, 01 February 2018 16:16] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04571 seconds