Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL related query
OCL related query [message #523267] Thu, 25 March 2010 17:31 Go to next message
arise76  is currently offline arise76 Friend
Messages: 15
Registered: March 2010
Junior Member
Hi,
I am trying to run following query on OCL Interpreter Console basically it tries to calculate Depth of Inheritance tree. From the theoritical part it looks fine, I need to define this query for my work, but it is hard to redefine it on UML metamodel , and on M2 layer. I do not find iterate(), isRoot() in the current specifications. I will be very gratefull if some body share his thougts to run it on eclipse OCL interpreter console or any other method to find DIT on OCL interpreter.

The source of this query is the following paper:
source: http://ctp.di.fct.unl.pt/QUASAR/Resources/Papers/2002/QUAOOS E2002FinalAline.pdf

Class::DIT():Integer 
post: result = (if self.IsRoot() then 
                   0 
    else 
       1 + self.Parents()->iterate(elem:Class; acc:Integer=0 | 
if elem.DIT() > acc then 
elem.DIT() 
else 
acc 
endif) 
    endif) 


Thanks in advance,
arise
Re: OCL related query [message #523667 is a reply to message #523267] Sun, 28 March 2010 08:26 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Arise

The paper you refer to is very old. Internally it refers to [OMG1997]
for OCL 1.1 and inaccurately using the same reference to an unspecified
version of UML.

Eclipse tools provide only accidental support for OCL 1.x or UML 1.x.

OCL 2.0 was a major revision.

There is no IsRoot() or isRoot() method in UML 2.x. You could define
an IsRoot query to access the parent/child properties appropriately.

The operation context preamble: "Class::DIT():Integer" is syntactically
incorrect for an OCL 2.x document. I would expect to see
"context Class::DIT():Integer".

The expression is a post-condition, which MDT/OCL will only check for
syntactic accuracy. The expression appears to be executable and so could
be changed to a body.

iterate() should not present problems. I suspect that you are being
misled by other issues.

You need to revise the paper's examples to accommodate language
evolution, perhaps building up from simpler queries as you gain
confidence in the languages and tooling.

Regards

Ed Willink



On 25/03/2010 17:31, arise76 wrote:
> Hi,
> I am trying to run following query on OCL Interpreter Console basically
> it tries to calculate Depth of Inheritance tree. From the theoritical
> part it looks fine, I need to define this query for my work, but it is
> hard to redefine it on UML metamodel , and on M2 layer. I do not find
> iterate(), isRoot() in the current specifications. I will be very
> gratefull if some body share his thougts to run it on eclipse OCL
> interpreter console or any other method to find DIT on OCL interpreter.
>
> The source of this query is the following paper:
> source:http://ctp.di.fct.unl.pt/QUASAR/Resources/Papers/2002 /QUAOOSE2002FinalAline.pdf
>
>
>
> Class::DIT():Integer post: result = (if self.IsRoot() then 0 else 1 +
> self.Parents()->iterate(elem:Class; acc:Integer=0 | if elem.DIT() > acc
> then elem.DIT() else acc endif) endif)
>
> Thanks in advance,
> arise
Re: OCL related query [message #523698 is a reply to message #523667] Sun, 28 March 2010 21:15 Go to previous message
arise76  is currently offline arise76 Friend
Messages: 15
Registered: March 2010
Junior Member
Hi Ed Willink,

I use OCL 2.0 syntax and I found isRoot() with the following query, but I do not now which method should I use for iteration,
I am using OCL console where I cant use context keyword, so I simply run if else block as follows.
if Class.allInstances()->exists(parents()->size()=0) then 0 -- its a root element 
else 1 ---, here I do not know how can I use iteration as used in the reference paper query
endif


Thanks
Arise
Re: OCL related query [message #523701 is a reply to message #523698] Sun, 28 March 2010 16:58 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Arise

iterate() should work. You need to explain why you think it doesn't.

Regards

Ed Willink

On 28/03/2010 22:15, arise76 wrote:
> Hi Ed Willink,
>
> I use OCL 2.0 syntax and I found isRoot() with the following query, but
> I do not now which method should I use for iteration, I am using OCL
> console where I cant use context keyword, so I simply run if else block
> as follows.
>
> if Class.allInstances()->exists(parents()->size()=0) then 0 -- its a
> root element else 1 ---, here I do not know how can I use iteration as
> used in the reference paper query
> endif
>
>
> Thanks
> Arise
>
Previous Topic:actor, usecase relationship query
Next Topic:EMF & OCL beginner question
Goto Forum:
  


Current Time: Sun Dec 21 14:38:31 GMT 2014

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

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