|
|
|
|
|
Re: [CDO] Saving resources in transaction [message #1061249 is a reply to message #1061014] |
Thu, 30 May 2013 18:41 |
|
Am 29.05.2013 16:02, schrieb Martin odloucký:
> Hi Eike,
> thank you very much for the link. I donwloaded the plugin from Git and studied the code. I have also looked at some
> documentation I have found. Unfortunately, I could not grasp the basic idea. I learned that you somehow create a
> source and target systems (such as FileSystemTransferSystem or RespositoryTransferSystem) and then create a
> CDOTransform object to perform the task.
So you could grasp the basic idea :P
> I have succesfully defined a source element of a file on my disk but I have no idea how to map it to another file or
> to a repository location.
Try these methods:
org.eclipse.emf.cdo.transfer.CDOTransfer.map(IPath, IProgressMonitor)
org.eclipse.emf.cdo.transfer.CDOTransfer.map(String, IProgressMonitor)
org.eclipse.emf.cdo.transfer.CDOTransfer.map(CDOTransferElement, IProgressMonitor)
> Sadly the FileSystemUIProvider class in the transfer plugins says TODO in convertTransferTarget method in which I
> hoped I would have found a hint.
Yeah, due to time constraints some methods are not implemented, yet. They're not needed for basic functionality.
>
> If you could provide just a few lines of simple code of how to do a very basic mapping you would make me happy for an
> entire week.
You're almost there. Try the methods above, call CDOTransfer.perform() and you're done.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: [CDO] Saving resources in transaction [message #1061362 is a reply to message #1061342] |
Fri, 31 May 2013 10:33 |
|
Am 31.05.2013 11:57, schrieb Martin odloucký:
> Ok Eike,
> seems you won't give me anything for free, will you? :) Well, I still believe that if you had written me five lines of
> code we would have saved each other a lot of time. But it seems you want to play the game. Alright then :)
No games. I'm just busy with the Kepler release preparations and way behind my schedule. I wish there was more
documentation available.
>
> This is what I have came up with so far
>
>
> CDOTransferElement source = FileSystemTransferSystem.INSTANCE.getElement(new Path("/some/file.xmi"));
> CDOSession cdoSession = connector.openSession("demo", "127.0.0.1", "2036");
> CDOTransaction transaction = cdoSession.openTransaction();
> CDOTransferSystem target = new RepositoryTransferSystem(transaction);
> CDOTransfer transfer = new CDOTransfer(source.getSystem(), target);
> CDOTransferMapping mapping = transfer.map("/some/file.xmi", new NullProgressMonitor());
> mapping.setRelativePath("/foo");
> transfer.perform();
> transaction.commit();
> transaction.close();
>
>
> After executing this block there is no resource 'foo' in the repo event though there was no expception thrown or
> semothing. Can you tell me what I am doing wrong?
I don't see anything that immediately pops into my eyes. What happens if you omit the setRelativePath() call? If that
doesn't help and there are no exceptions I recommend to set a breakpoint and step into the perform() call.
>
> Also I would like to ask if it is possible to transform resources already loaded in memory. Sometime the user creates
> the model and wants to upload it on the server without having it saved on hard drive before.
That's currently not supported by the resource transfer framework. If you submit a bugzilla we can discuss the new
feature there.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: [CDO] Saving resources in transaction [message #1061381 is a reply to message #1061374] |
Fri, 31 May 2013 11:53 |
|
Am 31.05.2013 13:18, schrieb Martin odloucký:
> Thanks Eike,
> I understand you are very busy and I appreciate your answers very much. I started debugging your code and I am now
> confident I can get it work. I have two points:
>
> * I think that direct transfer of ResourceSets can be done by implementing something like ResourceSetTransferSystem
> similar to FileSystemTransferSystem. I am going to do it right now since I need it for my project.
That was my idea, too ;-)
> * Your ResourceFactoryRegistryWithoutDefaults does not work correctly. I don't know what is the purpouse
How can you judge then whether it works correctly? :P
> of this class but it corrupts ResourceSet loading capabilities. For example, ResourceSet with this factory cannot load
> files with pure xmi extension. I am not sure how to fix it, since do resource loading mechanism in EMF is quite
> complex to me.
The resource transfer framework tries to figure out whether a transfer element (e.g. a file) is a model resource or a
"normal" file (see JavaDoc of ResourceFactoryRegistryWithoutDefaults) by attempting to load the file into a resourceset.
That would always succeed with the default extension / content type being registered.
You just need to register the resource factories for the files you want to be recognized (but not under the default
extension!).
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03467 seconds