Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Ecore/EVL check component is instantiated
Ecore/EVL check component is instantiated [message #1847601] Tue, 02 November 2021 09:10 Go to next message
Gary Collins is currently offline Gary CollinsFriend
Messages: 5
Registered: November 2021
Junior Member
I'm new to Eclipse Epsilon.
I created a meta model in Ecore and have written some EVL constraints.
But unable to write EVL constraint that checks if a component is instantiated.

* Created Ecore model with various components
* Between 2 components (component A and B) created a Composition Relation [1..1]
* Created dynamic instance (.xmi file)

I want to check if component B is instantiated in EVL.

If I validate the model it shows (as expected) that component B is not yet created with message ("The required feature 'containsFoo' of ''Model myModel must be set").

But how to do the same in EVL constraint ?

Tried checking the ref of component A but it will pass even without a component B.
	// check component has references 
	constraint HasReferenceToFoo {
		check: self.eClass().getEReferences().exists(c | c.name == "containsFoo")
		message: "Missing a reference to Foo" 
	}


Any help will be much appreciated.
Re: Ecore/EVL check component is instantiated [message #1847604 is a reply to message #1847601] Tue, 02 November 2021 09:42 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Gary,

The following should do the trick.

context A {
  constraint ContainsFoo {
    check: self.containsFoo.isDefined()
  }
}


Best,
Dimitris
Re: Ecore/EVL check component is instantiated [message #1847606 is a reply to message #1847604] Tue, 02 November 2021 10:07 Go to previous messageGo to next message
Gary Collins is currently offline Gary CollinsFriend
Messages: 5
Registered: November 2021
Junior Member
Hi Dimitris,

That worked out of the box.

Thanks !

Besides this forum what is the best place to find example EOL and EVL code ?

I'd like to view all the operations on an component/object ('self' for example).

I assume the JavaDoc is good starting point ?
https://javadoc.io/doc/org.eclipse.epsilon

I'm also reading your book (EpsilonBook) and looking at Youtube videos.


Gary
Re: Ecore/EVL check component is instantiated [message #1847611 is a reply to message #1847606] Tue, 02 November 2021 12:11 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Gary,

The book is no longer updated so my recommendation would be to consult the documentation pages for EVL [1] (and its base EOL [2] language) instead. The full JavaDoc is available in [3], [4] provides additional information for working with EMF models and there are also some live examples in [5]. There's a fair amount of EOL code on GitHub too [6].

Best,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/evl/
[2] https://www.eclipse.org/epsilon/doc/eol/
[3] https://download.eclipse.org/epsilon/stable-javadoc/
[4] https://www.eclipse.org/epsilon/doc/articles/epsilon-emf/
[5] https://www.eclipse.org/epsilon/live/
[6] https://github.com/search?q=extension%3Aeol+var
Re: Ecore/EVL check component is instantiated [message #1847612 is a reply to message #1847611] Tue, 02 November 2021 12:31 Go to previous messageGo to next message
Gary Collins is currently offline Gary CollinsFriend
Messages: 5
Registered: November 2021
Junior Member
Great thanks Dimitris !
Re: Ecore/EVL check component is instantiated [message #1847629 is a reply to message #1847604] Tue, 02 November 2021 14:42 Go to previous messageGo to next message
Gary Collins is currently offline Gary CollinsFriend
Messages: 5
Registered: November 2021
Junior Member
Hi Dimitris,

Should the same code work in case of Composition Relation [1..*] ?

check: self.containsFoo.isDefined()


I'm tried the [1..*] with no instantiated B component but EVL passes.

Any ideas why [1..1] fails but [1..*] passes ?


Rgds,

Gary


Re: Ecore/EVL check component is instantiated [message #1847631 is a reply to message #1847629] Tue, 02 November 2021 14:45 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Gary,

If containsFoo is multi-valued then self.containedFoo returns a collection (and hence is always non-null). What you're looking for in this case is

check: not self.containsFoo.isEmpty()


Best,
Dimitris
Re: Ecore/EVL check component is instantiated [message #1847638 is a reply to message #1847631] Tue, 02 November 2021 16:50 Go to previous message
Gary Collins is currently offline Gary CollinsFriend
Messages: 5
Registered: November 2021
Junior Member
Hi Dimitris,

Thanks that works for [1..*] !

Rgds,

Gary
Previous Topic:ETL Transformations: Types Not Found
Next Topic:Flock reordering items when using opposite references in EMF
Goto Forum:
  


Current Time: Sat Apr 27 08:02:48 GMT 2024

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

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

Back to the top