Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Using a Resource (URI) direct for M2M Transformation with ATL
[CDO] Using a Resource (URI) direct for M2M Transformation with ATL [message #639625] Wed, 17 November 2010 08:59 Go to next message
Eclipse UserFriend
Originally posted by: polzer.embedded.rwth-aachen.de

Hi,

i did the tutorial and followed the webinar. There i see
several accessing a CDO resource. But with the URI
described there i am only able to access the folders.

Is it possible to create an URI that has direct access to a
resource and can be used by an transformation language like
ATL?

Thanks

Andreas
Re: [CDO] Using a Resource (URI) direct for M2M Transformation with ATL [message #639649 is a reply to message #639625] Wed, 17 November 2010 10:03 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 17.11.2010 09:59, schrieb Andreas Polzer:
> Hi,
>
> i did the tutorial and followed the webinar. There i see
> several accessing a CDO resource. But with the URI
> described there
Can you give an example of such URI?

> i am only able to access the folders.
What happens if you do it?

> Is it possible to create an URI that has direct access to a
> resource and can be used by an transformation language like
> ATL?
It is certainly possible to call ResourceSet.getResource(uri, true) with

uri := cdo://repo-uuid/folder/resource

But with that URI format you're expected to associate the resourceSet with a CDOView/CDOTransaction:

CDOTransaction tx = session.openTransaction(resourceSet);
// work with the resource set
tx.commit();
session.close();

If you don't want to do all the scaffolding yourself you may want to read about the new "connection aware) URI format: https://bugs.eclipse.org/bugs/show_bug.cgi?id=326186#c10 , but be aware that there's no mechanism that closes connections that have been automatically opened.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Using a Resource (URI) direct for M2M Transformation with ATL [message #639680 is a reply to message #639649] Wed, 17 November 2010 12:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: polzer.embedded.rwth-aachen.de

Hi,

> Can you give an example of such URI?

I used the example given by Bernd Kolb (CDO Quickstart)
I registered an toy metamodel and added a folder:

CDO Server
+-> folder
+->Res1
| +-> Node1
+-> Res2
+-> Node2
+-> Node3

Node1, Node2 and Node3 are root Notes of my models. So the
thing i have to access

>> i am only able to access the folders.
> What happens if you do it?

So try to access the NodeX via a Ant skript:
<atl.loadModel
modelhandler="EMF"
metamodel="MM"
name="IN_M"
uri=" cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1"
/>
But i do not know how to access Node1 (name of root note) if
i try it as written above:
[atl.loadModel] Loading model IN_M from
cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1
[atl.loadModel] org.eclipse.m2m.atl.core.ATLCoreException: Error loading
cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1 :
org.eclipse.emf.cdo.util.InvalidURIException: Invalid URI
" cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1":
org.eclipse.emf.cdo.common.util.CDOException: Expected folder for id = OID16

so how can i load such a Node. If I use
<atl.loadModel
modelhandler="EMF"
metamodel="MM"
name="IN_M"
uri="cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1"
/>
i've got no error but the resource IN_M is empty.

What can i do?

> CDOTransaction tx = session.openTransaction(resourceSet);
> // work with the resource set
> tx.commit();
> session.close();
>
Is it necessary to write a new Function which get access to
an resource?

Thanks again,

Andreas
Re: [CDO] Using a Resource (URI) direct for M2M Transformation with ATL [message #639711 is a reply to message #639680] Wed, 17 November 2010 14:45 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 17.11.2010 13:58, schrieb Andreas Polzer:
> Hi,
>
>> Can you give an example of such URI?
> I used the example given by Bernd Kolb (CDO Quickstart)
> I registered an toy metamodel and added a folder:
>
> CDO Server
> +-> folder
> +->Res1
> | +-> Node1
> +-> Res2
> +-> Node2
> +-> Node3
>
> Node1, Node2 and Node3 are root Notes of my models. So the
> thing i have to access
I see.

>>> i am only able to access the folders.
>> What happens if you do it?
> So try to access the NodeX via a Ant skript:
> <atl.loadModel
> modelhandler="EMF"
> metamodel="MM"
> name="IN_M"
> uri=" cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1"
> />
> But i do not know how to access Node1 (name of root note)
Generally you access an object within a resource through the URI fragment, the stuff appended to the hash sign "#".

In CDO the URI fragments are made of the CDOID (id type + id value), e.g. #L4711. Hence you must know this id before you ask for the object. If you submit an enhancement request we yould eventually try to provide a positional fragment format in addition.

> if
> i try it as written above:
> [atl.loadModel] Loading model IN_M from
> cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1
> [atl.loadModel] org.eclipse.m2m.atl.core.ATLCoreException: Error loading
> cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1 :
> org.eclipse.emf.cdo.util.InvalidURIException: Invalid URI
> " cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1/Node1":
> org.eclipse.emf.cdo.common.util.CDOException: Expected folder for id = OID16
Correct, all segments of the URI path preceding the last segment must resolve to folders.

> so how can i load such a Node. If I use
> <atl.loadModel
> modelhandler="EMF"
> metamodel="MM"
> name="IN_M"
> uri="cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1"
> />
That should correctly load resource Res1.

> i've got no error but the resource IN_M is empty.
How did you find out that it's empty? The debugger can fool you as CDOResourceImpl is not a regular EObjectImpl, i.e. it does not store its state in instance fields.


> What can i do?
a) The easiest approach would be to determine the CDOID and then use uri="cdo://1ff5d226-b1f0-40fb-aba2-0c31b38c764f/folder/Res1#Lnnn". Try System.out.println(EcoreUtil.getURI(node1));

b) Submit the bugzilla mentioned above and provide a patch or wait until we find time ;-)

>> CDOTransaction tx = session.openTransaction(resourceSet);
>> // work with the resource set
>> tx.commit();
>> session.close();
>>
> Is it necessary to write a new Function which get access to
> an resource?
Not sure I understand this question...

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Previous Topic:Serializing EObjects over a webservice
Next Topic:Re: serialize ecore references into container
Goto Forum:
  


Current Time: Fri Apr 26 05:01:48 GMT 2024

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

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

Back to the top