Search in sources :

Example 1 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class WorkflowInputUtil method createInputForGFacService.

public static String createInputForGFacService(WSComponentPort port, String input) {
    DataType paramType = port.getType();
    StringBuffer inputString = new StringBuffer("<");
    if ("StringParameterType".equals(paramType) || "URIParameterType".equals(paramType) || "DoubleParameterType".equals(paramType) || "IntegerParameterType".equals(paramType) || "FloatParameterType".equals(paramType) || "BooleanParameterType".equals(paramType) || "FileParameterType".equals(paramType)) {
        inputString.append(port.getName()).append(">").append(getValueElement(input)).append("</").append(port.getName()).append(">");
    } else if (paramType.toString().equals("ArrayType")) {
        inputString.append(port.getName()).append(">");
        String[] valueList = StringUtil.getElementsFromString(input);
        for (String inputValue : valueList) {
            inputString.append(getValueElement(inputValue));
        }
        inputString.append(getValueElement(port.getName()));
    }
    inputString.append(">");
    return inputString.toString();
}
Also used : DataType(org.apache.airavata.model.application.io.DataType)

Example 2 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class SimpleOrchestratorImpl method createAndSaveOutputDataStagingTasks.

public List<String> createAndSaveOutputDataStagingTasks(ProcessModel processModel, String gatewayId) throws RegistryException, AiravataException {
    List<String> dataStagingTaskIds = new ArrayList<>();
    List<OutputDataObjectType> processOutputs = processModel.getProcessOutputs();
    String appName = OrchestratorUtils.getApplicationInterfaceName(orchestratorContext, processModel);
    if (processOutputs != null) {
        for (OutputDataObjectType processOutput : processOutputs) {
            DataType type = processOutput.getType();
            switch(type) {
                case STDOUT:
                    if (null == processOutput.getValue() || processOutput.getValue().trim().isEmpty()) {
                        processOutput.setValue(appName + ".stdout");
                    }
                    createOutputDataSatagingTasks(processModel, gatewayId, dataStagingTaskIds, processOutput);
                    break;
                case STDERR:
                    if (null == processOutput.getValue() || processOutput.getValue().trim().isEmpty()) {
                        processOutput.setValue(appName + ".stderr");
                    }
                    createOutputDataSatagingTasks(processModel, gatewayId, dataStagingTaskIds, processOutput);
                    break;
                case URI:
                    createOutputDataSatagingTasks(processModel, gatewayId, dataStagingTaskIds, processOutput);
                    break;
                default:
                    // nothing to do
                    break;
            }
        }
    }
    try {
        if (isArchive(processModel, gatewayId)) {
            createArchiveDataStatgingTask(processModel, gatewayId, dataStagingTaskIds);
        }
    } catch (AppCatalogException e) {
        throw new RegistryException("Error! Application interface retrieval failed");
    }
    return dataStagingTaskIds;
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) DataType(org.apache.airavata.model.application.io.DataType)

Example 3 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class WSPort method copyType.

/**
 * @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
 */
@Override
public void copyType(DataPort port) throws GraphException {
    DataType newType = port.getType();
    DataType type = getType();
    NodeImpl node = port.getNode();
    if (node instanceof ForEachNode || node instanceof EndForEachNode) {
        // from WSDL.
        return;
    }
    if (!(newType == null || newType.equals(WSConstants.XSD_ANY_TYPE) || type == null || type.equals(WSConstants.XSD_ANY_TYPE) || newType.equals(type))) {
        String message = "The type (" + newType + ")  must be same as the type  " + " (" + type + ") of " + getID() + ".";
        throw new GraphException(message);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataType(org.apache.airavata.model.application.io.DataType) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 4 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class EndBlockNode method portTypeChanged.

/**
 * @see org.apache.airavata.workflow.model.graph.system.SystemNode#portTypeChanged(org.apache.airavata.workflow.model.graph.system.SystemDataPort)
 */
@Override
protected void portTypeChanged(SystemDataPort port) throws GraphException {
    super.portTypeChanged(port);
    List<DataPort> inputPorts = getInputPorts();
    List<DataPort> outputPorts = getOutputPorts();
    int size = outputPorts.size();
    Kind kind = port.getKind();
    int index;
    if (kind == Kind.DATA_IN) {
        index = inputPorts.indexOf(port) % size;
    } else if (kind == Kind.DATA_OUT) {
        index = outputPorts.indexOf(port);
    } else {
        throw new WorkflowRuntimeException();
    }
    DataPort inputPort1 = inputPorts.get(index);
    DataPort inputPort2 = inputPorts.get(size + index);
    DataPort outputPort = outputPorts.get(index);
    DataType inputType1 = inputPort1.getType();
    DataType inputType2 = inputPort2.getType();
    DataType outputType = outputPort.getType();
    DataType portType = port.getType();
    if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
        // Do nothing
        return;
    }
    if (port == inputPort1) {
        // input1 -> input2
        if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort2.copyType(port);
        } else if (inputType2.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
            throw new GraphException(message);
        }
        // input1 -> output
        if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
            outputPort.copyType(port);
        } else if (outputType.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
    } else if (port == inputPort2) {
        // input2 -> input1
        if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort1.copyType(port);
        } else if (inputType1.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
            throw new GraphException(message);
        }
        // input2 -> output
        if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
            outputPort.copyType(port);
        } else if (outputType.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
    } else if (port == outputPort) {
        // output -> input1
        if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort1.copyType(port);
        } else if (inputType1.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
        // output -> input2
        if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
            inputPort2.copyType(port);
        } else if (inputType2.equals(portType)) {
        // Do nothing.
        } else {
            String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID() + " must be same as the type of input " + index + " (" + outputType + ").";
            throw new GraphException(message);
        }
    } else {
        throw new WorkflowRuntimeException();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 5 with DataType

use of org.apache.airavata.model.application.io.DataType in project airavata by apache.

the class EndDoWhileNode method edgeWasAdded.

/**
 * @throws GraphException
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    // XXX cannot detect if the type is array or not from WSDL at this
    // point. so no check here.
    // super.edgeWasAdded(edge);
    Port fromPort = edge.getFromPort();
    Port toPort = edge.getToPort();
    if (edge instanceof DataEdge) {
        if (fromPort instanceof EPRPort) {
            // TODO
            return;
        }
        DataPort fromDataPort = (DataPort) fromPort;
        DataPort toDataPort = (DataPort) toPort;
        DataType fromType = fromDataPort.getType();
        DataType toType = toDataPort.getType();
        if (fromDataPort.getNode() == this) {
            if (!(toType == null || toType.equals(WSConstants.XSD_ANY_TYPE))) {
                fromDataPort.copyType(toDataPort);
            }
        } else if (toDataPort.getNode() == this) {
            if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE))) {
                toDataPort.copyType(fromDataPort);
            }
        } else {
            throw new WorkflowRuntimeException();
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

DataType (org.apache.airavata.model.application.io.DataType)18 DataPort (org.apache.airavata.workflow.model.graph.DataPort)13 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)10 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)10 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)6 GraphException (org.apache.airavata.workflow.model.graph.GraphException)6 Port (org.apache.airavata.workflow.model.graph.Port)6 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)5 Kind (org.apache.airavata.workflow.model.graph.Port.Kind)4 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)3 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)2 Edge (org.apache.airavata.workflow.model.graph.Edge)2 List (java.util.List)1 TaskException (org.apache.airavata.gfac.core.task.TaskException)1 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)1 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)1 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)1 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)1 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)1 TException (org.apache.thrift.TException)1