use of org.knime.core.node.workflow.FlowVariable in project knime-core by knime.
the class ParameterizedDBQueryPanel method loadSettingsFrom.
void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs, final Collection<FlowVariable> flowVariables) {
try {
m_appendInputColsModel.loadSettingsFrom(settings);
m_includeEmptyResultsModel.loadSettingsFrom(settings);
m_retainAllColumnsModel.loadSettingsFrom(settings);
m_failIfExceptionModel.loadSettingsFrom(settings);
m_editor.setText(settings.getString(ParameterizedDBQueryNodeModel.CFG_SQL_STATEMENT, ParameterizedDBQueryNodeModel.getDefaultSQLStatement()));
} catch (InvalidSettingsException ex) {
m_appendInputColsModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_APPEND_INPUT_COL);
m_includeEmptyResultsModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_INCLUDE_EMPTY_RESULTS);
m_retainAllColumnsModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_RETAIN_ALL_COLUMNS);
m_failIfExceptionModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_FAIL_IF_EXCEPTION);
}
updateKnimeColumns((DataTableSpec) specs[0]);
updateDBColumns(((DatabasePortObjectSpec) specs[1]).getDataTableSpec());
updateFlowVariables(flowVariables.toArray(new FlowVariable[flowVariables.size()]));
if (specs[1] != null && specs[1] instanceof DatabasePortObjectSpec) {
final DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) specs[1];
final DatabaseUtility dbUtility = DatabaseUtility.getUtility(dbSpec.getDatabaseIdentifier());
m_statementManipulator = dbUtility.getStatementManipulator();
}
}
use of org.knime.core.node.workflow.FlowVariable in project knime-core by knime.
the class DBReaderDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
if (m_showConnectionPanel) {
m_connectionPane.loadSettingsFrom(settings, specs, getCredentialsProvider());
}
DatabaseQueryConnectionSettings s = new DatabaseQueryConnectionSettings();
try {
s.loadValidatedConnection(settings, getCredentialsProvider());
} catch (InvalidSettingsException ex) {
// use settings as they are
}
// statement
String statement = s.getQuery();
m_statmnt.setText(statement == null ? "SELECT * FROM " + DatabaseQueryConnectionSettings.TABLE_PLACEHOLDER : statement);
// select the table placeholder statement for easier replacements
selectPlaceHolder(m_statmnt, DatabaseQueryConnectionSettings.TABLE_PLACEHOLDER);
// update list of flow/workflow variables
m_listModelVars.removeAllElements();
for (Map.Entry<String, FlowVariable> e : getAvailableFlowVariables().entrySet()) {
m_listModelVars.addElement(e.getValue());
}
// read execute without configure checkbox
if (runWithoutConfigure()) {
m_configureBox.setSelected(!s.getValidateQuery());
}
m_upstreamConnectionSettings = null;
for (PortObjectSpec pos : specs) {
if (pos instanceof DatabaseConnectionPortObjectSpec) {
try {
m_upstreamConnectionSettings = ((DatabaseConnectionPortObjectSpec) pos).getConnectionSettings(getCredentialsProvider());
} catch (InvalidSettingsException ex) {
LOGGER.warn("Could not load database connection from upstream node: " + ex.getMessage(), ex);
}
}
}
if (m_upstreamConnectionSettings != null || !m_showConnectionPanel) {
m_connectionPane.setVisible(false);
} else {
m_connectionPane.setVisible(true);
}
}
use of org.knime.core.node.workflow.FlowVariable in project knime-core by knime.
the class FeatureSelectionLoopEndNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
final String scoreVariableName = m_settings.getScoreVariableName();
final Map<String, FlowVariable> fvs = getAvailableInputFlowVariables();
boolean compatibleFVExists = false;
for (final FlowVariable fv : fvs.values()) {
if (fv.getType() == FlowVariable.Type.DOUBLE) {
compatibleFVExists = true;
}
}
if (!compatibleFVExists) {
throw new InvalidSettingsException("There is no compatible flow variable (Double) at the inport.");
}
if (!fvs.containsKey(scoreVariableName)) {
throw new InvalidSettingsException("The defined score variable \"" + scoreVariableName + "\" is not contained in the input flow variables.");
}
final FlowVariable scoreVariable = getAvailableInputFlowVariables().get(scoreVariableName);
if (scoreVariable.getType() != FlowVariable.Type.DOUBLE) {
throw new InvalidSettingsException("The score variable must be of type Double.");
}
// first configure
if (m_iteration == 0) {
// m_selectionStrategy = ((FeatureSelectionLoopStartNodeModel)getLoopStartNode()).getSelectionStrategy();
// m_selectionStrategy.setIsMinimize(m_settings.isMinimize());
// m_selectionStrategy.setScoreName(scoreVariableName);
FeatureSelectionLoopStartNodeModel startNode = (FeatureSelectionLoopStartNodeModel) getLoopStartNode();
m_featureSelector = startNode.getFeatureSelector();
if (m_featureSelector == null) {
return null;
}
m_featureSelector.setIsMinimize(m_settings.isMinimize());
m_featureSelector.setScoreName(scoreVariableName);
}
// the second outSpec is null because before the search is finished, we don't know which feature levels there are
return new PortObjectSpec[] { m_featureSelector.getSpecForResultTable(), null };
}
use of org.knime.core.node.workflow.FlowVariable in project knime-core by knime.
the class LoopEndConditionNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
m_settings.loadSettingsForDialog(settings);
m_variablesModel.removeAllElements();
for (FlowVariable v : getAvailableFlowVariables().values()) {
m_variablesModel.addElement(v);
if (v.getName().equals(m_settings.variableName())) {
m_variables.setSelectedItem(v);
}
}
m_operator.setSelectedItem(m_settings.operator());
m_value.setText(m_settings.value());
m_addLastRows.setSelected(m_settings.addLastRows() || m_settings.addLastRowsOnly());
m_addLastRowsOnly.setSelected(m_settings.addLastRowsOnly());
m_addLastRows.setEnabled(!m_settings.addLastRowsOnly());
m_addIterationColumn.setSelected(m_settings.addIterationColumn());
}
use of org.knime.core.node.workflow.FlowVariable in project knime-core by knime.
the class VariableLoopEndNodeModel method createNewRow.
/**
* Creates and returns new instance of <code>DataRow</code> with the
* iteration count as row key and the specified and available flow vars as
* columns.
* @return <code>DataRow</code> with the iteration count as row key and
* the specified and available flow vars as columns.
* @throws InvalidSettingsException If flow variable is of any not
* compatible type.
*/
private DataRow createNewRow() throws InvalidSettingsException {
// get available flow vars and selected vars
Map<String, FlowVariable> availableFlowVars = getAvailableFlowVariables();
// for now take all variable names
String[] flowVarNames = m_selection.applyTo(availableFlowVars).getIncludes();
// create a cell for each selected and available flow var
DataCell[] cells = new DataCell[flowVarNames.length];
if (flowVarNames.length > 0) {
for (int i = 0; i < flowVarNames.length; i++) {
String varName = flowVarNames[i];
FlowVariable var = availableFlowVars.get(varName);
// if flow var is available use flow var value
if (var != null) {
cells[i] = getCompatibleDataCell(var);
// if flow var is not available insert missing cell
} else {
cells[i] = DataType.getMissingCell();
}
}
}
return new DefaultRow(RowKey.createRowKey(m_count), cells);
}
Aggregations