[QVTO] Blackboxing: how to set context? [message #100517] |
Mon, 23 February 2009 06:58  |
Eclipse User |
|
|
|
Hi all,
I try to add a blackbox operation to a qvto transformation as follows.
----------------------> blackbox library <----------------------
import mymodel.MyModel;
import mymodel.MymodelFactory;
public class BlackBox {
public static class Metainfo {
public static String[] ggg(String self) {
return new String[]{
"oclstdlib::String", "MyModel"
};
}
//// An exception is thrown if I enable the next 5 lines.
// public static String[] glub(MyModel self) {
// return new String[]{
// "mymodel::MyModel", "String"
// };
// }
}
public MyModel fff(String self) {
MyModel m = MymodelFactory.eINSTANCE.createMyModel();
m.setAnAttribute("blub");
return m;
}
public String glu(MyModel self) {
return self.getAnAttribute();
}
}
----------------------> blackbox library <----------------------
----------------------> qvto transformation <----------------------
modeltype mymodel uses mymodel('http://mymodel');
transformation blackboxtest();
import library BlackBox;
main() {
var x : MyModel := ''.fff();
log(x.anAttribute); -- works just fine and prints: blub
-- x.glu(); -- does not work
}
----------------------> qvto transformation <----------------------
An exception is thrown as soon as I uncomment all lines in the library and start the runtime workbench. I debugged it and found out that the context of the ocl statement in QvtLibraryOperation produces the error. The statements looks like that:
"context mymodel::MyModel def: glu():String=let r:String=null in r"
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:546)
at java.util.ArrayList.get(ArrayList.java:321)
at org.eclipse.m2m.internal.qvt.oml.ast.env.QvtLibraryOperation .parseConstraintUnvalidated(QvtLibraryOperation.java:125)
at org.eclipse.m2m.internal.qvt.oml.ast.env.QvtLibraryOperation . <init>(QvtLibraryOperation.java:58)
....
Does anyone have a hint on how to correctly set the context for an operation in the blackbox library?
Patrick
|
|
|
Re: [QVTO] Blackboxing: how to set context? [message #100536 is a reply to message #100517] |
Mon, 23 February 2009 07:47  |
Eclipse User |
|
|
|
Nevermind.. I figured it out.
I was missing the inMetamodel/outMetamodel in the plugin.xml:
<library class="mymodel.test.BlackBox" id="BlackBox">
<inMetamodel uri="http://mymodel"/>
<outMetamodel uri="http://mymodel"/>
</library>
Have a nice day everyone!
On 23-02-2009 12:58, Patrick Könemann wrote:
> Hi all,
>
> I try to add a blackbox operation to a qvto transformation as follows.
>
> ----------------------> blackbox library <----------------------
> import mymodel.MyModel;
> import mymodel.MymodelFactory;
> public class BlackBox {
> public static class Metainfo {
> public static String[] ggg(String self) {
> return new String[]{
> "oclstdlib::String", "MyModel"
> };
> }
> //// An exception is thrown if I enable the next 5 lines.
> // public static String[] glub(MyModel self) {
> // return new String[]{
> // "mymodel::MyModel", "String"
> // };
> // }
> }
> public MyModel fff(String self) {
> MyModel m = MymodelFactory.eINSTANCE.createMyModel();
> m.setAnAttribute("blub");
> return m;
> }
> public String glu(MyModel self) {
> return self.getAnAttribute();
> }
> }
> ----------------------> blackbox library <----------------------
>
>
> ----------------------> qvto transformation <----------------------
> modeltype mymodel uses mymodel('http://mymodel');
> transformation blackboxtest();
> import library BlackBox;
> main() {
> var x : MyModel := ''.fff();
> log(x.anAttribute); -- works just fine and prints: blub
> -- x.glu(); -- does not work
> }
> ----------------------> qvto transformation <----------------------
>
>
> An exception is thrown as soon as I uncomment all lines in the library
> and start the runtime workbench. I debugged it and found out that the
> context of the ocl statement in QvtLibraryOperation produces the error.
> The statements looks like that:
> "context mymodel::MyModel def: glu():String=let r:String=null in r"
>
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> at java.util.ArrayList.RangeCheck(ArrayList.java:546)
> at java.util.ArrayList.get(ArrayList.java:321)
> at
> org.eclipse.m2m.internal.qvt.oml.ast.env.QvtLibraryOperation .parseConstraintUnvalidated(QvtLibraryOperation.java:125)
>
> at
> org.eclipse.m2m.internal.qvt.oml.ast.env.QvtLibraryOperation . <init>(QvtLibraryOperation.java:58)
>
> ...
>
>
> Does anyone have a hint on how to correctly set the context for an
> operation in the blackbox library?
>
> Patrick
|
|
|
Powered by
FUDForum. Page generated in 0.20884 seconds