Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] 1 source 2 target with 2 subdestination and referenc(1 source 2 targets with 2 subdestination and reference)
[ATL] 1 source 2 target with 2 subdestination and referenc [message #542205] Thu, 24 June 2010 05:09 Go to next message
poltrox  is currently offline poltrox
Messages: 16
Registered: June 2010
Junior Member
HI,

I don't do to write my transformation :

I have this 2 models :

Source:
Module contains fields
Stringfields, NarrativeFields herited of Fields

Target :
Module contains Fields , businessObject
Stringfields, NarrativeFields herited of Fields
BusinessObject contains businessItems, BusinessFileItems
NarrativeItems herited of businessItems
StringFields herited of businessFileItems


I try 2 solution to write my transformation but i have always one problemes :
Solution 1 : Using a lazy rules with separated rules for fields and Items

rule ModuleToConnectedModule {
	from
		s : ClientMetaModel!Module
	to 
		Module : AppliMetaModel!ConnectedModule (
			Labels <- s.Labels,
			BusinessObject <- BusinessObjectFunction,
			FormFields <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!StringField))
								   -> collect(e | thisModule.StringFieldsToStringField(e)),
			FormFields <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!AmountField))
								   -> collect(e | thisModule.AmoutFieldToAmountCurrencyField(e)),
			FormFields <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!NarrativeField))
								   -> collect(e | thisModule.NarrativeFieldToNarrativeField(e))
		),
		BusinessObjectFunction :AppliMetaModel!BusinessObject(
		SpecificsBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!StringField))
										   -> collect(e | thisModule.StringFieldsToStringObject(e)),
		SpecificsBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!AmountField))
										   -> collect(e | thisModule.AmoutFieldToAmountCurrencyObject(e)),
								
		SpecificsFileBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!NarrativeField))
										   -> collect(e | thisModule.NarrativeFieldToNarrativeObject(e))
		)

lazy rule StringFieldsToStringObject {
	from
		ClientStringfield : ClientMetaModel!StringField 
		(ClientStringfield.oclIsTypeOf(ClientMetaModel!StringField))
	to 
		StringItem : AppliMetaModel!StringItem(
			name <- ClientStringfield.name,
			MappingBDD <- MappingDB
		),
		MappingDB :AppliMetaModel!MappingDB(
		name <- ClientStringfield.debug().name.toUpper(),
		Type <- StringMapping
		),
		StringMapping :AppliMetaModel!StringDBType(
		length <- ClientStringfield.maxLength
		) 
}

lazy rule StringFieldsToStringField {
	from
		ClientStringfield2 : ClientMetaModel!StringField 
		(ClientStringfield2.oclIsTypeOf(ClientMetaModel!StringField))
	to 
		StringField : AppliMetaModel!StringField (
			name <- ClientStringfield2.name,
			maxLength <- ClientStringfield2.maxLength,
			FormLabel <- thisModule.resolveTemp(ClientStringfield2.Label,'AppliLabel'),
			BusinessItemBinding <- thisModule.resolveTemp(ClientStringfield2.debug(),'StringItem').debug(),
			password <- false,
			upperCase <- false,
			size <- 35
		)
}

lazy rule NarrativeFieldToNarrativeObject{
	from
	 	ClientNarrativeField : ClientMetaModel!NarrativeField
		(ClientNarrativeField.oclIsTypeOf(ClientMetaModel!NarrativeField))
	to
		NarrativeItem : AppliMetaModel!NarrativeItem(
		name <- ClientNarrativeField.name
		)
}

lazy rule NarrativeFieldToNarrativeField{
	from
	 	ClientNarrativeField : ClientMetaModel!NarrativeField
		(ClientNarrativeField.oclIsTypeOf(ClientMetaModel!NarrativeField))
	to
		NarrativeField: AppliMetaModel!NarrativeField(
		BusinessItemBinding <- thisModule.resolveTemp(ClientNarrativeField,'NarrativeItem'),
		FormLabel <- thisModule.resolveTemp(ClientNarrativeField.Label,'AppliLabel'),
		name <- ClientNarrativeField.name,
		column <- ClientNarrativeField.column,
		row <- ClientNarrativeField.row,
		size <- 35
		)
}


Problems : Methods ResolveTemps do not run for lazy rules => I can't create the ref for the attribut BusinessItemBinding of Narrative fields




the second solution : Do not use Lazy rules => I can't separate Fields and Item


rule ModuleToConnectedModule {
	from
		s : ClientMetaModel!Module
	to 
		Module : AppliMetaModel!ConnectedModule (
			Labels <- s.Labels,
			BusinessObject <- BusinessObjectFunction,
			FormFields <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!StringField)).debug(),
			FormFields <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!AmountField)).debug(),
			FormFields <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!NarrativeField)).debug()
		),
		BusinessObjectFunction :AppliMetaModel!BusinessObject(
		SpecificsBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!StringField)),
		SpecificsBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!AmountField)),
		SpecificsFileBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!NarrativeField))
		)

rule StringFieldsToStringObject {
	from
		ClientStringfield : ClientMetaModel!StringField 
		(ClientStringfield.oclIsTypeOf(ClientMetaModel!StringField))
	to 
		
		StringField : AppliMetaModel!StringField (
			name <- ClientStringfield.name,
			maxLength <- ClientStringfield.maxLength,
			FormLabel <- thisModule.resolveTemp(ClientStringfield.Label,'AppliLabel'),
			BusinessItemBinding <- StringItem,
			password <- false,
			upperCase <- false,
			size <- 35
		),
		StringItem : AppliMetaModel!StringItem(
			name <- ClientStringfield.name,
			MappingBDD <- MappingDB
		),
		MappingDB :AppliMetaModel!MappingDB(
		name <- ClientStringfield.debug().name.toUpper(),
		Type <- StringMapping
		),
		StringMapping :AppliMetaModel!StringDBType(
		length <- ClientStringfield.maxLength
		)
}



Problems : In the result my fields do not populate the Modules->Fields
they are created at the root node , If I change the order of my Rule StringFieldsToStringFields, String Items is created in the root node
I can't separate this rules because ATL do not accept multiple rules with the same source.

Any one could give me a solution ?

Thanks

Ps: Sorry I have a bad english, I am french and accept a english and french response Wink

[Updated on: Thu, 24 June 2010 05:36]

Report message to a moderator

Re: [ATL] 1 source 2 target with 2 subdestination and referenc [message #542225 is a reply to message #542205] Thu, 24 June 2010 05:42 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
You better use the second option with resolveTemp because the resolution mechanism of ATL basically bind the "from" object to the first "to" object. By using resolveTemp you can reference the others "to" objects :

SpecificsBusinessItems <- s.Fields -> select(e | e.oclIsTypeOf(ClientMetaModel!StringField))->collect(e | thisModule.resolveTemp(e,'StringItem')
Re: [ATL] 1 source 2 target with 2 subdestination and referenc [message #542232 is a reply to message #542225] Thu, 24 June 2010 05:55 Go to previous messageGo to next message
poltrox  is currently offline poltrox
Messages: 16
Registered: June 2010
Junior Member
Thank you,

It works Very Happy

Re: [ATL] 1 source 2 target with 2 subdestination and referenc [message #542339 is a reply to message #542232] Thu, 24 June 2010 10:54 Go to previous messageGo to next message
Izaak van Niekerk is currently offline Izaak van Niekerk
Messages: 35
Registered: June 2010
Member
Poltrox

Do you write your ATL files all by hand?
Re: [ATL] 1 source 2 target with 2 subdestination and referenc [message #542517 is a reply to message #542339] Fri, 25 June 2010 03:40 Go to previous message
poltrox  is currently offline poltrox
Messages: 16
Registered: June 2010
Junior Member
Yes , the completion with eclipse-plug in is a good help.
Previous Topic:how to use enumerations literal in Atl Program
Next Topic:[QVT-R] Suggestions for QVT-Relations plug-in
Goto Forum:
  


Current Time: Tue Jul 22 13:38:55 EDT 2014

Powered by FUDForum. Page generated in 0.02017 seconds