Search in sources :

Example 71 with PortObject

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];
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) PortObject(org.knime.core.node.port.PortObject) URL(java.net.URL) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException)

Example 72 with PortObject

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 };
}
Also used : PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) TransformationDictionary(org.dmg.pmml.TransformationDictionaryDocument.TransformationDictionary) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject)

Example 73 with PortObject

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 };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 74 with PortObject

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 };
}
Also used : FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) PortObject(org.knime.core.node.port.PortObject) Result(org.knime.base.node.io.extractcontextprop.ReadContextPropertyConfiguration.Result)

Example 75 with PortObject

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 };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Aggregations

PortObject (org.knime.core.node.port.PortObject)173 BufferedDataTable (org.knime.core.node.BufferedDataTable)97 DataTableSpec (org.knime.core.data.DataTableSpec)68 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)59 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)39 InactiveBranchPortObject (org.knime.core.node.port.inactive.InactiveBranchPortObject)37 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)35 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)34 IOException (java.io.IOException)33 DataRow (org.knime.core.data.DataRow)25 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)24 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)23 DataCell (org.knime.core.data.DataCell)20 FileStorePortObject (org.knime.core.data.filestore.FileStorePortObject)19 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)19 DatabasePortObject (org.knime.core.node.port.database.DatabasePortObject)18 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)16 ExecutionContext (org.knime.core.node.ExecutionContext)15 DataColumnSpec (org.knime.core.data.DataColumnSpec)14 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)13