Hierarchy cast with oclAsType [message #651426] |
Sun, 30 January 2011 15:17  |
Eclipse User |
|
|
|
Hi, I'm learning OCL and I need a little help with my example.
I have 4 classes and 1 interface:
Partner (interface)
Person : Partner
Company : Partner
employees Employee[*]
Employee
person Person[1]
Job
partner Partner
responsible : Person
I need to constrain the Job class. When partner were <> null and were a Company so only its employees can be the Person responsible.
But f the partner where a Person, so only himself could be the responsible.
I've started by writing this at oclecore editor on Job:
invariant responsibleShouldBeEmployeeOrHimself:
if (responsible <> null and owner <> null and owner.oclIsTypeOf(Company)) then
owner.oclAsType(Company).employees -> exists(responsible)
else
false
endif;
well it wasn't a good try at all. builders raises a error: "Couldn't resolve reference to NamedElementCS 'employees'.
Could someone help build this constraint?
Thanks in advance
Cristiano
|
|
|
|
|
Re: Hierarchy cast with oclAsType [message #652106 is a reply to message #651885] |
Wed, 02 February 2011 12:04  |
Eclipse User |
|
|
|
Hi Cristiano
"Wondering if could be possible" ...
It's only software and a sensible idea so of course yes.
But. Interesting idea for future directions, as e4 increases the extent
to which information is modelled. It may be possible for OCL to be used
as a platform expression language.
Regards
Ed Willink
On 01/02/2011 21:36, Cristiano Gaviao wrote:
> Hi Ed,
>
> Thanks for tips !! :d
> btw, do you know any link where could I learn more best practices on
> constructing ocl sentences?
> good to know that new release is coming soon. I'm waiting it to test
> your tips.
>
> But I did some tests today using helios and I was just thinking and
> would like to ask to you...:
> Wondering if could be possible to use OCL to filter data that id show
> on combobox at generated editor ? I mean, could I use the inv
> HasResponsibleEnmployee to instead of constrain after I save the
> document, to "select" and restrict the instances to be shown ?
>
> thanks a lot
>
> Cristiano
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.26165 seconds