Skip to content

Commit

Permalink
Updated names JoinColumn and JoinTable to MergeColumn and MergeTable
Browse files Browse the repository at this point in the history
  • Loading branch information
suarezgpablo committed Dec 2, 2024
1 parent 2ab7154 commit b0fa673
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import giis.modevo.model.schema.Schema;
import giis.modevo.model.schema.Table;
import giis.modevo.model.schemaevolution.CriteriaSplit;
import giis.modevo.model.schemaevolution.JoinColumn;
import giis.modevo.model.schemaevolution.MergeColumn;
import giis.modevo.model.schemaevolution.SchemaChange;
import giis.modevo.model.schemaevolution.SchemaEvolution;
import giis.modevo.model.schemaevolution.SplitColumn;
Expand Down Expand Up @@ -83,7 +83,7 @@ private Script migrationJoinColumn(Schema schema, SchemaEvolution se, MigrationT
log.info("Join Column Script. Target table: %s", mt.getName());
Script script = new Script ();
for (SchemaChange sc : se.getChanges()) {
if (sc instanceof JoinColumn spc) {
if (sc instanceof MergeColumn spc) {
List<Column> sourceColumns = spc.getSourceColumns();
Column newColumn = spc.getC();
Table t = schema.getTable(mt.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="DataMigration">
<MigrationTable name="table1" joincol="/1"/>
<JoinColumn ColTarget="completetitle" ColSource="title , subtitle"/>
<MergeColumn ColTarget="completetitle" ColSource="title , subtitle"/>
</xmi:XMI>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?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">
<JoinTable xmi:id="a1" tableSource="table1" tableTarget="table2" newTableName="table2new"/>
<MergeTable xmi:id="a1" tableSource="table1" tableTarget="table2" newTableName="table2new"/>
</xmi:XMI>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?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">
<JoinTable xmi:id="a1" tableSource="table1" tableTarget="table2"/>
<MergeTable xmi:id="a1" tableSource="table1" tableTarget="table2"/>
</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">
<JoinColumn
<MergeColumn
xmi:id="a1"
table="table1" targetColumn="c3" sourceColumns="c1 c2"/>
<Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import giis.modevo.model.schemaevolution.AddColumn;
import giis.modevo.model.schemaevolution.AddTable;
import giis.modevo.model.schemaevolution.CopyTable;
import giis.modevo.model.schemaevolution.JoinColumn;
import giis.modevo.model.schemaevolution.JoinTable;
import giis.modevo.model.schemaevolution.MergeColumn;
import giis.modevo.model.schemaevolution.MergeTable;
import giis.modevo.model.schemaevolution.SchemaChange;
import giis.modevo.model.schemaevolution.SchemaEvolution;
import giis.modevo.model.schemaevolution.SplitColumn;
Expand Down Expand Up @@ -168,10 +168,10 @@ private boolean foundAndTrue(SchemaChange change, String nameCol) {
if (column.getName().equalsIgnoreCase(nameCol)) {
return column.isCk() || column.isPk();
}
} else if (change instanceof AddTable || change instanceof SplitColumn || change instanceof JoinColumn) {
} else if (change instanceof AddTable || change instanceof SplitColumn || change instanceof MergeColumn) {
column = change.getT().getColumn(nameCol);
checkColumnKey(column);
} else if (change instanceof JoinTable joinTableChange) {
} else if (change instanceof MergeTable joinTableChange) {
Table t = joinTableChange.getNewTable();
column = t.getColumn(nameCol);
checkColumnKey(column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Map;

import giis.modevo.model.schema.Schema;
import giis.modevo.model.schemaevolution.JoinColumn;
import giis.modevo.model.schemaevolution.MergeColumn;
import giis.modevo.model.schemaevolution.RemovePK;
import giis.modevo.model.schemaevolution.SchemaChange;
import giis.modevo.model.schemaevolution.SchemaEvolution;
Expand Down Expand Up @@ -140,7 +140,7 @@ public boolean migrationSplitColumn(SchemaEvolution se) {
}
public boolean migrationJoinColumn(SchemaEvolution se) {
for (SchemaChange sc : se.getChanges()) {
if (sc instanceof JoinColumn) {
if (sc instanceof MergeColumn) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* Subclass of SchemaChange to define the join of two or more columns into one.
*/
@Getter @Setter
public class JoinColumn extends SchemaChange {
public class MergeColumn extends SchemaChange {
private List<Column> sourceColumns;
private String criteria; //criteria to join the column

public JoinColumn() {
public MergeColumn() {
}

public JoinColumn(Column c, Table t, String criteria) {
public MergeColumn(Column c, Table t, String criteria) {
super(c, t);
setSourceColumns(new ArrayList<>());
this.setCriteria(criteria);
Expand All @@ -44,7 +44,7 @@ protected List<SchemaChange> changesSchemaModel (NodeList list, Node node) {
}
Column c = columnFromModelToObject(elementColumnSource, source);
String criteriaString = elementCopy.getAttribute("criteria");
JoinColumn jt = new JoinColumn(c, source, criteriaString);
MergeColumn jt = new MergeColumn(c, source, criteriaString);
String[] columnsIdArray = idsSourceColumns.split(" ");
for (String id : columnsIdArray) {
Element column = getElementById(list, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* Subclass of SchemaChange to define two tables to be joined.
*/
@Getter @Setter
public class JoinTable extends SchemaChange {
public class MergeTable extends SchemaChange {

private Table originalTable;
private Table newTable;

public JoinTable() {
public MergeTable() {
}

public JoinTable(Table originalTable, Table newTable) {
public MergeTable(Table originalTable, Table newTable) {
super(originalTable);
this.setOriginalTable(originalTable);
this.setNewTable(newTable);
Expand All @@ -36,7 +36,7 @@ protected List<SchemaChange> changesSchemaModel (Node node) {
String target = elementSplit.getAttribute("tableTarget");
Table tableSource = new Table(source);
Table tableTarget = new Table(target);
JoinTable jt = new JoinTable(tableSource, tableTarget);
MergeTable jt = new MergeTable(tableSource, tableTarget);
changes.add(jt);
return changes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ public SchemaEvolution readSchemaEvolutionModel(String pathSchemaEvolutionModel)
} else if (nameElement.equalsIgnoreCase("SplitColumn")) {
log.info ("New Split Column schema modification");
se.getChanges().addAll(new SplitColumn().changesSchemaModel(list, node));
} else if (nameElement.equalsIgnoreCase("JoinTable")) {
} else if (nameElement.equalsIgnoreCase("MergeTable")) {
log.info ("New Join Table schema modification");
se.getChanges().addAll(new JoinTable().changesSchemaModel(node));
se.getChanges().addAll(new MergeTable().changesSchemaModel(node));
} else if (nameElement.equalsIgnoreCase("CopyTable")) {
log.info ("New Copy Table schema modification");
se.getChanges().addAll(new CopyTable().changesSchemaModel(list, node));
} else if (nameElement.equalsIgnoreCase("SplitTable")) {
log.info ("New Split Table schema modification");
se.getChanges().addAll(new SplitTable().changesSchemaModel(list, node));
} else if (nameElement.equalsIgnoreCase("JoinColumn")) {
} else if (nameElement.equalsIgnoreCase("MergeColumn")) {
log.info ("New Join Column schema modification");
se.getChanges().addAll(new JoinColumn().changesSchemaModel(list, node));
se.getChanges().addAll(new MergeColumn().changesSchemaModel(list, node));
} else if (nameElement.equalsIgnoreCase("RemovePK")) {
log.info ("New Remove PK schema modification");
se.getChanges().addAll(new RemovePK().changesSchemaModel(node));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ public void launchTransformations(IProgressMonitor monitor) {
launcher.addLibrary("f", getLibraryAsStream("SchemaTable"));
launcher.addLibrary("g", getLibraryAsStream("NewColumn"));
launcher.addLibrary("h", getLibraryAsStream("NewTable"));
launcher.addLibrary("i", getLibraryAsStream("JoinTable"));
launcher.addLibrary("i", getLibraryAsStream("MergeTable"));
launcher.addLibrary("j", getLibraryAsStream("SplitColumn"));
launcher.addLibrary("k", getLibraryAsStream("SplitTable"));
launcher.addLibrary("l", getLibraryAsStream("CopyTable"));
launcher.addLibrary("m", getLibraryAsStream("JoinColumn"));
launcher.addLibrary("m", getLibraryAsStream("MergeColumn"));
launcher.addLibrary("n", getLibraryAsStream("RemovePK"));

} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module JoinColumn;
module MergeColumn;
create OUT: DataMigration from LM:Schema, CM:ConceptualModel, CH:SchemaEvolution;

rule JoinColumn {
rule MergeColumn {
from
j: SchemaEvolution!JoinColumn
j: SchemaEvolution!MergeColumn
to
add: DataMigration!MigrationTable(
name<- j.table,
joincol <- thisModule.JoinColumnMigCol(j)
joincol <- thisModule.MergeColumnMigCol(j)
)
}
---Lazy rule that creates a Migration Column class particularly specialized for a Join column schema modification
lazy rule JoinColumnMigCol {
lazy rule MergeColumnMigCol {
from
j: SchemaEvolution!JoinColumn
j: SchemaEvolution!MergeColumn
to
add: DataMigration!JoinColumn (
add: DataMigration!MergeColumn (
ColTarget <- j.targetColumn.name,
ColSource <- thisModule.getNamesColumn (j.sourceColumns)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module JoinTable;
module MergeTable;
create OUT: DataMigration from LM:Schema, CM:ConceptualModel, CH:SchemaEvolution;

---Rule for joining two tables
rule joinTable {
rule mergeTable {
from
j: SchemaEvolution!JoinTable
j: SchemaEvolution!MergeTable
using{
tableTarget: Schema!Table = Schema!Table.allInstancesFrom('LM') --Main table to get the data is the previous version
->any (t | t.name = j.tableTarget);
Expand All @@ -18,34 +18,34 @@ rule joinTable {
to
d: DataMigration!MigrationTable(
name<- j.tableTarget,
migcol <- columnsInOnlySourceTable -> collect (c | thisModule.columnMigColJoin(c, columnsInBothTablesTarget, tableTarget, j))
migcol <- columnsInOnlySourceTable -> collect (c | thisModule.columnMigColMerge(c, columnsInBothTablesTarget, tableTarget, j))
)
}

---Details migration for a single column that has been added to a new table
lazy rule columnMigColJoin {
lazy rule columnMigColMerge {
from
column: Schema!Column,
colPotentialKey: Sequence (Schema!Column),
tableTarget: Schema!Table,
j: SchemaEvolution!JoinTable
j: SchemaEvolution!MergeTable

using {
keyColumnToColumn : Sequence (Schema!Column) = thisModule.typeKey (colPotentialKey, thisModule.extractEntityByName (column.nameEntity), tableTarget);
}
to
add: DataMigration!MigrationCol ( --for each new column
MigrateTo <- thisModule.columnToJoinTable (keyColumnToColumn, column, j),
MigrateTo <- thisModule.columnToMergeTable (keyColumnToColumn, column, j),
MigrateFrom <- thisModule.columnFrom (keyColumnToColumn, column)
)
}

---Details the migration to a target column. This is rule is triggered when there is a new column added to an existing table
lazy rule columnToJoinTable {
lazy rule columnToMergeTable {
from
keysColumnFrom: Sequence (Schema!Column),
r: Schema!Column,
j: SchemaEvolution!JoinTable
j: SchemaEvolution!MergeTable
to
MigrateFrom: DataMigration!Target (
Data<- r.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="migcol" lowerBound="1"
upperBound="-1" eType="#//MigrationCol" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="joincol" eType="#//JoinColumn"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="joincol" eType="#//MergeColumn"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="MigrationCol">
<eStructuralFeatures xsi:type="ecore:EReference" name="MigrateTo" lowerBound="1" eType="#//Target"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="MigrateTo" lowerBound="1"
eType="#//Target" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="MigrateFrom" lowerBound="1"
eType="#//Source" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="migtab" lowerBound="1"
Expand All @@ -33,7 +33,7 @@
<eClassifiers xsi:type="ecore:EClass" name="ContainerMigrations">
<eStructuralFeatures xsi:type="ecore:EReference" name="migrations" eType="#//MigrationTable"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="JoinColumn">
<eClassifiers xsi:type="ecore:EClass" name="MergeColumn">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="ColTarget" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="ColSource" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="criteria" lowerBound="1"
upperBound="-1" eType="#//Column"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="JoinTable">
<eClassifiers xsi:type="ecore:EClass" name="MergeTable">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableSource" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableTarget" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="newTableName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
Expand All @@ -64,7 +64,7 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="resultingTables" lowerBound="1"
upperBound="-1" eType="#//Table"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="JoinColumn">
<eClassifiers xsi:type="ecore:EClass" name="MergeColumn">
<eStructuralFeatures xsi:type="ecore:EReference" name="targetColumn" lowerBound="1"
eType="#//Column"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="sourceColumns" lowerBound="2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ uses SchemaTable;
uses SplitColumn;
uses NewColumn;
uses NewTable;
uses JoinTable;
uses MergeTable;
uses CopyTable;
uses SplitTable;
uses JoinColumn;
uses MergeColumn;
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ MoDEvo.libraries.SchemaTable = helpers/SchemaTable.asm
MoDEvo.libraries.SplitColumn = SplitColumn.asm
MoDEvo.libraries.NewColumn = NewColumn.asm
MoDEvo.libraries.NewTable = NewTable.asm
MoDEvo.libraries.JoinTable = JoinTable.asm
MoDEvo.libraries.MergeTable = MergeTable.asm
MoDEvo.libraries.CopyTable = CopyTable.asm
MoDEvo.libraries.SplitTable = SplitTable.asm
MoDEvo.libraries.JoinColumn = JoinColumn.asm
MoDEvo.libraries.MergeColumn = MergeColumn.asm
MoDEvo.libraries.RemovePK = RemovePK.asm

# ATL Launching options
Expand Down

0 comments on commit b0fa673

Please sign in to comment.