use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class DBColumnRenameNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
final DatabasePortObject dbObject = (DatabasePortObject) inObjects[0];
final DatabasePortObject outObject = new DatabasePortObject(createDBOutSpec(dbObject.getSpec()));
return new PortObject[] { outObject };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class BWElimFilterNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
BWElimModel model = (BWElimModel) inData[0];
BufferedDataTable table = (BufferedDataTable) inData[1];
ColumnRearranger crea = createRearranger(((DataTable) inData[1]).getDataTableSpec(), m_settings.includedColumns(model));
return new PortObject[] { exec.createColumnRearrangeTable(table, crea, exec) };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class FeatureSelectionFilterNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
FeatureSelectionModel model = (FeatureSelectionModel) inData[0];
BufferedDataTable table = (BufferedDataTable) inData[1];
String warning = model.getTableSpecAndWarning(m_settings, table.getDataTableSpec()).getFirst();
if (warning != null) {
setWarningMessage(warning);
}
BufferedDataTable outTable = model.createTable(m_settings, table, exec);
return new PortObject[] { outTable };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class FeatureSelectionLoopEndNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
final FlowVariable scoreVariable = getAvailableInputFlowVariables().get(m_settings.getScoreVariableName());
final double score = scoreVariable.getDoubleValue();
if (m_resultTable == null) {
m_resultTable = exec.createDataContainer(m_featureSelector.getSpecForResultTable());
m_featureSelector.setResultTableContainer(m_resultTable);
}
m_featureSelector.addScore(score);
m_iteration++;
if (m_featureSelector.continueLoop()) {
continueLoop();
return null;
}
m_resultTable.close();
return new PortObject[] { m_resultTable.getTable(), m_featureSelector.getFeatureSelectionModel() };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class SleepNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
if (m_selection == 0) {
// wait for
exec.setMessage("Waiting for " + (m_waittime / 1000) + " seconds");
waitFor(m_waittime);
} else if (m_selection == 1) {
// wait to
Calendar c = Calendar.getInstance();
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE), m_toHours, m_toMin, m_toSec);
if (c.getTimeInMillis() - System.currentTimeMillis() <= 0) {
c.add(Calendar.DAY_OF_YEAR, 1);
}
exec.setMessage("Waiting until " + c.getTime());
final long sleepTime = c.getTimeInMillis() - System.currentTimeMillis();
waitFor(sleepTime);
} else if (m_selection == 2) {
WatchService w = FileSystems.getDefault().newWatchService();
Path p = FileUtil.resolveToPath(FileUtil.toURL(m_filePath));
if (p == null) {
throw new IllegalArgumentException("File location '" + m_filePath + "' is not a local file.");
}
exec.setMessage("Waiting for file '" + p + "'");
Path fileName = p.subpath(p.getNameCount() - 1, p.getNameCount());
Path parent = p.getParent();
Kind<Path> e = null;
if (m_fileStatus.equals("Creation")) {
e = StandardWatchEventKinds.ENTRY_CREATE;
} else if (m_fileStatus.equals("Modification")) {
e = StandardWatchEventKinds.ENTRY_MODIFY;
} else if (m_fileStatus.equals("Deletion")) {
e = StandardWatchEventKinds.ENTRY_DELETE;
} else {
throw new RuntimeException("Selected watchservice event is not available. Selected watchservice : " + m_fileStatus);
}
parent.register(w, e);
boolean keepLooking = true;
while (keepLooking) {
// watch file until the event appears
WatchKey key;
// wait for a key to be available
key = w.take();
for (WatchEvent<?> event : key.pollEvents()) {
if (fileName.equals(event.context())) {
keepLooking = false;
}
}
// reset key
boolean valid = key.reset();
if (!valid) {
break;
}
}
}
if (inData[0] == null) {
return new PortObject[] { FlowVariablePortObject.INSTANCE };
} else {
return inData;
}
}
Aggregations