use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class PortObjectWriterNodeModel method execute.
/**
* Writes model as ModelContent to file.
*
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] portObject, final ExecutionContext exec) throws Exception {
CheckUtils.checkDestinationFile(m_fileName.getStringValue(), m_overwriteOK.getBooleanValue());
URL url = FileUtil.toURL(m_fileName.getStringValue());
Path localPath = FileUtil.resolveToPath(url);
if (localPath != null) {
try {
PortUtil.writeObjectToFile(portObject[0], localPath.toFile(), exec);
} catch (Exception e) {
Files.deleteIfExists(localPath);
throw e;
}
} else {
try (OutputStream os = FileUtil.openOutputConnection(url, "PUT").getOutputStream()) {
PortUtil.writeObjectToStream(portObject[0], os, exec);
}
}
return new PortObject[0];
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class PMMLReaderNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
PMMLPortObject inPort = m_hasPMMLIn ? (PMMLPortObject) inData[0] : null;
if (inPort != null) {
TransformationDictionary dict = TransformationDictionary.Factory.newInstance();
dict.setDerivedFieldArray(inPort.getDerivedFields());
m_pmmlPort.addGlobalTransformations(dict);
m_pmmlPort.moveGlobalTransformationsToModel();
}
return new PortObject[] { m_pmmlPort };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class DBPivotNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
final DatabasePortObject dbObject = (DatabasePortObject) inData[0];
final DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObject.getSpec(), exec));
return new PortObject[] { outObject };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class ReadContextPropertyNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
Result result = m_config.createResult();
String message = result.getWarningMessage();
if (message != null) {
setWarningMessage(message);
}
pushFlowVariables(result);
return new PortObject[] { FlowVariablePortObject.INSTANCE };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class DBSorterNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
DatabasePortObject dbObj = (DatabasePortObject) inData[0];
DatabaseQueryConnectionSettings conn = dbObj.getConnectionSettings(getCredentialsProvider());
String newQuery = createQuery(conn.getQuery(), conn.getUtility().getStatementManipulator());
conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
DatabasePortObject outObj = new DatabasePortObject(new DatabasePortObjectSpec(dbObj.getSpec().getDataTableSpec(), conn.createConnectionModel()));
return new PortObject[] { outObj };
}
Aggregations