String sinkPort = "";
String sinkProcessor = "";
Link source;
Link sink;
Parameter parameter = null;
Output output = null;
Format format;
FileTypes fileTypes;
for(DataLink d : datalinks){
source = d.getSource();
sourceLinkType = source.getLinkType();
sourcePort = source.getPort();
sourceProcessor = source.getProcessor();
sink = d.getSink();
sinkLinkType = sink.getLinkType();
sinkPort = sink.getPort();
sinkProcessor = sink.getProcessor();
// Even if the Taverna port is a SOURCE, that will correspond to Output.class in LONI. It's weird, but you have to be careful. In side the Input of LONI, the dataModule actually contains <output>, not <input>!
if(sinkPort == inputPortName){
parameter = new Parameter();
parameter.setId(dataModule.getId() +".Input");
parameter.setName(inputPortName);
parameter.setDescription("Input description");
parameter.setRequired(true);
parameter.setEnabled(true);
parameter.setOrder(tavernaContext.getNextOrder());
parameter.setLink("");
parameter.setValues(new Values());
// Create a new Format for parameter
format = new Format();
format.setType("File");
format.setCardinality(1);
format.setCardinalityBase("");
format.setTransformationBase("");
// Create and fill in file types for format
fileTypes = new FileTypes();
fileTypes.addFileType(new FileType(TavernaType, "", ""));
format.setFileTypes(fileTypes);
// Give parameter the newly created Format object
parameter.setFileFormat(format);
dataModule.addInput(parameter);
break;
}
else if(sourcePort == inputPortName){
output = new Output();
output.setId(dataModule.getId() +".Output");
output.setName(inputPortName);
output.setDescription("Output description");
output.setRequired(true);
output.setEnabled(true);
output.setOrder(tavernaContext.getNextOrder());
output.setLink("");
output.setValues(new Values());
// Create a new Format for output
output.setFormat(new Format());
output.getFormat().setType("File");
output.getFormat().setCardinality(1);
output.getFormat().setCardinalityBase("");
output.getFormat().setTransformationBase("");
// Create and fill in file types for format
output.getFormat().getFileTypes().addFileType(new FileType(TavernaType, "", ""));
output.getValues().addValue(new Value("hi", "there"));
dataModule.addOutput(output);
break;
}
}
return dataModule;