Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [qvto]can I use an ocl operation as a model attribute
[qvto]can I use an ocl operation as a model attribute [message #829953] Tue, 27 March 2012 01:52 Go to next message
Allen Zhang is currently offline Allen ZhangFriend
Messages: 14
Registered: February 2012
Junior Member
When doing transformation, I may choose an element using ocl operations.
e.g. var s := source.objectsOfType(A)->select(i | i.name="name1")

But I want to define an element (e1) with an attribute (a1), may be a String ('source.objectsOfType(A)->select(i | i.name="name1")'),
so I can choose the elements like this:
var s := someOperation(e1.a1)

can I do this?Or is there some way?
Re: [qvto]can I use an ocl operation as a model attribute [message #829964 is a reply to message #829953] Tue, 27 March 2012 02:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7675
Registered: July 2009
Senior Member
Hi

The typos and vagueness in your question defeat me. Please try again.

Regards

Ed Willink

On 26/03/2012 21:52, Allen Zhang wrote:
> When doing transformation, I may choose an element using ocl
> operations. e.g. var s := source.objectsOfType(A)->select(i |
> i.name="name1")
>
> But I want to define an element (e1) with an attribute (a1), may be a
> String ('source.objectsOfType(A)->select(i | i.name="name1")'), so I
> can choose the elements like this: var s := someOperation(e1.a1)
>
> can I do this?Or is there some way?
Re: [qvto]can I use an ocl operation as a model attribute [message #846534 is a reply to message #829964] Mon, 16 April 2012 06:31 Go to previous messageGo to next message
Allen Zhang is currently offline Allen ZhangFriend
Messages: 14
Registered: February 2012
Junior Member
Hi, sorry about my poor English.
The question is:
when I write qvto transformation codes, I may need to select some elements.
such as: var element := a.select(i | i.name="name1");

But in this way, there is a limit that I can not dynamically set the condition: "i | i.name="name1".

I wander if I can set this condition in my source model, may be a String attribute.
so in the transformation, my codes will be like this:
var element := a.select(b.condition);

should I import ocl ecore in model b's metamodel, and set condition's type oclExpression?
Re: [qvto]can I use an ocl operation as a model attribute [message #846699 is a reply to message #846534] Mon, 16 April 2012 08:33 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7675
Registered: July 2009
Senior Member
Hi

Today: I don't think so. But the evolution of the OCL specification to
recognize iteration bodies as Lambda Expressions could allow it in the
future.

One possible workaround is to define a Predicate class and
select(OclAny) operation so that you can do

var element := aPredicate.select(a);

and pass alternate Predicate instances.

OCL currently has no ability to dynamically parse a Concrete Syntax
string, though I've raised an OMG issue to add support.

Regards

Ed Willink

On 16/04/2012 07:31, Allen Zhang wrote:
> Hi, sorry about my poor English.
> The question is:
> when I write qvto transformation codes, I may need to select some
> elements.
> such as: var element := a.select(i | i.name="name1");
>
> But in this way, there is a limit that I can not dynamically set the
> condition: "i | i.name="name1".
>
> I wander if I can set this condition in my source model, may be a
> String attribute.
> so in the transformation, my codes will be like this:
> var element := a.select(b.condition);
>
> should I import ocl ecore in model b's metamodel, and set condition's
> type oclExpression?
Previous Topic:Transformation failure
Next Topic:[ATL] programmatically launch of ATL transformation
Goto Forum:
  


Current Time: Sat Oct 05 16:54:11 GMT 2024

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

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

Back to the top