Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to instantiate a hierarchy of model elements using fixies in EVL
How to instantiate a hierarchy of model elements using fixies in EVL [message #1766439] Wed, 21 June 2017 13:50 Go to next message
Marcelo Rodrigues is currently offline Marcelo RodriguesFriend
Messages: 21
Registered: November 2016
Junior Member
The doubt is described in the attached figure.

index.php/fa/29742/0/
  • Attachment: image.png
    (Size: 105.57KB, Downloaded 163 times)
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766451 is a reply to message #1766439] Wed, 21 June 2017 14:37 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1550
Registered: July 2009
Location: York, UK
Senior Member

Hi,

You need to use containment references to structure your model elements in a hierarchical way (i.e. "val" instead of "ref" in Emfatic) [1].

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/reflective-emf-tutorial/
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766454 is a reply to message #1766451] Wed, 21 June 2017 15:03 Go to previous messageGo to next message
Marcelo Rodrigues is currently offline Marcelo RodriguesFriend
Messages: 21
Registered: November 2016
Junior Member
Thanks for the answer.

But how to do this, use EOL (in a Fix block)?
I'm trying to instantiate these elements semi-automatically via .evl code

The code I'm using is the one shown in the figure.

index.php/fa/29743/0/


  • Attachment: image.png
    (Size: 107.34KB, Downloaded 146 times)
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766460 is a reply to message #1766454] Wed, 21 June 2017 15:39 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1550
Registered: July 2009
Location: York, UK
Senior Member

Hi,

Adding a statement like the following would do the trick but the exact syntax depends on your metamodel

self.eContainer().interfaces.add(p);


Cheers,
Dimitris
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766461 is a reply to message #1766460] Wed, 21 June 2017 15:44 Go to previous messageGo to next message
Marcelo Rodrigues is currently offline Marcelo RodriguesFriend
Messages: 21
Registered: November 2016
Junior Member
Thank you!
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766667 is a reply to message #1766461] Sat, 24 June 2017 18:30 Go to previous messageGo to next message
Marcelo Rodrigues is currently offline Marcelo RodriguesFriend
Messages: 21
Registered: November 2016
Junior Member
Hi Dimitris,

I have not been able to instantiate yet.

Taking as an example the metamodel of the example given in [1] (example you had quoted in an earlier post), how would I do to instantiate a Book element as a sub-element of Library?

Here is the code, in EVL, that I'm using to execute an instantiation of a Book element. As it stands, the Book element is not being instantiated as a Library sub-element.

Thank you!

context mylibrary!Library{
	
	critique InstantiateModelElement {
		
		check  :  mylibrary!Library == null 
		 	 		
		message : "Instantiate model element"  
		
		fix {
			title : "Create a new book"
			
			do {
				mylibrary!Book.createInstance;
				  //self.eContainer().Book.add(new mylibrary!Library); Im trying this way, but doesn't working		
			}	
		}
	}
	
}
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766668 is a reply to message #1766667] Sat, 24 June 2017 18:52 Go to previous messageGo to next message
Marcelo Rodrigues is currently offline Marcelo RodriguesFriend
Messages: 21
Registered: November 2016
Junior Member
[1] https://www.eclipse.org/epsilon/doc/articles/reflective-emf-tutorial/
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766669 is a reply to message #1766667] Sat, 24 June 2017 18:52 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1550
Registered: July 2009
Location: York, UK
Senior Member

Hi Marcelo,

To create a book and add it under the library the following snippet should do the trick.

do {
  var book : new mylibrary!Book;
  // Note that if you're only running the constraint
  // against one model, var book : new Book would 
  // work equally well (i.e. you don't need "mylibrary!")
  self.books.add(book);
}


I hope this helps.

Cheers,
Dimitris
Re: How to instantiate a hierarchy of model elements using fixies in EVL [message #1766670 is a reply to message #1766669] Sat, 24 June 2017 19:01 Go to previous message
Marcelo Rodrigues is currently offline Marcelo RodriguesFriend
Messages: 21
Registered: November 2016
Junior Member
Hi Dimitris,

Thanks so much!

Cheers,
Marcelo
Previous Topic:Live validation with EVL
Next Topic:ETL and ATL
Goto Forum:
  


Current Time: Mon Jun 25 06:31:28 GMT 2018

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

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

Back to the top