Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Query for not all elements of a model
Query for not all elements of a model [message #486205] Wed, 16 September 2009 14:00 Go to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

Hello,
my meta model defines a composition model which can contain normal
components containing events. Besides normal components it can contain
composite components which also can contain events. Now I have another
model element (ReferenceEventElement) which has to reference events. But
it mustn't reference those events which are contained in a composite
component. Is this query correct?

context ReferenceEventElement:
inv: self.event ->forAll(ev|
not MyMetaModel::CompositeComponent.allInstances()->forAll(comp|
comp.eContents()->select(tempEv|
tempEv.oclIsTypeOf(MyMetaModel::Event))-> includes(ev)
)
)

Or is there a better solution?
Re: Query for not all elements of a model [message #486207 is a reply to message #486205] Wed, 16 September 2009 14:12 Go to previous messageGo to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

Besides this I want to check some more precisely that not only the
events are not contained in a composite component but also are of
special type. Therefore this expression with a let statement.

let contextEvents: Set(CRUISeMetaModel::Event) =
MyMetaModel::ContextComponent.allInstances().event->union(contextEvents)
in
self.event ->forAll(ev|
not MyMetaModel::CompositeComponent.allInstances()->forAll(comp|
comp.eContents()->select(tempEv|
tempEv.oclIsTypeOf(MyMetaModel::Event))-> includes(ev)
)
and
contextEvents->includes(ev)
)


But I get the result "Unrecognized variable: (contextEvents)". Is the
let statement wrong?
Re: Query for not all elements of a model [message #486240 is a reply to message #486207] Wed, 16 September 2009 16:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4031
Registered: July 2009
Senior Member
Hi Gilbert

There were some problems with 'let' precedence that have been fixed in
MDT-OCL 1.2.0. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=182201).

You need to identify the version of MDT-OCL that you are using and
if 1.2 or 1.3 submit a Bugzilla containing your models.

---

As a general rule, you should try hard to write OCL that does not use
allInstances.

Regards

Ed Willink

Gilbert Mirenque wrote:
> Besides this I want to check some more precisely that not only the
> events are not contained in a composite component but also are of
> special type. Therefore this expression with a let statement.
>
> let contextEvents: Set(CRUISeMetaModel::Event) =
> MyMetaModel::ContextComponent.allInstances().event->union(contextEvents)
> in
> self.event ->forAll(ev|
> not MyMetaModel::CompositeComponent.allInstances()->forAll(comp|
> comp.eContents()->select(tempEv|
> tempEv.oclIsTypeOf(MyMetaModel::Event))-> includes(ev)
> )
> and
> contextEvents->includes(ev)
> )
>
>
> But I get the result "Unrecognized variable: (contextEvents)". Is the
> let statement wrong?
Re: Query for not all elements of a model [message #486331 is a reply to message #486240] Thu, 17 September 2009 05:51 Go to previous message
Eclipse User
Originally posted by: formatzeh.gmx.de

Hi Ed,

> You need to identify the version of MDT-OCL that you are using and
> if 1.2 or 1.3 submit a Bugzilla containing your models.

I have two plugins (org.eclipse.emf.ocl, org.eclipse.emf.ocl.doc) in
version 1.1.* and all the other ocl plugins in version 1.3.*:

org.eclipse.ocl.doc
org.eclipse.emf.ocl.examples
org.eclipse.emf.ocl.examples.interpreter
org.eclipse.ocl
org.eclipse.ocl.ecore
org.eclipse.ocl.uml

I just just the Galileo Modeling Edition. Why are the versions mixed?
Previous Topic:OCLConsole Saving Error: The 'no duplicates' constraint is violated
Next Topic:How to check the types of containment?
Goto Forum:
  


Current Time: Sat Aug 23 15:30:24 EDT 2014

Powered by FUDForum. Page generated in 0.01574 seconds