use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class MovingAggregationNodeModel method configure.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
if (inSpecs == null || inSpecs.length != 1) {
throw new InvalidSettingsException("No input table specification available");
}
final DataTableSpec inputSpec = inSpecs[0];
m_columnAggregators2Use.clear();
final ArrayList<ColumnAggregator> invalidColAggrs = new ArrayList<>(1);
m_columnAggregators2Use.addAll(GroupByNodeModel.getAggregators(inputSpec, Collections.EMPTY_LIST, m_columnAggregators, m_patternAggregators, m_dataTypeAggregators, invalidColAggrs));
if (m_columnAggregators2Use.isEmpty()) {
setWarningMessage("No aggregation column defined");
}
if (!invalidColAggrs.isEmpty()) {
setWarningMessage(invalidColAggrs.size() + " invalid aggregation column(s) found.");
}
LOGGER.debug(m_columnAggregators2Use);
final MovingAggregationTableFactory tableFactory = createTableFactory(FileStoreFactory.createNotInWorkflowFileStoreFactory(), inputSpec);
return new DataTableSpec[] { tableFactory.createResultSpec() };
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class TimeFieldExtractorNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inSpec = inSpecs[0];
// contains timestamp?
if (!inSpec.containsCompatibleType(DateAndTimeValue.class)) {
throw new InvalidSettingsException("No timestamp found in input table!");
}
// currently selected column still there?
String selectedColName = m_selectedColumn.getStringValue();
if (selectedColName != null && !selectedColName.isEmpty()) {
if (!inSpec.containsName(selectedColName)) {
throw new InvalidSettingsException("Column " + selectedColName + " not found in input spec!");
}
} else {
// no value set: auto-configure -> choose first timeseries
for (DataColumnSpec colSpec : inSpec) {
if (colSpec.getType().isCompatible(DateAndTimeValue.class)) {
String colName = colSpec.getName();
m_selectedColumn.setStringValue(colName);
setWarningMessage("Auto-configure: selected " + colName);
break;
}
}
}
// create outputspec
ColumnRearranger colRearranger = createColumnRearranger(inSpec).getColumnRearranger();
return new DataTableSpec[] { colRearranger.createSpec() };
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class TimePresetNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
// does input spec contain a date and time col?
DataTableSpec inSpec = inSpecs[0];
if (!inSpec.containsCompatibleType(DateAndTimeValue.class)) {
throw new InvalidSettingsException("Input table must contain at least one time column!");
}
String selectedColName = m_selectedCol.getStringValue();
if (selectedColName != null && !selectedColName.isEmpty()) {
// already set -> search for column name in input table
if (!inSpec.containsName(selectedColName)) {
throw new InvalidSettingsException("Column " + selectedColName + " not found in input table!");
} else {
// check if it is of correct type
DataColumnSpec colSpec = inSpec.getColumnSpec(selectedColName);
if (!colSpec.getType().isCompatible(DateAndTimeValue.class)) {
throw new InvalidSettingsException("Selected column (" + selectedColName + ") must contain date or time!");
}
}
} else {
// not yet set -> auto-configure: choose first time column
for (DataColumnSpec colSpec : inSpec) {
if (colSpec.getType().isCompatible(DateAndTimeValue.class)) {
String colName = colSpec.getName();
m_selectedCol.setStringValue(colName);
setWarningMessage("Auto-configure: selected " + colName);
// take the first compatible column
break;
}
}
}
// values in time column are "enriched"
return inSpecs;
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class TimeMissingValueHandlingColSetting method loadSubConfigs.
/**
* Get ColSetting objects in a map, mapping name to ColSetting.
*/
private static Map<String, TimeMissingValueHandlingColSetting> loadSubConfigs(final NodeSettingsRO settings) throws InvalidSettingsException {
LinkedHashMap<String, TimeMissingValueHandlingColSetting> result = new LinkedHashMap<String, TimeMissingValueHandlingColSetting>();
for (String key : settings.keySet()) {
NodeSettingsRO subConfig = settings.getNodeSettings(key);
TimeMissingValueHandlingColSetting local = new TimeMissingValueHandlingColSetting();
try {
local.loadSettings(subConfig);
} catch (InvalidSettingsException ise) {
throw new InvalidSettingsException("Unable to load sub config for key '" + key + "'", ise);
}
result.put(key, local);
}
return result;
}
use of org.knime.core.node.InvalidSettingsException in project knime-core by knime.
the class VirtualParallelizedChunkPortObjectInNodeFactory method loadPortTypeList.
/**
* @param config
* @return TODO
* @throws InvalidSettingsException
*/
static PortType[] loadPortTypeList(final ConfigRO config) throws InvalidSettingsException {
Set<String> keySet = config.keySet();
PortType[] outTypes = new PortType[keySet.size()];
for (String s : keySet) {
ConfigRO portConfig = config.getConfig(s);
int index = portConfig.getInt("index");
CheckUtils.checkSetting(index >= 0 && index < outTypes.length, "Invalid port index must be in [0, %d]: %d", keySet.size() - 1, index);
Config portTypeConfig = portConfig.getConfig("type");
PortType type = PortType.load(portTypeConfig);
outTypes[index] = type;
}
int invalidIndex = Arrays.asList(outTypes).indexOf(null);
if (invalidIndex >= 0) {
throw new InvalidSettingsException("Unassigned port type at index " + invalidIndex);
}
return outTypes;
}
Aggregations