Refactoring
This commit is contained in:
parent
c696d83ef8
commit
70c738c97e
@ -1,11 +1,4 @@
|
|||||||
import data.source.PersonSource;
|
|
||||||
import data.target.CharacterTarget;
|
|
||||||
import etl.*;
|
|
||||||
import migration.ThesisMigration;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import utils.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class Main
|
public class Main
|
||||||
{
|
{
|
||||||
@ -17,56 +10,4 @@ public class Main
|
|||||||
new ThesisMigration().executeMigrations();
|
new ThesisMigration().executeMigrations();
|
||||||
log.info("------------- Migration Finished -------------");
|
log.info("------------- Migration Finished -------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<PersonSource> testExtract()
|
|
||||||
{
|
|
||||||
final var dbInfo = new DatabaseInformation("localhost", "sourcedb1", "test", "test", 25003);
|
|
||||||
final var connection = new ConnectionHelper(DatabaseType.MARIADB, dbInfo).createConnection();
|
|
||||||
|
|
||||||
final DataStorer<PersonSource> personSourceDataStorer = (rs) -> {
|
|
||||||
final var persons = new ArrayList<PersonSource>();
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
persons.add(new PersonSource(
|
|
||||||
rs.getInt("personId"),
|
|
||||||
rs.getString("name"),
|
|
||||||
rs.getBoolean("mortal"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return persons;
|
|
||||||
};
|
|
||||||
|
|
||||||
final StatementPreparerExtractor statementPreparer = (preparedStatement) -> {
|
|
||||||
};
|
|
||||||
|
|
||||||
final var sql = "select * from person;";
|
|
||||||
|
|
||||||
return new Extractor<>(connection, personSourceDataStorer, statementPreparer, sql).doExtract();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<CharacterTarget> testTransform(final List<PersonSource> persons)
|
|
||||||
{
|
|
||||||
final DataTransformer<PersonSource, CharacterTarget> personTransformer =
|
|
||||||
(personSource) -> new CharacterTarget(personSource.getPersonId(),
|
|
||||||
personSource.getName(),
|
|
||||||
personSource.isMortal());
|
|
||||||
|
|
||||||
return new Transformer<>(personTransformer, persons).doTransform();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void testLoad(final List<CharacterTarget> transformedData)
|
|
||||||
{
|
|
||||||
final var dbInfo = new DatabaseInformation("localhost", "targetdb", "test", "test", 25001);
|
|
||||||
final var connection = new ConnectionHelper(DatabaseType.POSTGRESQL, dbInfo).createConnection();
|
|
||||||
|
|
||||||
final StatementPreparerLoader<CharacterTarget> statementPreparerLoader = (preparedStatement, data) -> {
|
|
||||||
preparedStatement.setInt(1, data.getPersonId());
|
|
||||||
preparedStatement.setString(2, data.getName());
|
|
||||||
preparedStatement.setBoolean(3, data.isMortal());
|
|
||||||
};
|
|
||||||
|
|
||||||
final var sql = "insert into person values (?, ?, ?)";
|
|
||||||
|
|
||||||
new Loader<>(connection, statementPreparerLoader, transformedData, sql).doLoad();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package migration;
|
import migration.*;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import utils.ConnectionHelper;
|
import utils.ConnectionHelper;
|
||||||
import utils.DatabaseInformation;
|
import utils.DatabaseInformation;
|
||||||
import utils.DatabaseType;
|
import utils.DatabaseType;
|
||||||
import utils.ETL;
|
import etl.ETL;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
@ -1,4 +1,4 @@
|
|||||||
package utils;
|
package etl;
|
||||||
|
|
||||||
import data.SourceDataset;
|
import data.SourceDataset;
|
||||||
import data.TargetDataset;
|
import data.TargetDataset;
|
@ -3,6 +3,7 @@ package migration;
|
|||||||
import com.mysql.cj.exceptions.NumberOutOfRange;
|
import com.mysql.cj.exceptions.NumberOutOfRange;
|
||||||
import data.source.AbilitiesSource;
|
import data.source.AbilitiesSource;
|
||||||
import data.target.AbilityTarget;
|
import data.target.AbilityTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -3,6 +3,7 @@ package migration;
|
|||||||
import com.mysql.cj.exceptions.NumberOutOfRange;
|
import com.mysql.cj.exceptions.NumberOutOfRange;
|
||||||
import data.source.ActiveQuestsSource;
|
import data.source.ActiveQuestsSource;
|
||||||
import data.target.ActiveQuestsTarget;
|
import data.target.ActiveQuestsTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -2,6 +2,7 @@ package migration;
|
|||||||
|
|
||||||
import data.source.PersonInventorySource;
|
import data.source.PersonInventorySource;
|
||||||
import data.target.CharacterInventoryTarget;
|
import data.target.CharacterInventoryTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -2,6 +2,7 @@ package migration;
|
|||||||
|
|
||||||
import data.source.PersonSource;
|
import data.source.PersonSource;
|
||||||
import data.target.CharacterTarget;
|
import data.target.CharacterTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -2,6 +2,7 @@ package migration;
|
|||||||
|
|
||||||
import data.source.GameobjectSource;
|
import data.source.GameobjectSource;
|
||||||
import data.target.GameobjectTarget;
|
import data.target.GameobjectTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -2,6 +2,7 @@ package migration;
|
|||||||
|
|
||||||
import data.source.InventorySource;
|
import data.source.InventorySource;
|
||||||
import data.target.InventoryTarget;
|
import data.target.InventoryTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -2,6 +2,7 @@ package migration;
|
|||||||
|
|
||||||
import data.source.ModSource;
|
import data.source.ModSource;
|
||||||
import data.target.ModTarget;
|
import data.target.ModTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -2,6 +2,7 @@ package migration;
|
|||||||
|
|
||||||
import data.source.PlayerAbilitiesSource;
|
import data.source.PlayerAbilitiesSource;
|
||||||
import data.target.PlayerAbilitiesTarget;
|
import data.target.PlayerAbilitiesTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
@ -51,7 +52,6 @@ public class PlayerAbilitiesMigration extends ETL<PlayerAbilitiesSource, PlayerA
|
|||||||
@Override
|
@Override
|
||||||
protected void load(final List<PlayerAbilitiesTarget> transformedData)
|
protected void load(final List<PlayerAbilitiesTarget> transformedData)
|
||||||
{
|
{
|
||||||
|
|
||||||
final StatementPreparerLoader<PlayerAbilitiesTarget> statementPreparerLoader = (preparedStatement, data) -> {
|
final StatementPreparerLoader<PlayerAbilitiesTarget> statementPreparerLoader = (preparedStatement, data) -> {
|
||||||
preparedStatement.setInt(1, data.getPlayerId());
|
preparedStatement.setInt(1, data.getPlayerId());
|
||||||
preparedStatement.setInt(2, data.getAbilityId());
|
preparedStatement.setInt(2, data.getAbilityId());
|
||||||
|
@ -3,7 +3,7 @@ package migration;
|
|||||||
import data.SourceDataset;
|
import data.SourceDataset;
|
||||||
import data.target.PlayerTarget;
|
import data.target.PlayerTarget;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import utils.ETL;
|
import etl.ETL;
|
||||||
import utils.StatementPreparerLoader;
|
import utils.StatementPreparerLoader;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package migration;
|
package migration;
|
||||||
|
|
||||||
import com.mysql.cj.jdbc.Clob;
|
|
||||||
import data.source.QuestSource;
|
import data.source.QuestSource;
|
||||||
import data.target.QuestTarget;
|
import data.target.QuestTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
@ -3,6 +3,7 @@ package migration;
|
|||||||
import com.mysql.cj.exceptions.NumberOutOfRange;
|
import com.mysql.cj.exceptions.NumberOutOfRange;
|
||||||
import data.source.RelationshipsSource;
|
import data.source.RelationshipsSource;
|
||||||
import data.target.RelationshipTarget;
|
import data.target.RelationshipTarget;
|
||||||
|
import etl.ETL;
|
||||||
import etl.Extractor;
|
import etl.Extractor;
|
||||||
import etl.Loader;
|
import etl.Loader;
|
||||||
import etl.Transformer;
|
import etl.Transformer;
|
||||||
|
Loading…
Reference in New Issue
Block a user