Home » Modeling » OCL » OCL can not match operation and argument types if argument is EClass

Re: OCL can not match operation and argument types if argument is EClass [message #65368 is a reply to message #65346] 
Fri, 12 December 2008 20:27 
Eclipse User 



Originally posted by: cdamus.zeligsoft.com
Hi, Kirill,
I'm not so sure about that. The error message that you are getting is
that the Bag(EObject) type does not have an operation
intersection(Bag(EClass)). I would expect this parse error because
Bag(EObject) defines only intersection(Bag(EObject)).
You can, instead, reverse the intersection thus:
self.element.oclAsType(ecore::EClass).eSuperTypes>asBag() >
intersection(notation::Node.allInstances()>select(
a : notation::Node  not a.element.oclIsUndefined() ).element)
because the Bag(EClass) type can do intersection(Bag(EObject)), as
Bag(EClass) conforms to Bag(EObject).
For example, in an Ecore editor, if I select an EClass and do this in
the OCL Console:
self.eSuperTypes>asBag()>intersection(EReference.allInstances().eType)
I get this error:
Cannot find operation (intersection(Bag(EClassifier))) for the type
(Bag(EClass))
but if I do this, instead:
EReference.allInstances().eType>intersection(self.eSuperTypes >asBag())
then all is well.
HTH,
Christian
Kirill A. Balod wrote:
> Hello,
>
> I experimented with OCL over Ecore diagram and found strange behavior (error
> from my point of view).
> As you know notation::Node.element refers to model element and for Ecore
> diagram it could be EClass.
> I would like to know  which super classes of this class there are on
> diagram.
>
> I wrote query:
> notation::Node.allInstances()>select(
> a : notation::Node  not a.element.oclIsUndefined() ).element>
> inttersection(self.element.oclAsType(ecore::EClass).eSuperTy pes >asBag())
>
> and found error: Cannot find operation (inttersection(Bag(EClass))) for the
> type (Bag(EObject))
>
> After investigation I found that if argument is EClass OCL use as type of
> argument _not_ argument.eClass() but argument itself and can not match
> operation and argument types.
>
> Look like problem in UMLReflection.getOCLType(Object metaElement)
>
> Best regards
> Kirill A. Balod
>
>



Re: OCL can not match operation and argument types if argument is EClass [message #65388 is a reply to message #65368] 
Fri, 12 December 2008 21:11 
Eclipse User 



Originally posted by: cdamus.zeligsoft.com
Hi, again, Kirill,
Sorry, I seem to have got myself turned backwards this Friday afternoon.
Your formulation of the expression should be OK. The inverse would be
invalid.
I do notice that the snippet you pasted has two ts in the word
'inttersection.' Could that be the problem?
When I use 'intersection', the expression parses successfully for me in
the Interactive OCL Console.
Cheers,
Christian
Christian W. Damus wrote:
> Hi, Kirill,
>
> I'm not so sure about that. The error message that you are getting is
> that the Bag(EObject) type does not have an operation
> intersection(Bag(EClass)). I would expect this parse error because
> Bag(EObject) defines only intersection(Bag(EObject)).
>
> You can, instead, reverse the intersection thus:
>
> self.element.oclAsType(ecore::EClass).eSuperTypes>asBag() >
> intersection(notation::Node.allInstances()>select(
> a : notation::Node  not a.element.oclIsUndefined() ).element)
>
> because the Bag(EClass) type can do intersection(Bag(EObject)), as
> Bag(EClass) conforms to Bag(EObject).
>
> For example, in an Ecore editor, if I select an EClass and do this in
> the OCL Console:
>
> self.eSuperTypes>asBag()>intersection(EReference.allInstances().eType)
>
> I get this error:
>
> Cannot find operation (intersection(Bag(EClassifier))) for the type
> (Bag(EClass))
>
> but if I do this, instead:
>
> EReference.allInstances().eType>intersection(self.eSuperTypes >asBag())
>
> then all is well.
>
> HTH,
>
> Christian
>
> Kirill A. Balod wrote:
>> Hello,
>>
>> I experimented with OCL over Ecore diagram and found strange behavior
>> (error from my point of view).
>> As you know notation::Node.element refers to model element and for
>> Ecore diagram it could be EClass.
>> I would like to know  which super classes of this class there are on
>> diagram.
>>
>> I wrote query:
>> notation::Node.allInstances()>select(
>> a : notation::Node  not a.element.oclIsUndefined() ).element>
>> inttersection(self.element.oclAsType(ecore::EClass).eSuperTy pes >asBag())
>>
>> and found error: Cannot find operation (inttersection(Bag(EClass)))
>> for the type (Bag(EObject))
>>
>> After investigation I found that if argument is EClass OCL use as type
>> of argument _not_ argument.eClass() but argument itself and can not
>> match operation and argument types.
>>
>> Look like problem in UMLReflection.getOCLType(Object metaElement)
>>
>> Best regards
>> Kirill A. Balod
>>
>>



Re: OCL can not match operation and argument types if argument is EClass [message #65410 is a reply to message #65388] 
Sun, 14 December 2008 21:00 
Kirill A. Balod Messages: 30 Registered: July 2009 
Member 


I'm so so sorry.
It is my double mistake.
The first  the name 'inttersection.' in my example and the second in my
code
Helper helper =
auxGetOcl().createOCLHelper();helper.setContext(getContextEC lass());
"Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
news:ghuk1m$3fd$1@build.eclipse.org...
> Hi, again, Kirill,
>
> Sorry, I seem to have got myself turned backwards this Friday afternoon.
>
> Your formulation of the expression should be OK. The inverse would be
> invalid.
>
> I do notice that the snippet you pasted has two ts in the word
> 'inttersection.' Could that be the problem?
>
> When I use 'intersection', the expression parses successfully for me in
> the Interactive OCL Console.
>
> Cheers,
>
> Christian
>
> Christian W. Damus wrote:
>> Hi, Kirill,
>>
>> I'm not so sure about that. The error message that you are getting is
>> that the Bag(EObject) type does not have an operation
>> intersection(Bag(EClass)). I would expect this parse error because
>> Bag(EObject) defines only intersection(Bag(EObject)).
>>
>> You can, instead, reverse the intersection thus:
>>
>> self.element.oclAsType(ecore::EClass).eSuperTypes>asBag() >
>> intersection(notation::Node.allInstances()>select(
>> a : notation::Node  not a.element.oclIsUndefined() ).element)
>>
>> because the Bag(EClass) type can do intersection(Bag(EObject)), as
>> Bag(EClass) conforms to Bag(EObject).
>>
>> For example, in an Ecore editor, if I select an EClass and do this in the
>> OCL Console:
>>
>> self.eSuperTypes>asBag()>intersection(EReference.allInstances().eType)
>>
>> I get this error:
>>
>> Cannot find operation (intersection(Bag(EClassifier))) for the type
>> (Bag(EClass))
>>
>> but if I do this, instead:
>>
>> EReference.allInstances().eType>intersection(self.eSuperTypes >asBag())
>>
>> then all is well.
>>
>> HTH,
>>
>> Christian
>>
>> Kirill A. Balod wrote:
>>> Hello,
>>>
>>> I experimented with OCL over Ecore diagram and found strange behavior
>>> (error from my point of view).
>>> As you know notation::Node.element refers to model element and for
>>> Ecore diagram it could be EClass.
>>> I would like to know  which super classes of this class there are on
>>> diagram.
>>>
>>> I wrote query:
>>> notation::Node.allInstances()>select(
>>> a : notation::Node  not a.element.oclIsUndefined() ).element>
>>> inttersection(self.element.oclAsType(ecore::EClass).eSuperTy pes >asBag())
>>>
>>> and found error: Cannot find operation (inttersection(Bag(EClass))) for
>>> the type (Bag(EObject))
>>>
>>> After investigation I found that if argument is EClass OCL use as type
>>> of argument _not_ argument.eClass() but argument itself and can not
>>> match operation and argument types.
>>>
>>> Look like problem in UMLReflection.getOCLType(Object metaElement)
>>>
>>> Best regards
>>> Kirill A. Balod
>>>
>>>



Re: OCL can not match operation and argument types if argument is EClass [message #65433 is a reply to message #65410] 
Sun, 14 December 2008 21:03 
Kirill A. Balod Messages: 30 Registered: July 2009 
Member 


Ups..
Previous mail is incomplete...
so problem was in my function getContextEClass()
Thanks a lot for your replies.
Sorry one more..
Kirill
"Kirill A. Balod" <Kirill.Balod@borland.com> wrote in message
news:gi3s64$1tk$1@build.eclipse.org...
> I'm so so sorry.
>
> It is my double mistake.
> The first  the name 'inttersection.' in my example and the second in my
> code
> Helper helper =
> auxGetOcl().createOCLHelper();helper.setContext(getContextEC lass());
>
>
> "Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
> news:ghuk1m$3fd$1@build.eclipse.org...
>> Hi, again, Kirill,
>>
>> Sorry, I seem to have got myself turned backwards this Friday afternoon.
>>
>> Your formulation of the expression should be OK. The inverse would be
>> invalid.
>>
>> I do notice that the snippet you pasted has two ts in the word
>> 'inttersection.' Could that be the problem?
>>
>> When I use 'intersection', the expression parses successfully for me in
>> the Interactive OCL Console.
>>
>> Cheers,
>>
>> Christian
>>
>> Christian W. Damus wrote:
>>> Hi, Kirill,
>>>
>>> I'm not so sure about that. The error message that you are getting is
>>> that the Bag(EObject) type does not have an operation
>>> intersection(Bag(EClass)). I would expect this parse error because
>>> Bag(EObject) defines only intersection(Bag(EObject)).
>>>
>>> You can, instead, reverse the intersection thus:
>>>
>>> self.element.oclAsType(ecore::EClass).eSuperTypes>asBag() >
>>> intersection(notation::Node.allInstances()>select(
>>> a : notation::Node  not a.element.oclIsUndefined() ).element)
>>>
>>> because the Bag(EClass) type can do intersection(Bag(EObject)), as
>>> Bag(EClass) conforms to Bag(EObject).
>>>
>>> For example, in an Ecore editor, if I select an EClass and do this in
>>> the OCL Console:
>>>
>>> self.eSuperTypes>asBag()>intersection(EReference.allInstances().eType)
>>>
>>> I get this error:
>>>
>>> Cannot find operation (intersection(Bag(EClassifier))) for the type
>>> (Bag(EClass))
>>>
>>> but if I do this, instead:
>>>
>>> EReference.allInstances().eType>intersection(self.eSuperTypes >asBag())
>>>
>>> then all is well.
>>>
>>> HTH,
>>>
>>> Christian
>>>
>>> Kirill A. Balod wrote:
>>>> Hello,
>>>>
>>>> I experimented with OCL over Ecore diagram and found strange behavior
>>>> (error from my point of view).
>>>> As you know notation::Node.element refers to model element and for
>>>> Ecore diagram it could be EClass.
>>>> I would like to know  which super classes of this class there are on
>>>> diagram.
>>>>
>>>> I wrote query:
>>>> notation::Node.allInstances()>select(
>>>> a : notation::Node  not a.element.oclIsUndefined() ).element>
>>>> inttersection(self.element.oclAsType(ecore::EClass).eSuperTy pes >asBag())
>>>>
>>>> and found error: Cannot find operation (inttersection(Bag(EClass)))
>>>> for the type (Bag(EObject))
>>>>
>>>> After investigation I found that if argument is EClass OCL use as type
>>>> of argument _not_ argument.eClass() but argument itself and can not
>>>> match operation and argument types.
>>>>
>>>> Look like problem in UMLReflection.getOCLType(Object metaElement)
>>>>
>>>> Best regards
>>>> Kirill A. Balod
>>>>
>>>>
>
>



Goto Forum:
Current Time: Mon Mar 30 20:15:21 GMT 2015
Powered by FUDForum. Page generated in 0.02275 seconds
