Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problum validating inherited attribute
Problum validating inherited attribute [message #93548] Wed, 17 January 2007 06:22 Go to next message
Eclipse UserFriend
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 #94679 is a reply to message #93548] Sat, 20 January 2007 00:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

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 #95024 is a reply to message #94679] Mon, 22 January 2007 08:37 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
>>>
>
Previous Topic:Adding constraints for limiting connections from/to a node
Next Topic:Displaying custom tabs in propertysheet
Goto Forum:
  


Current Time: Thu May 08 09:47:30 EDT 2025

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

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

Back to the top