Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Programmatically load a complete OCL file
Programmatically load a complete OCL file [message #1153325] Thu, 24 October 2013 14:33 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I have an ecore file and a complete OCL file which "decorates" this model. The reason why I am using a complete OCL file is because nested collections are not supported in OCLinEcore (see bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=401938).

In this complete OCL file, I define an attribute like this:

def: paths : Sequence(OrderedSet(ConnectionPoint)) = ...


(how this attribute is calculated is not relevant here).

Now, I have an instance of my domain model (Java code was generated from the ecore file) and I would like to be able to retrieve this "paths" attribute programmatically (actually, as if the variable was defined inside the ecore model).

Is there any way to do something like that ?

Thank you,
Cédric
Re: Programmatically load a complete OCL file [message #1154383 is a reply to message #1153325] Fri, 25 October 2013 06:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Strictly speaking, nested collections are not supported in OCLinEcore
serialized as *.ecore... which doesn't help you much.

Revisiting the bug, it doesn't look that hard to fix; which doesn't help
you today.

Complete OCL facilities are intended to be accessed by OCL not Java, so
you would have to go in with the reflective API to locate the property
to peek and poke. All a bit nasty.

Today, I would recommend that you define an OrderedSet_ConnectionPoint
datatype and cast backwards and forwards to OrderedSet(ConnectionPoint)
where you need to.

Regards

Ed Willink

On 24/10/2013 15:33, Cedric Moonen wrote:
> Hello,
>
> I have an ecore file and a complete OCL file which "decorates" this
> model. The reason why I am using a complete OCL file is because nested
> collections are not supported in OCLinEcore (see bug:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=401938).
>
> In this complete OCL file, I define an attribute like this:
>
> def: paths : Sequence(OrderedSet(ConnectionPoint)) = ...
>
>
> (how this attribute is calculated is not relevant here).
>
> Now, I have an instance of my domain model (Java code was generated
> from the ecore file) and I would like to be able to retrieve this
> "paths" attribute programmatically (actually, as if the variable was
> defined inside the ecore model).
> Is there any way to do something like that ?
>
> Thank you,
> Cédric
Re: Programmatically load a complete OCL file [message #1158946 is a reply to message #1154383] Mon, 28 October 2013 07:38 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Ed,

Thanks for the quick reply.

Quote:
Strictly speaking, nested collections are not supported in OCLinEcore
serialized as *.ecore... which doesn't help you much.


Yes, indeed, this works fine if I save it as a complete OCL file. But I need to have an ecore file. So as you say, it doesn't help me much Razz

Quote:
Revisiting the bug, it doesn't look that hard to fix; which doesn't help
you today.


Would it be possible to have an estimate about when this could be fixed ? This way we can see if we wait for the bug fix or try to implement a workaround.

Quote:
Today, I would recommend that you define an OrderedSet_ConnectionPoint
datatype and cast backwards and forwards to OrderedSet(ConnectionPoint)
where you need to.


I tried this but I encounter issues when using oclAsType: it is giving me a cast error (the return type of oclAsType is apparently different from what I give as type for the argument...). I'll see if I can make an example showing the problem.

Thanks you,
Cédric
Re: Programmatically load a complete OCL file [message #1159735 is a reply to message #1158946] Mon, 28 October 2013 19:03 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Support for nested/bounded collections and templates has been a kind of
creeping disease/cure; it's all there at the core but is only gradually
appearing at the periphery.

You can probably tell from

https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&component=Core&product=MDT.OCL&classification=Modeling&list_id=7316863

that I'm not exactly short of things to do, so I can't honestly say that
I'm going to rush to fix this one. It will naturally cure as we go to
the next round of model-driven autogeneration. At the moment I seem to
have more on more concurrent activities to juggle.

Sorry.

Workarounds using oclAsType are almost certainly harder than fixing the bug.

Regards

Ed Willink

On 28/10/2013 07:38, Cedric Moonen wrote:
> Hello Ed,
>
> Thanks for the quick reply.
>
> Quote:
>> Strictly speaking, nested collections are not supported in OCLinEcore
>> serialized as *.ecore... which doesn't help you much.
>
>
> Yes, indeed, this works fine if I save it as a complete OCL file. But
> I need to have an ecore file. So as you say, it doesn't help me much :p
> Quote:
>> Revisiting the bug, it doesn't look that hard to fix; which doesn't help
>> you today.
>
>
> Would it be possible to have an estimate about when this could be
> fixed ? This way we can see if we wait for the bug fix or try to
> implement a workaround.
>
> Quote:
>> Today, I would recommend that you define an OrderedSet_ConnectionPoint
>> datatype and cast backwards and forwards to OrderedSet(ConnectionPoint)
>> where you need to.
>
>
> I tried this but I encounter issues when using oclAsType: it is giving
> me a cast error (the return type of oclAsType is apparently different
> from what I give as type for the argument...). I'll see if I can make
> an example showing the problem.
>
> Thanks you,
> Cédric
Previous Topic:Debugging OCL constraints in UML profiles
Next Topic:generate OCL code from "OCL ecore instance"
Goto Forum:
  


Current Time: Tue Mar 19 04:03:42 GMT 2024

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

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

Back to the top