String moduleName = (String) module.get("name");
String source = (String) module.get("source");
// Default domain
Domain domain;
String domainPrefix, sourceTail;
if(! source.contains(":"))
{
domain = Global.defaultDomain();
domainPrefix = "java";
sourceTail = source;
} else
{
domainPrefix = source.split(":")[0];
sourceTail = source.split(":", 2)[1];
if(! Global.domainExists(domainPrefix))
throw new RuntimeException("Domain "+domainPrefix+" is not known");
domain = Global.domain(domainPrefix);
}
// get name
builder.module(moduleName, domain);
// get the source
builder.source(moduleName, sourceTail);
// get the inputs
Map inputMap = (Map) module.get("inputs");
// Get the coupled inputs
List<?> couples = (List <?>) module.get("couple");
List<String> errors = new ArrayList<String>();
if(!domain.validate(source, errors)){
throw new InconsistentWorkflowException(errors);
}
parseInputAndCouples(builder, moduleName, domain, sourceTail, inputMap, couples);
// ask the domain object for the outputs
Map<String, DataType> outputTypeMap = getOutputTypes(source, domain);
for(String outputName : outputTypeMap.keySet())
{
boolean print = domain.printOutput(sourceTail, outputName);
String description = domain.outputDescription(sourceTail, outputName);
builder.output(moduleName, outputName, description, outputTypeMap.get(outputName), print);
}
}
return builder.workflow();