Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Evaluate Ecore Instances programatically
Evaluate Ecore Instances programatically [message #663276] Mon, 04 April 2011 13:59 Go to next message
khurram is currently offline khurramFriend
Messages: 3
Registered: April 2011
Junior Member
Hi,

I am creating ECore model with OCL embedded in it programatically using JAVA. I am also creating instances of Ecore model but i want instances with evaluated values with respect to OCL derivations defined inside Ecore. As there are some attribute having derivation statement. I want to access those attributes and want to get the derived values from them.

class Library
{
property totalBooks : ecore_0::EDouble[1] { derived,volatile }
{
derivation: self.books.copies->sum() + testFunction1();
}
property books : Book[*] { composes };
property members : Member[*] { composes };
property loans : Loan[*] { composes };
operation testFunction1() : ecore_0::EInt[?]
{
body: 2;
}
}
class Book
{
attribute name : String[?];
attribute copies : ecore_0::EIntegerObject[?];
}
class Loan
{
property member : Member[1];
property book : Book[1];
}

This is structure of my generated Ecore. I am taking the instance of library and added few books into it and wants that Library.totalBooks should have calculated values.

Please guide me!

Warmest Regards,
Khurram
Re: Evaluate Ecore Instances programatically [message #663315 is a reply to message #663276] Mon, 04 April 2011 15:10 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Khurram,

This is really more of an OCL question best asked on the OCL newsgroup.


khurram wrote:
> Hi,
>
> I am creating ECore model with OCL embedded in it programatically
> using JAVA. I am also creating instances of Ecore model but i want
> instances with evaluated values with respect to OCL derivations
> defined inside Ecore. As there are some attribute having derivation
> statement. I want to access those attributes and want to get the
> derived values from them.
>
> class Library
> {
> property totalBooks : ecore_0::EDouble[1] { derived,volatile }
> {
> derivation: self.books.copies->sum() + testFunction1();
> }
> property books : Book[*] { composes };
> property members : Member[*] { composes };
> property loans : Loan[*] { composes };
> operation testFunction1() : ecore_0::EInt[?]
> {
> body: 2;
> }
> }
> class Book
> {
> attribute name : String[?];
> attribute copies : ecore_0::EIntegerObject[?];
> }
> class Loan
> {
> property member : Member[1];
> property book : Book[1];
> }
>
> This is structure of my generated Ecore. I am taking the instance of
> library and added few books into it and wants that Library.totalBooks
> should have calculated values.
>
> Please guide me!
>
> Warmest Regards,
> Khurram
Previous Topic:updating ecore instance with derived ocl values
Next Topic:Filter the avaible values for a non-containment reference
Goto Forum:
  


Current Time: Sat Oct 19 06:40:11 GMT 2019

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

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

Back to the top