Ternary Association [message #1220102] |
Mon, 09 December 2013 16:53 |
John Guerson Messages: 51 Registered: August 2011 |
Member |
|
|
Hi,
It might be a silly question but I still didn't find the answer anywhere. As far as I studied, there is really few documentations about n-ary assocations that has clear explanations about it. So,
Given a ternary association such as for instance:
Student 1 --< >-- 1..* Enrollment
|
1..*
Time
1. What would be the result of a navigation such as: "context Student self.enrollment"? Is the set o tuples{Enrollment,Time} or the set of enrollments?
2. If I wanted to know the set of Enrollments in a certain Time instance, what would be the concrete syntax for that in OCL? Perhaps like "self.enrollments[t]" (t being a Time instance) or there's none CS defined for that sort of selection?
3. Finally, regarding the implementation in Eclipse, I read in a topic that all the ends (properties) must be owned by the assocation and one of them must not be navigable. But creating such association in UML, the Complete OCL editor was unable to find that ends (the editor always search for ends owned by the context class). I can provide a UML model if necessary together with my constraints file, but I just wanted to know if I missing something here.
Thanks in advance for anyone that may help me.
John
|
|
|
Re: Ternary Association [message #1220106 is a reply to message #1220102] |
Mon, 09 December 2013 18:24 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
It is only recently that the asymmetry of ternary associations was
explained to me so that they now make sense, but I haven't yet got round
to exploiting this to produce useable code.
On 09/12/2013 16:53, John Guerson wrote:
> Hi,
>
> It might be a silly question but I still didn't find the answer
> anywhere. As far as I studied, there is really few documentations
> about n-ary assocations that has clear explanations about it. So,
> Given a ternary association such as for instance:
>
> Student 1 --< >-- 1..* Enrollment
> |
> 1..*
> Time
>
The asymmetry means that you may only navigate from unit multiplicities.
Thus in your example:
Student::enrollment and Student::Time and their opposites are sensible.
Time::entollment and its opposite is meaningless.
> 1. What would be the result of a navigation such as: "context Student
> self.enrollment"? Is the set o tuples{Enrollment,Time} or the set of
> enrollments?
>
Collection(Enrollment)[1..*]
> 2. If I wanted to know the set of Enrollments in a certain Time
> instance, what would be the concrete syntax for that in OCL? Perhaps
> like "self.enrollments[t]" (t being a Time instance) or there's none
> CS defined for that sort of selection?
>
I would expect something like the following that first navigates to the
AssociationClass instances
aStudent.EnrollmentRecord->select(Time = t).Enrollment
> 3. Finally, regarding the implementation in Eclipse, I read in a topic
> that all the ends (properties) must be owned by the assocation and one
> of them must not be navigable. But creating such association in UML,
> the Complete OCL editor was unable to find that ends (the editor
> always search for ends owned by the context class). I can provide a
> UML model if necessary together with my constraints file, but I just
> wanted to know if I missing something here.
>
The must not be navigable is the meaningless Time-Enrollment relationship.
I'm afraid that the Xtext grammar behind the CompleteOCL editor is very
very suspect where associations are actually required.
Regards
Ed Willink
|
|
|
|
Powered by
FUDForum. Page generated in 0.03106 seconds