Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] transforming UML to EJB
[ATL] transforming UML to EJB [message #21911] Wed, 07 March 2007 18:59 Go to next message
Eclipse UserFriend
Originally posted by: walcir.fontanini.cenpra.gov.br

Hi all,

Please, tell me if I am not in the wrong place. I am trying to transform
some UML model to an EJB model. The "parameter" target pattern is
not working, and I think I need a lot more "distinct-foreach" !!! It
seems that I need just one big "rule" with every possible target pattern
there .

Thanks,
-walcir

=== UML model ====
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="UML">

<DataType name="String"/>
<DataType name="Integer"/>
<Class name="BreakfastOrder">
<feature xsi:type="Operation" name="calculatePrice">
<parameter name="year_price" type="/1"/>
<parameter name="rate" type="/1"/>
</feature>
<feature xsi:type="Attribute" name="deliveryStatus" type="/0"/>
<feature xsi:type="Attribute" name="deliveryDate" type="/0"/>
<feature xsi:type="AssociationEnd" name="customer" lower="1"
upper="1" otherEnd="/3/@feature.3"/>
<feature xsi:type="AssociationEnd" name="breakfasts" lower="1"
upper="-1" composition="true" otherEnd="/4/@feature.2"/>
</Class>
</xmi:XMI>
==== EJB model ====
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="EJB">
<EJBEntityComponent name="BreakfastOrder" usedTable="/1">
<feature xsi:type="EJBAttribute" name="deliveryStatus"/>
<feature xsi:type="EJBAttribute" name="deliveryDate"/>
<feature xsi:type="EJBAssociationEnd" name="customer" lower="1"
upper="1"/>
<feature xsi:type="EJBAssociationEnd" name="breakfasts" lower="1"
upper="-1" composition="true"/>
<feature xsi:type="EJBBusinessMethod" name="calculatePrice">
<parameter name="year_price" type="/1"/>
<parameter name="rate" type="/1"/>
</feature>
</EJBEntityComponent>
<Table/>
</xmi:XMI>




And I am using an ATL code like this:

... some helpers deleted here ...
lazy rule kkkk {
from umlOper : UML!Operation
to Parameters : distinct EJB!EJBParameter
foreach (par in umlOper.parameter) (
name <- par.name
)
}

rule ClassToEntityComponent{
from class : UML!Class
( not class.isAComposition() )
to entityComponent : EJB!EJBEntityComponent (
name <- class.name.debug('debug here'),
feature <- ATTRS->union(ASSOCENDS)->union(OPERS),
usedTable <- EJBTable
),
EJBTable : EJB!Table (
),
OPERS : distinct EJB!EJBBusinessMethod
foreach (oper in class.operations()) (
name <- oper.name,
parameter <- oper->collect(e | thisModule.kkkk(e))
),
ATTRS : distinct EJB!EJBAttribute
foreach (attr in class.attributes())(
name <- attr.name
),
ASSOCENDS : distinct EJB!EJBAssociationEnd
foreach (assocEnd in class.getAssociationEnds())(
name <- assocEnd.name,
lower <-assocEnd.lower,
upper <- assocEnd.upper,
composition <- assocEnd.composition
)
}
Re: [ATL] transforming UML to EJB [message #22002 is a reply to message #21911] Wed, 07 March 2007 21:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcos.didonet-del-fabro.univ-nantes.fr

Hi Walcir,

maybe I am missing some details about your metamodels, but I think you could write your
transformations in a different way, taking advantage of the declarative nature of ATL. See
the example rewritten below:

rule ClassToEntityComponent{
from class : UML!Class
( not class.isAComposition() )
to entityComponent : EJB!EJBEntityComponent (
name <- class.name.debug('debug here'),
feature <- class.feature,
usedTable <- EJBTable
),
EJBTable : EJB!Table (
)
}

rule Operation {
from
oper : UML!Operation
to
method : EJB!EJBBusinessMethod
OPERS : distinct EJB!EJBBusinessMethod (
name <- oper.name,
parameter <- oper.parameter
)
}
rule Parameter {
from
parameter : UML!Parameter
to
out : EJB!Parameter (
name <- parameter.name
)
}

rule Attribute {
from
attr : UML!Atribute
to
out : EJB!EJBAttribute (
name <- attr.name
)

}

rule AssocEnds {
from
assocEnd : UML!AssociationEnd
to
ASSOCENDS : EJB!EJBAssociationEnd
(
name <- assocEnd.name,
lower <-assocEnd.lower,
upper <- assocEnd.upper,
composition <- assocEnd.composition
)
}

Regards,

Marcos.


walcir fontanini wrote:
> Hi all,
>
> Please, tell me if I am not in the wrong place. I am trying to transform
> some UML model to an EJB model. The "parameter" target pattern is not
> working, and I think I need a lot more "distinct-foreach" !!! It seems
> that I need just one big "rule" with every possible target pattern there .
>
> Thanks,
> -walcir
>
> === UML model ====
> <?xml version="1.0" encoding="ASCII"?>
> <xmi:XMI xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="UML">
>
> <DataType name="String"/>
> <DataType name="Integer"/>
> <Class name="BreakfastOrder">
> <feature xsi:type="Operation" name="calculatePrice">
> <parameter name="year_price" type="/1"/>
> <parameter name="rate" type="/1"/>
> </feature>
> <feature xsi:type="Attribute" name="deliveryStatus" type="/0"/>
> <feature xsi:type="Attribute" name="deliveryDate" type="/0"/>
> <feature xsi:type="AssociationEnd" name="customer" lower="1"
> upper="1" otherEnd="/3/@feature.3"/>
> <feature xsi:type="AssociationEnd" name="breakfasts" lower="1"
> upper="-1" composition="true" otherEnd="/4/@feature.2"/>
> </Class>
> </xmi:XMI>
> ==== EJB model ====
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="EJB">
> <EJBEntityComponent name="BreakfastOrder" usedTable="/1">
> <feature xsi:type="EJBAttribute" name="deliveryStatus"/>
> <feature xsi:type="EJBAttribute" name="deliveryDate"/>
> <feature xsi:type="EJBAssociationEnd" name="customer" lower="1"
> upper="1"/>
> <feature xsi:type="EJBAssociationEnd" name="breakfasts" lower="1"
> upper="-1" composition="true"/>
> <feature xsi:type="EJBBusinessMethod" name="calculatePrice">
> <parameter name="year_price" type="/1"/>
> <parameter name="rate" type="/1"/>
> </feature>
> </EJBEntityComponent>
> <Table/>
> </xmi:XMI>
>
>
>
>
> And I am using an ATL code like this:
>
> .. some helpers deleted here ...
> lazy rule kkkk {
> from umlOper : UML!Operation
> to Parameters : distinct EJB!EJBParameter
> foreach (par in umlOper.parameter) (
> name <- par.name
> )
> }
>
> rule ClassToEntityComponent{
> from class : UML!Class
> ( not class.isAComposition() )
> to entityComponent : EJB!EJBEntityComponent (
> name <- class.name.debug('debug here'),
> feature <- ATTRS->union(ASSOCENDS)->union(OPERS),
> usedTable <- EJBTable
> ),
> EJBTable : EJB!Table (
> ),
> OPERS : distinct EJB!EJBBusinessMethod
> foreach (oper in class.operations()) (
> name <- oper.name,
> parameter <- oper->collect(e | thisModule.kkkk(e))
> ),
> ATTRS : distinct EJB!EJBAttribute
> foreach (attr in class.attributes())(
> name <- attr.name
> ),
> ASSOCENDS : distinct EJB!EJBAssociationEnd
> foreach (assocEnd in class.getAssociationEnds())(
> name <- assocEnd.name,
> lower <-assocEnd.lower,
> upper <- assocEnd.upper,
> composition <- assocEnd.composition
> )
> }
Re: [ATL] transforming UML to EJB (continuing) [message #22179 is a reply to message #22002] Wed, 07 March 2007 22:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcos.didonet-del-fabro.univ-nantes.fr

Hello again,

I tested the code I wrote in the previous message with the EJB and UML files you provided
some days ago in the post
( http://www.eclipse.org/newsportal/article.php?id=313&gro up=eclipse.modeling.m2m#313), and
it worked fine.

The transformation generated a EJBBusinessMethod with a set of parameters (2 on that example).

Regards,

Marcos.

PS.: I copied below the transformation I executed. Then you can add any extra processing
you need.

------------------------------------------------------------ ---------------------

module UML2EJB; -- Module Template
create OUT : EJB from IN : UML ;

-- Tested: OK
helper context UML!Class def: getAssociationEnds(): Sequence( UML!AssociationEnd) =
let associationEnds : Sequence(UML!AssociationEnd) = self.feature->
select( e | e.oclIsKindOf(UML!AssociationEnd)) in
if associationEnds->notEmpty() then

associationEnds->iterate( e;
acc: Sequence(UML!AssociationEnd) = Sequence{} |
acc.append(e) )
else
Sequence{}
endif;

-- Tested: OK
helper context UML!Class def:isAComposition(): Boolean =
self.getAssociationEnds()->exists(end | end.otherEnd.composition = true)
;

rule ClassToEntityComponent{
from class : UML!Class
( not class.isAComposition() )
to entityComponent : EJB!EJBEntityComponent (
name <- class.name.debug('debug here'),
feature <- class.feature,
usedTable <- EJBTable
),
EJBTable : EJB!Table (
)
}

rule Operation {
from
oper : UML!Operation
to
method : EJB!EJBBusinessMethod (
name <- oper.name,
parameter <- oper.parameter
)
}
rule Parameter {
from
parameter : UML!Parameter
to
out : EJB!EJBParameter (
name <- parameter.name
)
}

rule Attribute {
from
attr : UML!Attribute
to
out : EJB!EJBAttribute (
name <- attr.name
)

}

rule AssocEnds {
from
assocEnd : UML!AssociationEnd
to
ASSOCENDS : EJB!EJBAssociationEnd
(
name <- assocEnd.name,
lower <-assocEnd.lower,
upper <- assocEnd.upper,
composition <- assocEnd.composition
)
}

------------------------------------------------------------ ---------------------


Marcos Didonet Del Fabro wrote:
> Hi Walcir,
>
> maybe I am missing some details about your metamodels, but I think you
> could write your transformations in a different way, taking advantage of
> the declarative nature of ATL. See the example rewritten below:
>

> walcir fontanini wrote:
>> Hi all,
>>
>> Please, tell me if I am not in the wrong place. I am trying to
>> transform some UML model to an EJB model. The "parameter" target
>> pattern is not working, and I think I need a lot more
>> "distinct-foreach" !!! It seems that I need just one big "rule" with
>> every possible target pattern there .
>>
>> Thanks,
>> -walcir
>>
>> === UML model ====
>> <?xml version="1.0" encoding="ASCII"?>
>> <xmi:XMI xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns="UML">
>>
>> <DataType name="String"/>
>> <DataType name="Integer"/>
>> <Class name="BreakfastOrder">
>> <feature xsi:type="Operation" name="calculatePrice">
>> <parameter name="year_price" type="/1"/>
>> <parameter name="rate" type="/1"/>
>> </feature>
>> <feature xsi:type="Attribute" name="deliveryStatus" type="/0"/>
>> <feature xsi:type="Attribute" name="deliveryDate" type="/0"/>
>> <feature xsi:type="AssociationEnd" name="customer" lower="1"
>> upper="1" otherEnd="/3/@feature.3"/>
>> <feature xsi:type="AssociationEnd" name="breakfasts" lower="1"
>> upper="-1" composition="true" otherEnd="/4/@feature.2"/>
>> </Class>
>> </xmi:XMI>
>> ==== EJB model ====
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <xmi:XMI xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns="EJB">
>> <EJBEntityComponent name="BreakfastOrder" usedTable="/1">
>> <feature xsi:type="EJBAttribute" name="deliveryStatus"/>
>> <feature xsi:type="EJBAttribute" name="deliveryDate"/>
>> <feature xsi:type="EJBAssociationEnd" name="customer" lower="1"
>> upper="1"/>
>> <feature xsi:type="EJBAssociationEnd" name="breakfasts" lower="1"
>> upper="-1" composition="true"/>
>> <feature xsi:type="EJBBusinessMethod" name="calculatePrice">
>> <parameter name="year_price" type="/1"/>
>> <parameter name="rate" type="/1"/>
>> </feature>
>> </EJBEntityComponent>
>> <Table/>
>> </xmi:XMI>
>>
>>
>>
>>
>> And I am using an ATL code like this:
>>
>> .. some helpers deleted here ...
>> lazy rule kkkk {
>> from umlOper : UML!Operation
>> to Parameters : distinct EJB!EJBParameter
>> foreach (par in umlOper.parameter) (
>> name <- par.name ) }
>>
>> rule ClassToEntityComponent{
>> from class : UML!Class
>> ( not class.isAComposition() )
>> to entityComponent : EJB!EJBEntityComponent (
>> name <- class.name.debug('debug here'),
>> feature <- ATTRS->union(ASSOCENDS)->union(OPERS),
>> usedTable <- EJBTable
>> ),
>> EJBTable : EJB!Table (
>> ),
>> OPERS : distinct EJB!EJBBusinessMethod
>> foreach (oper in class.operations()) (
>> name <- oper.name,
>> parameter <- oper->collect(e | thisModule.kkkk(e))
>> ),
>> ATTRS : distinct EJB!EJBAttribute
>> foreach (attr in class.attributes())(
>> name <- attr.name
>> ),
>> ASSOCENDS : distinct EJB!EJBAssociationEnd
>> foreach (assocEnd in class.getAssociationEnds())(
>> name <- assocEnd.name,
>> lower <-assocEnd.lower,
>> upper <- assocEnd.upper,
>> composition <- assocEnd.composition
>> )
>> }
Re: [ATL] transforming UML to EJB (continuing) [message #22300 is a reply to message #22179] Thu, 08 March 2007 14:14 Go to previous message
Eclipse UserFriend
Originally posted by: walcir.fontanini.cenpra.gov.br

Marcos,

It works fine now !!! You are very right !!

Thanks a lot,

-walcir

Marcos Didonet Del Fabro wrote:
> Hello again,
>
> I tested the code I wrote in the previous message with the EJB and UML
> files you provided some days ago in the post
> ( http://www.eclipse.org/newsportal/article.php?id=313&gro up=eclipse.modeling.m2m#313),
> and it worked fine.
>
> The transformation generated a EJBBusinessMethod with a set of
> parameters (2 on that example).
>
> Regards,
>
> Marcos.
>
> PS.: I copied below the transformation I executed. Then you can add any
> extra processing you need.
>
> ------------------------------------------------------------ ---------------------
>
>
> module UML2EJB; -- Module Template
> create OUT : EJB from IN : UML ;
>
> -- Tested: OK
> helper context UML!Class def: getAssociationEnds(): Sequence(
> UML!AssociationEnd) =
> let associationEnds : Sequence(UML!AssociationEnd) = self.feature->
> select( e | e.oclIsKindOf(UML!AssociationEnd)) in
> if associationEnds->notEmpty() then
>
> associationEnds->iterate( e;
> acc: Sequence(UML!AssociationEnd) = Sequence{} |
> acc.append(e) )
> else
> Sequence{}
> endif;
>
> -- Tested: OK
> helper context UML!Class def:isAComposition(): Boolean =
> self.getAssociationEnds()->exists(end | end.otherEnd.composition =
> true)
> ;
>
> rule ClassToEntityComponent{
> from class : UML!Class
> ( not class.isAComposition() )
> to entityComponent : EJB!EJBEntityComponent (
> name <- class.name.debug('debug here'),
> feature <- class.feature,
> usedTable <- EJBTable
> ),
> EJBTable : EJB!Table (
> )
> }
>
> rule Operation {
> from
> oper : UML!Operation
> to
> method : EJB!EJBBusinessMethod (
> name <- oper.name,
> parameter <- oper.parameter
> )
> }
> rule Parameter {
> from
> parameter : UML!Parameter
> to
> out : EJB!EJBParameter (
> name <- parameter.name
> )
> }
>
> rule Attribute {
> from
> attr : UML!Attribute
> to
> out : EJB!EJBAttribute (
> name <- attr.name
> )
>
> }
>
> rule AssocEnds {
> from
> assocEnd : UML!AssociationEnd
> to
> ASSOCENDS : EJB!EJBAssociationEnd
> (
> name <- assocEnd.name,
> lower <-assocEnd.lower,
> upper <- assocEnd.upper,
> composition <- assocEnd.composition
> )
> }
>
> ------------------------------------------------------------ ---------------------
>
>
>
> Marcos Didonet Del Fabro wrote:
>
>> Hi Walcir,
>>
>> maybe I am missing some details about your metamodels, but I think you
>> could write your transformations in a different way, taking advantage
>> of the declarative nature of ATL. See the example rewritten below:
>>
>
>> walcir fontanini wrote:
>>
>>> Hi all,
>>>
>>> Please, tell me if I am not in the wrong place. I am trying to
>>> transform some UML model to an EJB model. The "parameter" target
>>> pattern is not working, and I think I need a lot more
>>> "distinct-foreach" !!! It seems that I need just one big "rule" with
>>> every possible target pattern there .
>>>
>>> Thanks,
>>> -walcir
>>>
>>> === UML model ====
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <xmi:XMI xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns="UML">
>>>
>>> <DataType name="String"/>
>>> <DataType name="Integer"/>
>>> <Class name="BreakfastOrder">
>>> <feature xsi:type="Operation" name="calculatePrice">
>>> <parameter name="year_price" type="/1"/>
>>> <parameter name="rate" type="/1"/>
>>> </feature>
>>> <feature xsi:type="Attribute" name="deliveryStatus" type="/0"/>
>>> <feature xsi:type="Attribute" name="deliveryDate" type="/0"/>
>>> <feature xsi:type="AssociationEnd" name="customer" lower="1"
>>> upper="1" otherEnd="/3/@feature.3"/>
>>> <feature xsi:type="AssociationEnd" name="breakfasts" lower="1"
>>> upper="-1" composition="true" otherEnd="/4/@feature.2"/>
>>> </Class>
>>> </xmi:XMI>
>>> ==== EJB model ====
>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>> <xmi:XMI xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns="EJB">
>>> <EJBEntityComponent name="BreakfastOrder" usedTable="/1">
>>> <feature xsi:type="EJBAttribute" name="deliveryStatus"/>
>>> <feature xsi:type="EJBAttribute" name="deliveryDate"/>
>>> <feature xsi:type="EJBAssociationEnd" name="customer" lower="1"
>>> upper="1"/>
>>> <feature xsi:type="EJBAssociationEnd" name="breakfasts" lower="1"
>>> upper="-1" composition="true"/>
>>> <feature xsi:type="EJBBusinessMethod" name="calculatePrice">
>>> <parameter name="year_price" type="/1"/>
>>> <parameter name="rate" type="/1"/>
>>> </feature>
>>> </EJBEntityComponent>
>>> <Table/>
>>> </xmi:XMI>
>>>
>>>
>>>
>>>
>>> And I am using an ATL code like this:
>>>
>>> .. some helpers deleted here ...
>>> lazy rule kkkk {
>>> from umlOper : UML!Operation
>>> to Parameters : distinct EJB!EJBParameter
>>> foreach (par in umlOper.parameter) (
>>> name <- par.name ) }
>>>
>>> rule ClassToEntityComponent{
>>> from class : UML!Class
>>> ( not class.isAComposition() )
>>> to entityComponent : EJB!EJBEntityComponent (
>>> name <- class.name.debug('debug here'),
>>> feature <- ATTRS->union(ASSOCENDS)->union(OPERS),
>>> usedTable <- EJBTable
>>> ),
>>> EJBTable : EJB!Table (
>>> ),
>>> OPERS : distinct EJB!EJBBusinessMethod
>>> foreach (oper in class.operations()) (
>>> name <- oper.name,
>>> parameter <- oper->collect(e | thisModule.kkkk(e))
>>> ),
>>> ATTRS : distinct EJB!EJBAttribute
>>> foreach (attr in class.attributes())(
>>> name <- attr.name
>>> ),
>>> ASSOCENDS : distinct EJB!EJBAssociationEnd
>>> foreach (assocEnd in class.getAssociationEnds())(
>>> name <- assocEnd.name,
>>> lower <-assocEnd.lower,
>>> upper <- assocEnd.upper,
>>> composition <- assocEnd.composition
>>> )
>>> }
Previous Topic:Using ATL and UML2
Next Topic:EMF M1 model transformation with ATL
Goto Forum:
  


Current Time: Tue Mar 19 02:28:21 GMT 2024

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

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

Back to the top