Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » My model to model transformation doesn´t work
My model to model transformation doesn´t work [message #555612] Fri, 27 August 2010 11:14 Go to next message
Pablo Nieto is currently offline Pablo NietoFriend
Messages: 31
Registered: August 2010
Location: Cuenca, Spain
Member
Hello I´m new in model to model transformation.
I´ve done a qvto file and this doesnt work.

this is my code:

modeltype MMSCXMLWeb 'strict' uses 'http://MMSCXMLWeb';
modeltype SCXMLw3c 'strict' uses'http://www.w3.org/2005/07/scxml';
transformation MMW2SCXML(in inModel:MMSCXMLWeb, out outModel:SCXMLw3c);

property transitions : Set(Transition) =null;

main(){
inModel.rootObjects()[SCXML]->map toSCXML();
}


mapping MMSCXMLWeb::SCXML::toSCXML() : SCXMLw3c::ScxmlScxmlType
{
name =self.Name;
initial1:=self.Initial;
state +=self.ApplicationState.map ApptoState();

}

mapping MMSCXMLWeb::Application::ApptoState() : SCXMLw3c::ScxmlStateType{

init{
this.transitions=self.GetTransitions();
self.Transition=this.transitions->select(Source_State = self);
}
id = self.ID;
initial1= self.Initial;
transition +=self.Transition.map toScxmlTransitions();
state += self.Generic.map toSCXMLStates();
state += self.OP.map OPToScxmlStates();

}

mapping MMSCXMLWeb::Generic::toSCXMLStates() : SCXMLw3c::ScxmlStateType{
init{
self.Transition=this.transitions->select(Source_State = self);
result := object SCXMLw3c::ScxmlStateType{
id=self.ID;
initial1=self.Initial;
transition+= self.Transition.map toScxmlTransitions();

}
}

}

mapping MMSCXMLWeb::OP::OPToScxmlStates() : SCXMLw3c::ScxmlStateType{
init{
self.Transition=this.transitions->select(Source_State = self);
result := object SCXMLw3c::ScxmlStateType{
id=self.ID;
initial1=self.Initial;
transition += self.Transition.map toScxmlTransitions();
state += self.View.map ViewToScxmlStates();


}
}
}

mapping MMSCXMLWeb::View::ViewToScxmlStates() : SCXMLw3c::ScxmlStateType{
init{
self.Transition=this.transitions->select(Source_State = self);
result := object SCXMLw3c::ScxmlStateType{
id=self.ID;
initial1=self.Initial;
transition += self.Transition.map toScxmlTransitions();
}
}
}
mapping MMSCXMLWeb::Transition::toScxmlTransitions() : SCXMLw3c::ScxmlTransitionType{
init{
result:=object SCXMLw3c::ScxmlTransitionType{
cond=self.Cond;
event1=self.Event;
target=self.Target;
}
}
}



query MMSCXMLWeb::State::GetTransitions() : Set(MMSCXMLWeb::Transition){
return self.Transition;
}


Does anyone how to make this work??

Is there any guide for model to model transformation?

Thanks, Pablo

Re: My model to model transformation doesn´t work [message #555621 is a reply to message #555612] Fri, 27 August 2010 11:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl

Hello Pablo,

first things first. In the future, please prefix QVTo related posts with
[QVTo].

> I´ve done a qvto file and this doesnt work.
> Does anyone how to make this work??

Secondly, this kind of statements don't give much indication where to
look. What doesn't work. What did you do, what happened, and what did
you expect to happen?

OK, now to the real issue. I see some problems with your source code:

> name =self.Name;

I think you mean:

name :=self.Name;

you seem to use = instead of := a lot. I think you get syntax errors
that way, right?

Furthermore, let's look at this:

> init{
> this.transitions=self.GetTransitions();
> self.Transition=this.transitions->select(Source_State = self);
> }

assigning self.Transition is not allowed, as self refers to an input
element (a part of 'in inModel:MMSCXMLWeb'), and that is read-only. You
are only allowed to create and modify output elements.

Then there is this:

> query MMSCXMLWeb::State::GetTransitions() :
> Set(MMSCXMLWeb::Transition){
> return self.Transition;
> }

It doesn't make sense. Can't you just use self.Transition everywhere you
use that query? Wouldn't that be easier?

Also, I don't know what the transformation is supposed to do, so I can't
comment on the whether your general approach would work. I do have some
doubts regarding the 'transitions' property. You seem to assign it with
source objects, and then use it locally in the same mapping where you
assign it. Can't you just eliminate that property entirely?

Finally "mapping MMSCXMLWeb::Generic::toSCXMLStates()". I think you can
get rid of the init, the explicit assignment to result, and the explicit
creation of the target element.


Hope this helps,
Dennis


Pablo Nieto wrote:
> Hello I´m new in model to model transformation.
> I´ve done a qvto file and this doesnt work.
>
> this is my code:
>
> modeltype MMSCXMLWeb 'strict' uses 'http://MMSCXMLWeb';
> modeltype SCXMLw3c 'strict' uses'http://www.w3.org/2005/07/scxml';
> transformation MMW2SCXML(in inModel:MMSCXMLWeb, out outModel:SCXMLw3c);
>
> property transitions : Set(Transition) =null;
>
> main(){
> inModel.rootObjects()[SCXML]->map toSCXML();
> }
>
>
> mapping MMSCXMLWeb::SCXML::toSCXML() : SCXMLw3c::ScxmlScxmlType
> {
> name =self.Name;
> initial1:=self.Initial;
> state +=self.ApplicationState.map ApptoState();
>
> }
>
> mapping MMSCXMLWeb::Application::ApptoState() : SCXMLw3c::ScxmlStateType{
>
> init{
> this.transitions=self.GetTransitions();
> self.Transition=this.transitions->select(Source_State = self);
> }
> id = self.ID;
> initial1= self.Initial;
> transition +=self.Transition.map toScxmlTransitions();
> state += self.Generic.map toSCXMLStates();
> state += self.OP.map OPToScxmlStates();
>
> }
>
> mapping MMSCXMLWeb::Generic::toSCXMLStates() : SCXMLw3c::ScxmlStateType{
> init{
> self.Transition=this.transitions->select(Source_State = self);
> result := object SCXMLw3c::ScxmlStateType{
> id=self.ID;
> initial1=self.Initial;
> transition+= self.Transition.map toScxmlTransitions();
>
> }
> }
>
> }
>
> mapping MMSCXMLWeb::OP::OPToScxmlStates() : SCXMLw3c::ScxmlStateType{
> init{
> self.Transition=this.transitions->select(Source_State = self);
> result := object SCXMLw3c::ScxmlStateType{
> id=self.ID;
> initial1=self.Initial;
> transition += self.Transition.map toScxmlTransitions();
> state += self.View.map ViewToScxmlStates();
>
>
> }
> }
> }
>
> mapping MMSCXMLWeb::View::ViewToScxmlStates() : SCXMLw3c::ScxmlStateType{
> init{
> self.Transition=this.transitions->select(Source_State = self);
> result := object SCXMLw3c::ScxmlStateType{
> id=self.ID;
> initial1=self.Initial;
> transition += self.Transition.map toScxmlTransitions();
> }
> }
> }
> mapping MMSCXMLWeb::Transition::toScxmlTransitions() :
> SCXMLw3c::ScxmlTransitionType{
> init{
> result:=object SCXMLw3c::ScxmlTransitionType{
> cond=self.Cond;
> event1=self.Event;
> target=self.Target;
> }
> }
> }
>
>
>
> query MMSCXMLWeb::State::GetTransitions() : Set(MMSCXMLWeb::Transition){
> return self.Transition;
> }
>
>
> Does anyone how to make this work??
>
> Is there any guide for model to model transformation?
>
> Thanks, Pablo
>
>
Re: My model to model transformation doesn´t work [message #556173 is a reply to message #555621] Tue, 31 August 2010 08:19 Go to previous messageGo to next message
Pablo Nieto is currently offline Pablo NietoFriend
Messages: 31
Registered: August 2010
Location: Cuenca, Spain
Member
Hello thaks a lot for the help.

I´ve corrected all my code and now it´s right.

Now I have a new question:
I have this sentence:
target=self.Source_State.ID;

The problem is that target Type is java.util.List and self.Source_State.ID is a String;

How can I create Lists in qvto? or How can I convert types in qvto?

thanks againk, Pablo.
Re: My model to model transformation doesn´t work [message #556180 is a reply to message #556173] Tue, 31 August 2010 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl

Hello Pablo,

> I have this sentence: target=self.Source_State.ID;

I assume you mean := instead of =?

> How can I create Lists in qvto?

Depending other whether how you modeled it in the metamodel, it can be a
Sequence (ordered, non-unique), OrderedSet (ordered, unique), etc.

You can use this: 'target := Sequence{self.Source_State.ID};'

> How can I convert types in qvto?

I don't think that would work. You can't cast a string to list in Java
either... However, converting types is done using the OCL operator
'oclAsType(<typename>)'.

Dennis


Pablo Nieto wrote:
> Hello thaks a lot for the help.
>
> I´ve corrected all my code and now it´s right.
>
> Now I have a new question:
> I have this sentence: target=self.Source_State.ID;
>
> The problem is that target Type is java.util.List and
> self.Source_State.ID is a String;
>
> How can I create Lists in qvto? or How can I convert types in qvto?
>
> thanks againk, Pablo.
Re: My model to model transformation doesn´t work [message #556205 is a reply to message #556180] Tue, 31 August 2010 11:01 Go to previous messageGo to next message
Pablo Nieto is currently offline Pablo NietoFriend
Messages: 31
Registered: August 2010
Location: Cuenca, Spain
Member
Hello, this doesn´t work:
'target := Sequence{self.Source_State.ID};'

I can´t complete my mapping without this.
Is there any way to create lists and add Strngs manually??

thanks
Re: My model to model transformation doesn´t work [message #556307 is a reply to message #556205] Tue, 31 August 2010 16:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
On 31/08/2010 12:01, Pablo Nieto wrote:
> Hello, this doesn´t work:

In what way?

> 'target := Sequence{self.Source_State.ID};'
>
> I can´t complete my mapping without this. Is there any way to create
> lists and add Strngs manually??
>
> thanks
Re: My model to model transformation doesn´t work [message #556343 is a reply to message #556307] Tue, 31 August 2010 21:23 Go to previous messageGo to next message
Pablo Nieto is currently offline Pablo NietoFriend
Messages: 31
Registered: August 2010
Location: Cuenca, Spain
Member
the code doesn´t compile.

I can´t execute the qvto file.

It´s because the asignation has difrent types:

Java.util.list and String

Thanks
Re: My model to model transformation doesn´t work [message #556376 is a reply to message #556205] Wed, 01 September 2010 06:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl

Hello Pablo,

> Hello, this doesn´t work:
> 'target := Sequence{self.Source_State.ID};'

What is the exact error message you get?


you can also try this:

target += self.Source_State.ID;

Dennis


Pablo Nieto wrote:
> Hello, this doesn´t work:
> 'target := Sequence{self.Source_State.ID};'
>
> I can´t complete my mapping without this. Is there any way to create
> lists and add Strngs manually??
>
> thanks
Re: My model to model transformation doesn´t work [message #556379 is a reply to message #556343] Wed, 01 September 2010 06:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl

Hello Pablo,

> I can´t execute the qvto file.
> It´s because the asignation has difrent types:
> Java.util.list and String

Java.utils.list does not seem like a type that QVTo would generally use.
I would have expected one of the OCL types like Sequence, OrderedSet,
Set, or Bag. How did you end up with java.util.List? Did you not define
the language using an Ecore?

What does QVTo indicate as the type of 'target'?

Note that if it is a QVTo List type, it is mutable type. In that case
you can take a look at section 8.3.8 of the QVT standard. In particular
8.3.8.1 explains the add operation, which would be something like:

target.add(self.Source_State.ID);

If none of this works, maybe you can post the entire transformation, so
that we have more information, and more context?

Dennis


Pablo Nieto wrote:
> the code doesn´t compile.
>
> I can´t execute the qvto file.
>
> It´s because the asignation has difrent types:
>
> Java.util.list and String
>
> Thanks
Re: My model to model transformation doesn´t work [message #556387 is a reply to message #556379] Wed, 01 September 2010 06:46 Go to previous messageGo to next message
Pablo Nieto is currently offline Pablo NietoFriend
Messages: 31
Registered: August 2010
Location: Cuenca, Spain
Member
Hello:

This is the error
The type 'oclstdlib::String' does not conform to the base type 'oclstdlib::T' of the multi-valued property 'target'

I use the java.util.List because the Model I´m using is a standard and I can´t change it.

If I use target.add(self.Source_State.ID) this error occurs:
Cannot find operation (add(String)) neither for the type (Sequence(T)) nor for its element type (T)

thanks again
Re: My model to model transformation doesn´t work [message #556608 is a reply to message #556387] Thu, 02 September 2010 06:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl

Hello Pablo,

I've never explicitly declared something as java.util.List in my
metamodel, so I guess I don't really know either. Maybe if you posted
the metamodel and QVTo transformation, that would give more information?

Dennis

Pablo Nieto wrote:
> Hello:
>
> This is the error
> The type 'oclstdlib::String' does not conform to the base type
> 'oclstdlib::T' of the multi-valued property 'target'
> I use the java.util.List because the Model I´m using is a standard and I
> can´t change it.
>
> If I use target.add(self.Source_State.ID) this error occurs:
> Cannot find operation (add(String)) neither for the type (Sequence(T))
> nor for its element type (T)
>
> thanks again
Re: My model to model transformation doesn´t work [message #556623 is a reply to message #556608] Thu, 02 September 2010 06:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Pablo

Your error looks to be the normal result of using the wrong collection type.

You should never need to use java.util.List explicitly in a meta-model;
indeed I'm baffled as to where you might even try to use it.

Youe meta-model and transformation are almost certainly
type-incompatible and this exactly what the error message is telling you.

We cannot diagnose further without seeing both.

Regards

Ed Willink

On 02/09/2010 07:15, Dennis Hendriks wrote:
> Hello Pablo,
>
> I've never explicitly declared something as java.util.List in my
> metamodel, so I guess I don't really know either. Maybe if you posted
> the metamodel and QVTo transformation, that would give more information?
>
> Dennis
>
> Pablo Nieto wrote:
>> Hello:
>>
>> This is the error
>> The type 'oclstdlib::String' does not conform to the base type
>> 'oclstdlib::T' of the multi-valued property 'target'
>> I use the java.util.List because the Model I´m using is a standard and
>> I can´t change it.
>>
>> If I use target.add(self.Source_State.ID) this error occurs:
>> Cannot find operation (add(String)) neither for the type (Sequence(T))
>> nor for its element type (T)
>>
>> thanks again
Re: My model to model transformation doesn´t work [message #556631 is a reply to message #556623] Thu, 02 September 2010 07:34 Go to previous messageGo to next message
Pablo Nieto is currently offline Pablo NietoFriend
Messages: 31
Registered: August 2010
Location: Cuenca, Spain
Member
Hello,
The problem is that the model with the list element is a W3C standard (SCXML) and some elemet´s atributes are of List type.
So I can´t modify this model.

I think that the error occurs because QVTo doesn´t recognize the List type.

this is the mapping method:

mapping MMSCXMLWeb::Transition::toScxmlTransitions() : SCXMLw3c::ScxmlTransitionType{
init{
result:=object SCXMLw3c::ScxmlTransitionType{
cond:=self.Cond;
event1:=self.Event;
//target:=self.Target;
result.target.oclAsType(OrderedSet(String))->append(self.Target_State.ID);


}
}
}

Thanks
Re: My model to model transformation doesn´t work [message #556646 is a reply to message #556631] Thu, 02 September 2010 08:06 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Pablo

Please supply the model; just because it's standard to you doesn't mean
we all know it. We need to see your declaration of 'target'.

oclAsType(OrderedSet(String)) is not valid OCL; there is an OMG issue to
make it valid and an MDT/OCL bug
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=299957) to support it.

target.oclAsType(OrderedSet(String)) is very suspect. You are using a
non-Collection operation on target which presumably must be a Collection
to support append.

Perhaps you just need "->".

Regards

Ed Willink

On 02/09/2010 08:34, Pablo Nieto wrote:
> Hello,
> The problem is that the model with the list element is a W3C standard
> (SCXML) and some elemet´s atributes are of List type.
> So I can´t modify this model.
>
> I think that the error occurs because QVTo doesn´t recognize the List type.
>
> this is the mapping method:
>
> mapping MMSCXMLWeb::Transition::toScxmlTransitions() :
> SCXMLw3c::ScxmlTransitionType{
> init{
> result:=object SCXMLw3c::ScxmlTransitionType{
> cond:=self.Cond;
> event1:=self.Event;
> //target:=self.Target;
> result.target.oclAsType(OrderedSet(String))->append(self.Target_State.ID);
>
>
> }
> }
> }
>
> Thanks
Previous Topic:[QVTo] Copy operator
Next Topic:[QVTo] integrate a QVTo file into a GMF Editor
Goto Forum:
  


Current Time: Sat Dec 20 15:12:10 GMT 2014

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

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