Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Debugging: model definition for transformation vs. input
Debugging: model definition for transformation vs. input [message #987841] Wed, 28 November 2012 05:59 Go to next message
Eclipse User
Hello,

I'm trying to debug a transformation and use an dynamic XMI instance as
input. This XMI model specifies the meta-model using a XML
schemaLocation entry.

In the debugger I notice that QVT does not relate/match input object
EClasses to the EClasses of the model:

var x := input.rootObjects()->any(true);
var y : MODEL::Room := x.oclAsType(MODEL::Room);

var room = input.rootObjects()[MODEL::Room]->any(true);

Inspecting input.rootObjects(), I do see it containing an object of type
MODEL::Room, yet when this code is done, room = null and y = OclInvalid.

What I /think/ what happens is that QVT loads the input meta-model
according to the project's URI map and when the input is loaded, the
same meta-model is loaded AGAIN using the embedded schemaLocation. But
then I don't understand how this is supposed to work, and how others
create model input for debugging?

Regards
Marius
Re: Debugging: model definition for transformation vs. input [message #987882 is a reply to message #987841] Wed, 28 November 2012 08:58 Go to previous messageGo to next message
Eclipse User
On 28.11.2012 11:59, Marius Gröger wrote:
> I'm trying to debug a transformation and use an dynamic XMI instance as
> input. This XMI model specifies the meta-model using a XML
> schemaLocation entry.
>
> In the debugger I notice that QVT does not relate/match input object
> EClasses to the EClasses of the model:
>
> var x := input.rootObjects()->any(true);
> var y : MODEL::Room := x.oclAsType(MODEL::Room);
>
> var room = input.rootObjects()[MODEL::Room]->any(true);
>
> Inspecting input.rootObjects(), I do see it containing an object of type
> MODEL::Room, yet when this code is done, room = null and y = OclInvalid.
>
> What I /think/ what happens is that QVT loads the input meta-model
> according to the project's URI map and when the input is loaded, the
> same meta-model is loaded AGAIN using the embedded schemaLocation. But
> then I don't understand how this is supposed to work, and how others
> create model input for debugging?

I did some more research and found that the method
org.eclipse.m2m.internal.qvt.oml.TransformationRunner.createResourceSet(Registry)
is broken for my use case of using XMI dynamic model instances (with and
without schema locations).

private static ResourceSetImpl
createResourceSet(EPackage.Registry registry) {
Map<URI, Resource> resourceMap = new HashMap<URI,
Resource>();
for (String key : registry.keySet()) {
Object value = registry.get(key);
if(value instanceof EPackage) {
EPackage ePackage = (EPackage) value;
Resource res = ePackage.eResource();
if(res != null && res.getURI() != null) {
resourceMap.put(res.getURI(), res);
}
}
}

return new ResourceSetImpl();
}

There two issues with this implementation:

1) resourceMap is constructed, but unused (no real harm there)
2) the passed package registry which was previously derived from the
project's URI map is ignored

Attached is a patch against the R3_2 branch (also applies to master)
which fixes this. I copy the passed registry to new one and assign it to
the newly created resource set. At the same time I expand any contained
sub-packages so that the subsequent loading of model extents get to see
the sub packages as well.

Does that look reasonable?

Regards,
Marius
Re: Debugging: model definition for transformation vs. input [message #988213 is a reply to message #987882] Wed, 28 November 2012 15:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

Please attach the patch together with a JUnit test to a Bugzilla.

Once a pending mega-patch from JPL is appolied it may be possible to
start on some of the backlog.

Regards

Ed Willink


On 28/11/2012 13:58, Marius Gröger wrote:
> On 28.11.2012 11:59, Marius Gröger wrote:
>> I'm trying to debug a transformation and use an dynamic XMI instance as
>> input. This XMI model specifies the meta-model using a XML
>> schemaLocation entry.
>>
>> In the debugger I notice that QVT does not relate/match input object
>> EClasses to the EClasses of the model:
>>
>> var x := input.rootObjects()->any(true);
>> var y : MODEL::Room := x.oclAsType(MODEL::Room);
>>
>> var room = input.rootObjects()[MODEL::Room]->any(true);
>>
>> Inspecting input.rootObjects(), I do see it containing an object of type
>> MODEL::Room, yet when this code is done, room = null and y = OclInvalid.
>>
>> What I /think/ what happens is that QVT loads the input meta-model
>> according to the project's URI map and when the input is loaded, the
>> same meta-model is loaded AGAIN using the embedded schemaLocation. But
>> then I don't understand how this is supposed to work, and how others
>> create model input for debugging?
> I did some more research and found that the method
> org.eclipse.m2m.internal.qvt.oml.TransformationRunner.createResourceSet(Registry)
> is broken for my use case of using XMI dynamic model instances (with and
> without schema locations).
>
> private static ResourceSetImpl
> createResourceSet(EPackage.Registry registry) {
> Map<URI, Resource> resourceMap = new HashMap<URI,
> Resource>();
> for (String key : registry.keySet()) {
> Object value = registry.get(key);
> if(value instanceof EPackage) {
> EPackage ePackage = (EPackage) value;
> Resource res = ePackage.eResource();
> if(res != null&& res.getURI() != null) {
> resourceMap.put(res.getURI(), res);
> }
> }
> }
>
> return new ResourceSetImpl();
> }
>
> There two issues with this implementation:
>
> 1) resourceMap is constructed, but unused (no real harm there)
> 2) the passed package registry which was previously derived from the
> project's URI map is ignored
>
> Attached is a patch against the R3_2 branch (also applies to master)
> which fixes this. I copy the passed registry to new one and assign it to
> the newly created resource set. At the same time I expand any contained
> sub-packages so that the subsequent loading of model extents get to see
> the sub packages as well.
>
> Does that look reasonable?
>
> Regards,
> Marius
>
Re: Debugging: model definition for transformation vs. input [message #988259 is a reply to message #988213] Thu, 29 November 2012 02:43 Go to previous messageGo to next message
Eclipse User
On 28.11.2012 21:58, Ed Willink wrote:
> Please attach the patch together with a JUnit test to a Bugzilla.

I will, though I don't know if I can manage to devise a unit test for
this issue due to lack of knowledge and time.

Meanwhile: locally, what is the best way for me to replace the
org.eclipse.m2m.qvt.oml_3.2.0.v20120918-0827.jar? It belongs to an
entire feature and it's signed... I already even tried to rebuild the
complete feature and place it into dropins/ but it was just ignored.

Regards
Marius
Re: Debugging: model definition for transformation vs. input [message #988329 is a reply to message #988259] Thu, 29 November 2012 07:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

You are not the only person with limited knowledge and time ...

Providing a JUnit test significantly increases the chances of the patch
making it into the code base.

If by 'replacing the JAR' you mean, how do you get to use you own
version of QVTo, I just check the entire
project out of GIT and use a modified version that is built
automatically for use in a nested workspace.

The distributed JARs are built rather painfully on Hudson, and if you're
a real enthusiast, you can endeavour to replicate
the Eclipse Hudson environment - not recommended.

In the past, I have variously had success with Export deployable
plugins, and building my own Update site.

Use of "dropins" is now strongly discouraged because the P2 installer
behind the Install New Software
understands what's going on, and things get in a real mess when you try
to outwit it. Try to create a
ZIP file that you can just give to Install New Software.

You may find the ANT tools referred to in
http://wiki.eclipse.org/Modeling_Project_Builds/Utilities helpful if you
want
to build a composite repo.

Regards

Ed Willink



On 29/11/2012 07:43, Marius Gröger wrote:
> On 28.11.2012 21:58, Ed Willink wrote:
>> Please attach the patch together with a JUnit test to a Bugzilla.
> I will, though I don't know if I can manage to devise a unit test for
> this issue due to lack of knowledge and time.
>
> Meanwhile: locally, what is the best way for me to replace the
> org.eclipse.m2m.qvt.oml_3.2.0.v20120918-0827.jar? It belongs to an
> entire feature and it's signed... I already even tried to rebuild the
> complete feature and place it into dropins/ but it was just ignored.
>
> Regards
> Marius
Re: Debugging: model definition for transformation vs. input [message #988485 is a reply to message #988329] Fri, 30 November 2012 03:10 Go to previous message
Eclipse User
On 29.11.2012 13:24, Ed Willink wrote:
> Providing a JUnit test significantly increases the chances of the
> patch making it into the code base.

Yes, I'm absolutely aware of that. I just need to convince my client to
allow some extra time for this.

Thanks for the hints wrt building a local version.

Regards
Marius
Previous Topic:Passing a profile instance to a QVTo transform
Next Topic:l'utilisation de qvt
Goto Forum:
  


Current Time: Fri Jul 25 19:20:46 EDT 2014

Powered by FUDForum. Page generated in 0.09281 seconds