Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF-IncQuery » Accessing the values of attributes/references in pattern bodies
Accessing the values of attributes/references in pattern bodies [message #1269294] Tue, 11 March 2014 17:09 Go to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hello!

What is the most convenient way to access the values of e.g. attributes/references of model being queried in the pattern bodies and store them temporary variables again in the pattern bodies, to use them in check()/eval()?

A simple example might look like this; A model element named Book, which has an attribute ISBN. A trivial pattern definition is as follows:

pattern getISBN(Book: Book, ISBN: EString) {
Book.ISBN(Book, ISBN);
}

What I want to achieve is to access the value of ISBN-Attribute of the book, using similar queries as defined above.

Maybe the questions should have been, if that approach is even possible? I am a little bit confused these days, so I hope I am not missing something trivial out.

Thanks.



Re: Accessing the values of attributes/references in pattern bodies [message #1269299 is a reply to message #1269294] Tue, 11 March 2014 17:13 Go to previous message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 260
Registered: July 2015
Senior Member
Hi,

the constraint Book.ISBN(Book, ISBN); already puts the required value into the ISBN variable. In other words, the following should work as expected:

pattern getISBN(Book: Book, ISBN: EString) {
Book.ISBN(Book, ISBN);
check(ISBN.startsWith("1));
}

Similarly, if you call this pattern via a 'find' construct, the variable in the find will store the value that is reusable inside the check expression.

Cheers,
Zoltán
Previous Topic:Variable has a type which has multiple definitions
Next Topic:Statements and Operations in Query Definitions
Goto Forum:
  


Current Time: Fri Jul 31 19:33:47 GMT 2015

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

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