use of eu.esdihumboldt.hale.common.align.merge.impl.MatchingMigration in project hale by halestudio.
the class AbstractMergeCellMigratorTest method mergeWithMigrator.
/**
* Perform merging using a specific merge migrator.
*
* @param migrator the migrator to test, <code>null</code> if the migrator
* configured in the system should be used
* @param cellToMigrate the cell to migrate
* @param matchingProject the project providing the matching information
* @return the merge result
*/
protected List<MutableCell> mergeWithMigrator(MergeCellMigrator migrator, Cell cellToMigrate, ProjectTransformationEnvironment matchingProject) {
MergeIndex mergeIndex = new TargetIndex(matchingProject.getAlignment());
AlignmentMigration migration = new MatchingMigration(matchingProject, true);
List<MutableCell> cells = new ArrayList<>();
if (migrator == null) {
try {
migrator = MigratorExtension.getInstance().getMigrator(cellToMigrate.getTransformationIdentifier()).orElse(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (migrator == null) {
CellMigrator mig = getCellMigrator(cellToMigrate.getTransformationIdentifier());
if (mig instanceof MergeCellMigrator) {
migrator = (MergeCellMigrator) mig;
} else if (mig == null) {
throw new IllegalStateException("No cell migrator could be retrieved");
} else {
// perform migration with "ordinary" CellMigrator
MigrationOptions options = new MigrationOptions() {
@Override
public boolean updateTarget() {
return false;
}
@Override
public boolean updateSource() {
return true;
}
@Override
public boolean transferBase() {
return false;
}
};
cells.add(mig.updateCell(cellToMigrate, migration, options, SimpleLog.CONSOLE_LOG));
}
}
if (migrator != null) {
// perform merge with MergeCellMigrator
Iterable<MutableCell> result = migrator.mergeCell(cellToMigrate, mergeIndex, migration, this::getCellMigrator, SimpleLog.CONSOLE_LOG);
Iterables.addAll(cells, result);
}
return cells;
}
Aggregations