Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » incomplete output because containment reference
incomplete output because containment reference [message #759832] Wed, 30 November 2011 04:11 Go to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Hi All,
I have a simple transformation like this

rule Person2Student{
from 
	person : PersonMM!Person(person.age < 26)
to
	student : StudentMM!Student(
		name <- person.name --attribute
                has_adress <-person.has_adress -- reference  Person ----- 1..* : has_adress ----> Home 
        )
}
rule Home2Adress{){
from 
	home : PersonMM!Home 
to
	adress : StudentMM!Adress(
		adress <- home.adress
	)
}


the has_adress reference is defined with containment = true.
and sometimes I have some students that have the same adress
So, my output model is generated incomplete for first students that have the same adress.

For example, StudentA and StudentB have the same adress,
So, in the generated output, the first hasn't an adress
I understand that is because the containment=true
but how resolve this problem while keeping containment=true

Thanks
Re: incomplete output because containment reference [message #759838 is a reply to message #759832] Wed, 30 November 2011 04:31 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
Use a lazy rule instead for the second rule
Re: incomplete output because containment reference [message #762080 is a reply to message #759838] Wed, 07 December 2011 09:17 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Thank you Sylvain
It works
Re: incomplete output because containment reference [message #775102 is a reply to message #762080] Thu, 05 January 2012 05:24 Go to previous message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Hi All,
after resolving problem with the lazy rule,
I have now an another problem:
I add an if expression in :
has_adress <-if person.has_adress.oclIsTypeOf(PersonMM!HOME) then person.has_adress else OclUndefined endif

has_adress is a reference that containment = true

So, for the first element, it works but, for following elements, the if expression returs a false because the type become OclAny and not the good Type.
I think after the first assignment, the element or its type is lost.
How resolve this problem ?
Previous Topic:[ATL] ATL life console
Next Topic:[QVTo] Unit not found while executing qvto in own application
Goto Forum:
  


Current Time: Sun Aug 31 04:39:44 EDT 2014

Powered by FUDForum. Page generated in 0.08874 seconds