Search in sources :

Example 1 with PortModel

use of org.apache.airavata.model.PortModel in project airavata by apache.

the class JsonWorkflowParser method readApplicationOutputs.

private List<OutPort> readApplicationOutputs(JsonReader jsonReader) throws IOException, ParserException {
    List<OutPort> outPorts = new ArrayList<>();
    PortModel portModel;
    OutPort outPort;
    String name;
    JsonToken peek = jsonReader.peek();
    if (peek == JsonToken.NULL) {
        jsonReader.nextNull();
    } else if (peek == JsonToken.BEGIN_ARRAY) {
        jsonReader.beginArray();
        while (jsonReader.hasNext()) {
            portModel = new PortModel();
            outPort = new OutPortImpl(portModel);
            jsonReader.beginObject();
            while (jsonReader.hasNext()) {
                name = jsonReader.nextName();
                if (name.equals(NAME)) {
                    portModel.setName(jsonReader.nextString());
                } else if (name.equals(ID)) {
                    portModel.setPortId(jsonReader.nextString());
                } else if (name.equals(DATATYPE)) {
                    jsonReader.skipValue();
                } else if (name.equals(DEFAULT_VALUE)) {
                    // can output has default values?
                    jsonReader.skipValue();
                } else if (name.equals(DESCRIPTION)) {
                    portModel.setDescription(jsonReader.nextString());
                } else {
                    jsonReader.skipValue();
                }
            }
            jsonReader.endObject();
            outPorts.add(outPort);
        }
        jsonReader.endArray();
    } else {
        throw new ParserException("Error! reading application outputs, expected " + getTokenString(JsonToken.NULL) + " or " + getTokenString(JsonToken.BEGIN_ARRAY) + " but found " + getTokenString(peek));
    }
    return outPorts;
}
Also used : OutPort(org.apache.airavata.workflow.core.dag.port.OutPort) PortModel(org.apache.airavata.model.PortModel) ArrayList(java.util.ArrayList) JsonToken(com.google.gson.stream.JsonToken) OutPortImpl(org.apache.airavata.workflow.core.dag.port.OutPortImpl)

Example 2 with PortModel

use of org.apache.airavata.model.PortModel in project airavata by apache.

the class JsonWorkflowParser method readApplicationInputs.

private List<InPort> readApplicationInputs(JsonReader jsonReader) throws IOException, ParserException {
    List<InPort> inPorts = new ArrayList<>();
    JsonToken peek = jsonReader.peek();
    PortModel portModel;
    InPort inPort;
    String name;
    if (peek == JsonToken.NULL) {
        jsonReader.nextNull();
    } else if (peek == JsonToken.BEGIN_ARRAY) {
        jsonReader.beginArray();
        while (jsonReader.hasNext()) {
            portModel = new PortModel();
            inPort = new InputPortIml(portModel);
            jsonReader.beginObject();
            while (jsonReader.hasNext()) {
                name = jsonReader.nextName();
                if (name.equals(NAME)) {
                    portModel.setName(jsonReader.nextString());
                } else if (name.equals(ID)) {
                    portModel.setPortId(jsonReader.nextString());
                } else if (name.equals(DATATYPE)) {
                    jsonReader.skipValue();
                } else if (name.equals(DEFAULT_VALUE)) {
                    inPort.setDefaultValue(jsonReader.nextString());
                } else if (name.equals(DESCRIPTION)) {
                    portModel.setDescription(jsonReader.nextString());
                } else {
                    jsonReader.skipValue();
                }
            }
            jsonReader.endObject();
            inPorts.add(inPort);
        }
        jsonReader.endArray();
    } else {
        throw new ParserException("Error! reading application inputs, expected " + getTokenString(JsonToken.NULL) + " or " + getTokenString(JsonToken.BEGIN_ARRAY) + " but found " + getTokenString(peek));
    }
    return inPorts;
}
Also used : InPort(org.apache.airavata.workflow.core.dag.port.InPort) PortModel(org.apache.airavata.model.PortModel) ArrayList(java.util.ArrayList) JsonToken(com.google.gson.stream.JsonToken) InputPortIml(org.apache.airavata.workflow.core.dag.port.InputPortIml)

Example 3 with PortModel

use of org.apache.airavata.model.PortModel in project airavata by apache.

the class InputNodeImpl method convert.

private PortModel convert(NodeModel nodeModel) {
    PortModel portModel = new PortModel(nodeModel.getNodeId());
    portModel.setName(nodeModel.getName());
    portModel.setDescription(nodeModel.getDescription());
    return portModel;
}
Also used : PortModel(org.apache.airavata.model.PortModel)

Aggregations

PortModel (org.apache.airavata.model.PortModel)3 JsonToken (com.google.gson.stream.JsonToken)2 ArrayList (java.util.ArrayList)2 InPort (org.apache.airavata.workflow.core.dag.port.InPort)1 InputPortIml (org.apache.airavata.workflow.core.dag.port.InputPortIml)1 OutPort (org.apache.airavata.workflow.core.dag.port.OutPort)1 OutPortImpl (org.apache.airavata.workflow.core.dag.port.OutPortImpl)1