Problum validating inherited attribute [message #93548] |
Wed, 17 January 2007 06:22  |
Eclipse User |
|
|
|
Originally posted by: biju_gopinathan.rediffmail.com
Hi friends,
In my EMF model I have a class B which extends class A. In A there is a
String attribute 'sourcePortLimit '.
I just wanted to constrain the 'sourcePortLimit ' of A (and thus of B,
too) to a length less than 20 characters. So I added this OCL expression
to A:
self.sourcePortLimit > 2
In my GMF Editor I only have instances of B and doing the validation
raises a validation Error, with details as follows:
Diagnosis of Constraint self.sourcePortLimit >2
Invalid expression body 'self.sourcePortLimit >2'. Cause: Invalid
expression body 'self.sourcePortLimit >2'. Cause:
org.eclipse.emf.ocl.parser.SemanticException: ERROR in (variableExpCS):
(Unrecognized variable: (sourcePortLimit))
Thanks in advance regards biju
|
|
|
|
Re: Problum validating inherited attribute [message #95024 is a reply to message #94679] |
Mon, 22 January 2007 08:37   |
Eclipse User |
|
|
|
Hi biju,
In OCL, inherited attributes should be accessible on sub-types
automatically.
I have tried to reproduce the behavior you have described but everything
works
fine.
Could you please re-check the context EClass that was set in
DomainElementTarget
element used with your constraint?
Regards,
/Radek
"biju" <biju_gopinathan@rediffmail.com> wrote in message
news:eosa6n$qq3$1@utils.eclipse.org...
> Hi friends,
>
> I got the solution, which is to cast it as the required super type as
> follows:
>
> We have a class B as a subtype of class A, and to access property p1 of A
> in B, we can write
>
> self.oclAsType(A).p1 -- where self is B
>
>
> regards biju
> biju wrote:
>> Hi friends,
>>
>> In my EMF model I have a class B which extends class A. In A there is
>> a String attribute 'sourcePortLimit '.
>>
>> I just wanted to constrain the 'sourcePortLimit ' of A (and thus of
>> B, too) to a length less than 20 characters. So I added this OCL
>> expression to A:
>> self.sourcePortLimit > 2
>>
>> In my GMF Editor I only have instances of B and doing the validation
>> raises a validation Error, with details as follows:
>>
>> Diagnosis of Constraint self.sourcePortLimit >2
>> Invalid expression body 'self.sourcePortLimit >2'. Cause: Invalid
>> expression body 'self.sourcePortLimit >2'. Cause:
>> org.eclipse.emf.ocl.parser.SemanticException: ERROR in (variableExpCS):
>> (Unrecognized variable: (sourcePortLimit))
>>
>> Thanks in advance regards biju
>>
|
|
|
Re: Problum validating inherited attribute [message #95394 is a reply to message #95024] |
Tue, 23 January 2007 04:53  |
Eclipse User |
|
|
|
Originally posted by: biju_gopinathan.rediffmail.com
Hi Radek Dvorak,
Thanks to see your response,what you said is right, I might have made
some other mistake in my first attempt.
> In OCL, inherited attributes should be accessible on sub-types
> automatically.
Thanks again regards biju
Radek Dvorak wrote:
> Hi biju,
>
> In OCL, inherited attributes should be accessible on sub-types
> automatically.
> I have tried to reproduce the behavior you have described but everything
> works
> fine.
> Could you please re-check the context EClass that was set in
> DomainElementTarget
> element used with your constraint?
>
> Regards,
> /Radek
>
> "biju" <biju_gopinathan@rediffmail.com> wrote in message
> news:eosa6n$qq3$1@utils.eclipse.org...
>> Hi friends,
>>
>> I got the solution, which is to cast it as the required super type as
>> follows:
>>
>> We have a class B as a subtype of class A, and to access property p1 of A
>> in B, we can write
>>
>> self.oclAsType(A).p1 -- where self is B
>>
>>
>> regards biju
>> biju wrote:
>>> Hi friends,
>>>
>>> In my EMF model I have a class B which extends class A. In A there is
>>> a String attribute 'sourcePortLimit '.
>>>
>>> I just wanted to constrain the 'sourcePortLimit ' of A (and thus of
>>> B, too) to a length less than 20 characters. So I added this OCL
>>> expression to A:
>>> self.sourcePortLimit > 2
>>>
>>> In my GMF Editor I only have instances of B and doing the validation
>>> raises a validation Error, with details as follows:
>>>
>>> Diagnosis of Constraint self.sourcePortLimit >2
>>> Invalid expression body 'self.sourcePortLimit >2'. Cause: Invalid
>>> expression body 'self.sourcePortLimit >2'. Cause:
>>> org.eclipse.emf.ocl.parser.SemanticException: ERROR in (variableExpCS):
>>> (Unrecognized variable: (sourcePortLimit))
>>>
>>> Thanks in advance regards biju
>>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.30339 seconds