use of eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment in project hale by halestudio.
the class AlignmentServiceUndoSupport method clean.
/**
* @see AlignmentServiceDecorator#clean()
*/
@Override
public synchronized void clean() {
// XXX problem: what about cleans that should not be undone? e.g. when
// the schemas have changed
// XXX -> currently on project clean the workbench history is reset
Alignment alignment = getAlignment();
if (alignment.getCells().isEmpty()) {
return;
}
if (alignment instanceof MutableAlignment) {
/*
* As long as there is no copy constructor in DefaultAlignment, undo
* only supported if the current alignment is a MutableAlignment.
*/
IUndoableOperation operation = new CleanOperation((MutableAlignment) alignment);
executeOperation(operation);
} else {
super.clean();
}
}
use of eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment in project hale by halestudio.
the class ReplaceEntitiesHandler method execute.
/**
* @see IHandler#execute(ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// collect cells from selection
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
List<?> list = ((IStructuredSelection) selection).toList();
// create dummy alignment
DefaultAlignment dummy = new DefaultAlignment();
for (Object object : list) {
if (object instanceof MutableCell) {
dummy.addCell((MutableCell) object);
// FIXME what about others?
}
}
/*
* Replace entities on cells
*/
SimpleReporter reporter = new SimpleReporter("Replace entities for cells", null, false);
try {
// create migrator
AlignmentMigrator migrator = new DefaultAlignmentMigrator(HaleUI.getServiceProvider());
AlignmentMigration migration = new UserMigration(schemaSpace);
MigrationOptions options = new MigrationOptionsImpl(schemaSpace.equals(SchemaSpaceID.SOURCE), schemaSpace.equals(SchemaSpaceID.TARGET), false);
Alignment updated = migrator.updateAligmment(dummy, migration, options, reporter);
AlignmentService as = HaleUI.getServiceProvider().getService(AlignmentService.class);
Map<Cell, MutableCell> replacements = new HashMap<>();
for (Cell newCell : updated.getCells()) {
Cell oldCell = dummy.getCell(newCell.getId());
if (oldCell == null) {
reporter.error("No original cell with ID {0} found", newCell.getId());
} else {
// TODO detect where there has been no change?
replacements.put(oldCell, (MutableCell) newCell);
}
}
as.replaceCells(replacements);
reporter.setSuccess(true);
} catch (Throwable e) {
reporter.error("Fatal error when trying to replace entities", e);
reporter.setSuccess(false);
} finally {
HaleUI.getServiceProvider().getService(ReportService.class).addReport(reporter);
}
}
return null;
}
use of eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment in project hale by halestudio.
the class TransformDataWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
InstanceCollection rawSources = new MultiInstanceCollection(sourceSelectionPage.getSourceInstances());
// Create a copy of the current alignment to be independent and run
// everything in a job.
AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
Alignment alignment = new DefaultAlignment(alignmentService.getAlignment());
// schema service for getting source schema
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
Transformation.transform(rawSources, targetSink, sourceSelectionPage.getExportJob(), sourceSelectionPage.getValidationJob(), alignment, ss.getSchemas(SchemaSpaceID.SOURCE), DefaultReportHandler.getInstance(), HaleUI.getServiceProvider(), null);
return true;
}
Aggregations