use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class NewToOldTimeNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public StreamableOperatorInternals saveInternals() {
return null;
}
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
final RowInput in = (RowInput) inputs[0];
final RowOutput out = (RowOutput) outputs[0];
final DataTableSpec inSpec = in.getDataTableSpec();
String[] includeList = m_colSelect.applyTo(inSpec).getIncludes();
final int[] includeIndeces = Arrays.stream(includeList).mapToInt(s -> inSpec.findColumnIndex(s)).toArray();
DataRow row;
while ((row = in.poll()) != null) {
exec.checkCanceled();
DataCell[] datacells = new DataCell[includeIndeces.length];
for (int i = 0; i < includeIndeces.length; i++) {
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includeList[i], DateAndTimeCell.TYPE);
final ConvertTimeCellFactory cellFac = new ConvertTimeCellFactory(dataColumnSpecCreator.createSpec(), includeIndeces[i]);
datacells[i] = cellFac.getCells(row)[0];
} else {
final DataColumnSpec dataColSpec = new UniqueNameGenerator(inSpec).newColumn(includeList[i] + m_suffix.getStringValue(), DateAndTimeCell.TYPE);
final ConvertTimeCellFactory cellFac = new ConvertTimeCellFactory(dataColSpec, includeIndeces[i]);
datacells[i] = cellFac.getCells(row)[0];
}
}
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
out.push(new ReplacedColumnsDataRow(row, datacells, includeIndeces));
} else {
out.push(new AppendedColumnRow(row, datacells));
}
}
in.close();
out.close();
}
};
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class TwoSampleTTest method execute.
public TwoSampleTTestStatistics[] execute(final BufferedDataTable table, final ExecutionContext exec) throws InvalidSettingsException, CanceledExecutionException {
DataTableSpec spec = table.getDataTableSpec();
int groupingIndex = spec.findColumnIndex(m_grouping.getColumn());
if (groupingIndex == -1) {
throw new InvalidSettingsException("Grouping column not found.");
}
int[] testColumnsIndex = new int[m_testColumns.length];
for (int i = 0; i < testColumnsIndex.length; i++) {
testColumnsIndex[i] = spec.findColumnIndex(m_testColumns[i]);
}
int testColumnCount = m_testColumns.length;
TwoSampleTTestStatistics[] result = new TwoSampleTTestStatistics[testColumnCount];
for (int i = 0; i < testColumnCount; i++) {
result[i] = new TwoSampleTTestStatistics(m_testColumns[i], m_grouping.getGroupLabels(), m_confidenceIntervalProb);
}
final int rowCount = table.getRowCount();
int rowIndex = 0;
for (DataRow row : table) {
exec.checkCanceled();
exec.setProgress(rowIndex++ / (double) rowCount, rowIndex + "/" + rowCount + " (\"" + row.getKey() + "\")");
DataCell groupCell = row.getCell(groupingIndex);
Group group = m_grouping.getGroup(groupCell);
for (int i = 0; i < testColumnCount; i++) {
if (group == null) {
if (groupCell.isMissing()) {
result[i].addMissingGroup();
} else {
result[i].addIgnoredGroup();
}
continue;
}
DataCell cell = row.getCell(testColumnsIndex[i]);
if (!cell.isMissing()) {
DoubleValue value = (DoubleValue) cell;
result[i].addValue(value.getDoubleValue(), group);
} else {
result[i].addMissing(group);
}
}
}
return result;
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class StringToDurationPeriodNodeModel method createColumnRearranger.
private ColumnRearranger createColumnRearranger(final DataTableSpec spec) throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(spec);
final String[] includeList = m_colSelect.applyTo(spec).getIncludes();
final int[] includeIndices = Arrays.stream(m_colSelect.applyTo(spec).getIncludes()).mapToInt(s -> spec.findColumnIndex(s)).toArray();
int i = 0;
for (final String includedCol : includeList) {
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includedCol, m_detectedTypes[i]);
final StringToDurationPeriodCellFactory cellFac = new StringToDurationPeriodCellFactory(dataColumnSpecCreator.createSpec(), includeIndices[i++]);
rearranger.replace(cellFac, includedCol);
} else {
final DataColumnSpec dataColSpec = new UniqueNameGenerator(spec).newColumn(includedCol + m_suffix.getStringValue(), m_detectedTypes[i]);
final StringToDurationPeriodCellFactory cellFac = new StringToDurationPeriodCellFactory(dataColSpec, includeIndices[i++]);
rearranger.append(cellFac);
}
}
return rearranger;
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class CreateDateTimeNodeDialog method saveSettingsTo.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
updateWarningLabel();
final String text = m_warningLabel.getText();
if (!StringUtils.isEmpty(text)) {
throw new InvalidSettingsException(text);
}
settings.addString("type", ((DateTimeType) m_typeCombobox.getModel().getSelectedItem()).name());
m_dialogCompColumnName.saveSettingsTo(settings);
m_dialogCompRowNrOptionSelection.saveSettingsTo(settings);
m_dialogCompRowNrFixed.saveSettingsTo(settings);
m_dialogCompStart.saveSettingsTo(settings);
m_dialogCompDurationOrEnd.saveSettingsTo(settings);
m_dialogCompDuration.saveSettingsTo(settings);
m_dialogCompEnd.saveSettingsTo(settings);
m_dialogCompStartUseExecTime.saveSettingsTo(settings);
m_dialogCompEndUseExecTime.saveSettingsTo(settings);
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class DateTimeDifferenceNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_col1stSelectModel.validateSettings(settings);
m_col2ndSelectModel.validateSettings(settings);
m_modusSelectModel.validateSettings(settings);
SettingsModelString temp = createModusSelection();
temp.loadSettingsFrom(settings);
try {
ModusOptions.valueOf(temp.getStringValue());
} catch (IllegalArgumentException ex) {
throw new InvalidSettingsException("Unknown difference modus '" + temp.getStringValue() + "'");
}
m_fixedDateTimeModel.validateSettings(settings);
m_calculationSelectModel.validateSettings(settings);
m_granularityModel.validateSettings(settings);
m_newColNameModel.validateSettings(settings);
}
Aggregations