package Taverna.Visitor;
import java.util.ArrayList;
import Taverna.Tree.Workflow;
import Taverna.Tree.Annotation.AnnotationAssertionImpl;
import Taverna.Tree.Annotation.AnnotationAssertions;
import Taverna.Tree.Annotation.AnnotationBean;
import Taverna.Tree.Annotation.AnnotationChain;
import Taverna.Tree.Annotation.AnnotationChainImpl;
import Taverna.Tree.Annotation.AnnotationContent;
import Taverna.Tree.Annotation.Annotations;
public class AnnotationConverter extends AnnotationVisitor {
public Object visit(Annotations annotations){
int chain_size=annotations.getAnnotationChain().size();
AnnotationContent annotationContent = new AnnotationContent();
for (int i=0;i<chain_size;i++){
ArrayList<String> classList= new ArrayList<String>();
classList=(ArrayList<String>)visit(annotations.getAnnotationChain().get(i).getAnnotationChainImpl().getAnnotationAssertions().getAnnotationAssertionImpl().getAnnotationBean());
// Assign different part into LONI xml
if (classList.contains("net.sf.taverna.t2.annotation.annotationbeans.Author")){
annotationContent.name=new String(classList.get(1));
annotationContent.iD=annotationContent.name+"_1";
}
if (classList.contains("net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription")){
annotationContent.description=new String(classList.get(1));
}
}
return annotationContent;
}
public Object visit(AnnotationChain annotationChain){
return null;
}
public Object visit(AnnotationChainImpl annotationChainImpl){
return null;
}
public Object visit(AnnotationAssertions annotationAssertions){
return null;
}
public Object visit(AnnotationAssertionImpl annotationAssertionImpl){
return null;
}
public Object visit(AnnotationBean annotationBean){
String myClass=null;
String myClassText=null;
try{
myClass=annotationBean.getMyClass();
myClassText=annotationBean.getMyClassText();
}catch (Exception e){}
ArrayList<String> classList=new ArrayList<String>();
classList.add(myClass);
classList.add(myClassText);
return classList;
}
}