Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Blackboxing: how to set context?
[QVTO] Blackboxing: how to set context? [message #100517] Mon, 23 February 2009 11:58 Go to next message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
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 12:47 Go to previous message
Patrick Konemann is currently offline Patrick KonemannFriend
Messages: 116
Registered: July 2009
Senior Member
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
Previous Topic:EMF Tiger
Next Topic:[ATL] Problem when trying to compile programmatically an ATL file with ATL 3.0
Goto Forum:
  


Current Time: Sun Dec 22 06:08:02 GMT 2024

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

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

Back to the top