Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » my example is in trouble ...
my example is in trouble ... [message #19735] Wed, 28 February 2007 17:26
Eclipse UserFriend
Originally posted by: walcir.fontanini.cenpra.gov.br

This is a multi-part message in MIME format.
--------------050702040009040707040104
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi all,

The "Parameter" target pattern in rule ClassToEntityComponent (see
UML2EJB.atl file) was supposed to produce a list of parameters, but it
is not working. The UML!CLASS has a composite part UML!Operation and
UML!Operation has another composite part UML!Parameter. How to reflect
this hierarchy in rule ClassToEntityComponent ? Any hint for me ?


Thanks,
-walcir

=================Output.ecore ==========================================
<?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="Customer" usedTable="/1">
<feature xsi:type="EJBBusinessMethod" name="createOrder">
<parameter/>
</feature>
</EJBEntityComponent>
<Table/>
<EJBEntityComponent name="BreakfastOrder" usedTable="/3">
<feature xsi:type="EJBBusinessMethod" name="calculatePrice">
<parameter name="year_price"/>
</feature>
<feature xsi:type="EJBBusinessMethod" name="calcPriceOO">
<parameter name="year_priceoo"/>
</feature>
</EJBEntityComponent>
<Table/>
<EJBEntityComponent name="StandardBreakfast" usedTable="/5"/>
<Table/>
</xmi:XMI>

=======UML2EJB.atl========================================== ================
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)
;

-- tested : ok
helper context UML!Class def: operations(): Sequence(UML!Operation) =
let operations : Sequence(UML!Operation) = self.feature->
select( e | e.oclIsKindOf(UML!Operation)) in
if operations->notEmpty() then
operations
-- operations->iterate( e;
-- acc: Sequence(UML!Operation) = Sequence{} |
-- acc.append(e) )
else
Sequence{}
endif
;


rule ClassToEntityComponent{
from class : UML!Class
( not class.isAComposition() )
to entityComponent : EJB!EJBEntityComponent (
name <- class.name,
feature <- Features,
usedTable <- EJBTable
),
EJBTable : EJB!Table (
),
Features : distinct EJB!EJBBusinessMethod
foreach (oper in class.operations()) (
name <- oper.name,
parameter <- Parameters
),
Parameters : distinct EJB!EJBParameter
foreach (oper in class.operations()) (
name <- oper.parameter->first().name
)
}

=========UMLinput4.ecore==================================== =============
<?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="Attribute" name="deliveryStatus" type="/0"/>
<feature xsi:type="Attribute" name="deliveryDate" type="/0"/>
<feature xsi:type="Operation" name="calculatePrice">
<parameter name="year_price" type="/1"/>
<parameter name="rate" type="/1"/>
</feature>
<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"/>

<feature xsi:type="Operation" name="calcPriceOO">
<parameter name="year_priceoo" type="/1"/>
</feature>
</Class>
<Class name="Customer">
<feature xsi:type="Attribute" name="accounNumber" type="/1"/>
<feature xsi:type="Attribute" name="address" type="/1"/>
<feature xsi:type="Operation" name="createOrder"/>
<feature xsi:type="AssociationEnd" name="orders" lower="1"
upper="1" otherEnd="/2/@feature.3"/>
</Class>
<Class name="Breakfast">
<feature xsi:type="Attribute" name="number" type="/1"/>
<feature xsi:type="AssociationEnd" name="standard" lower="1"
upper="1" otherEnd="/5/@feature.3"/>
<feature xsi:type="AssociationEnd" name="order" lower="1" upper="1"
otherEnd="/2/@feature.4"/>
</Class>
<Class name="StandardBreakfast">
<feature xsi:type="Attribute" name="name" type="/0"/>
<feature xsi:type="Attribute" name="style" type="/0"/>
<feature xsi:type="Attribute" name="price" type="/1"/>
<feature xsi:type="AssociationEnd" name="standard_other_end"
upper="-1" otherEnd="/4/@feature.1"/>
</Class>

</xmi:XMI>

============================================================ =================
package UML {
abstract class Classifier {
attribute name : String;
}

class DataType extends Classifier {}

class Set extends DataType {
reference elementType : Classifier;
}

abstract class Typed {
attribute name : String;
reference type : Classifier;
}

abstract class Feature extends Typed {
attribute visibility : String;
reference classs : Class oppositeOf feature; -- 'classs' foi usado
como 'class'
}

class Class extends Classifier {
reference feature[*] container : Feature oppositeOf classs;
}

class Attribute extends Feature { }

class Parameter extends Typed {
reference operationn : Operation oppositeOf parameter; --
'operationn' foi usado como 'operation'
}

class Operation extends Feature {
reference parameter[*] container : Parameter oppositeOf operationn;
}


class AssociationEnd extends Feature {
attribute lower : Integer;
attribute upper : Integer;
attribute composition : Boolean;

reference otherEnd[0-1] : AssociationEnd;
reference association : Association oppositeOf end;
}

class Association {
reference end[2-*] : AssociationEnd oppositeOf association;
}


}

package PrimitiveTypes {
datatype String;
datatype Integer;
datatype Boolean;
}
============================================================ ===========================
package EJB {
abstract class EJBClassifier {
attribute name : String;
}

class EJBDataType extends EJBClassifier {}

abstract class EJBTyped {
attribute name : String;
reference type : EJBClassifier;
}

abstract class EJBClass extends EJBClassifier {
reference feature[*] container : EJBFeature oppositeOf classs;
}

class EJBKeyClass extends EJBClass {}

abstract class EJBComponent extends EJBClass {}

class EJBSessionComponent extends EJBComponent {}
class EJBEntityComponent extends EJBComponent {
reference usedTable[1-*] : Table;
}
class Table {}

class EJBDataSchema {
reference element[*] container : EJBDataSchemaElement oppositeOf
packagee;
}
abstract class EJBDataSchemaElement {
reference packagee : EJBDataSchema oppositeOf element;
}

class EJBDataClass extends EJBDataSchemaElement, EJBClass {}

class EJBDataAssociation extends EJBDataSchemaElement {
reference end[2-2] : EJBAssociationEnd oppositeOf association;
}


abstract class EJBFeature extends EJBTyped {
reference classs : EJBClass oppositeOf feature;
}

class EJBAttribute extends EJBFeature {}

class EJBBusinessMethod extends EJBFeature {
reference parameter[*] container : EJBParameter oppositeOf operationn;
}

class EJBParameter extends EJBTyped {
reference operationn : EJBBusinessMethod oppositeOf parameter;
}

class EJBAssociationEnd extends EJBFeature {
attribute lower : Integer;
attribute upper : Integer;
attribute composition : Boolean;
reference association[0-1] : EJBDataAssociation oppositeOf end;
}

class EJBServingAttribute extends EJBAssociationEnd {}
}

package PrimitiveTypes {
datatype String;
datatype Integer;
datatype Boolean;
}
============================================================ ===========================

--------------050702040009040707040104
Content-Type: text/xml;
name="EJB.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="EJB.ecore"

<?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:ecore="http://www.eclipse.org/emf/2002/Ecore">
<ecore:EPackage name="PrimitiveTypes">
<eClassifiers xsi:type="ecore:EDataType" name="String"/>
<eClassifiers xsi:type="ecore:EDataType" name="Integer"/>
<eClassifiers xsi:type="ecore:EDataType" name="Boolean"/>
</ecore:EPackage>
<ecore:EPackage name="EJB">
<eClassifiers xsi:type="ecore:EClass" name="EJBClassifier" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false" unique="false" lowerBound="1" eType="/0/String"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBDataType" eSuperTypes="/1/EJBClassifier"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBTyped" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false" unique="false" lowerBound="1" eType="/0/String"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="type" ordered="false" lowerBound="1" eType="/1/EJBClassifier"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBClass" abstract="true" eSuperTypes="/1/EJBClassifier">
<eStructuralFeatures xsi:type="ecore:EReference" name="feature" ordered="false" upperBound="-1" eType="/1/EJBFeature" containment="true" eOpposite="/1/EJBFeature/classs"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBKeyClass" eSuperTypes="/1/EJBClass"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBComponent" abstract="true" eSuperTypes="/1/EJBClass"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBSessionComponent" eSuperTypes="/1/EJBComponent"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBEntityComponent" eSuperTypes="/1/EJBComponent">
<eStructuralFeatures xsi:type="ecore:EReference" name="usedTable" ordered="false" lowerBound="1" upperBound="-1" eType="/1/Table"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Table"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBDataSchema">
<eStructuralFeatures xsi:type="ecore:EReference" name="element" ordered="false" upperBound="-1" eType="/1/EJBDataSchemaElement" containment="true" eOpposite="/1/EJBDataSchemaElement/packagee"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBDataSchemaElement" abstract="true">
<eStructuralFeatures xsi:type="ecore:EReference" name="packagee" ordered="false" lowerBound="1" eType="/1/EJBDataSchema" eOpposite="/1/EJBDataSchema/element"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBDataClass" eSuperTypes="/1/EJBDataSchemaElement /1/EJBClass"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBDataAssociation" eSuperTypes="/1/EJBDataSchemaElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="end" ordered="false" lowerBound="2" upperBound="2" eType="/1/EJBAssociationEnd" eOpposite="/1/EJBAssociationEnd/association"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBFeature" abstract="true" eSuperTypes="/1/EJBTyped">
<eStructuralFeatures xsi:type="ecore:EReference" name="classs" ordered="false" lowerBound="1" eType="/1/EJBClass" eOpposite="/1/EJBClass/feature"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBAttribute" eSuperTypes="/1/EJBFeature"/>
<eClassifiers xsi:type="ecore:EClass" name="EJBBusinessMethod" eSuperTypes="/1/EJBFeature">
<eStructuralFeatures xsi:type="ecore:EReference" name="parameter" ordered="false" upperBound="-1" eType="/1/EJBParameter" containment="true" eOpposite="/1/EJBParameter/operationn"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBParameter" eSuperTypes="/1/EJBTyped">
<eStructuralFeatures xsi:type="ecore:EReference" name="operationn" ordered="false" lowerBound="1" eType="/1/EJBBusinessMethod" eOpposite="/1/EJBBusinessMethod/parameter"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBAssociationEnd" eSuperTypes="/1/EJBFeature">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lower" ordered="false" unique="false" lowerBound="1" eType="/0/Integer"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="upper" ordered="false" unique="false" lowerBound="1" eType="/0/Integer"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="composition" ordered="false" unique="false" lowerBound="1" eType="/0/Boolean"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="association" ordered="false" eType="/1/EJBDataAssociation" eOpposite="/1/EJBDataAssociation/end"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="EJBServingAttribute" eSuperTypes="/1/EJBAssociationEnd"/>
</ecore:EPackage>
</xmi:XMI>

--------------050702040009040707040104
Content-Type: text/plain;
name="UML2EJB.atl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="UML2EJB.atl"

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)
;

-- tested : ok
helper context UML!Class def: operations(): Sequence(UML!Operation) =
let operations : Sequence(UML!Operation) = self.feature->
select( e | e.oclIsKindOf(UML!Operation)) in
if operations->notEmpty() then
operations
-- operations->iterate( e;
-- acc: Sequence(UML!Operation) = Sequence{} |
-- acc.append(e) )
else
Sequence{}
endif
;


rule ClassToEntityComponent{
from class : UML!Class
( not class.isAComposition() )
to entityComponent : EJB!EJBEntityComponent (
name <- class.name,
feature <- Features,
usedTable <- EJBTable
),
EJBTable : EJB!Table (
),
Features : distinct EJB!EJBBusinessMethod
foreach (oper in class.operations()) (
name <- oper.name,
parameter <- Parameters
),
Parameters : distinct EJB!EJBParameter
foreach (oper in class.operations()) (
name <- oper.parameter->first().name
)
}





--------------050702040009040707040104
Content-Type: text/xml;
name="UML.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="UML.ecore"

<?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:ecore="http://www.eclipse.org/emf/2002/Ecore">
<ecore:EPackage name="PrimitiveTypes">
<eClassifiers xsi:type="ecore:EDataType" name="String"/>
<eClassifiers xsi:type="ecore:EDataType" name="Integer"/>
<eClassifiers xsi:type="ecore:EDataType" name="Boolean"/>
</ecore:EPackage>
<ecore:EPackage name="UML">
<eClassifiers xsi:type="ecore:EClass" name="Classifier" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false" unique="false" lowerBound="1" eType="/0/String"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DataType" eSuperTypes="/1/Classifier"/>
<eClassifiers xsi:type="ecore:EClass" name="Set" eSuperTypes="/1/DataType">
<eStructuralFeatures xsi:type="ecore:EReference" name="elementType" ordered="false" lowerBound="1" eType="/1/Classifier"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Typed" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false" unique="false" lowerBound="1" eType="/0/String"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="type" ordered="false" lowerBound="1" eType="/1/Classifier"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Feature" abstract="true" eSuperTypes="/1/Typed">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="visibility" ordered="false" unique="false" lowerBound="1" eType="/0/String"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="classs" ordered="false" lowerBound="1" eType="/1/Class" eOpposite="/1/Class/feature"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Class" eSuperTypes="/1/Classifier">
<eStructuralFeatures xsi:type="ecore:EReference" name="feature" ordered="false" upperBound="-1" eType="/1/Feature" containment="true" eOpposite="/1/Feature/classs"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Attribute" eSuperTypes="/1/Feature"/>
<eClassifiers xsi:type="ecore:EClass" name="Parameter" eSuperTypes="/1/Typed">
<eStructuralFeatures xsi:type="ecore:EReference" name="operationn" ordered="false" lowerBound="1" eType="/1/Operation" eOpposite="/1/Operation/parameter"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Operation" eSuperTypes="/1/Feature">
<eStructuralFeatures xsi:type="ecore:EReference" name="parameter" ordered="false" upperBound="-1" eType="/1/Parameter" containment="true" eOpposite="/1/Parameter/operationn"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AssociationEnd" eSuperTypes="/1/Feature">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lower" ordered="false" unique="false" lowerBound="1" eType="/0/Integer"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="upper" ordered="false" unique="false" lowerBound="1" eType="/0/Integer"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="composition" ordered="false" unique="false" lowerBound="1" eType="/0/Boolean"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="otherEnd" ordered="false" eType="/1/AssociationEnd"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="association" ordered="false" lowerBound="1" eType="/1/Association" eOpposite="/1/Association/end"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Association">
<eStructuralFeatures xsi:type="ecore:EReference" name="end" ordered="false" lowerBound="2" upperBound="-1" eType="/1/AssociationEnd" eOpposite="/1/AssociationEnd/association"/>
</eClassifiers>
</ecore:EPackage>
</xmi:XMI>

--------------050702040009040707040104
Content-Type: text/xml;
name="UMLinput4.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="UMLinput4.ecore"

<?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="Attribute" name="deliveryStatus" type="/0"/>
<feature xsi:type="Attribute" name="deliveryDate" type="/0"/>
<feature xsi:type="Operation" name="calculatePrice">
<parameter name="year_price" type="/1"/>
<parameter name="rate" type="/1"/>
</feature>
<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"/>

<feature xsi:type="Operation" name="calcPriceOO">
<parameter name="year_priceoo" type="/1"/>
</feature>
</Class>
<Class name="Customer">
<feature xsi:type="Attribute" name="accounNumber" type="/1"/>
<feature xsi:type="Attribute" name="address" type="/1"/>
<feature xsi:type="Operation" name="createOrder"/>
<feature xsi:type="AssociationEnd" name="orders" lower="1" upper="1" otherEnd="/2/@feature.3"/>
</Class>
<Class name="Breakfast">
<feature xsi:type="Attribute" name="number" type="/1"/>
<feature xsi:type="AssociationEnd" name="standard" lower="1" upper="1" otherEnd="/5/@feature.3"/>
<feature xsi:type="AssociationEnd" name="order" lower="1" upper="1" otherEnd="/2/@feature.4"/>
</Class>
<Class name="StandardBreakfast">
<feature xsi:type="Attribute" name="name" type="/0"/>
<feature xsi:type="Attribute" name="style" type="/0"/>
<feature xsi:type="Attribute" name="price" type="/1"/>
<feature xsi:type="AssociationEnd" name="standard_other_end" upper="-1" otherEnd="/4/@feature.1"/>
</Class>

</xmi:XMI>

--------------050702040009040707040104--
Previous Topic:How to check out ATL source
Next Topic:How to use ecore(metamodel) generated from xsd schema for m2m transformation ?
Goto Forum:
  


Current Time: Thu Apr 25 15:16:52 GMT 2024

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

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

Back to the top