Search in sources :

Example 1 with NodeModel

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

the class JsonWorkflowParser method readApplication.

private ApplicationNode readApplication(JsonReader jsonReader) throws IOException, ParserException {
    jsonReader.beginObject();
    NodeModel nodeModel = new NodeModel();
    ComponentStatus status = new ComponentStatus();
    status.setState(ComponentState.CREATED);
    status.setReason("Created");
    nodeModel.setStatus(status);
    ApplicationNode applicationNode = new ApplicationNodeImpl(nodeModel);
    String name;
    while (jsonReader.hasNext()) {
        name = jsonReader.nextName();
        if (name.equals(APPLICATION_ID)) {
            nodeModel.setApplicationId(jsonReader.nextString());
        } else if (name.equals(NAME)) {
            nodeModel.setName(jsonReader.nextString());
        } else if (name.equals(DESCRIPTION)) {
            nodeModel.setDescription(jsonReader.nextString());
        } else if (name.equals(APPTYPE)) {
            jsonReader.skipValue();
        } else if (name.equals(INPUTS)) {
            applicationNode.addInputPorts(readApplicationInputs(jsonReader));
        } else if (name.equals(OUTPUTS)) {
            applicationNode.addOutPorts(readApplicationOutputs(jsonReader));
        } else if (name.equals(POSITION)) {
            readPosition(jsonReader);
        } else if (name.equals(NODE_ID)) {
            nodeModel.setNodeId(jsonReader.nextString());
        } else if (name.equals(PARALLEL_EXECUTION)) {
            jsonReader.skipValue();
        } else if (name.equals(PROPERTIES)) {
            readProperties(jsonReader);
        }
    }
    jsonReader.endObject();
    return applicationNode;
}
Also used : NodeModel(org.apache.airavata.model.NodeModel) ComponentStatus(org.apache.airavata.model.ComponentStatus) ApplicationNodeImpl(org.apache.airavata.workflow.core.dag.nodes.ApplicationNodeImpl) ApplicationNode(org.apache.airavata.workflow.core.dag.nodes.ApplicationNode)

Example 2 with NodeModel

use of org.apache.airavata.model.NodeModel 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)

Example 3 with NodeModel

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

the class JsonWorkflowParser method readWorkflowInputs.

private void readWorkflowInputs(JsonReader jsonReader) throws ParserException, IOException {
    JsonToken peek = jsonReader.peek();
    InputNode inputNode;
    NodeModel nodeModel;
    ComponentStatus status;
    String name;
    if (peek == JsonToken.NULL) {
        throw new ParserException("Error! workflow inputs 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);
            inputNode = new InputNodeImpl(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)) {
                    inputNode.setDataType(DataType.valueOf(jsonReader.nextString()));
                } 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)) {
                    inputNode.setValue(jsonReader.nextString());
                } else {
                    jsonReader.skipValue();
                }
            }
            jsonReader.endObject();
            inputs.add(inputNode);
        }
        jsonReader.endArray();
    } else {
        throw new ParserException("Error! Unsupported value for Workflow Inputs, exptected " + getTokenString(JsonToken.BEGIN_OBJECT) + " but found" + getTokenString(peek));
    }
}
Also used : InputNode(org.apache.airavata.workflow.core.dag.nodes.InputNode) NodeModel(org.apache.airavata.model.NodeModel) InputNodeImpl(org.apache.airavata.workflow.core.dag.nodes.InputNodeImpl) ComponentStatus(org.apache.airavata.model.ComponentStatus) JsonToken(com.google.gson.stream.JsonToken)

Aggregations

ComponentStatus (org.apache.airavata.model.ComponentStatus)3 NodeModel (org.apache.airavata.model.NodeModel)3 JsonToken (com.google.gson.stream.JsonToken)2 ApplicationNode (org.apache.airavata.workflow.core.dag.nodes.ApplicationNode)1 ApplicationNodeImpl (org.apache.airavata.workflow.core.dag.nodes.ApplicationNodeImpl)1 InputNode (org.apache.airavata.workflow.core.dag.nodes.InputNode)1 InputNodeImpl (org.apache.airavata.workflow.core.dag.nodes.InputNodeImpl)1 OutputNode (org.apache.airavata.workflow.core.dag.nodes.OutputNode)1 OutputNodeImpl (org.apache.airavata.workflow.core.dag.nodes.OutputNodeImpl)1