Skip to main content



      Home
Home » Modeling » EMF » Using an EMF Resource without persisting it
Using an EMF Resource without persisting it [message #1061475] Fri, 31 May 2013 16:07 Go to next message
Eclipse UserFriend
Hello everyone!

I have a Resource, which has been created after a programmatic model-to-model transformation with QVT and it holds the output of the transformed model. For now it is being persisted into an xmi-file. But I want to give this transformed model to another method as a parameter for further use (search etc.), without persisting it.

How should I realize it? I believe, it is not easy -or maybe even not possible- to use a Resource without persisting it. Don't I have to create also a specific URI for this Resource? And doesn't it mean persisting it?

Should I then use the model elements directly, as they are still a List of EObjects? If so, I will have to make some changes to my whole project, since this other method, which needs the model output(that is for now being persisted), uses a Resource object.

Would be very thankful for any kind of help.

Thank you!
Re: Using an EMF Resource without persisting it [message #1061497 is a reply to message #1061475] Sat, 01 June 2013 02:13 Go to previous messageGo to next message
Eclipse UserFriend
Emre,

Comments below.

On 31/05/2013 10:07 PM, Emre Taspolatoglu wrote:
> Hello everyone!
>
> I have a Resource, which has been created after a programmatic
> model-to-model transformation with QVT and it holds the output of the
> transformed model. For now it is being persisted into an xmi-file. But
> I want to give this transformed model to another method as a parameter
> for further use (search etc.), without persisting it.
In what form does it want this other model? It sounds like you already
have it in memory...
>
> How should I realize it? I believe, it is not easy -or maybe even not
> possible- to use a Resource without persisting it.
That depends on what you mean by us. Of course it's in memory and you
can use it...
> Don't I have to create also a specific URI for this Resource?
Generally a resource as a URI to identify it, i.e., where it comes from
and where it should go when saved...
> And doesn't it mean persisting it?
When you call load or save...
>
> Should I then use the model elements directly, as they are still a
> List of EObjects?
Yes.
> If so, I will have to make some changes to my whole project, since
> this other method, which needs the model output(that is for now being
> persisted), uses a Resource object.
So pass in the resource.
>
> Would be very thankful for any kind of help.
It's not clear what your problem is. Perhaps it's a QVT question...
>
> Thank you!
>
Re: Using an EMF Resource without persisting it [message #1061516 is a reply to message #1061497] Sat, 01 June 2013 11:43 Go to previous messageGo to next message
Eclipse UserFriend
Hello Ed,

thanks for the quick reply.

The other class wants the model as resource and calls it with its URI. And for now I am letting it get the persisted model resource by using it platformURI.

But when I don't persist the resulted model by using save(), I get an empty file with the defined URI created and the following error:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseExceptionpublicId: platform:/plugin/..../.../.../sample.xmi; systemId: platform:/plugin/.../.../sample.xmi; lineNumber: 1; columnNumber: 1; Premature end of file.

I guess this logic of persisting was not clear enough to me. Unless you call the load() or save() on the created URI with the resulted object as input of the method, it won't get persisted. But the file path will be created, which can be seen in an axplorer?

I don't think my problem is a QVT question, since there is really nothing wrong with my transformation.

What I want to do, I can achieve completely, when the resulted resource is persisted. But when I give this resource with the model without saving it to the other class, it won't work. So the question I am asking myself is, whether it makes a different to use a model resource with our without persisting (saving/loading) it? Can a resource that isn't persisted into the file created be still called with its defined URI? And are somehow resources differently represented when they are indeed persisted into a file or only existing it the memory as a resource?

Thanks a lot again!



Ed Merks wrote on Sat, 01 June 2013 02:13
Emre,

Comments below.

On 31/05/2013 10:07 PM, Emre Taspolatoglu wrote:
> Hello everyone!
>
> I have a Resource, which has been created after a programmatic
> model-to-model transformation with QVT and it holds the output of the
> transformed model. For now it is being persisted into an xmi-file. But
> I want to give this transformed model to another method as a parameter
> for further use (search etc.), without persisting it.
In what form does it want this other model? It sounds like you already
have it in memory...

>
> How should I realize it? I believe, it is not easy -or maybe even not
> possible- to use a Resource without persisting it.
That depends on what you mean by us. Of course it's in memory and you
can use it...

> Don't I have to create also a specific URI for this Resource?
Generally a resource as a URI to identify it, i.e., where it comes from
and where it should go when saved...
> And doesn't it mean persisting it?
When you call load or save...

>
> Should I then use the model elements directly, as they are still a
> List of EObjects?
Yes.

> If so, I will have to make some changes to my whole project, since
> this other method, which needs the model output(that is for now being
> persisted), uses a Resource object.
So pass in the resource.

>
> Would be very thankful for any kind of help.
It's not clear what your problem is. Perhaps it's a QVT question...
>
> Thank you!
>

Re: Using an EMF Resource without persisting it [message #1061519 is a reply to message #1061516] Sat, 01 June 2013 13:31 Go to previous message
Eclipse UserFriend
Emre,

Comments below.

On 01/06/2013 5:43 PM, Emre Taspolatoglu wrote:
> Hello Ed,
>
> thanks for the quick reply.
> The other class wants the model as resource and calls it with its URI.
So it wants a URI. And it has not API for getting the resource object
itself?
> And for now I am letting it get the persisted model resource by using
> it platformURI.
I see.
> But when I don't persist the resulted model by using save(), I get an
> empty file with the defined URI created and the following error:
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
> org.xml.sax.SAXParseExceptionpublicId:
> platform:/plugin/..../.../.../sample.xmi; systemId:
> platform:/plugin/.../.../sample.xmi; lineNumber: 1; columnNumber: 1;
> Premature end of file.
Yes, if some tool tries to load a URI that refers to an empty stream,
you'd get that.
>
> I guess this logic of persisting was not clear enough to me. Unless
> you call the load() or save() on the created URI with the resulted
> object as input of the method, it won't get persisted.
Load, loads it and save saves it. That seems pretty clear...
> But the file path will be created, which can be seen in an axplorer?
If you save to the workspace you can see it in the explorers, yes.
>
> I don't think my problem is a QVT question, since there is really
> nothing wrong with my transformation.
It sounds like one question is "Can I pass in directly the objects I
want to transform or must they be deserialized into a resource via a URI.
>
> What I want to do, I can achieve completely, when the resulted
> resource is persisted. But when I give this resource with the model
> without saving it to the other class, it won't work.
Hence the need to ask the above question.
> So the question I am asking myself is, whether it makes a different to
> use a model resource with our without persisting (saving/loading) it?
Of course if you don't save something, another tool won't be able to
load something...
> Can a resource that isn't persisted into the file created be still
> called with its defined URI?
If you play enough games with things like the URI converter I suppose
so, but in the end, if some other tools insists on loading from a URI
then you'll need to provide them with the bytes they need to load.
> And are somehow resources differently represented when they are indeed
> persisted into a file or only existing it the memory as a resource?
It's like having an editor open, changing the contents, but not saving
it. How will another tool see the contents? If they insist on reading
it from the file system, you have to save it. So what's possible with
QVT? I don't know.
>
> Thanks a lot again!
>
>
>
> Ed Merks wrote on Sat, 01 June 2013 02:13
>> Emre,
>>
>> Comments below.
>>
>> On 31/05/2013 10:07 PM, Emre Taspolatoglu wrote:
>> > Hello everyone!
>> >
>> > I have a Resource, which has been created after a programmatic >
>> model-to-model transformation with QVT and it holds the output of the
>> > transformed model. For now it is being persisted into an xmi-file.
>> But > I want to give this transformed model to another method as a
>> parameter > for further use (search etc.), without persisting it.
>> In what form does it want this other model? It sounds like you
>> already have it in memory...
>>
>> >
>> > How should I realize it? I believe, it is not easy -or maybe even
>> not > possible- to use a Resource without persisting it.
>> That depends on what you mean by us. Of course it's in memory and
>> you can use it...
>>
>> > Don't I have to create also a specific URI for this Resource?
>> Generally a resource as a URI to identify it, i.e., where it comes
>> from and where it should go when saved...
>> > And doesn't it mean persisting it?
>> When you call load or save...
>>
>> >
>> > Should I then use the model elements directly, as they are still a
>> > List of EObjects? Yes.
>>
>> > If so, I will have to make some changes to my whole project, since
>> > this other method, which needs the model output(that is for now
>> being > persisted), uses a Resource object.
>> So pass in the resource.
>>
>> >
>> > Would be very thankful for any kind of help.
>> It's not clear what your problem is. Perhaps it's a QVT question...
>> >
>> > Thank you!
>> >
>
>
Previous Topic:[Texo] Extend Ecore Model
Next Topic:Standalone Java Application
Goto Forum:
  


Current Time: Mon Jul 14 14:05:14 EDT 2025

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

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

Back to the top