Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Can't resolve EObject as OCL type?
[QVTO] Can't resolve EObject as OCL type? [message #492389] Tue, 20 October 2009 10:39 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

I have the following black box library method:

@org.eclipse.m2m.qvt.oml.blackbox.java.Operation(contextual = true, kind
= Kind.OPERATION)
public boolean removeContainedElement(MyCompositionModel rootModel,
EObject containedElement){
for (EObject element : rootModel.eContents()) {
if(containedElement.equals(element)){
return rootModel.eContents().remove(containedElement);
}
}
return false;
}

But when I start the second Eclipse instance with my transformations the
declaring library can't be found because the error log says that

Can't resolve 'interface org.eclipse.emf.ecore.EObject' as OCL type in
java method 'public boolean my.libraries.ModelUtil.removeContainedElement

I need a method which generically can remove children from parents. How
can I achieve this?
Re: [QVTO] Can't resolve EObject as OCL type? [message #492393 is a reply to message #492389] Tue, 20 October 2009 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

....I don't understand the error because every modeled interface is
sub-interface of EObject.
Re: [QVTO] Can't resolve EObject as OCL type? [message #492394 is a reply to message #492389] Tue, 20 October 2009 10:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

In a transformation I just want to invoke something like this:

rootModel.removeContainedElement(rootModel.subModel);
Re: [QVTO] Can't resolve EObject as OCL type? [message #492634 is a reply to message #492389] Wed, 21 October 2009 07:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

No ideas?
Re: [QVTO] Can't resolve EObject as OCL type? [message #492655 is a reply to message #492389] Wed, 21 October 2009 09:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi Gilbert,

The type is to be resolved in the scope of the metamodels declared as used
by the library. If you include the 'ecore' metamodel there,
it resolves to the ecore::EObject class, though it does not solve your
problem yet ;).

As you mention in the other thread:
On Tue, 20 Oct 2009 12:40:17 +0200, Gilbert Mirenque <formatzeh@gmx.de>
wrote:
> ...I don't understand the error because every modeled interface is
> sub-interface of EObject.

This may seem from the Java code perspective but is not true from the
metamodel perspective.
FYI, in QVTO, every user model class conforms to 'Element' type (from the
QVTO Standard Library),
an analog of what you know as EObject in EMF.
It provides a limited subset of MOF reflective operations (read-only).

The problem:
The current black-box library does not support explicit mapping of EObject
java class to 'Element' type, which would allow to pass every user model
class
to the operation call. However, you would get read-only access.

Solution:
To workaround this issue, you can use java.lang.Object instead of EObject,
which is mapped to OclAny, so every type would conform (the only drawback).
Perform appropriate cast inside your black-box implementation.

Regards,
/Radek


On Tue, 20 Oct 2009 12:39:04 +0200, Gilbert Mirenque <formatzeh@gmx.de>
wrote:

> I have the following black box library method:
>
> @org.eclipse.m2m.qvt.oml.blackbox.java.Operation(contextual = true, kind
> = Kind.OPERATION)
> public boolean removeContainedElement(MyCompositionModel rootModel,
> EObject containedElement){
> for (EObject element : rootModel.eContents()) {
> if(containedElement.equals(element)){
> return rootModel.eContents().remove(containedElement);
> }
> }
> return false;
> }
>
> But when I start the second Eclipse instance with my transformations the
> declaring library can't be found because the error log says that
>
> Can't resolve 'interface org.eclipse.emf.ecore.EObject' as OCL type in
> java method 'public boolean my.libraries.ModelUtil.removeContainedElement
>
> I need a method which generically can remove children from parents. How
> can I achieve this?
Re: [QVTO] Can't resolve EObject as OCL type? [message #492692 is a reply to message #492655] Wed, 21 October 2009 12:32 Go to previous message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Thank you Radek, it works now.
Previous Topic:[ATL] ATL as source metamodel
Next Topic:Re: Problem with href
Goto Forum:
  


Current Time: Thu Apr 25 02:05:23 GMT 2024

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

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

Back to the top