Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EVL] Call Operations of Metamodel
[EVL] Call Operations of Metamodel [message #1725985] Tue, 08 March 2016 20:39 Go to next message
Glatz Martin is currently offline Glatz MartinFriend
Messages: 16
Registered: March 2016
Junior Member
Hello,

I'm quite new to EVL and I'd appreciate your help with the following problem.

I have an ECore metamoodel where I have a hiearchy of classes. I'd like to implement some kind of API in the metamodel (e.g. traverse the tree and get all Elements of a specific typ) - so I've created an operation in the mode, generated the model code and edited the code there.

Now I'd like to access this code.

I've tried the basic "access java code from EOL/EVL" - the examples with setText, getText etc. work fine, but I would like to hand over e.g. the "root element of the concrete model", to traverse it with my API functionality.

I've created a static helper Method in my "Tool-java-class", but when I call it like

var t : new Native("amlutil.ModelTransformer");
t.getAllIEs(self);

the method is not found.

Is there a way to achive the functionality I want to implement or do you have any suggestions?

Thanks a lot in advance,
Martin
Re: [EVL] Call Operations of Metamodel [message #1725996 is a reply to message #1725985] Tue, 08 March 2016 22:12 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1484
Registered: July 2009
Location: York, UK
Senior Member

Hi Martin,

If you've added an EOperation to an EClass and implemented its behaviour in the code generated by EMF, you should be able to invoke it directly from EOL/EVL on instances of that EClass. For example, if your EClass is called "X" and your EOperation is called "op", the following code should work.

var x : new X;
x.op();


Cheers,
Dimitris
Re: [EVL] Call Operations of Metamodel [message #1726002 is a reply to message #1725996] Tue, 08 March 2016 23:09 Go to previous messageGo to next message
Glatz Martin is currently offline Glatz MartinFriend
Messages: 16
Registered: March 2016
Junior Member
Hello Dimitris,

thanks a lot for your quick reply.

I've removed the wrapper function in the meantime, but somehow the EOperation is not found.

I have simplified my example in the meantime - my Operation declaration looks as follows (EOperation op in class InstanceHierarchy):

[code]
<eClassifiers xsi:type="ecore:EClass" name="InstanceHierarchy" eSuperTypes="#//CAEXObject">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="InstanceHierarchy"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eOperations name="op" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return &quot;Operation executed&quot;;"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="internalElement" upperBound="-1"
eType="#//InternalElement" containment="true" resolveProxies="false">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Shall be used in order to define nested objects inside of a SystemUnitClass or another InternalElement. Allows description of the internal structure of an CAEX object."/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="InternalElement"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>

Then I generate model Code - basically the test functionality is already there, as I've put it in the model for now.

The EVL file looks as follows (I know doesn't make much sense)

context CAEX!InstanceHierarchy
{

constraint IsIDUnique
{
check: self.op().println()
message : self + ": ID's are not unique"
}
}

But still I get the error message:

Method 'op' not found for: InstanceHierarchy [changeMode=state, iD=null, name=, ]

I'm running the application with a debug-Configuration in Eclipse, where I've introduced the CAEX model and metamodel.

In addition it's not quite clear for me how the generated model code is integrated here - it's generated as a different project - I've copied the model code etc. to the project where the EVL file is located, but that didn't help either.

Do you have any idea, what I'm missing here?

Thanks a lot,

Best regards
Martin

Re: [EVL] Call Operations of Metamodel [message #1726006 is a reply to message #1726002] Tue, 08 March 2016 23:51 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1484
Registered: July 2009
Location: York, UK
Senior Member

Hi Martin,

How do you run the EVL constraints? A minimal example [1] I can use to reproduce this would probably help.

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/minimal-examples/
Re: [EVL] Call Operations of Metamodel [message #1726357 is a reply to message #1726006] Fri, 11 March 2016 19:10 Go to previous messageGo to next message
Glatz Martin is currently offline Glatz MartinFriend
Messages: 16
Registered: March 2016
Junior Member
Hello Dimitris,

thank you for your reply - I've solved the problem in the meantime with my thesis adviser Manuel Wimmer.

In case somebody else is facing same issues - it seems the problem was a mixture of following issues:

1) I've used in the run-configuration of the EVL modul a file reference to the metamodel instead of a URI to the deployed EMF metamodel Eclipse plugin.
2) My EVL file was located within the metamodel-project.

After separating the metamodel from the EVL, redeployment of the metamodel-plugin, and using a URI to the metamodel, the invocation of EOperations works fine.

Thanks a lot for your help,

Best regards,
Martin
Re: [EVL] Call Operations of Metamodel [message #1726408 is a reply to message #1726357] Sat, 12 March 2016 22:14 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1484
Registered: July 2009
Location: York, UK
Senior Member

Hi Martin,

That's good news. Thanks for sharing your solution!

Cheers,
Dimitris
Previous Topic:Flock: migration when model and metamodel are split into several files
Next Topic:EVL: How to define a Generic Constraint
Goto Forum:
  


Current Time: Mon Nov 20 15:51:25 GMT 2017

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

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