|[qvto]can I use an ocl operation as a model attribute [message #829953]
||Mon, 26 March 2012 21:52
| Allen Zhang
Registered: February 2012
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 #846699 is a reply to message #846534]
||Mon, 16 April 2012 04:33
| Ed Willink
Registered: July 2009
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
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.
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
> 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?
Powered by FUDForum
. Page generated in 0.01807 seconds