| Using OCL as a setter for derived features in EMF? [message #1338697] |
Wed, 07 May 2014 06:31  |
Eclipse User |
|
|
|
Hello, can OCL be used to set the values of derived attributes or references in EMF models?
I have been using OCL until now only to for general validation purposes. But I have come across to the "derivation" of OCL, and wasn't sure whether this is to set the values of such derived features or simply an extra invariant for them?
Since EMF lets the bodies of getters for derived (also volatile, transient and non-changeable) references etc. empty and expects you to implement these, I believe that this would ease this process of manually implementing the getters, if this derivation of OCL indeed this does. Or it like sad above only for further validation for derived features, after the getters are manually implemented?
Thanks!
|
|
|
| Re: Using OCL as a setter for derived features in EMF? [message #1338724 is a reply to message #1338697] |
Wed, 07 May 2014 06:47   |
Eclipse User |
|
|
|
Hi
As I replied on the EMF newsgroup, a truly derived property can never be
set; just derived, and OCL supports the derived computation.
Regards
Ed Willink
On 07/05/2014 11:31, Emre T wrote:
> Hello, can OCL be used to set the values of derived attributes or
> references in EMF models?
> I have been using OCL until now only to for general validation
> purposes. But I have come across to the "derivation" of OCL, and
> wasn't sure whether this is to set the values of such derived features
> or simply an extra invariant for them?
> Since EMF lets the bodies of getters for derived (also volatile,
> transient and non-changeable) references etc. empty and expects you to
> implement these, I believe that this would ease this process of
> manually implementing the getters, if this derivation of OCL indeed
> this does. Or it like sad above only for further validation for
> derived features, after the getters are manually implemented?
>
> Thanks!
|
|
|
|
|
|
| Re: Using OCL as a setter for derived features in EMF? [message #1338867 is a reply to message #1338832] |
Wed, 07 May 2014 08:06   |
Eclipse User |
|
|
|
See https://wiki.eclipse.org/OCL/ForumNetiquette
On 07/05/2014 12:46, Emre T wrote:
> Hi Ed, thanks it looks pretty clear there.
>
> But I have another problem regarding my model setup. Maybe you can help further.
>
> The derived reference, of which I am trying to compute its value, is between two elements from two different models. As depicted in the uploaded diagram.
>
>
>
> And what I do is loading an instance of the model being referenced by the derived reference of the SuperClass as a resouce into a dynamic instance (xmi). But I don't know how to traverse between these two different models with OCL, since there are no other references between these two models except the derived reference I want to compute. So my question would be how can I access the elements of the referenced package in the derivation clause of the "derivedReference"?
>
> My first try of OCL derivation looked like this:
>
> derivation: javaproperties::ReferencedElement.allInstances() -> select(re| re.oclIsTypeOf(javaproperties::ReferencedElement) and
> re.oclAsType(javaproperties::ReferencedElement).key -> exists(someString| htt = 'someAnotherString'))
>
> In the last part where I compare a fix String with the attribute could be any other comparisons, in fact I need to compare two different String attributes of ReferencedElement and SubClass. But first I need to solve this main problem.
>
> In an interactive OCL console can I indeed access the element I need with this or a very similiar OCL constraint, but only upon selecting the ReferencedElement (or its container) from the model as the loaded resource, and not my own model.
>
> Any further help will be very appreciated.
>
> Thanks and best regards,
> Emre
>
|
|
|
|
|
| Re: Using OCL as a setter for derived features in EMF? [message #1338989 is a reply to message #1338958] |
Wed, 07 May 2014 09:12  |
Eclipse User |
|
|
|
Oh, I see, sorry for that. The .png was actually just an obfuscated part of the model to show where the derived reference is. The model itself is a lot larger and pretty dependent, that unfortunately I cannot deliver.
The issue I am having isn't an error or so, but a possible function of OCL unknown to me, so I thought that there is no need for reproduction and an initial push towards this function could be given based on the information provided. But in this case, I would try to depict the situation in more detail again later.
Thanks any way.
Best regards,
Emre
|
|
|
Powered by
FUDForum. Page generated in 0.04792 seconds