public Future<DigitalObject> generateExecutablePlan(final String planName, final Alternative alternative,
final List<String> measures, final String sourceMimetype, final String targetMimetype) throws PlanningException {
DigitalObject workflow = new DigitalObject();
String name = planName + " - " + alternative.getName();
T2FlowExecutablePlanGenerator generator = new T2FlowExecutablePlanGenerator(name, user.getFullName());
// Add ports
generator.addSourcePort();
generator.addTargetPort();
// Migration action
PreservationActionDefinition action = alternative.getAction();
if (action != null) {
try {
WorkflowDescription wf = MyExperimentRESTClient.getWorkflow(action.getDescriptor());
HashMap<String, String> parameters = new HashMap<String, String>();
for (Parameter p : action.getParams()) {
parameters.put(p.getName(), p.getValue());
}
wf.readMetadata();
String workflowContent = MyExperimentRESTClient.getWorkflowContent(wf);
generator.setMigrationComponent(wf, workflowContent, parameters);
} catch (Exception e) {
log.warn("An error occured querying myExperiment migration component.", e.getMessage());
throw new PlanningException("An error occured querying myExperiment migration component", e);
}
}
// Add QA components
addQaComponents(generator, measures, sourceMimetype, targetMimetype);
// Create digital object
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
try {
generator.generate(writer);
} catch (IOException e) {
log.warn("An error occured generating the executable plan.", e.getMessage());
throw new PlanningException("An error occured generating the executable plan.", e);
} finally {
if (writer != null) {