Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Multiple Contexts and allInstances Override
Multiple Contexts and allInstances Override [message #1210299] Mon, 25 November 2013 23:46 Go to next message
John Guerson is currently offline John GuersonFriend
Messages: 51
Registered: August 2011
Member
Hi,

1. OCL (Pivot or even UML/Ecore bindings) allows multiple contexts such as:

context p:Person, u:University
inv: <expression-with-p-and-u>

? I tried in Juno (did not work) and was wondering if it was implemented in some current release. If not, why?

2. Is it possible to override the predefined allInstances() operation? In this case, I was thinking about deriving a type (class) in UML by overriding allInstances() operation.

Cheers,
John

[Updated on: Mon, 25 November 2013 23:48]

Report message to a moderator

Re: Multiple Contexts and allInstances Overriding [message #1211210 is a reply to message #1210299] Tue, 26 November 2013 10:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4149
Registered: July 2009
Senior Member
Hi

You seem to be seriously mistaken.

I find no suggestion of a multi-context in OMG OCL.

I find no multi-context in the LPG grammar (used by the Ecore binding)

I find no multi-context in the Xtext grammar (used by the PIvot binding)

So how can you write: "OCL (Pivot or even UML/Ecore bindings) allows
multiple contexts"

Please don't waste my time.

Regards

Ed Willink


On 25/11/2013 23:46, John Guerson wrote:
> Hi,
>
> 1. OCL (Pivot or even UML/Ecore bindings) allows multiple contexts
> such as:
>
> context p:Person, u:University
> inv: <expression-with-p-and-u>
>
> ? I tried in Juno (did not work) and was wondering if it was
> implemented in some current release. If not, why?
>
> 2. Is it possible to override the predefined allInstances() operation?
> In this case, I was thinking about deriving a type (class) in UML by
> overriding allInstances() operation.
>
> Cheers,
> John
>
Re: Multiple Contexts and allInstances Overriding [message #1211829 is a reply to message #1211210] Tue, 26 November 2013 16:44 Go to previous messageGo to next message
John Guerson is currently offline John GuersonFriend
Messages: 51
Registered: August 2011
Member
Hey Ed.

I was just referring to this part of the OMG spec 2.3.1 regarding free variables in the context (shown below). I may have misused the term. But anyhow, I really sorry if I offended you in some way, I was just curious if this is supported within Eclipse.
And also about the allInstances operation which I wander if it could be overridden in some way.

==================
A.5.1.5 Invariants

An invariant

context v1 : C1, . . . , vn : Cn inv: <expression>

is equivalent to the following expression without free variables that must be valid in all system states:

C1.allInstances->forAll(v1 : C1 |
...
Cn.allInstances->forAll(vn : Cn |
<expression>
)
...
)
==================

Sorry again Ed.

Regards,
Joh
Re: Multiple Contexts and allInstances Overriding [message #1213374 is a reply to message #1211829] Wed, 27 November 2013 07:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4149
Registered: July 2009
Senior Member
Hi

Interesting. Not many people make it into the dark recesses of Annex A.
But Annex A is non-normative.

However the extension to multi-contexts overlaps nicely with a different
problem of no-contexts. In 7.6.10

context Person inv:
Person.allInstances()->forAll(p1, p2 |
p1 <> p2 implies p1.name <> p2.name)

would be better written as

context inv: -- this is not legal in OCL 2.3.1
Person.allInstances()->forAll(p1, p2 |
p1 <> p2 implies p1.name <> p2.name)

to avoid the naive O(P*P*P) rather than O(P*P) complexity.

[Or O(P*log(P)) of: context inv: let allPersons = Person.allInstances()
in allPersons->size() = allPersons.name->asSet()->size()]

I've raised an OMG issue, so it might happen one day.

Sorry for the gripe; you had an interesting issue after all. I just get
frustrated by the number of 15 minutes' that I spend understanding
stupid ideas that take away 15 minutes from positive progress.

Regards

Ed Willink


On 26/11/2013 16:44, John Guerson wrote:
> Hey Ed.
>
> I was just referring to this part of the OMG spec 2.3.1 regarding free
> variables in the context (shown below). I may have misused the term.
> But anyhow, I really sorry if I offended you in some way, I was just
> curious if this is supported within Eclipse.
> And also about the allInstances operation which I wander if it could
> be overridden in some way.
>
> ==================
> A.5.1.5 Invariants
> An invariant
> context v1 : C1, . . . , vn : Cn inv: <expression>
>
> is equivalent to the following expression without free variables that
> must be valid in all system states:
>
> C1.allInstances->forAll(v1 : C1 |
> ...
> Cn.allInstances->forAll(vn : Cn |
> <expression>
> )
> ...
> )
> ==================
>
> Sorry again Ed.
>
> Regards,
> Joh
Re: Multiple Contexts and allInstances Overriding [message #1213878 is a reply to message #1213374] Wed, 27 November 2013 12:37 Go to previous messageGo to next message
John Guerson is currently offline John GuersonFriend
Messages: 51
Registered: August 2011
Member
Hi Edward,

Thanks a lot for the reply.
Well, if wasn't ask you too much, I still have two issues that you might enlighten me regarding both Eclipse & OMG:

(1) If it is possible to override the built-in allInstances() operation. I know the OMG spec did not specify this, but it would be nice if they did,
to write something like the follow. Did you already came across wanting to do this?

context Employed::allInstances()
body: Person.allInstances()-NonEmployed.allInstances()

(2) Anf If it is possible to create ternary association in UML2 and use OCL to navigate through the ends (tuples)
I read the follow topic (which you answered) but still don´t know how can I do that in Eclipse (if it is implemented):
http://www.eclipse.org/forums/index.php/t/263125/

Regards,
John
Re: Multiple Contexts and allInstances Overriding [message #1214101 is a reply to message #1213878] Wed, 27 November 2013 14:42 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4149
Registered: July 2009
Senior Member
Hi

allInstances is built-in with, in principle, well-defined type-based
matching criteria; it is only the domain from which allInstnaces are
located that is unclear. In your example Employed is already a type so I
cannot see why you would want to waste time redefining the built-in
behaviour as unchnaged, and to redefine it as something different seems
really confusing.

Ternary associations are extremely confusing. I couldn't understand them
at all until it was explained to me that they're not symmetric. You are
only allowed to view them from a [1]/[0..1] end. The OCL syntax does not
seem able to handle both [] for disambiguation and qualification, so for
the Pivot-based OCL this has been a low priority cleanup once the
specification is also cleaned up. If you're lucky, you may find that
Christian understood it all perfectly and that the legacy Ecore/UML
bindings work fine.

Regards

Ed Willink

On 27/11/2013 12:37, John Guerson wrote:
> Hi Edward,
>
> Thanks a lot for the reply.
> Well, if wasn't ask you too much, I still have two issues that you
> might enlighten me regarding both Eclipse & OMG:
>
> (1) If it is possible to override the built-in allInstances()
> operation. I know the OMG spec did not specify this, but it would be
> nice if they did,
> to write something like the follow. Did you already came across
> wanting to do this?
> context Employed::allInstances() body:
> Person.allInstances()-NonEmployed.allInstances()
>
> (2) Anf If it is possible to create ternary association in UML2 and
> use OCL to navigate through the ends (tuples)
> I read the follow topic (which you answered) but still don´t know
> how can I do that in Eclipse (if it is implemented):
> http://www.eclipse.org/forums/index.php/t/263125/
> Regards,
> John
Previous Topic:Custom primitive types in OCL
Next Topic:Pivot doesn't support package stereotypes
Goto Forum:
  


Current Time: Fri Nov 21 02:51:47 GMT 2014

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

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