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 09:09 |
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
[Updated on: Thu, 24 June 2010 09:36] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Fri Sep 20 14:57:35 GMT 2024
Powered by FUDForum. Page generated in 0.03339 seconds
|