1
package uk.org.taverna.server.client;
3
import java.io.IOException;
4
import java.io.InputStream;
6
import org.apache.tika.io.IOUtils;
7
import org.taverna.server.client.wadl.TavernaServer.Root.RunsRunName.Input.InputName;
9
import uk.org.taverna.server.client.generic.port.InputPort;
10
import uk.org.taverna.server.client.rest.InputDescription;
11
import uk.org.taverna.server.client.rest.InputDescription.Value;
14
private InputPort port;
16
private InputName handle;
18
Input(Run run, InputPort port) {
21
this.handle = run.run.input().inputName(port.getName());
24
public String getName() {
25
return port.getName();
28
public Integer getDepth() {
29
return port.getDepth();
32
public Character getListSeparator() {
33
String sep = handle.getAsInputDescriptionXml().getListDelimiter();
34
if (sep == null || sep.isEmpty())
39
public String getValue() {
40
InputDescription idesc = handle.getAsInputDescriptionXml();
41
Value v = idesc.getValue();
44
String name = idesc.getFile().getValue();
45
try (InputStream s = new File(run, name).getAsStream()) {
46
return IOUtils.toString(s);
47
} catch (IOException e) {
48
// Can't read from the input; should COMPLAIN but this is really a
49
// "can't happen" case.
54
public void setValue(String value) {
55
Value v = new Value();
57
InputDescription idesc = new InputDescription();
59
handle.putXmlAsInputDescription(idesc);
62
public void setValue(String value, char listSeparator) {
63
Value v = new Value();
65
InputDescription idesc = new InputDescription();
67
idesc.setListDelimiter(new String(new char[] { listSeparator }));
68
handle.putXmlAsInputDescription(idesc);