[QVTO] Can't resolve EObject as OCL type? [message #492389] |
Tue, 20 October 2009 10:39 |
Eclipse User |
|
|
|
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 #492655 is a reply to message #492389] |
Wed, 21 October 2009 09:34 |
Eclipse User |
|
|
|
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?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03638 seconds