Home » Archived » M2M (model-to-model transformation) » [QVTO] One more question...
[QVTO] One more question... [message #76890] |
Tue, 18 March 2008 08:36 |
|
Hey guys, I have one more question. Is it possible to declare variables in
a transformation file to be referenced across all the rules? For example,
the result of an expensive query that yields the same thing during all the
transformation. Thanks a lot!
-Juan
|
|
| |
Re: [QVTO] One more question... [message #76939 is a reply to message #76922] |
Tue, 18 March 2008 15:21 |
|
Thanks a lot. I would also like to know how the local variables inside
queries work. I've noticed there's a 'var' keyword, but haven't been able
to guess its syntax. I keep getting "is not compatible with actual type
'oclstdlib::Boolean' ".
Thank you!
-Juan
|
|
| |
Re: [QVTO] One more question... [message #77018 is a reply to message #76953] |
Wed, 19 March 2008 01:36 |
|
Thanks a lot! I wasn't clever enough to figure the := operator... or the
content assist already available :P
However, I hope I don't abuse your help but I got one more question, about
transformation-scope variables with 'property'. I have declared the
following property:
property providers: OrderedSet(Component) = OrderedSet{};
and then, later in a query, I try to add an element to this collection,
like this:
query myQuery() : Boolean{
var comp : Component := Object Component{};
providers->append(comp);
return true;
}
but after running some tests, I realize it doesn't work as expected; the
collection remains empty. I tried redefining the providers collection
inside the query, but '=' is a boolean operator and ':=' isn't allowed.
Can you give me some ideas please?
Also, I wanted to ask you for some debugging tips, besides looking at at
qvtotrace file, since this displays results only on the mappings but not
the query results and the such. Is there a way to do a .println() or
something during queries? Thanks a lot.
|
|
|
Re: [QVTO] One more question... [message #77102 is a reply to message #77018] |
Wed, 19 March 2008 04:56 |
Radomil Dvorak Messages: 249 Registered: July 2009 |
Senior Member |
|
|
Hi Juan,
Some comments in-lined bellow.
Regards,
/Radek
> Thanks a lot! I wasn't clever enough to figure the :=3D operator... or=
the =
> content assist already available :P
>
> However, I hope I don't abuse your help but I got one more question,
Do not hesitate to ask, that's what we are here for ;-)
Also, the following link might be useful: =
http://www.omg.org/cgi-bin/doc?ptc/2007-07-07
> about transformation-scope variables with 'property'. I have declared =
=
> the following property:
>
> property providers: OrderedSet(Component) =3D OrderedSet{};
>
> and then, later in a query, I try to add an element to this collection=
, =
> like this:
>
> query myQuery() : Boolean{
> var comp : Component :=3D Object Component{};
> providers->append(comp);
> return true;
> }
The problem is the in append() operation. You actually call =
OrderedSet::append() from
the OCL standard library, and OCL is side effect-free language.
IOW, it does not modify a collection here, but creates a new one with th=
e
element appended already. Therefore the original collection is not =
modified.
You can use the code bellow instead:
providers +=3D comp; -- additive assignment semantics
>
> but after running some tests, I realize it doesn't work as expected; t=
he =
> collection remains empty. I tried redefining the providers collection =
=
> inside the query, but '=3D' is a boolean operator and ':=3D' isn't all=
owed. =
> Can you give me some ideas please?
>
> Also, I wanted to ask you for some debugging tips, besides looking at =
at =
> qvtotrace file, since this displays results only on the mappings but n=
ot =
> the query results and the such. Is there a way to do a .println() or =
> something during queries? Thanks a lot.
The traces are created only for mapping operation calls, as defined by t=
he =
spec.
You can use log expression like this:
log('your message', obj);
See LogExp in the spec link I have posted above.
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
|
|
|
Re: [QVTO] About [message #77122 is a reply to message #77102] |
Wed, 19 March 2008 06:11 |
|
Hi Radek,
I just tried the additive assignment inside the query and it triggers an
error in the editor that says "'providers' cannot be resolved", and when
trying to execute it, yields a parsing error. It's weird, because when I
invoke operations on this collection (for example, as I was trying to do
in 'providers->append()') I don't get this error in the editor.
I just made a test having 'providers' as a local variable inside the query:
var providers: OrderedSet(Component) := OrderedSet{};
instead of a transformation-scope property:
property providers: OrderedSet(Component) = OrderedSet{};
And the error isn't there. Maybe this isn't allowed for properties? Is
there anything I could do in that case?
BTW, I'm using build I200803070100.
Thanks a lot guys!
-Juan
Radek Dvorak wrote:
> Hi Juan,
> Some comments in-lined bellow.
> Regards,
> /Radek
>> Thanks a lot! I wasn't clever enough to figure the := operator... or the
>> content assist already available :P
>>
>> However, I hope I don't abuse your help but I got one more question,
> Do not hesitate to ask, that's what we are here for ;-)
> Also, the following link might be useful:
> http://www.omg.org/cgi-bin/doc?ptc/2007-07-07
>> about transformation-scope variables with 'property'. I have declared
>> the following property:
>>
>> property providers: OrderedSet(Component) = OrderedSet{};
>>
>> and then, later in a query, I try to add an element to this collection,
>> like this:
>>
>> query myQuery() : Boolean{
>> var comp : Component := Object Component{};
>> providers->append(comp);
>> return true;
>> }
> The problem is the in append() operation. You actually call
> OrderedSet::append() from
> the OCL standard library, and OCL is side effect-free language.
> IOW, it does not modify a collection here, but creates a new one with the
> element appended already. Therefore the original collection is not
> modified.
> You can use the code bellow instead:
> providers += comp; -- additive assignment semantics
>>
>> but after running some tests, I realize it doesn't work as expected; the
>> collection remains empty. I tried redefining the providers collection
>> inside the query, but '=' is a boolean operator and ':=' isn't allowed.
>> Can you give me some ideas please?
>>
>> Also, I wanted to ask you for some debugging tips, besides looking at at
>> qvtotrace file, since this displays results only on the mappings but not
>> the query results and the such. Is there a way to do a .println() or
>> something during queries? Thanks a lot.
> The traces are created only for mapping operation calls, as defined by the
> spec.
> You can use log expression like this:
> log('your message', obj);
> See LogExp in the spec link I have posted above.
|
|
|
Re: [QVTO] About [message #77135 is a reply to message #77122] |
Wed, 19 March 2008 06:54 |
Radomil Dvorak Messages: 249 Registered: July 2009 |
Senior Member |
|
|
Hi Juan,
Your propblem should be solved by using 'this' variable to access the =
transformation property.
Looks like you hit a bug as 'this' should be automatically resolved as t=
he =
implicit source
of calls to transformation properties an operations, which works but fai=
ls =
just for the write access.
So rewrite it as follows:
this.providers +=3D comp; -- this - predefined variable, refers to the =
=
transformation instance
/Radek
On Tue, 18 Mar 2008 23:11:27 -0700, Juan Jose Cadavid G =
<juanjosecg@gmail.com> wrote:
> Hi Radek,
>
> I just tried the additive assignment inside the query and it triggers =
an =
> error in the editor that says "'providers' cannot be resolved", and wh=
en =
> trying to execute it, yields a parsing error. It's weird, because when=
I =
> invoke operations on this collection (for example, as I was trying to =
do =
> in 'providers->append()') I don't get this error in the editor.
>
> I just made a test having 'providers' as a local variable inside the =
> query:
>
> var providers: OrderedSet(Component) :=3D OrderedSet{};
>
> instead of a transformation-scope property: property providers: =
> OrderedSet(Component) =3D OrderedSet{};
>
> And the error isn't there. Maybe this isn't allowed for properties? Is=
=
> there anything I could do in that case?
>
> BTW, I'm using build I200803070100.
>
> Thanks a lot guys!
>
> -Juan
>
> Radek Dvorak wrote:
>
>> Hi Juan,
>
>> Some comments in-lined bellow.
>
>> Regards,
>> /Radek
>
>>> Thanks a lot! I wasn't clever enough to figure the :=3D operator... =
or =
>>> the content assist already available :P
>>>
>>> However, I hope I don't abuse your help but I got one more question,=
>
>> Do not hesitate to ask, that's what we are here for ;-)
>> Also, the following link might be useful: =
>> http://www.omg.org/cgi-bin/doc?ptc/2007-07-07
>
>>> about transformation-scope variables with 'property'. I have declare=
d =
>>> the following property:
>>>
>>> property providers: OrderedSet(Component) =3D OrderedSet{};
>>>
>>> and then, later in a query, I try to add an element to this =
>>> collection, like this:
>>>
>>> query myQuery() : Boolean{
>>> var comp : Component :=3D Object Component{};
>>> providers->append(comp);
>>> return true;
>>> }
>
>> The problem is the in append() operation. You actually call =
>> OrderedSet::append() from
>> the OCL standard library, and OCL is side effect-free language.
>> IOW, it does not modify a collection here, but creates a new one with=
=
>> the
>> element appended already. Therefore the original collection is not =
>> modified.
>> You can use the code bellow instead:
>
>> providers +=3D comp; -- additive assignment semantics
>
>>>
>>> but after running some tests, I realize it doesn't work as expected;=
=
>>> the collection remains empty. I tried redefining the providers =
>>> collection inside the query, but '=3D' is a boolean operator and ':=
=3D' =
>>> isn't allowed. Can you give me some ideas please?
>>>
>>> Also, I wanted to ask you for some debugging tips, besides looking a=
t =
>>> at qvtotrace file, since this displays results only on the mappings=
=
>>> but not the query results and the such. Is there a way to do a =
>>> .println() or something during queries? Thanks a lot.
>
>> The traces are created only for mapping operation calls, as defined b=
y =
>> the spec.
>> You can use log expression like this:
>> log('your message', obj);
>
>> See LogExp in the spec link I have posted above.
>
>
>
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
|
|
|
Re: [QVTO] About [message #77151 is a reply to message #77135] |
Wed, 19 March 2008 07:11 |
|
Wow, thanks a lot! My transformation is working alright now :)
You guys rock... hope I can contribute to the project somehow soon.
-Juan
|
|
| |
Goto Forum:
Current Time: Fri Jan 03 07:32:16 GMT 2025
Powered by FUDForum. Page generated in 0.04124 seconds
|