diff options
Diffstat (limited to 'examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org')
8 files changed, 1090 insertions, 0 deletions
diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/.gitignore b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/.gitignore new file mode 100644 index 000000000..c1103d198 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/.gitignore @@ -0,0 +1,6 @@ +/SimpleRDBMSPeople.xmi +/SimpleUML2RDBMS.qvtias +/SimpleUML2RDBMS.qvtm.qvtcas +/SimpleUML2RDBMS.qvtp.qvtcas +/SimpleUML2RDBMS.qvts.xmi +/SimpleUML2RDBMS.qvtu.qvtcas diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleRDBMS.ecore b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleRDBMS.ecore new file mode 100644 index 000000000..70e7ca7c7 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleRDBMS.ecore @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage 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" name="simplerdbms" nsURI="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/SimpleRDBMS" + nsPrefix="simplerdbms"> + <eClassifiers xsi:type="ecore:EClass" name="Column" eSuperTypes="#//RModelElement"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//Table" + eOpposite="#//Table/columns"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="foreignKeys" upperBound="-1" + eType="#//ForeignKey" eOpposite="#//ForeignKey/columns"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="keys" upperBound="-1" eType="#//Key" + eOpposite="#//Key/column"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="ForeignKey" eSuperTypes="#//RModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="refersTo" lowerBound="1" + eType="#//Key"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="columns" upperBound="-1" + eType="#//Column" eOpposite="#//Column/foreignKeys"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//Table" + eOpposite="#//Table/foreignKeys"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Key" eSuperTypes="#//RModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//Table" + eOpposite="#//Table/keys"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="column" upperBound="-1" + eType="#//Column" eOpposite="#//Column/keys"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="RModelElement" abstract="true"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="kind" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Schema" eSuperTypes="#//RModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="tables" upperBound="-1" + eType="#//Table" containment="true" eOpposite="#//Table/schema"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Table" eSuperTypes="#//RModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="columns" upperBound="-1" + eType="#//Column" containment="true" eOpposite="#//Column/owner"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="schema" lowerBound="1" + eType="#//Schema" eOpposite="#//Schema/tables"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="keys" upperBound="-1" eType="#//Key" + containment="true" eOpposite="#//Key/owner"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="foreignKeys" upperBound="-1" + eType="#//ForeignKey" containment="true" eOpposite="#//ForeignKey/owner"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EDataType" name="String" instanceTypeName="EString"/> +</ecore:EPackage> diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleRDBMSPeople_expected.xmi b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleRDBMSPeople_expected.xmi new file mode 100644 index 000000000..864612d33 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleRDBMSPeople_expected.xmi @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="ASCII"?>
+<simplerdbms:Schema
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:simplerdbms="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/SimpleRDBMS"
+ xsi:schemaLocation="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/SimpleRDBMS SimpleRDBMS.ecore"
+ name="People">
+ <tables name="Address"
+ kind="base">
+ <columns
+ name="Address_tid"
+ type="NUMBER"
+ keys="//@tables.0/@keys.0"/>
+ <columns
+ name="street"
+ type="VARCHAR"/>
+ <columns
+ name="number"
+ type="VARCHAR"/>
+ <keys name="Address_pk"
+ kind="primary"
+ column="//@tables.0/@columns.0"/>
+ </tables>
+ <tables name="Budget"
+ kind="base">
+ <columns
+ name="Budget_tid"
+ type="NUMBER"
+ keys="//@tables.1/@keys.0"/>
+ <columns
+ name="year"
+ type="VARCHAR"/>
+ <columns
+ name="budget"
+ type="NUMBER"/>
+ <keys name="Budget_pk"
+ kind="primary"
+ column="//@tables.1/@columns.0"/>
+ </tables>
+ <tables name="Professor"
+ kind="base">
+ <columns
+ name="Professor_tid"
+ type="NUMBER"
+ keys="//@tables.2/@keys.0"/>
+ <columns
+ name="name"
+ type="VARCHAR"/>
+ <columns
+ name="employed"
+ type="BOOLEAN"/>
+ <columns
+ name="professorLivesAt_tid"
+ type="NUMBER"
+ foreignKeys="//@tables.2/@foreignKeys.0"/>
+ <columns
+ name="professorGroup_tid"
+ type="NUMBER"
+ foreignKeys="//@tables.2/@foreignKeys.1"/>
+ <keys name="Professor_pk"
+ kind="primary"
+ column="//@tables.2/@columns.0"/>
+ <foreignKeys
+ name="professorLivesAt"
+ refersTo="//@tables.0/@keys.0"
+ columns="//@tables.2/@columns.3"/>
+ <foreignKeys
+ name="professorGroup"
+ refersTo="//@tables.3/@keys.0"
+ columns="//@tables.2/@columns.4"/>
+ </tables>
+ <tables name="ResearchGroup"
+ kind="base">
+ <columns
+ name="ResearchGroup_tid"
+ type="NUMBER"
+ keys="//@tables.3/@keys.0"/>
+ <columns
+ name="name"
+ type="VARCHAR"/>
+ <columns
+ name="groupBudget_tid"
+ type="NUMBER"
+ foreignKeys="//@tables.3/@foreignKeys.0"/>
+ <keys name="ResearchGroup_pk"
+ kind="primary"
+ column="//@tables.3/@columns.0"/>
+ <foreignKeys
+ name="groupBudget"
+ refersTo="//@tables.1/@keys.0"
+ columns="//@tables.3/@columns.2"/>
+ </tables>
+ <tables name="Student"
+ kind="base">
+ <columns
+ name="Student_tid"
+ type="NUMBER"
+ keys="//@tables.4/@keys.0"/>
+ <columns
+ name="guardian"
+ type="VARCHAR"/>
+ <columns
+ name="name"
+ type="VARCHAR"/>
+ <columns
+ name="studentNumber"
+ type="NUMBER"/>
+ <columns
+ name="studentTimetable_tid"
+ type="NUMBER"
+ foreignKeys="//@tables.4/@foreignKeys.0"/>
+ <keys name="Student_pk"
+ kind="primary"
+ column="//@tables.4/@columns.0"/>
+ <foreignKeys
+ name="studentTimetable"
+ refersTo="//@tables.5/@keys.0"
+ columns="//@tables.4/@columns.4"/>
+ </tables>
+ <tables name="Timetable"
+ kind="base">
+ <columns
+ name="Timetable_tid"
+ type="NUMBER"
+ keys="//@tables.5/@keys.0"/>
+ <columns
+ name="year"
+ type="VARCHAR"/>
+ <keys name="Timetable_pk"
+ kind="primary"
+ column="//@tables.5/@columns.0"/>
+ </tables>
+</simplerdbms:Schema>
diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML.ecore b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML.ecore new file mode 100644 index 000000000..233831f84 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML.ecore @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage 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" name="simpleuml" nsURI="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/simpleUML" + nsPrefix="simpleuml"> + <eClassifiers xsi:type="ecore:EClass" name="Attribute" eSuperTypes="#//UMLModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//Class" + eOpposite="#//Class/attributes"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="type" lowerBound="1" eType="#//Classifier" + eOpposite="#//Classifier/typeOpposite"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Association" eSuperTypes="#//PackageElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="destination" lowerBound="1" + eType="#//Class" eOpposite="#//Class/reverse"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="source" lowerBound="1" + eType="#//Class" eOpposite="#//Class/forward"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Class" eSuperTypes="#//Classifier"> + <eStructuralFeatures xsi:type="ecore:EReference" name="attributes" upperBound="-1" + eType="#//Attribute" containment="true" eOpposite="#//Attribute/owner"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="forward" upperBound="-1" + eType="#//Association" eOpposite="#//Association/source"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="general" upperBound="-1" + eType="#//Class" eOpposite="#//Class/generalOpposite"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="generalOpposite" upperBound="-1" + eType="#//Class" eOpposite="#//Class/general"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="reverse" upperBound="-1" + eType="#//Association" derived="true" eOpposite="#//Association/destination"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Classifier" abstract="true" eSuperTypes="#//PackageElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="typeOpposite" upperBound="-1" + eType="#//Attribute" eOpposite="#//Attribute/type"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Package" eSuperTypes="#//UMLModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="elements" upperBound="-1" + eType="#//PackageElement" containment="true" eOpposite="#//PackageElement/namespace"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PackageElement" abstract="true" eSuperTypes="#//UMLModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="namespace" lowerBound="1" + eType="#//Package" eOpposite="#//Package/elements"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PrimitiveDataType" eSuperTypes="#//Classifier"/> + <eClassifiers xsi:type="ecore:EClass" name="UMLModelElement" abstract="true"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="kind" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> +</ecore:EPackage> diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.ecore b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.ecore new file mode 100644 index 000000000..2caf1ddea --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.ecore @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage 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" name="simpleuml2rdbms" nsURI="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/SimpleUMLtoRDBMS" + nsPrefix="simpleuml2rdbms"> + <eClassifiers xsi:type="ecore:EClass" name="AttributeToColumn" eSuperTypes="#//FromAttribute #//ToColumn"> + <eStructuralFeatures xsi:type="ecore:EReference" name="type" eType="#//PrimitiveToName"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="AssociationToForeignKey" eSuperTypes="#//ToColumn #//UmlToRdbmsModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="association" eType="ecore:EClass SimpleUML.ecore#//Association"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="foreignKey" eType="ecore:EClass SimpleRDBMS.ecore#//ForeignKey"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//ClassToTable" + eOpposite="#//ClassToTable/associationsToForeignKeys"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="referenced" eType="#//ClassToTable"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="BooleanToBoolean" eSuperTypes="#//PrimitiveToName"/> + <eClassifiers xsi:type="ecore:EClass" name="ClassToTable" eSuperTypes="#//FromAttributeOwner #//ToColumn #//UmlToRdbmsModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="associationsToForeignKeys" + upperBound="-1" eType="#//AssociationToForeignKey" containment="true" eOpposite="#//AssociationToForeignKey/owner"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//PackageToSchema" + eOpposite="#//PackageToSchema/classesToTables"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="primaryKey" eType="ecore:EClass SimpleRDBMS.ecore#//Key"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="table" eType="ecore:EClass SimpleRDBMS.ecore#//Table"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="umlClass" eType="ecore:EClass SimpleUML.ecore#//Class"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="FromAttribute" abstract="true" eSuperTypes="#//UmlToRdbmsModelElement"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="kind" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="attribute" eType="ecore:EClass SimpleUML.ecore#//Attribute"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="leafs" ordered="false" + upperBound="-1" eType="#//AttributeToColumn"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//FromAttributeOwner" + eOpposite="#//FromAttributeOwner/fromAttributes"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="FromAttributeOwner" abstract="true"> + <eStructuralFeatures xsi:type="ecore:EReference" name="fromAttributes" ordered="false" + upperBound="-1" eType="#//FromAttribute" containment="true" eOpposite="#//FromAttribute/owner"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="IntegerToNumber" eSuperTypes="#//PrimitiveToName"/> + <eClassifiers xsi:type="ecore:EClass" name="NonLeafAttribute" eSuperTypes="#//FromAttributeOwner #//FromAttribute"/> + <eClassifiers xsi:type="ecore:EClass" name="PackageToSchema" eSuperTypes="#//UmlToRdbmsModelElement"> + <eStructuralFeatures xsi:type="ecore:EReference" name="classesToTables" ordered="false" + lowerBound="1" upperBound="-1" eType="#//ClassToTable" containment="true" + eOpposite="#//ClassToTable/owner"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="primitivesToNames" ordered="false" + upperBound="-1" eType="#//PrimitiveToName" containment="true" eOpposite="#//PrimitiveToName/owner"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="schema" lowerBound="1" + eType="ecore:EClass SimpleRDBMS.ecore#//Schema"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="umlPackage" lowerBound="1" + eType="ecore:EClass SimpleUML.ecore#//Package"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PrimitiveToName" abstract="true" eSuperTypes="#//UmlToRdbmsModelElement"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="typeName" lowerBound="1" + eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="owner" lowerBound="1" eType="#//PackageToSchema" + eOpposite="#//PackageToSchema/primitivesToNames"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="primitive" lowerBound="1" + eType="ecore:EClass SimpleUML.ecore#//PrimitiveDataType"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="StringToVarchar" eSuperTypes="#//PrimitiveToName"/> + <eClassifiers xsi:type="ecore:EClass" name="ToColumn" abstract="true"> + <eStructuralFeatures xsi:type="ecore:EReference" name="column" lowerBound="1" + eType="ecore:EClass SimpleRDBMS.ecore#//Column"> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeUpper"> + <details key="body" value="1"/> + </eAnnotations> + <eAnnotations source="http://schema.omg.org/spec/MOF/2.0/emof.xml#Property.oppositeRoleName"> + <details key="body" value="middle"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="UmlToRdbmsModelElement" abstract="true"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> +</ecore:EPackage> diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.genmodel b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.genmodel new file mode 100644 index 000000000..e2def6751 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.genmodel @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2015, 2016 Willink Transformations and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
 E.D.Willink - Initial API and implementation" + modelDirectory="/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src-gen" modelPluginID="org.eclipse.qvtd.examples.qvtcore.uml2rdbms" + modelName="SimpleUML2RDBMS" updateClasspath="false" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" + importerID="org.eclipse.emf.importer.ecore" bundleManifest="false" complianceLevel="8.0" + copyrightFields="false" runtimeVersion="2.7" operationReflection="true" importOrganizing="true" + pluginKey=""> + <foreignModel>SimpleUML2RDBMS.ecore</foreignModel> + <genPackages prefix="Simpleuml2rdbms" basePackage="org.eclipse.qvtd.examples.qvtcore.uml2rdbms" + disposableProviderFactory="true" ecorePackage="SimpleUML2RDBMS.ecore#/"> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//AttributeToColumn"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//AttributeToColumn/type"/> + </genClasses> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//AssociationToForeignKey"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//AssociationToForeignKey/association"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//AssociationToForeignKey/foreignKey"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//AssociationToForeignKey/owner"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//AssociationToForeignKey/referenced"/> + </genClasses> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//BooleanToBoolean"/> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//ClassToTable"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//ClassToTable/associationsToForeignKeys"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//ClassToTable/owner"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//ClassToTable/primaryKey"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//ClassToTable/table"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//ClassToTable/umlClass"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleUML2RDBMS.ecore#//FromAttribute"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleUML2RDBMS.ecore#//FromAttribute/kind"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//FromAttribute/attribute"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//FromAttribute/leafs"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//FromAttribute/owner"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleUML2RDBMS.ecore#//FromAttributeOwner"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//FromAttributeOwner/fromAttributes"/> + </genClasses> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//IntegerToNumber"/> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//NonLeafAttribute"/> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//PackageToSchema"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//PackageToSchema/classesToTables"/> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//PackageToSchema/primitivesToNames"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//PackageToSchema/schema"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//PackageToSchema/umlPackage"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleUML2RDBMS.ecore#//PrimitiveToName"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleUML2RDBMS.ecore#//PrimitiveToName/typeName"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//PrimitiveToName/owner"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//PrimitiveToName/primitive"/> + </genClasses> + <genClasses ecoreClass="SimpleUML2RDBMS.ecore#//StringToVarchar"/> + <genClasses image="false" ecoreClass="SimpleUML2RDBMS.ecore#//ToColumn"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML2RDBMS.ecore#//ToColumn/column"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleUML2RDBMS.ecore#//UmlToRdbmsModelElement"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleUML2RDBMS.ecore#//UmlToRdbmsModelElement/name"/> + </genClasses> + </genPackages> + <genPackages prefix="Simpleuml" basePackage="org.eclipse.qvtd.examples.qvtcore.uml2rdbms" + disposableProviderFactory="true" ecorePackage="SimpleUML.ecore#/"> + <genClasses ecoreClass="SimpleUML.ecore#//Attribute"> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleUML.ecore#//Attribute/owner"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Attribute/type"/> + </genClasses> + <genClasses ecoreClass="SimpleUML.ecore#//Association"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Association/destination"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Association/source"/> + </genClasses> + <genClasses ecoreClass="SimpleUML.ecore#//Class"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Class/attributes"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Class/forward"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Class/general"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Class/generalOpposite"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Class/reverse"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleUML.ecore#//Classifier"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Classifier/typeOpposite"/> + </genClasses> + <genClasses ecoreClass="SimpleUML.ecore#//Package"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleUML.ecore#//Package/elements"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleUML.ecore#//PackageElement"> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleUML.ecore#//PackageElement/namespace"/> + </genClasses> + <genClasses ecoreClass="SimpleUML.ecore#//PrimitiveDataType"/> + <genClasses image="false" ecoreClass="SimpleUML.ecore#//UMLModelElement"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleUML.ecore#//UMLModelElement/kind"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleUML.ecore#//UMLModelElement/name"/> + </genClasses> + </genPackages> + <genPackages prefix="Simplerdbms" basePackage="org.eclipse.qvtd.examples.qvtcore.uml2rdbms" + disposableProviderFactory="true" ecorePackage="SimpleRDBMS.ecore#/"> + <genDataTypes ecoreDataType="SimpleRDBMS.ecore#//String"/> + <genClasses ecoreClass="SimpleRDBMS.ecore#//Column"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleRDBMS.ecore#//Column/type"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Column/owner"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Column/foreignKeys"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Column/keys"/> + </genClasses> + <genClasses ecoreClass="SimpleRDBMS.ecore#//ForeignKey"> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//ForeignKey/refersTo"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//ForeignKey/columns"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//ForeignKey/owner"/> + </genClasses> + <genClasses ecoreClass="SimpleRDBMS.ecore#//Key"> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Key/owner"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Key/column"/> + </genClasses> + <genClasses image="false" ecoreClass="SimpleRDBMS.ecore#//RModelElement"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleRDBMS.ecore#//RModelElement/name"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute SimpleRDBMS.ecore#//RModelElement/kind"/> + </genClasses> + <genClasses ecoreClass="SimpleRDBMS.ecore#//Schema"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Schema/tables"/> + </genClasses> + <genClasses ecoreClass="SimpleRDBMS.ecore#//Table"> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Table/columns"/> + <genFeatures property="None" notify="false" createChild="false" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Table/schema"/> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Table/keys"/> + <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference SimpleRDBMS.ecore#//Table/foreignKeys"/> + </genClasses> + </genPackages> +</genmodel:GenModel> diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.qvtc b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.qvtc new file mode 100644 index 000000000..136a97562 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUML2RDBMS.qvtc @@ -0,0 +1,558 @@ +import SimpleUML : 'SimpleUML.ecore#/'; +import SimpleRDBMS : 'SimpleRDBMS.ecore#/'; +import SimpleUML2RDBMS : 'SimpleUML2RDBMS.ecore#/'; + +transformation umlRdbms +{ + uml imports simpleuml; + rdbms imports simplerdbms; + imports simpleuml2rdbms; +} +/* + * -- Package and Schema mapping + * class PackageToSchema { + * composite classesToTables : Set(ClassToTable) opposites owner; + * composite primitivesToNames : Set(PrimitiveToName) opposites owner; + * name : String; + * -- uml + * umlPackage : Package; + * -- rdbms + * schema : Schema; + * } + */ + +map packageToSchema in umlRdbms +{ + uml() { + p : Package + |} + + enforce rdbms() { + realize s : Schema + |} + + where() { + realize p2s : SimpleUML2RDBMS::PackageToSchema + | + p2s.umlPackage := p; + p2s.schema := s; + } + + map + { + + where() { + p2s.name := p.name; + p2s.name := s.name; + p.name := p2s.name; + s.name := p2s.name; + } + } +} +/* + * -- Primitive data type marshaling + * class PrimitiveToName { + * owner : PackageToSchema opposites primitivesToNames; + * name : String; + * -- uml + * primitive : PrimitiveDataType; + * -- rdbms + * typeName : String; + * } + */ + +map primitiveToName in umlRdbms +{ + uml(p : Package + |) { + prim : PrimitiveDataType + | + prim.namespace = p; + } + check enforce rdbms() { + sqlType : String + |} + + where(p2s : SimpleUML2RDBMS::PackageToSchema + | + p2s.umlPackage = p;) { + realize p2n : SimpleUML2RDBMS::PrimitiveToName + | + p2n.owner := p2s; + p2n.primitive := prim; + p2n.typeName := sqlType; + } +} + +map integerToNumber in umlRdbms refines primitiveToName +{ + uml() { + prim.name = 'Integer'; + } + check enforce rdbms() { + sqlType := 'NUMBER'; + } + + where() { + realize p2n : SimpleUML2RDBMS::IntegerToNumber + |} + + map + { + + where() { + p2n.name := prim.name + '2' + 'NUMBER'; + } + } +} + +map booleanToBoolean in umlRdbms refines primitiveToName +{ + uml() { + prim.name = 'Boolean'; + } + check enforce rdbms() { + sqlType := 'BOOLEAN'; + } + + where() { + realize p2n : SimpleUML2RDBMS::BooleanToBoolean + |} + + map + { + + where() { + p2n.name := prim.name + '2' + 'BOOLEAN'; + } + } +} + +map stringToVarchar in umlRdbms refines primitiveToName +{ + uml() { + prim.name = 'String'; + } + check enforce rdbms() { + sqlType := 'VARCHAR'; + } + + where() { + realize p2n : SimpleUML2RDBMS::StringToVarchar + |} + + map + { + + where() { + p2n.name := prim.name + '2' + 'VARCHAR'; + } + } +} + +map flattening in umlRdbms +{ + + where() {} +} +/* + * query umlRdbms::getAllSupers(cls : SimpleUML::Class) : Set(SimpleUML::Class) { + * cls.general->collect(gen | getAllSupers(gen))->including(cls)->asSet() + * } + * + * query umlRdbms::getAllAttributes(cls : SimpleUML::Class) : Set( SimpleUML::Attribute) { + * getAllSupers(cls)->collect(c | c.attributes) + * } + * + * query umlRdbms::getAllForwards(cls : SimpleUML::Class) : Set( SimpleUML::Association) { + * getAllSupers(cls)->collect(c | true) + * } + */ +/* + * -- Class and Table mapping + * class ClassToTable extends FromAttributeOwner, ToColumn { + * owner : PackageToSchema opposites classesToTables; + * composite associationToForeignKeys : + * OrderedSet(AssociationToForeignKey) opposites owner; + * name : String; + * -- uml + * umlClass : Class; + * -- rdbms + * table : Table; + * primaryKey : Key; + * } + */ + +map classToTable in umlRdbms +{ + check enforce uml(p : Package + |) { + realize c : Class + | + c.kind := 'persistent'; + c.namespace := p; + } + + check enforce rdbms(s : Schema + |) { + realize t : Table + | + default t.kind := 'base'; + t.schema := s; + t.kind <> 'meta'; + } + + where(p2s : SimpleUML2RDBMS::PackageToSchema + | + p2s.umlPackage = p; + p2s.schema = s;) { + realize c2t : SimpleUML2RDBMS::ClassToTable + | + c2t.owner := p2s; + c2t.umlClass := c; + c2t.table := t; + } + + map + { + + where() { + c2t.name := c.name; + c2t.name := t.name; + c.name := c2t.name; + t.name := c2t.name; + } + } + + map + { + check enforce rdbms() { + realize pk : Key, + realize pc : Column + | + pk.owner := t; + pk.kind := 'primary'; + pc.owner := t; + default pc.keys := Set(SimpleRDBMS::Key){pk}; + default pc.type := 'NUMBER'; + pc.keys->includes(pk); + } + + where() { + c2t.primaryKey := pk; + c2t.column := pc; + } + + map + { + check enforce rdbms() { + pc.name := t.name + '_tid'; + pk.name := t.name + '_pk'; + } + + where() {} + } + } +} +/* + * -- Association and ForeignKey mapping + * class AssociationToForeignKey extends ToColumn { + * referenced : ClassToTable; + * owner : ClassToTable opposites associationToForeignKeys; + * name : String; + * -- uml + * association : Association; + * -- rdbms + * foreignKey : ForeignKey; + * } + */ + +map associationToForeignKey in umlRdbms refines flattening +{ + check enforce uml(p : Package, + sc : Class, + dc : Class + | + sc.namespace = p;) { + realize a : Association + | + default a.source := sc; + default a.destination := dc; + default a.namespace := p; + } + check enforce rdbms(s : Schema, + st : Table, + dt : Table, + rk : Key + | + st.schema = s; + rk.owner = dt; + rk.kind = 'primary';) { + realize fk : ForeignKey, + realize fc : Column + | + fk.owner := st; + fc.owner := st; + fk.refersTo := rk; + default fc.foreignKeys := Set(SimpleRDBMS::ForeignKey){fk}; + fc.foreignKeys->includes(fk); + } + + where(p2s : SimpleUML2RDBMS::PackageToSchema, + sc2t : SimpleUML2RDBMS::ClassToTable, + dc2t : SimpleUML2RDBMS::ClassToTable + | + sc2t.owner = p2s; + p2s.umlPackage = p; + p2s.schema = s; + sc2t.table = st; + dc2t.table = dt; + sc2t.umlClass = sc; + dc2t.umlClass = dc;) { + realize a2f : SimpleUML2RDBMS::AssociationToForeignKey + | + a2f.owner := sc2t; + a2f.referenced := dc2t; + a2f.association := a; + a2f.foreignKey := fk; + a2f.column := fc; + } + + map + { + + where() { + a2f.name := if a.destination = dc and a.source = sc then a.name + else if a.destination <> dc and a.source = sc then dc.name + '_' + a.name else if + a.destination = dc and a.source <> sc then a.name + '_' + sc.name else dc.name + '_' + a.name + '_' + sc.name + endif endif endif; + a.name := if a.destination = dc and a.source = sc then a2f.name + else a.name + endif; + fk.name := a2f.name; + a2f.name := fk.name; + fc.name := a2f.name + '_tid'; + } + } + + map + { + + where() { + fc.type := rk.column->first().type; + } + } +} +/* + * -- attribute mapping + * abstract class FromAttributeOwner { + * composite fromAttributes : Set(FromAttribute) opposites owner; + * } + * abstract class FromAttribute { + * name : String; + * kind : String; + * owner : FromAttributeOwner opposites fromAttributes; + * leafs : Set(AttributeToColumn); + * -- uml + * attribute : Attribute; + * } + * abstract class ToColumn { + * -- rdbms + * column : Column; + * } + * class NonLeafAttribute extends FromAttributeOwner, FromAttribute { + * leafs := fromAttributes.leafs; + * } + * class AttributeToColumn extends FromAttribute, ToColumn { + * type : PrimitiveToName; + * } + */ + +map attributes in umlRdbms refines flattening +{ + check enforce uml(c : Class + |) { + realize a : Attribute + | + default a.owner := c; + } + + where(fao : SimpleUML2RDBMS::FromAttributeOwner + |) { + realize fa : SimpleUML2RDBMS::FromAttribute + | + fa.attribute := a; + fa.owner := fao; + } + + map + { + + where() { + fa.kind := a.kind; + a.kind := fa.kind; + } + } +} + +map classAttributes in umlRdbms refines attributes +{ + + where(fao : SimpleUML2RDBMS::ClassToTable + | + fao.umlClass = c;) {} + + map + { + + where() { + fa.name := a.name; + a.name := fa.name; + } + } +} + +map primitiveAttribute in umlRdbms refines attributes +{ + check enforce uml(t : PrimitiveDataType + |) { + a.type := t; + } + + where(p2n : SimpleUML2RDBMS::PrimitiveToName + | + p2n.primitive = t;) { + realize fa : SimpleUML2RDBMS::AttributeToColumn + | + fa.type := p2n; + } + + map + { + + where() { + fa.leafs := Set(SimpleUML2RDBMS::AttributeToColumn){fa}; + } + } +} + +map complexAttributeAttributes in umlRdbms refines attributes +{ + check uml(ca : Attribute + | + ca.type = c;) {} + + where(fao : SimpleUML2RDBMS::NonLeafAttribute + | + fao.attribute = ca;) {} + + map + { + + where() { + fa.name := fao.name + '_' + a.name; + } + } +} + +map complexAttribute in umlRdbms refines attributes +{ + check uml(t : Class + |) { + a.type = t; + } + + where() { + realize fa : SimpleUML2RDBMS::NonLeafAttribute + |} + + map + { + + where() { + fa.leafs := fao.fromAttributes.leafs; + } + } +} + +map classPrimitiveAttributes in umlRdbms refines classAttributes , primitiveAttribute +{ + + where() {} +} + +map classComplexAttributes in umlRdbms refines classAttributes , complexAttribute +{ + + where() {} +} + +map complexAttributePrimitiveAttributes in umlRdbms refines complexAttributeAttributes , primitiveAttribute +{ + + where() {} +} + +map complexAttributeComplexAttributes in umlRdbms refines complexAttributeAttributes , complexAttribute +{ + + where() {} +} +/* + * -- column mapping + */ + +map attributeColumns in umlRdbms +{ + check enforce rdbms(t : Table + |) { + realize c : Column + | + c.owner := t; + c.keys->size() = 0; + c.foreignKeys->size() = 0; + } + + where(c2t : SimpleUML2RDBMS::ClassToTable + | + c2t.table = t;) { + realize a2c : SimpleUML2RDBMS::AttributeToColumn + | + a2c.column := c; + default a2c.owner := c2t; + c2t.fromAttributes.leafs->includes(a2c); + } + + map + { + + where(p2n : SimpleUML2RDBMS::PrimitiveToName + |) { + ct : String + | + a2c.type := p2n; + ct := c.type; + ct := p2n.typeName; + p2n.typeName := ct; + c.type := ct; + } + } + + map + { + + where() { + c.name := a2c.name; + a2c.name := c.name; + } + } + + map + { + + where() { + c.kind := a2c.kind; + a2c.kind := c.kind; + } + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUMLPeople.xmi b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUMLPeople.xmi new file mode 100644 index 000000000..13609c830 --- /dev/null +++ b/examples/org.eclipse.qvtd.examples.qvtcore.uml2rdbms/src/org/eclipse/qvtd/examples/qvtcore/uml2rdbms/SimpleUMLPeople.xmi @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="ASCII"?> +<simpleuml:Package + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:simpleuml="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/simpleUML" + xsi:schemaLocation="http://www.eclipse.org/qvtd/examples/qvtcore/UML2RDBMS/1.0/simpleUML SimpleUML.ecore" + kind="" + name="People"> + <elements xsi:type="simpleuml:Class" kind="persistent" name="Address" reverse="//@elements.7"> + <attributes name="street" type="//@elements.12"/> + <attributes name="number" type="//@elements.12"/> + </elements> + <elements xsi:type="simpleuml:Class" kind="persistent" name="Budget" reverse="//@elements.6"> + <attributes name="year" type="//@elements.12"/> + <attributes name="budget" type="//@elements.11"/> + </elements> + <elements xsi:type="simpleuml:Class" kind="persistent" name="Professor" forward="//@elements.7 //@elements.8"> + <attributes name="employed" type="//@elements.10"/> + <attributes name="name" type="//@elements.12"/> + </elements> + <elements xsi:type="simpleuml:Class" kind="persistent" name="ResearchGroup" forward="//@elements.6" reverse="//@elements.8"> + <attributes name="name" type="//@elements.12"/> + </elements> + <elements xsi:type="simpleuml:Class" kind="persistent" name="Student" forward="//@elements.9"> + <attributes name="guardian" type="//@elements.12"/> + <attributes name="name" type="//@elements.12"/> + <attributes name="studentNumber" type="//@elements.11"/> + </elements> + <elements xsi:type="simpleuml:Class" kind="persistent" name="Timetable" reverse="//@elements.9"> + <attributes name="year" type="//@elements.12"/> + </elements> + <elements xsi:type="simpleuml:Association" name="groupBudget" destination="//@elements.1" source="//@elements.3"/> + <elements xsi:type="simpleuml:Association" kind="" name="professorLivesAt" destination="//@elements.0" source="//@elements.2"/> + <elements xsi:type="simpleuml:Association" name="professorGroup" destination="//@elements.3" source="//@elements.2"/> + <elements xsi:type="simpleuml:Association" kind="" name="studentTimetable" destination="//@elements.5" source="//@elements.4"/> + <elements xsi:type="simpleuml:PrimitiveDataType" name="Boolean" typeOpposite="//@elements.2/@attributes.0"/> + <elements xsi:type="simpleuml:PrimitiveDataType" name="Integer" typeOpposite="//@elements.4/@attributes.2 //@elements.1/@attributes.1"/> + <elements xsi:type="simpleuml:PrimitiveDataType" name="String" typeOpposite="//@elements.4/@attributes.1 //@elements.4/@attributes.0 //@elements.2/@attributes.1 //@elements.5/@attributes.0 //@elements.3/@attributes.0 //@elements.1/@attributes.0 //@elements.0/@attributes.0 //@elements.0/@attributes.1"/> +</simpleuml:Package> |