Skip to content

Commit

Permalink
Updated names
Browse files Browse the repository at this point in the history
  • Loading branch information
suarezgpablo committed Dec 13, 2024
1 parent 34f1414 commit 7740c55
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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="SchemaEvolution" xsi:schemaLocation="SchemaEvolution ../../src/main/java/giis/modevo/transformations/atl/Metamodels/SchemaEvolution.ecore">
<NewColumn xmi:id="a1" tab="a2"/>
<NewColumn xmi:id="a1" table="table2" columns="a3"/>
<Table xmi:id="a2" cols="a3" name="table2"/>
<Column xmi:id="a3" name="title" tab="a2" nameAttribute = "title" nameEntity = "Book"/>
</xmi:XMI>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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="SchemaEvolution" xsi:schemaLocation="SchemaEvolution ../../src/main/java/giis/modevo/transformations/atl/Metamodels/SchemaEvolution.ecore">
<NewColumn xmi:id="a1" tab="a2"/>
<NewColumn xmi:id="a1" table="table2" columns = "a3 a4"/>
<Table xmi:id="a2" cols="a3 a4" name="table2"/>
<Column xmi:id="a3" name="title" tab="a2" nameAttribute = "title" nameEntity = "Book"/>
<Column xmi:id="a4" name="publisher" tab="a2" nameAttribute = "publisher" nameEntity = "Book"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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="SchemaEvolution" xsi:schemaLocation="SchemaEvolution ../../src/main/java/giis/modevo/transformations/atl/Metamodels/SchemaEvolution.ecore">
<NewColumn xmi:id="a1" tab="a2"/>
<NewColumn xmi:id="a1" table="table2" columns="a3 a4"/>
<Table xmi:id="a2" cols="a3 a4" name="table2" NewTableName="table2New" isNew="true"/>
<Column xmi:id="a3" name="title" tab="a2" nameAttribute = "title" nameEntity = "Book"/>
<Column xmi:id="a4" name="idBook" tab="a2" nameAttribute = "id" nameEntity = "Book" key ="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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="SchemaEvolution" xsi:schemaLocation="SchemaEvolution ../../src/main/java/giis/modevo/transformations/atl/Metamodels/SchemaEvolution.ecore">
<NewColumn xmi:id="a1" tab="a2"/>
<NewColumn xmi:id="a1" table="entity_view" columns ="a3"/>
<Table xmi:id="a2" cols="a3" name="entity_view"/>
<Column xmi:id="a3" name="dev_type" tab="a2" nameAttribute = "dev_type" nameEntity = "device"/>
</xmi:XMI>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?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="SchemaEvolution" xsi:schemaLocation="SchemaEvolution ../../src/main/java/giis/modevo/transformations/atl/Metamodels/SchemaEvolution.ecore">
<NewColumn xmi:id="a1"
tab="a2"/>
<NewColumn xmi:id="a1" table="entity_view2_old" columns="a3"/>
<Table xmi:id="a2"
cols="a3"
name="entity_view2_old"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="SchemaEvolution" xsi:schemaLocation="SchemaEvolution ../../src/main/java/giis/modevo/transformations/atl/Metamodels/SchemaEvolution.ecore">

<NewColumn xmi:id="a1"
tab="a2"/>
table="entity_view_devpk" columns="a3"/>
<Table xmi:id="a2"
name="entity_view_devpk" cols="a3">
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ public AddColumn(Column c, Table t) {
@Override
protected List<SchemaChange> changesSchemaModel (NodeList list, Element element) {
List<SchemaChange> changes = new ArrayList<>();
String idTable = element.getAttribute("tab");
Element table = getElementById(list, idTable);
if (table == null) {
throw new DocumentException(messageIdMissing(idTable));
}
Table t = new Table(table.getAttribute("name"));
String idColumns = table.getAttribute("cols");
String nameTable = element.getAttribute("table");
Table t = new Table(nameTable);
String idColumns = element.getAttribute("columns");
String[] columnsArray = idColumns.split(" ");
for (String c : columnsArray) {
Element column = getElementById(list, c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<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="SchemaEvolution">
<eClassifiers xsi:type="ecore:EClass" name="NewColumn">
<eStructuralFeatures xsi:type="ecore:EReference" name="tab" upperBound="-1" eType="#//Table"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="columns" upperBound="-1"
eType="#//Column"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="table" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Table">
<eStructuralFeatures xsi:type="ecore:EReference" name="cols" lowerBound="1" upperBound="-1"
Expand All @@ -20,10 +20,12 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="nameEntity" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="RemoveColumn">
<eStructuralFeatures xsi:type="ecore:EReference" name="col" upperBound="-1" eType="#//Column"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="column" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="table" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AddPk">
<eStructuralFeatures xsi:type="ecore:EReference" name="tab" upperBound="-1" eType="#//Table"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="column" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="table" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="NewTable">
<eStructuralFeatures xsi:type="ecore:EReference" name="tab" lowerBound="1" eType="#//Table"/>
Expand Down Expand Up @@ -65,7 +67,7 @@
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="RemoveTable">
<eStructuralFeatures xsi:type="ecore:EReference" name="remove" eType="#//Table"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="table" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="CriteriaSplit">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ rule newColumn {
r: SchemaEvolution!NewColumn
to
add: DataMigration!MigrationTable ( --for the moment, it creates a MigrationTable to define the data migration. In the future this will change in order to consider migrations for more than column
name <- r.tab.first().name, --there will only be one table for the moment
migcol <- r.tab.first().cols -> collect (c | thisModule.MigCol(c)) --call the lazy rule to define the table to create
name <- r.table, --there will only be one table for the moment
migcol <- r.columns -> collect (c | thisModule.MigCol(c, r.table)) --call the lazy rule to define the table to create
)
}

---Details migration for a single column that has been added to a new table
lazy rule MigCol {
from
r: SchemaEvolution!Column
r: SchemaEvolution!Column,
nameTable: String
using {
keyColumnToColumn : Sequence (Schema!Column) = thisModule.typeKey (r.tab.tableFromLM().Column, thisModule.extractEntityByName (r.nameEntity), r.tab.tableFromLM());
keyColumnToColumn : Sequence (Schema!Column) = thisModule.typeKey (thisModule.findTable(nameTable).Column, thisModule.extractEntityByName (r.nameEntity), thisModule.findTable(nameTable));
--first table that contains the data to be migrated is obtained by also requiring that the key column from keyColumnToColumn are obtained. Gets data column. Finished code
MigrateFromVariable : Schema!Column = Schema!Column.allInstancesFrom('LM')
->select (c | c.nameAttribute = r.nameAttribute and c.nameEntity = r.nameEntity and thisModule.keyInTable(c.tableColumn, keyColumnToColumn)).first();
--Gets key columns
colKeyFromVariable: Sequence (Schema!Column) = MigrateFromVariable.tableColumn.Column -> select (c | c.equivalentColumnInSequenceTables(keyColumnToColumn));

ascendantsUsed : Boolean = thisModule.ascendentsUsed (r.tab.tableFromLM().Column, thisModule.extractEntityByName (r.nameEntity), r.tab.tableFromLM());
ascendantsUsed : Boolean = thisModule.ascendentsUsed (thisModule.findTable(nameTable).Column, thisModule.extractEntityByName (r.nameEntity), thisModule.findTable(nameTable));
}
to
add: DataMigration!MigrationCol ( --for each new column
Expand Down Expand Up @@ -142,3 +143,7 @@ helper def: keyAttributesFunction (entities: Sequence (ConceptualModel!Entity)):
helper def: keyAttributesFunctionOneEntity (entity: ConceptualModel!Entity): Sequence (ConceptualModel!Attribute) =
ConceptualModel!Attribute.allInstancesFrom('CM') -> select (a | entity = a.entity and a.isUnique);

---Obtains equivalent Table in the Schema model
helper def: findTable (name : String): Schema!Table =
Schema!Table.allInstancesFrom('LM') -> any (t | t.name = name);

Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ helper context Schema!Table def: ascendantsEntityInTable (e: ConceptualModel!Ent

---Obtains the key columns of a given table.
helper def: keyColumnsNewTable (table : SchemaEvolution!Table): Sequence (SchemaEvolution!Column) =
table.cols -> select (c | c.key and c.existsInOtherTable());--The second condition is to not count new columns that are also new attributes. In these cases the datamigration model will warn the user about this issue.

table.cols -> select (c | c.key and c.existsInOtherTable());--The second condition is to not count new columns that are also new attributes. In these cases the datamigration model will warn the user about this issue.

0 comments on commit 7740c55

Please sign in to comment.