Skip to content

Commit 414f501

Browse files
committed
scala: fixed an incorrect column type convertion
1 parent bd4b2cb commit 414f501

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

RubyScript/src/org/knime/ext/jruby/RubyScriptNodeModel.scala

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,27 @@ end
318318
return Array(newSpec)
319319
}
320320
for (i <- 0 until columnNames.length) {
321-
var `type` = StringCell.TYPE
321+
var newColumnType = StringCell.TYPE
322322
var columnType:String = columnTypes(i) match {
323323
case "String" => classOf[StringCell].getName
324324
case "Integer" => classOf[IntCell].getName
325325
case "Double" => classOf[DoubleCell].getName
326+
case _ => columnTypes(i)
326327
}
327-
/* Workaround!!!!
328-
val cls = Class.forName(columnType)
329-
if (classOf[org.knime.core.data.DataCell].isAssignableFrom(cls)) `type` = DataType.getType(cls)
330-
else throw new InvalidSettingsException(columnType + " does not extend org.knime.core.data.DataCell class.")
331-
*/
328+
329+
try {
330+
val cls = Class.forName(columnType)
331+
if (classOf[org.knime.core.data.DataCell].isAssignableFrom(cls))
332+
newColumnType = DataType.getType(cls.asInstanceOf[Class[_ <: org.knime.core.data.DataCell]])
333+
else
334+
throw new InvalidSettingsException(columnType + " does not extends org.knime.core.data.DataCell class.")
335+
} catch {
336+
case e: java.lang.ClassNotFoundException =>
337+
throw new InvalidSettingsException("The class " + columnType + " not found.")
338+
}
339+
332340
if (columnTypes(i) != columnType) columnTypes(i) = columnType
333-
val newColumn = new DataColumnSpecCreator(columnNames(i), `type`).createSpec()
341+
val newColumn = new DataColumnSpecCreator(columnNames(i), newColumnType).createSpec()
334342
newSpec = AppendedColumnTable.getTableSpec(newSpec, newColumn)
335343
}
336344
if (script == null) {
@@ -465,6 +473,9 @@ end
465473
script_error.lineNum
466474
}
467475

476+
protected def reset() {
477+
}
478+
468479
/*
469480
Original Java:
470481
|**

0 commit comments

Comments
 (0)