return result.isSuccessful();
}
@Override
public MigrationResult migrate(Alternative alternative, DigitalObject digitalObject) throws PlatoException {
DigitalObject workflow = alternative.getExperiment().getWorkflow();
MigrationResult result = new MigrationResult();
result.setSourceFormat(digitalObject.getFormatInfo());
result.setSuccessful(false);
// Prepare executor
SSHTavernaExecutor tavernaExecutor = new SSHTavernaExecutor();
tavernaExecutor.init();
SSHTavernaExecutor.ByteArraySourceFile workflowFile = tavernaExecutor.new ByteArraySourceFile(
FileUtils.makeFilename(workflow.getFullname()), workflow.getData().getData());
tavernaExecutor.setWorkflow(workflowFile);
// Input
HashMap<String, Object> inputData = new HashMap<String, Object>();
SSHTavernaExecutor.ByteArraySourceFile sourceFile = tavernaExecutor.new ByteArraySourceFile(
FileUtils.makeFilename(digitalObject.getFullname()), digitalObject.getData().getData());
inputData.put("source", sourceFile);
tavernaExecutor.setInputData(inputData);
// Outputs
tavernaExecutor.setOutputPorts(null);
HashMap<String, SSHInMemoryTempFile> requestedFiles = new HashMap<String, SSHInMemoryTempFile>(1);
SSHInMemoryTempFile tempFile = new SSHInMemoryTempFile();
requestedFiles.put("target", tempFile);
tavernaExecutor.setOutputFiles(requestedFiles);
// Execute
try {
tavernaExecutor.execute();
result.setReport(tavernaExecutor.getOutputDoc());
// Migrated file
Map<String, ?> outputFiles = tavernaExecutor.getOutputFiles();
DigitalObject migrated = new DigitalObject();
for (Entry<String, ?> entry : outputFiles.entrySet()) {
SSHInMemoryTempFile resultFile = (SSHInMemoryTempFile) entry.getValue();
migrated.getData().setData(resultFile.getData());
migrated.setFullname(alternative.getAction().getShortname() + " - " + digitalObject.getFullname());
}
result.setMigratedObject(migrated);
result.setTargetFormat(migrated.getFormatInfo());
result.setSuccessful(migrated.isDataExistent());
// Measures
Map<String, ?> outputData = tavernaExecutor.getOutputData();
Map<String, Measurement> measurements = new HashMap<String, Measurement>();
for (Entry<String, ?> outputEntry : outputData.entrySet()) {