Search in sources :

Example 6 with OutVar

use of org.knime.base.node.jsnippet.util.field.OutVar in project knime-core by knime.

the class OutFieldsTable method getOutVarFields.

/**
 * Get the field definitions representing output flow variables.
 *
 * @return fields representing output flow variables
 */
public OutVarList getOutVarFields() {
    OutVarList outVars = new OutVarList();
    for (int r = 0; r < m_model.getRowCount(); r++) {
        if (!m_model.validateValues(r)) {
            // there are errors in this row
            continue;
        }
        Object fieldTypeValue = getFieldType(r);
        if (null == fieldTypeValue) {
            continue;
        }
        boolean isFlowVar = fieldTypeValue.equals(FieldType.FlowVariable);
        if (isFlowVar) {
            OutVar outVar = new OutVar();
            outVar.setReplaceExisting((Boolean) m_model.getValueAt(r, Column.REPLACE_EXISTING));
            Object colColValue = m_model.getValueAt(r, Column.COLUMN);
            if (colColValue instanceof FlowVariable) {
                FlowVariable flowVar = (FlowVariable) colColValue;
                outVar.setKnimeName(flowVar.getName());
            } else if (colColValue instanceof String) {
                outVar.setKnimeName(colColValue.toString());
            } else {
                continue;
            }
            Object dataTypeValue = m_model.getValueAt(r, Column.DATA_TYPE);
            if (dataTypeValue instanceof Type) {
                Type type = (Type) dataTypeValue;
                outVar.setFlowVarType(type);
            } else {
                continue;
            }
            outVar.setJavaName((String) m_model.getValueAt(r, Column.JAVA_FIELD));
            Object javaTypeObject = m_model.getValueAt(r, Column.JAVA_TYPE);
            if (javaTypeObject instanceof Class) {
                outVar.setJavaType((Class) javaTypeObject);
            } else {
                continue;
            }
            outVars.add(outVar);
        }
    }
    return outVars;
}
Also used : FieldType(org.knime.base.node.jsnippet.util.field.JavaField.FieldType) Type(org.knime.core.node.workflow.FlowVariable.Type) DataType(org.knime.core.data.DataType) OutVarList(org.knime.base.node.jsnippet.util.JavaFieldList.OutVarList) OutVar(org.knime.base.node.jsnippet.util.field.OutVar) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Aggregations

OutVar (org.knime.base.node.jsnippet.util.field.OutVar)6 FlowVariable (org.knime.core.node.workflow.FlowVariable)5 OutCol (org.knime.base.node.jsnippet.util.field.OutCol)4 DataType (org.knime.core.data.DataType)4 InCol (org.knime.base.node.jsnippet.util.field.InCol)3 InVar (org.knime.base.node.jsnippet.util.field.InVar)3 ArrayList (java.util.ArrayList)2 TypeException (org.knime.base.node.jsnippet.expression.TypeException)2 OutVarList (org.knime.base.node.jsnippet.util.JavaFieldList.OutVarList)2 FieldType (org.knime.base.node.jsnippet.util.field.JavaField.FieldType)2 JavaToDataCellConverterFactory (org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory)2 Type (org.knime.core.node.workflow.FlowVariable.Type)2 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 BadLocationException (javax.swing.text.BadLocationException)1 Abort (org.knime.base.node.jsnippet.expression.Abort)1 Cell (org.knime.base.node.jsnippet.expression.Cell)1