Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] EMF semantics of ModelExtent
[QVTO] EMF semantics of ModelExtent [message #481184] Thu, 20 August 2009 03:11 Go to next message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
Hi,

I am trying to execute transformations from Java and have started with the
InvokeInJava example.

I have executed a trasform that does nothing but generate a log message so
I know the general environment is working. I have created test
transformation by using the QVTO editor and running the transformations via
the lancher so I know the transformations work.

However, it seems I must not be setting up the input correctly because
iInever get the output I expect and the log message I place in the mapping
don't get printed, just the ones in begining and end of main, so I am
assuming the mapping is not matching the contents of my input model. The
executiong of the transformation returns Diagnostic.OK so it must think it
executed with out errors.

As a result, I wanted to make sure I clearly understand how the input should
be set up. In the InvokeInJava example the resource.getContents() list is
placed in a BasicModelExtent. My input is the root node of a tree. So my
resource returns one EObject when I call resource.getContents(). All other
objects are held as children of the root. I made sure my root EObject was
correct when I execute the transformation. I specifically checked the list
inside the input ModelExtent to make sure it was correct and it seemed to
be.

I did observe that after invoking executor.execute() the input extent was
empty. I wonder if this is relevant to my problem.

I also try just getting all EObjects out of my resource and putting them in
the input extent but I still observed no improvemt.

Is there some way to debug this via enabling some logging or something? The
code is pretty complex but if I knew which specific lines to check I could
do it in the debugger. I suspect there is just something wrong with my
environment. Since the basic logging is working, maybe a model package is
not getting resolved or something else model specific is happening. I
probably should try using a model we know must work versus my own like Ecore
or UML. BTW, I do run the java invocation in the same Eclipse instance as I
developed the transformations so they must at least be available for the
laucher. I can see my model in the model browser too.

Any insight is greatly appreciated.
Thanks,
Derek
Re: [QVTO] EMF semantics of ModelExtent [message #481402 is a reply to message #481184] Thu, 20 August 2009 19:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi Derek,

The ModelExtent is a high level abstraction of MOF extents associated with
each model parameter declared in the signature of every transformation.
You can see it as a placeholder for objects that belong there and are
accessible
via a corresponding model parameter name within transformation scope.
The relationship to the ModelExtent is realized via the #set/getContents
contract
in the ModelExtent interface. The contents represent the root objects of
the extent.
The input EObjects may be the contents of a resource or even have another
container
EObject in a tree hierarchy, which is quite handy for in-place
transformations where
we can't simply isolate the objects of our interest.
In all cases they will appear as the root objects of an extent inside our
transformations.

The BasicModelExtent represents a simple in memory representation of an
extent
ready for use, not focused on where the objects reside (in a resource,
object hierarchy or
whatever else). That's the concept of the API.

The user is responsible for setting the contents of [in/inout] extents,
while
[out] are passed initially empty and its contents is set as a result of a
transformation
execution. The [inout] parameters have initial contents set by the caller
and
a transformation my modify it, IOW even replace by a new contents.

The problem of the empty input after execution you have mentioned might be
simply caused by the transformationn logic, which may move the input
extent's root
objects to another extent. Hard to say what happens in your case ;-),
anyway, I think we can provide more protection against this to happen.

I assume you might also be affected by the fact that you develop your
transformation
against the dynamic model (metamodel ecore file in the workspace).
This scenario is a known problem for the current 2.0.0 invocation API.
A possibly different metamodel instance loaded along with its
model instance can be distinct from the one loaded with the transformation,
causing no appropriate input objects resolved.
It's to be fixed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=284989.

Sorry for the delayed response, I'm on vacation this week, being online
sporadically.
I will resolve things the next week, unless someone else on the team will
help.

Regards,
/Radek


On Thu, 20 Aug 2009 05:11:51 +0200, Derek Palma <derek.palma@gmail.com>
wrote:

> Hi,
>
> I am trying to execute transformations from Java and have started with
> the InvokeInJava example.
>
> I have executed a trasform that does nothing but generate a log message
> so I know the general environment is working. I have created test
> transformation by using the QVTO editor and running the transformations
> via the lancher so I know the transformations work.
>
> However, it seems I must not be setting up the input correctly because
> iInever get the output I expect and the log message I place in the
> mapping don't get printed, just the ones in begining and end of main, so
> I am assuming the mapping is not matching the contents of my input
> model. The executiong of the transformation returns Diagnostic.OK so it
> must think it executed with out errors.
>
> As a result, I wanted to make sure I clearly understand how the input
> should be set up. In the InvokeInJava example the resource.getContents()
> list is placed in a BasicModelExtent. My input is the root node of a
> tree. So my resource returns one EObject when I call
> resource.getContents(). All other objects are held as children of the
> root. I made sure my root EObject was correct when I execute the
> transformation. I specifically checked the list inside the input
> ModelExtent to make sure it was correct and it seemed to be.
>
> I did observe that after invoking executor.execute() the input extent
> was empty. I wonder if this is relevant to my problem.
>
> I also try just getting all EObjects out of my resource and putting them
> in the input extent but I still observed no improvemt.
>
> Is there some way to debug this via enabling some logging or something?
> The code is pretty complex but if I knew which specific lines to check I
> could do it in the debugger. I suspect there is just something wrong
> with my environment. Since the basic logging is working, maybe a model
> package is not getting resolved or something else model specific is
> happening. I probably should try using a model we know must work versus
> my own like Ecore or UML. BTW, I do run the java invocation in the same
> Eclipse instance as I developed the transformations so they must at
> least be available for the laucher. I can see my model in the model
> browser too.
>
> Any insight is greatly appreciated.
> Thanks,
> Derek
Re: [QVTO] EMF semantics of ModelExtent [message #481411 is a reply to message #481184] Thu, 20 August 2009 20:36 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
Hi Derek ,

See some replies in-line, below.

Regards,
Sergey

Derek Palma wrote:
> Hi,
>
> I am trying to execute transformations from Java and have started with
> the InvokeInJava example.

Btw, there's some typo in URI declaration in this example. Platform
resources should start with "platform:/resource/.." (not
"platform:/resources/..").

>
> I have executed a trasform that does nothing but generate a log message
> so I know the general environment is working. I have created test
> transformation by using the QVTO editor and running the transformations
> via the lancher so I know the transformations work.
>
> However, it seems I must not be setting up the input correctly because
> iInever get the output I expect and the log message I place in the
> mapping don't get printed, just the ones in begining and end of main, so
> I am assuming the mapping is not matching the contents of my input
> model. The executiong of the transformation returns Diagnostic.OK so it
> must think it executed with out errors.

It might be that your input is empty or contains objects of metaclass
you are not expected so they were filtered out by [] shortcut.

>
> As a result, I wanted to make sure I clearly understand how the input
> should be set up. In the InvokeInJava example the resource.getContents()
> list is placed in a BasicModelExtent. My input is the root node of a
> tree. So my resource returns one EObject when I call
> resource.getContents(). All other objects are held as children of the
> root. I made sure my root EObject was correct when I execute the
> transformation. I specifically checked the list inside the input
> ModelExtent to make sure it was correct and it seemed to be.
>
> I did observe that after invoking executor.execute() the input extent
> was empty. I wonder if this is relevant to my problem.

You can try the following simple test. Fill input model extent like follows:
EPackage myPackage = EcoreFactory.eINSTANCE.createEPackage();
myPackage.setName("pack");
ModelExtent input = new BasicModelExtent(Arrays.asList(myPackage));

Then launch the following script via your launcher:

modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
transformation testLog(in model : ecore);
main() {
var s := model.rootObjects()![EPackage];
log ("log output: ", s.name) when true;
}

Upon executed output log should looks like:
"log output: , data: pack"

In case you get the same result you can try to use your workspace
metamodel in place of 'ecore'.

>
> I also try just getting all EObjects out of my resource and putting them
> in the input extent but I still observed no improvemt.
>
> Is there some way to debug this via enabling some logging or something?
> The code is pretty complex but if I knew which specific lines to check I
> could do it in the debugger. I suspect there is just something wrong
> with my environment. Since the basic logging is working, maybe a model
> package is not getting resolved or something else model specific is
> happening. I probably should try using a model we know must work versus
> my own like Ecore or UML. BTW, I do run the java invocation in the same
> Eclipse instance as I developed the transformations

How did you achieve that? I mean java invocation in the same Eclipse
instance.

> so they must at
> least be available for the laucher. I can see my model in the model
> browser too.

You mention workspace model or deployed one?

>
> Any insight is greatly appreciated.
> Thanks,
> Derek
Re: [QVTO] EMF semantics of ModelExtent [message #481444 is a reply to message #481402] Fri, 21 August 2009 04:49 Go to previous messageGo to next message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
Hi Radek,

Here is how I am running the transformation. Maybe you can see if I will
definitively hit those bugs or not.

BTW, I also noticed that when specifiying the URI for the tranformation
text, it seems the QVT code does not let me just use a generic file URI
(like URI.createFileURI). It seems to want a plugin or resource URI (I had
to use URI.createPlatformResourceURI). What is the reason this is so strict?
I expected it not to matter where the transformation comes from as long as
the parser accepts it.

Thanks for all the great support!
Derek

In my development workspace I dynamically generate two models, save them to
XMI files, and register them as follows:

<extension point="org.eclipse.emf.ecore.dynamic_package">
<resource uri="http://model.virtunomic.com/vml/Instance"
location="model/instance.ecore"/>
</extension>

<extension point="org.eclipse.emf.ecore.dynamic_package">
<resource uri="http://java.sun.com/xml/ns/j2ee"
location="model/xmlcontent.ecore"/>
</extension>

In my runtime workspace I run the following Java code and QVT
transformation.

public static List<EObject> transform(URI transformationURI, List<EObject>
contextList) {

TransformationExecutor executor = new
TransformationExecutor(transformationURI);

System.out.println("Input size: " + contextList.size());

ModelExtent input = new BasicModelExtent(contextList);
ModelExtent output = new BasicModelExtent();

ExecutionContextImpl context = new ExecutionContextImpl();
// context.setConfigProperty("keepModeling", true);
PrintWriter writer = new PrintWriter(System.out);
context.setLog(new WriterLog(writer));

System.out.println("$$$Begin QVT logging");
ExecutionDiagnostic diagnostic = executor.execute(context, input, output);
writer.flush();
System.out.println("$$$End QVT logging");

if(diagnostic.getSeverity() == Diagnostic.OK) {
List<EObject> outputList = output.getContents();
System.out.println("Output size: " + outputList.size());
return outputList;
} else {
IStatus status = BasicDiagnostic.toIStatus(diagnostic);
String message = status.getMessage();
System.out.println("transform failure: " + message);
// InvokeActivator.getDefault().getLog().log(status);
}

return null;
}



modeltype VML uses 'http://model.virtunomic.com/vml/Instance';
modeltype J2eeWebApp uses 'http://java.sun.com/xml/ns/j2ee';

transformation TestTransformation(in webxml: J2eeWebApp, out VML);

main() {
log("Entered main");
webxml.objectsOfType(J2eeWebApp::ServletType)->map generateServlets()
}


mapping J2eeWebApp::ServletType::generateServlets() :
VML::com_virtunomic_vml_j2ee_Servlet {
log("Entered aToB()");
name := self.servletName.value;
className := self.servletClass.value
}


"radek dvorak" <dvorak.radek@gmail.com> wrote in message
news:op.uyy7q0q912y5f2@kliste.local...
> Hi Derek,
>
> The ModelExtent is a high level abstraction of MOF extents associated with
> each model parameter declared in the signature of every transformation.
> You can see it as a placeholder for objects that belong there and are
> accessible
> via a corresponding model parameter name within transformation scope.
> The relationship to the ModelExtent is realized via the #set/getContents
> contract
> in the ModelExtent interface. The contents represent the root objects of
> the extent.
> The input EObjects may be the contents of a resource or even have another
> container
> EObject in a tree hierarchy, which is quite handy for in-place
> transformations where
> we can't simply isolate the objects of our interest.
> In all cases they will appear as the root objects of an extent inside our
> transformations.
>
> The BasicModelExtent represents a simple in memory representation of an
> extent
> ready for use, not focused on where the objects reside (in a resource,
> object hierarchy or
> whatever else). That's the concept of the API.
>
> The user is responsible for setting the contents of [in/inout] extents,
> while
> [out] are passed initially empty and its contents is set as a result of a
> transformation
> execution. The [inout] parameters have initial contents set by the caller
> and
> a transformation my modify it, IOW even replace by a new contents.
>
> The problem of the empty input after execution you have mentioned might be
> simply caused by the transformationn logic, which may move the input
> extent's root
> objects to another extent. Hard to say what happens in your case ;-),
> anyway, I think we can provide more protection against this to happen.
>
> I assume you might also be affected by the fact that you develop your
> transformation
> against the dynamic model (metamodel ecore file in the workspace).
> This scenario is a known problem for the current 2.0.0 invocation API.
> A possibly different metamodel instance loaded along with its
> model instance can be distinct from the one loaded with the
> transformation,
> causing no appropriate input objects resolved.
> It's to be fixed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=284989.
>
> Sorry for the delayed response, I'm on vacation this week, being online
> sporadically.
> I will resolve things the next week, unless someone else on the team will
> help.
>
> Regards,
> /Radek
>
>
> On Thu, 20 Aug 2009 05:11:51 +0200, Derek Palma <derek.palma@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am trying to execute transformations from Java and have started with
>> the InvokeInJava example.
>>
>> I have executed a trasform that does nothing but generate a log message
>> so I know the general environment is working. I have created test
>> transformation by using the QVTO editor and running the transformations
>> via the lancher so I know the transformations work.
>>
>> However, it seems I must not be setting up the input correctly because
>> iInever get the output I expect and the log message I place in the
>> mapping don't get printed, just the ones in begining and end of main, so
>> I am assuming the mapping is not matching the contents of my input
>> model. The executiong of the transformation returns Diagnostic.OK so it
>> must think it executed with out errors.
>>
>> As a result, I wanted to make sure I clearly understand how the input
>> should be set up. In the InvokeInJava example the resource.getContents()
>> list is placed in a BasicModelExtent. My input is the root node of a
>> tree. So my resource returns one EObject when I call
>> resource.getContents(). All other objects are held as children of the
>> root. I made sure my root EObject was correct when I execute the
>> transformation. I specifically checked the list inside the input
>> ModelExtent to make sure it was correct and it seemed to be.
>>
>> I did observe that after invoking executor.execute() the input extent
>> was empty. I wonder if this is relevant to my problem.
>>
>> I also try just getting all EObjects out of my resource and putting them
>> in the input extent but I still observed no improvemt.
>>
>> Is there some way to debug this via enabling some logging or something?
>> The code is pretty complex but if I knew which specific lines to check I
>> could do it in the debugger. I suspect there is just something wrong
>> with my environment. Since the basic logging is working, maybe a model
>> package is not getting resolved or something else model specific is
>> happening. I probably should try using a model we know must work versus
>> my own like Ecore or UML. BTW, I do run the java invocation in the same
>> Eclipse instance as I developed the transformations so they must at
>> least be available for the laucher. I can see my model in the model
>> browser too.
>>
>> Any insight is greatly appreciated.
>> Thanks,
>> Derek
>
Re: [QVTO] EMF semantics of ModelExtent [message #481592 is a reply to message #481444] Fri, 21 August 2009 16:56 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090705090804090208030406
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Derek,

Some replies are in-lined, below

Derek Palma wrote:
> Hi Radek,
>
> Here is how I am running the transformation. Maybe you can see if I will
> definitively hit those bugs or not.
>
> BTW, I also noticed that when specifiying the URI for the tranformation
> text, it seems the QVT code does not let me just use a generic file URI
> (like URI.createFileURI). It seems to want a plugin or resource URI (I
> had to use URI.createPlatformResourceURI). What is the reason this is so
> strict? I expected it not to matter where the transformation comes from
> as long as the parser accepts it.

You're right, it's unreasonable limitation of the current
implementation. Will be fixed in the next milestone.

>
> Thanks for all the great support!
> Derek
>
> In my development workspace I dynamically generate two models, save them
> to XMI files, and register them as follows:
>
> <extension point="org.eclipse.emf.ecore.dynamic_package">
> <resource uri="http://model.virtunomic.com/vml/Instance"
> location="model/instance.ecore"/>
> </extension>
>
> <extension point="org.eclipse.emf.ecore.dynamic_package">
> <resource uri="http://java.sun.com/xml/ns/j2ee"
> location="model/xmlcontent.ecore"/>
> </extension>
>
> In my runtime workspace I run the following Java code and QVT
> transformation.

You use deployed metamodels so it doesn't look like related to bug Radek
mentioned.
I also guess you watch your metamodels under "platform" root in
"Metamodel Explorer".

I've create test case similar to yours, i.e. created and registered in
plugin.xml two models (xmlcontent.ecore and instance.ecore).
First contained 'ServletType' EClass and second contained
'com_virtunomic_vml_j2ee_Servlet' EClass so I utilized your .qvto script
with minimal changes.
Then I run new runtime Eclipse instance and launched Java code for
transformation invocation.
As the input I used attached dynamic instance of ServletType. And script
(besides other info) outputs "Entered aToB()" to console which means
that mapping was executed.
So it might be that iput EObject's are not of expected type. How did you
fill 'contextList' for the transformation?

>
> public static List<EObject> transform(URI transformationURI,
> List<EObject> contextList) {
>
> TransformationExecutor executor = new
> TransformationExecutor(transformationURI);
>
> System.out.println("Input size: " + contextList.size());
>
> ModelExtent input = new BasicModelExtent(contextList);
> ModelExtent output = new BasicModelExtent();
>
> ExecutionContextImpl context = new ExecutionContextImpl();
> // context.setConfigProperty("keepModeling", true);
> PrintWriter writer = new PrintWriter(System.out);
> context.setLog(new WriterLog(writer));
>
> System.out.println("$$$Begin QVT logging");
> ExecutionDiagnostic diagnostic = executor.execute(context, input, output);
> writer.flush();
> System.out.println("$$$End QVT logging");
>
> if(diagnostic.getSeverity() == Diagnostic.OK) {
> List<EObject> outputList = output.getContents();
> System.out.println("Output size: " + outputList.size());
> return outputList;
> } else {
> IStatus status = BasicDiagnostic.toIStatus(diagnostic);
> String message = status.getMessage();
> System.out.println("transform failure: " + message);
> // InvokeActivator.getDefault().getLog().log(status);
> }
>
> return null;
> }
>
>
>
> modeltype VML uses 'http://model.virtunomic.com/vml/Instance';
> modeltype J2eeWebApp uses 'http://java.sun.com/xml/ns/j2ee';
>
> transformation TestTransformation(in webxml: J2eeWebApp, out VML);
>
> main() {
> log("Entered main");
> webxml.objectsOfType(J2eeWebApp::ServletType)->map generateServlets()
> }
>
>
> mapping J2eeWebApp::ServletType::generateServlets() :
> VML::com_virtunomic_vml_j2ee_Servlet {
> log("Entered aToB()");
> name := self.servletName.value;
> className := self.servletClass.value
> }
>
>
> "radek dvorak" <dvorak.radek@gmail.com> wrote in message
> news:op.uyy7q0q912y5f2@kliste.local...
>> Hi Derek,
>>
>> The ModelExtent is a high level abstraction of MOF extents associated
>> with
>> each model parameter declared in the signature of every transformation.
>> You can see it as a placeholder for objects that belong there and are
>> accessible
>> via a corresponding model parameter name within transformation scope.
>> The relationship to the ModelExtent is realized via the
>> #set/getContents contract
>> in the ModelExtent interface. The contents represent the root objects of
>> the extent.
>> The input EObjects may be the contents of a resource or even have
>> another container
>> EObject in a tree hierarchy, which is quite handy for in-place
>> transformations where
>> we can't simply isolate the objects of our interest.
>> In all cases they will appear as the root objects of an extent inside
>> our transformations.
>>
>> The BasicModelExtent represents a simple in memory representation of
>> an extent
>> ready for use, not focused on where the objects reside (in a resource,
>> object hierarchy or
>> whatever else). That's the concept of the API.
>>
>> The user is responsible for setting the contents of [in/inout]
>> extents, while
>> [out] are passed initially empty and its contents is set as a result
>> of a transformation
>> execution. The [inout] parameters have initial contents set by the
>> caller and
>> a transformation my modify it, IOW even replace by a new contents.
>>
>> The problem of the empty input after execution you have mentioned
>> might be
>> simply caused by the transformationn logic, which may move the input
>> extent's root
>> objects to another extent. Hard to say what happens in your case ;-),
>> anyway, I think we can provide more protection against this to happen.
>>
>> I assume you might also be affected by the fact that you develop your
>> transformation
>> against the dynamic model (metamodel ecore file in the workspace).
>> This scenario is a known problem for the current 2.0.0 invocation API.
>> A possibly different metamodel instance loaded along with its
>> model instance can be distinct from the one loaded with the
>> transformation,
>> causing no appropriate input objects resolved.
>> It's to be fixed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=284989.
>>
>> Sorry for the delayed response, I'm on vacation this week, being
>> online sporadically.
>> I will resolve things the next week, unless someone else on the team
>> will help.
>>
>> Regards,
>> /Radek
>>
>>
>> On Thu, 20 Aug 2009 05:11:51 +0200, Derek Palma
>> <derek.palma@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I am trying to execute transformations from Java and have started
>>> with the InvokeInJava example.
>>>
>>> I have executed a trasform that does nothing but generate a log
>>> message so I know the general environment is working. I have created
>>> test transformation by using the QVTO editor and running the
>>> transformations via the lancher so I know the transformations work.
>>>
>>> However, it seems I must not be setting up the input correctly
>>> because iInever get the output I expect and the log message I place
>>> in the mapping don't get printed, just the ones in begining and end
>>> of main, so I am assuming the mapping is not matching the contents of
>>> my input model. The executiong of the transformation returns
>>> Diagnostic.OK so it must think it executed with out errors.
>>>
>>> As a result, I wanted to make sure I clearly understand how the input
>>> should be set up. In the InvokeInJava example the
>>> resource.getContents() list is placed in a BasicModelExtent. My input
>>> is the root node of a tree. So my resource returns one EObject when I
>>> call resource.getContents(). All other objects are held as children
>>> of the root. I made sure my root EObject was correct when I execute
>>> the transformation. I specifically checked the list inside the input
>>> ModelExtent to make sure it was correct and it seemed to be.
>>>
>>> I did observe that after invoking executor.execute() the input extent
>>> was empty. I wonder if this is relevant to my problem.
>>>
>>> I also try just getting all EObjects out of my resource and putting
>>> them in the input extent but I still observed no improvemt.
>>>
>>> Is there some way to debug this via enabling some logging or
>>> something? The code is pretty complex but if I knew which specific
>>> lines to check I could do it in the debugger. I suspect there is just
>>> something wrong with my environment. Since the basic logging is
>>> working, maybe a model package is not getting resolved or something
>>> else model specific is happening. I probably should try using a model
>>> we know must work versus my own like Ecore or UML. BTW, I do run the
>>> java invocation in the same Eclipse instance as I developed the
>>> transformations so they must at least be available for the laucher. I
>>> can see my model in the model browser too.
>>>
>>> Any insight is greatly appreciated.
>>> Thanks,
>>> Derek
>>
>


--------------090705090804090208030406
Content-Type: text/xml;
name="ServletType.xmi"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ServletType.xmi"

<?xml version="1.0" encoding="ASCII"?>
<xmlcontent:ServletType xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xmlcontent="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee platform:/plugin/emf.dynmodels/model/xmlcontent.ecore"/>

--------------090705090804090208030406--
Re: [QVTO] EMF semantics of ModelExtent [message #486913 is a reply to message #481592] Sun, 20 September 2009 22:40 Go to previous messageGo to next message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
Hi Sergey,

Do you have a bug ID and/or estimate for availability change to reduce the
restriction on the kind of URI passed to QVTO (described below)?
Reason I ask is I am facing some issues being forced to have my
transformations located in an Eclipse plug-in when all my other
models/content are located in some external directory locations. My only
solution is to add code which copies them into some plugin directory which
is starting to become annoying.

Thank
Derek

"Sergey Boyko" <sboyko@borland.com> wrote in message
news:4A8ED1D2.2070100@borland.com...
> Hi Derek,
>
> Some replies are in-lined, below
>
> Derek Palma wrote:
>> Hi Radek,
>>
>> Here is how I am running the transformation. Maybe you can see if I will
>> definitively hit those bugs or not.
>>
>> BTW, I also noticed that when specifiying the URI for the tranformation
>> text, it seems the QVT code does not let me just use a generic file URI
>> (like URI.createFileURI). It seems to want a plugin or resource URI (I
>> had to use URI.createPlatformResourceURI). What is the reason this is so
>> strict? I expected it not to matter where the transformation comes from
>> as long as the parser accepts it.
>
> You're right, it's unreasonable limitation of the current
> implementation. Will be fixed in the next milestone.
>
>>
>> Thanks for all the great support!
>> Derek
>>
>> In my development workspace I dynamically generate two models, save them
>> to XMI files, and register them as follows:
>>
>> <extension point="org.eclipse.emf.ecore.dynamic_package">
>> <resource uri="http://model.virtunomic.com/vml/Instance"
>> location="model/instance.ecore"/>
>> </extension>
>>
>> <extension point="org.eclipse.emf.ecore.dynamic_package">
>> <resource uri="http://java.sun.com/xml/ns/j2ee"
>> location="model/xmlcontent.ecore"/>
>> </extension>
>>
>> In my runtime workspace I run the following Java code and QVT
>> transformation.
>
> You use deployed metamodels so it doesn't look like related to bug Radek
> mentioned.
> I also guess you watch your metamodels under "platform" root in
> "Metamodel Explorer".
>
> I've create test case similar to yours, i.e. created and registered in
> plugin.xml two models (xmlcontent.ecore and instance.ecore).
> First contained 'ServletType' EClass and second contained
> 'com_virtunomic_vml_j2ee_Servlet' EClass so I utilized your .qvto script
> with minimal changes.
> Then I run new runtime Eclipse instance and launched Java code for
> transformation invocation.
> As the input I used attached dynamic instance of ServletType. And script
> (besides other info) outputs "Entered aToB()" to console which means
> that mapping was executed.
> So it might be that iput EObject's are not of expected type. How did you
> fill 'contextList' for the transformation?
>
>>
>> public static List<EObject> transform(URI transformationURI,
>> List<EObject> contextList) {
>>
>> TransformationExecutor executor = new
>> TransformationExecutor(transformationURI);
>>
>> System.out.println("Input size: " + contextList.size());
>>
>> ModelExtent input = new BasicModelExtent(contextList);
>> ModelExtent output = new BasicModelExtent();
>>
>> ExecutionContextImpl context = new ExecutionContextImpl();
>> // context.setConfigProperty("keepModeling", true);
>> PrintWriter writer = new PrintWriter(System.out);
>> context.setLog(new WriterLog(writer));
>>
>> System.out.println("$$$Begin QVT logging");
>> ExecutionDiagnostic diagnostic = executor.execute(context, input,
>> output);
>> writer.flush();
>> System.out.println("$$$End QVT logging");
>>
>> if(diagnostic.getSeverity() == Diagnostic.OK) {
>> List<EObject> outputList = output.getContents();
>> System.out.println("Output size: " + outputList.size());
>> return outputList;
>> } else {
>> IStatus status = BasicDiagnostic.toIStatus(diagnostic);
>> String message = status.getMessage();
>> System.out.println("transform failure: " + message);
>> // InvokeActivator.getDefault().getLog().log(status);
>> }
>>
>> return null;
>> }
>>
>>
>>
>> modeltype VML uses 'http://model.virtunomic.com/vml/Instance';
>> modeltype J2eeWebApp uses 'http://java.sun.com/xml/ns/j2ee';
>>
>> transformation TestTransformation(in webxml: J2eeWebApp, out VML);
>>
>> main() {
>> log("Entered main");
>> webxml.objectsOfType(J2eeWebApp::ServletType)->map generateServlets()
>> }
>>
>>
>> mapping J2eeWebApp::ServletType::generateServlets() :
>> VML::com_virtunomic_vml_j2ee_Servlet {
>> log("Entered aToB()");
>> name := self.servletName.value;
>> className := self.servletClass.value
>> }
>>
>>
>> "radek dvorak" <dvorak.radek@gmail.com> wrote in message
>> news:op.uyy7q0q912y5f2@kliste.local...
>>> Hi Derek,
>>>
>>> The ModelExtent is a high level abstraction of MOF extents associated
>>> with
>>> each model parameter declared in the signature of every transformation.
>>> You can see it as a placeholder for objects that belong there and are
>>> accessible
>>> via a corresponding model parameter name within transformation scope.
>>> The relationship to the ModelExtent is realized via the
>>> #set/getContents contract
>>> in the ModelExtent interface. The contents represent the root objects of
>>> the extent.
>>> The input EObjects may be the contents of a resource or even have
>>> another container
>>> EObject in a tree hierarchy, which is quite handy for in-place
>>> transformations where
>>> we can't simply isolate the objects of our interest.
>>> In all cases they will appear as the root objects of an extent inside
>>> our transformations.
>>>
>>> The BasicModelExtent represents a simple in memory representation of
>>> an extent
>>> ready for use, not focused on where the objects reside (in a resource,
>>> object hierarchy or
>>> whatever else). That's the concept of the API.
>>>
>>> The user is responsible for setting the contents of [in/inout]
>>> extents, while
>>> [out] are passed initially empty and its contents is set as a result
>>> of a transformation
>>> execution. The [inout] parameters have initial contents set by the
>>> caller and
>>> a transformation my modify it, IOW even replace by a new contents.
>>>
>>> The problem of the empty input after execution you have mentioned
>>> might be
>>> simply caused by the transformationn logic, which may move the input
>>> extent's root
>>> objects to another extent. Hard to say what happens in your case ;-),
>>> anyway, I think we can provide more protection against this to happen.
>>>
>>> I assume you might also be affected by the fact that you develop your
>>> transformation
>>> against the dynamic model (metamodel ecore file in the workspace).
>>> This scenario is a known problem for the current 2.0.0 invocation API.
>>> A possibly different metamodel instance loaded along with its
>>> model instance can be distinct from the one loaded with the
>>> transformation,
>>> causing no appropriate input objects resolved.
>>> It's to be fixed by
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=284989.
>>>
>>> Sorry for the delayed response, I'm on vacation this week, being
>>> online sporadically.
>>> I will resolve things the next week, unless someone else on the team
>>> will help.
>>>
>>> Regards,
>>> /Radek
>>>
>>>
>>> On Thu, 20 Aug 2009 05:11:51 +0200, Derek Palma
>>> <derek.palma@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to execute transformations from Java and have started
>>>> with the InvokeInJava example.
>>>>
>>>> I have executed a trasform that does nothing but generate a log
>>>> message so I know the general environment is working. I have created
>>>> test transformation by using the QVTO editor and running the
>>>> transformations via the lancher so I know the transformations work.
>>>>
>>>> However, it seems I must not be setting up the input correctly
>>>> because iInever get the output I expect and the log message I place
>>>> in the mapping don't get printed, just the ones in begining and end
>>>> of main, so I am assuming the mapping is not matching the contents of
>>>> my input model. The executiong of the transformation returns
>>>> Diagnostic.OK so it must think it executed with out errors.
>>>>
>>>> As a result, I wanted to make sure I clearly understand how the input
>>>> should be set up. In the InvokeInJava example the
>>>> resource.getContents() list is placed in a BasicModelExtent. My input
>>>> is the root node of a tree. So my resource returns one EObject when I
>>>> call resource.getContents(). All other objects are held as children
>>>> of the root. I made sure my root EObject was correct when I execute
>>>> the transformation. I specifically checked the list inside the input
>>>> ModelExtent to make sure it was correct and it seemed to be.
>>>>
>>>> I did observe that after invoking executor.execute() the input extent
>>>> was empty. I wonder if this is relevant to my problem.
>>>>
>>>> I also try just getting all EObjects out of my resource and putting
>>>> them in the input extent but I still observed no improvemt.
>>>>
>>>> Is there some way to debug this via enabling some logging or
>>>> something? The code is pretty complex but if I knew which specific
>>>> lines to check I could do it in the debugger. I suspect there is just
>>>> something wrong with my environment. Since the basic logging is
>>>> working, maybe a model package is not getting resolved or something
>>>> else model specific is happening. I probably should try using a model
>>>> we know must work versus my own like Ecore or UML. BTW, I do run the
>>>> java invocation in the same Eclipse instance as I developed the
>>>> transformations so they must at least be available for the laucher. I
>>>> can see my model in the model browser too.
>>>>
>>>> Any insight is greatly appreciated.
>>>> Thanks,
>>>> Derek
>>>
>>
>
>


------------------------------------------------------------ --------------------


> <?xml version="1.0" encoding="ASCII"?>
> <xmlcontent:ServletType xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xmlcontent="http://java.sun.com/xml/ns/j2ee"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> platform:/plugin/emf.dynmodels/model/xmlcontent.ecore"/>
>
Re: [QVTO] EMF semantics of ModelExtent [message #486947 is a reply to message #486913] Mon, 21 September 2009 09:30 Go to previous message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
Hi Derek,

There's bugzilla request
https://bugs.eclipse.org/bugs/show_bug.cgi?id=287714. Fix will be
available soon.

Regards,
Sergey.

Derek Palma wrote:
> Hi Sergey,
>
> Do you have a bug ID and/or estimate for availability change to reduce
> the restriction on the kind of URI passed to QVTO (described below)?
> Reason I ask is I am facing some issues being forced to have my
> transformations located in an Eclipse plug-in when all my other
> models/content are located in some external directory locations. My only
> solution is to add code which copies them into some plugin directory
> which is starting to become annoying.
>
> Thank
> Derek
>
> "Sergey Boyko" <sboyko@borland.com> wrote in message
> news:4A8ED1D2.2070100@borland.com...
>> Hi Derek,
>>
>> Some replies are in-lined, below
>>
>> Derek Palma wrote:
>>> Hi Radek,
>>>
>>> Here is how I am running the transformation. Maybe you can see if I will
>>> definitively hit those bugs or not.
>>>
>>> BTW, I also noticed that when specifiying the URI for the tranformation
>>> text, it seems the QVT code does not let me just use a generic file URI
>>> (like URI.createFileURI). It seems to want a plugin or resource URI (I
>>> had to use URI.createPlatformResourceURI). What is the reason this is so
>>> strict? I expected it not to matter where the transformation comes from
>>> as long as the parser accepts it.
>>
>> You're right, it's unreasonable limitation of the current
>> implementation. Will be fixed in the next milestone.
>>
>>>
>>> Thanks for all the great support!
>>> Derek
>>>
>>> In my development workspace I dynamically generate two models, save them
>>> to XMI files, and register them as follows:
>>>
>>> <extension point="org.eclipse.emf.ecore.dynamic_package">
>>> <resource uri="http://model.virtunomic.com/vml/Instance"
>>> location="model/instance.ecore"/>
>>> </extension>
>>>
>>> <extension point="org.eclipse.emf.ecore.dynamic_package">
>>> <resource uri="http://java.sun.com/xml/ns/j2ee"
>>> location="model/xmlcontent.ecore"/>
>>> </extension>
>>>
>>> In my runtime workspace I run the following Java code and QVT
>>> transformation.
>>
>> You use deployed metamodels so it doesn't look like related to bug Radek
>> mentioned.
>> I also guess you watch your metamodels under "platform" root in
>> "Metamodel Explorer".
>>
>> I've create test case similar to yours, i.e. created and registered in
>> plugin.xml two models (xmlcontent.ecore and instance.ecore).
>> First contained 'ServletType' EClass and second contained
>> 'com_virtunomic_vml_j2ee_Servlet' EClass so I utilized your .qvto script
>> with minimal changes.
>> Then I run new runtime Eclipse instance and launched Java code for
>> transformation invocation.
>> As the input I used attached dynamic instance of ServletType. And script
>> (besides other info) outputs "Entered aToB()" to console which means
>> that mapping was executed.
>> So it might be that iput EObject's are not of expected type. How did you
>> fill 'contextList' for the transformation?
>>
>>>
>>> public static List<EObject> transform(URI transformationURI,
>>> List<EObject> contextList) {
>>>
>>> TransformationExecutor executor = new
>>> TransformationExecutor(transformationURI);
>>>
>>> System.out.println("Input size: " + contextList.size());
>>>
>>> ModelExtent input = new BasicModelExtent(contextList);
>>> ModelExtent output = new BasicModelExtent();
>>>
>>> ExecutionContextImpl context = new ExecutionContextImpl();
>>> // context.setConfigProperty("keepModeling", true);
>>> PrintWriter writer = new PrintWriter(System.out);
>>> context.setLog(new WriterLog(writer));
>>>
>>> System.out.println("$$$Begin QVT logging");
>>> ExecutionDiagnostic diagnostic = executor.execute(context, input,
>>> output);
>>> writer.flush();
>>> System.out.println("$$$End QVT logging");
>>>
>>> if(diagnostic.getSeverity() == Diagnostic.OK) {
>>> List<EObject> outputList = output.getContents();
>>> System.out.println("Output size: " + outputList.size());
>>> return outputList;
>>> } else {
>>> IStatus status = BasicDiagnostic.toIStatus(diagnostic);
>>> String message = status.getMessage();
>>> System.out.println("transform failure: " + message);
>>> // InvokeActivator.getDefault().getLog().log(status);
>>> }
>>>
>>> return null;
>>> }
>>>
>>>
>>>
>>> modeltype VML uses 'http://model.virtunomic.com/vml/Instance';
>>> modeltype J2eeWebApp uses 'http://java.sun.com/xml/ns/j2ee';
>>>
>>> transformation TestTransformation(in webxml: J2eeWebApp, out VML);
>>>
>>> main() {
>>> log("Entered main");
>>> webxml.objectsOfType(J2eeWebApp::ServletType)->map generateServlets()
>>> }
>>>
>>>
>>> mapping J2eeWebApp::ServletType::generateServlets() :
>>> VML::com_virtunomic_vml_j2ee_Servlet {
>>> log("Entered aToB()");
>>> name := self.servletName.value;
>>> className := self.servletClass.value
>>> }
>>>
>>>
>>> "radek dvorak" <dvorak.radek@gmail.com> wrote in message
>>> news:op.uyy7q0q912y5f2@kliste.local...
>>>> Hi Derek,
>>>>
>>>> The ModelExtent is a high level abstraction of MOF extents associated
>>>> with
>>>> each model parameter declared in the signature of every transformation.
>>>> You can see it as a placeholder for objects that belong there and are
>>>> accessible
>>>> via a corresponding model parameter name within transformation scope.
>>>> The relationship to the ModelExtent is realized via the
>>>> #set/getContents contract
>>>> in the ModelExtent interface. The contents represent the root
>>>> objects of
>>>> the extent.
>>>> The input EObjects may be the contents of a resource or even have
>>>> another container
>>>> EObject in a tree hierarchy, which is quite handy for in-place
>>>> transformations where
>>>> we can't simply isolate the objects of our interest.
>>>> In all cases they will appear as the root objects of an extent inside
>>>> our transformations.
>>>>
>>>> The BasicModelExtent represents a simple in memory representation of
>>>> an extent
>>>> ready for use, not focused on where the objects reside (in a resource,
>>>> object hierarchy or
>>>> whatever else). That's the concept of the API.
>>>>
>>>> The user is responsible for setting the contents of [in/inout]
>>>> extents, while
>>>> [out] are passed initially empty and its contents is set as a result
>>>> of a transformation
>>>> execution. The [inout] parameters have initial contents set by the
>>>> caller and
>>>> a transformation my modify it, IOW even replace by a new contents.
>>>>
>>>> The problem of the empty input after execution you have mentioned
>>>> might be
>>>> simply caused by the transformationn logic, which may move the input
>>>> extent's root
>>>> objects to another extent. Hard to say what happens in your case ;-),
>>>> anyway, I think we can provide more protection against this to happen.
>>>>
>>>> I assume you might also be affected by the fact that you develop your
>>>> transformation
>>>> against the dynamic model (metamodel ecore file in the workspace).
>>>> This scenario is a known problem for the current 2.0.0 invocation API.
>>>> A possibly different metamodel instance loaded along with its
>>>> model instance can be distinct from the one loaded with the
>>>> transformation,
>>>> causing no appropriate input objects resolved.
>>>> It's to be fixed by
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=284989.
>>>>
>>>> Sorry for the delayed response, I'm on vacation this week, being
>>>> online sporadically.
>>>> I will resolve things the next week, unless someone else on the team
>>>> will help.
>>>>
>>>> Regards,
>>>> /Radek
>>>>
>>>>
>>>> On Thu, 20 Aug 2009 05:11:51 +0200, Derek Palma
>>>> <derek.palma@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to execute transformations from Java and have started
>>>>> with the InvokeInJava example.
>>>>>
>>>>> I have executed a trasform that does nothing but generate a log
>>>>> message so I know the general environment is working. I have created
>>>>> test transformation by using the QVTO editor and running the
>>>>> transformations via the lancher so I know the transformations work.
>>>>>
>>>>> However, it seems I must not be setting up the input correctly
>>>>> because iInever get the output I expect and the log message I place
>>>>> in the mapping don't get printed, just the ones in begining and end
>>>>> of main, so I am assuming the mapping is not matching the contents of
>>>>> my input model. The executiong of the transformation returns
>>>>> Diagnostic.OK so it must think it executed with out errors.
>>>>>
>>>>> As a result, I wanted to make sure I clearly understand how the input
>>>>> should be set up. In the InvokeInJava example the
>>>>> resource.getContents() list is placed in a BasicModelExtent. My input
>>>>> is the root node of a tree. So my resource returns one EObject when I
>>>>> call resource.getContents(). All other objects are held as children
>>>>> of the root. I made sure my root EObject was correct when I execute
>>>>> the transformation. I specifically checked the list inside the input
>>>>> ModelExtent to make sure it was correct and it seemed to be.
>>>>>
>>>>> I did observe that after invoking executor.execute() the input extent
>>>>> was empty. I wonder if this is relevant to my problem.
>>>>>
>>>>> I also try just getting all EObjects out of my resource and putting
>>>>> them in the input extent but I still observed no improvemt.
>>>>>
>>>>> Is there some way to debug this via enabling some logging or
>>>>> something? The code is pretty complex but if I knew which specific
>>>>> lines to check I could do it in the debugger. I suspect there is just
>>>>> something wrong with my environment. Since the basic logging is
>>>>> working, maybe a model package is not getting resolved or something
>>>>> else model specific is happening. I probably should try using a model
>>>>> we know must work versus my own like Ecore or UML. BTW, I do run the
>>>>> java invocation in the same Eclipse instance as I developed the
>>>>> transformations so they must at least be available for the laucher. I
>>>>> can see my model in the model browser too.
>>>>>
>>>>> Any insight is greatly appreciated.
>>>>> Thanks,
>>>>> Derek
>>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>
>> <?xml version="1.0" encoding="ASCII"?>
>> <xmlcontent:ServletType xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:xmlcontent="http://java.sun.com/xml/ns/j2ee"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>> platform:/plugin/emf.dynmodels/model/xmlcontent.ecore"/>
>>
>
Previous Topic:syntax to define exp(3*log(3) in ATL file
Next Topic:complete a model using ATL
Goto Forum:
  


Current Time: Thu Apr 25 16:53:03 GMT 2024

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

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

Back to the top