in taverna-scufl2-t2flow/src/main/java/org/apache/taverna/scufl2/translator/t2flow/defaultactivities/BeanshellActivityParser.java [78:153]
public Configuration parseConfiguration(T2FlowParser t2FlowParser,
ConfigBean configBean, ParserState parserState)
throws ReaderException {
BeanshellConfig beanshellConfig = unmarshallConfig(t2FlowParser,
configBean, "xstream", BeanshellConfig.class);
Configuration configuration = new Configuration();
configuration.setParent(parserState.getCurrentProfile());
ObjectNode json = (ObjectNode) configuration.getJson();
configuration.setType(ACTIVITY_URI.resolve("#Config"));
if (beanshellConfig.getLocalworkerName() != null) {
URI localWorkerURI = LOCAL_WORKER_URI.resolve(uriTools
.validFilename(beanshellConfig.getLocalworkerName()));
/*
* FIXME: As we can't read the annotation chain yet, we can't tell
* whether this local worker has been edited or not, and so can't
* use #definedBy
*/
json.put("derivedFrom", localWorkerURI.toString());
}
String script = beanshellConfig.getScript();
json.put("script", script);
ClassLoaderSharing classLoaderSharing = beanshellConfig
.getClassLoaderSharing();
if (classLoaderSharing == ClassLoaderSharing.SYSTEM)
json.put("classLoaderSharing", "system");
else {
// default is "workflow" but don't need to be expressed
// json.put("classLoaderSharing", "workflow");
}
if (beanshellConfig.getLocalDependencies() != null) {
ArrayNode dependencies = json.arrayNode();
for (String localDep : beanshellConfig.getLocalDependencies()
.getString())
dependencies.add(localDep);
if (dependencies.size() > 0)
json.put("localDependency", dependencies);
}
/*
* Note: Maven Dependencies are not supported by Taverna 3 - only here
* for informational purposes and potential t2flow->t2flow scenarios
*/
if (beanshellConfig.getArtifactDependencies() != null) {
ArrayNode dependencies = json.arrayNode();
for (BasicArtifact mavenDep : beanshellConfig
.getArtifactDependencies()
.getNetSfTavernaRavenRepositoryBasicArtifact()) {
ObjectNode mavenDependency = json.objectNode();
dependencies.add(mavenDependency);
mavenDependency.put("groupId", mavenDep.getGroupId());
mavenDependency.put("artifactId", mavenDep.getArtifactId());
mavenDependency.put("version", mavenDep.getVersion());
}
if (dependencies.size() > 0)
json.put("mavenDependency", dependencies);
}
Activity activity = parserState.getCurrentActivity();
activity.getInputPorts().clear();
activity.getOutputPorts().clear();
for (ActivityPortDefinitionBean portBean : beanshellConfig
.getInputs()
.getNetSfTavernaT2WorkflowmodelProcessorActivityConfigActivityInputPortDefinitionBean())
parseAndAddInputPortDefinition(portBean, configuration, activity);
for (ActivityPortDefinitionBean portBean : beanshellConfig
.getOutputs()
.getNetSfTavernaT2WorkflowmodelProcessorActivityConfigActivityOutputPortDefinitionBean())
parseAndAddOutputPortDefinition(portBean, configuration, activity);
return configuration;
}