}
/**
* Convert a Pipeline to a Galaxy Workflow
*/
public Object visit(Pipeline pipeline) {
Workflow workflow;
ModuleGroup mgroup = pipeline.getPipelineModuleGroup();
Connections conns = pipeline.getConnections();
GalaxyContext context= new GalaxyContext();
context.getDatabase().clear();
NODE_COUNT = 0;
//convert the module group
Pair<List<Step>, Object> mystp = moduleVisitor.visit(mgroup, context);
/* Visit connections */
List<Pair<Pair<Integer,String>, InputConnection>> connlist;
connlist = (List<Pair<Pair<Integer,String>, InputConnection>>) visit(conns, context).getElem1();
/* Add resulting connections */
for(Pair<Pair<Integer,String>, InputConnection> myconn : connlist){
for(Step mystep : mystp.getElem1()){
if(mystep.getId() == myconn.getElem1().getElem1().intValue()){
mystep.getConnections().put(
myconn.getElem1().getElem2(), myconn.getElem2());
}
}
}
//create workflow from modulegroup, connections
workflow = new Workflow(mgroup.getName(),
mgroup.getDescription(),
pipeline.getVersion(),
true);
//add steps retrieved from visiting modulegroup.
for(Step s : mystp.getElem1())
workflow.addStep(s.getId(), s);
return workflow;
}