Search in sources :

Example 1 with OutputNodeImpl

use of org.apache.airavata.workflow.core.dag.nodes.OutputNodeImpl in project airavata by apache.

the class JsonWorkflowParser method readWorkflowOutputs.

private void readWorkflowOutputs(JsonReader jsonReader) throws IOException, ParserException {
    JsonToken peek = jsonReader.peek();
    OutputNode outputNode;
    NodeModel nodeModel;
    ComponentStatus status;
    String name;
    if (peek == JsonToken.NULL) {
        throw new ParserException("Error! workflow outputs can't be null");
    } else if (peek == JsonToken.BEGIN_ARRAY) {
        jsonReader.beginArray();
        while (jsonReader.hasNext()) {
            jsonReader.beginObject();
            nodeModel = new NodeModel();
            status = new ComponentStatus();
            status.setState(ComponentState.CREATED);
            status.setReason("Created");
            nodeModel.setStatus(status);
            outputNode = new OutputNodeImpl(nodeModel);
            while (jsonReader.hasNext()) {
                name = jsonReader.nextName();
                if (name.equals(NAME)) {
                    nodeModel.setName(jsonReader.nextString());
                } else if (name.equals(ID)) {
                    nodeModel.setNodeId(jsonReader.nextString());
                } else if (name.equals(DATATYPE)) {
                    jsonReader.skipValue();
                } else if (name.equals(DESCRIPTION)) {
                    nodeModel.setDescription(jsonReader.nextString());
                } else if (name.equals(POSITION)) {
                    readPosition(jsonReader);
                } else if (name.equals(NODE_ID)) {
                    jsonReader.skipValue();
                // nodeModel.setNodeId(jsonReader.nextString());
                } else if (name.equals(DEFAULT_VALUE)) {
                    jsonReader.skipValue();
                } else {
                    jsonReader.skipValue();
                }
            }
            jsonReader.endObject();
            outputs.add(outputNode);
        }
        jsonReader.endArray();
    } else {
        throw new ParserException("Error! Unsupported value for Workflow Outputs, exptected " + getTokenString(JsonToken.BEGIN_OBJECT) + " but found" + getTokenString(peek));
    }
}
Also used : OutputNode(org.apache.airavata.workflow.core.dag.nodes.OutputNode) NodeModel(org.apache.airavata.model.NodeModel) ComponentStatus(org.apache.airavata.model.ComponentStatus) JsonToken(com.google.gson.stream.JsonToken) OutputNodeImpl(org.apache.airavata.workflow.core.dag.nodes.OutputNodeImpl)

Aggregations

JsonToken (com.google.gson.stream.JsonToken)1 ComponentStatus (org.apache.airavata.model.ComponentStatus)1 NodeModel (org.apache.airavata.model.NodeModel)1 OutputNode (org.apache.airavata.workflow.core.dag.nodes.OutputNode)1 OutputNodeImpl (org.apache.airavata.workflow.core.dag.nodes.OutputNodeImpl)1