use of org.knime.core.node.config.ConfigRO in project knime-core by knime.
the class AbstractHistogramNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
try {
final File settingsFile = new File(nodeInternDir, CFG_TABLESPEC_FILE);
final FileInputStream settingsIS = new FileInputStream(settingsFile);
final ConfigRO settings = NodeSettings.loadFromXML(settingsIS);
m_tableSpec = DataTableSpec.load(settings);
final File histoDataDir = new File(nodeInternDir, CFG_DATA_DIR_NAME);
loadXCol();
loadAggrColumns();
// load the data of the implementation
loadHistogramInternals(histoDataDir, exec);
} catch (final FileNotFoundException e) {
LOGGER.debug("Previous implementations haven't stored the data");
m_tableSpec = null;
} catch (final Exception e) {
LOGGER.debug("Error while loading table specification: " + e.getMessage());
m_tableSpec = null;
throw new IOException(e.getMessage());
}
}
use of org.knime.core.node.config.ConfigRO in project knime-core by knime.
the class InteractivePieDataModel method loadFromFile.
/**
* @param dataDir the data directory to read from
* @param exec {@link ExecutionMonitor}
* @return the {@link InteractivePieDataModel}
* @throws IOException if the file could not be read
* @throws InvalidSettingsException if a setting wasn't present
* @throws CanceledExecutionException if the operation was canceled
*/
public static InteractivePieDataModel loadFromFile(final File dataDir, final ExecutionMonitor exec) throws IOException, InvalidSettingsException, CanceledExecutionException {
final File settingFile = new File(dataDir, CFG_SETTING_FILE);
final FileInputStream is = new FileInputStream(settingFile);
final GZIPInputStream inData = new GZIPInputStream(is);
final ConfigRO config = NodeSettings.loadFromXML(inData);
final boolean supportHiliting = config.getBoolean(CFG_HILITING);
final boolean detailsAvailable = config.getBoolean(CFG_DETAILS);
exec.checkCanceled();
final File dataFile = new File(dataDir, CFG_DATA_FILE);
final ContainerTable table = DataContainer.readFromZip(dataFile);
final int rowCount = table.getRowCount();
final DefaultDataArray dataArray = new DefaultDataArray(table, 1, rowCount, exec);
return new InteractivePieDataModel(dataArray, detailsAvailable, supportHiliting);
}
use of org.knime.core.node.config.ConfigRO in project knime-core by knime.
the class VirtualSubNodeInputNodeFactory 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;
}
use of org.knime.core.node.config.ConfigRO in project knime-core by knime.
the class PMCCPortObjectAndSpec method load.
/**
* Factory method to load from config.
* @param m to load from.
* @return new object loaded from argument
* @throws InvalidSettingsException If that fails.
*/
public static PMCCPortObjectAndSpec load(final ConfigRO m) throws InvalidSettingsException {
ConfigRO sub = m.getConfig(CFG_INTERNAL);
String[] names = sub.getStringArray(CFG_NAMES);
if (names == null) {
throw new InvalidSettingsException("Column names array is null.");
}
if (sub.getBoolean(CFG_CONTAINS_VALUES)) {
HalfDoubleMatrix corrMatrix = new HalfDoubleMatrix(sub.getConfig(CFG_VALUES));
return new PMCCPortObjectAndSpec(names, corrMatrix);
} else {
return new PMCCPortObjectAndSpec(names);
}
}
use of org.knime.core.node.config.ConfigRO in project knime-core by knime.
the class ShapeModelNominal method load.
/**
* Reads Shape settings from given <code>Config</code> and returns a new
* <code>ShapeModelNominal</code> object.
* @param config Reads shape model from.
* @return A new <code>ShapeModelNominal</code> object.
* @throws InvalidSettingsException If the <code>ShapeModel</code> settings
* could not be read.
* @throws NullPointerException If the <i>config</i> is <code>null</code>.
*/
public static ShapeModelNominal load(final ConfigRO config) throws InvalidSettingsException {
Map<DataCell, Shape> map = new LinkedHashMap<>();
ConfigRO keyConfig = config.getConfig(CFG_KEYS);
for (String key : keyConfig.keySet()) {
String shape = config.getString(key.toString());
DataCell cell = keyConfig.getDataCell(key);
map.put(cell, ShapeFactory.getShape(shape));
}
return new ShapeModelNominal(map);
}
Aggregations