use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.
the class DBReaderConnectionNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
try {
// DatabaseQueryConnectionSettings conn = m_load.getQueryConnection();
if (m_conn == null) {
throw new InvalidSettingsException("No database connection available.");
}
final DatabaseQueryConnectionSettings conn = new DatabaseQueryConnectionSettings(m_conn, parseQuery(m_conn.getQuery()));
if (!conn.getRetrieveMetadataInConfigure()) {
return new PortObjectSpec[1];
}
DBReader load = conn.getUtility().getReader(conn);
DataTableSpec spec = load.getDataTableSpec(getCredentialsProvider());
if (spec == null) {
throw new InvalidSettingsException("No database connection available.");
}
DatabasePortObjectSpec dbSpec = new DatabasePortObjectSpec(spec, conn.createConnectionModel());
return new PortObjectSpec[] { dbSpec };
} catch (InvalidSettingsException ise) {
throw ise;
} catch (Throwable t) {
throw new InvalidSettingsException(t);
}
}
use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.
the class DBRowFilterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
final String columnName = m_column.getStringValue();
if (columnName == null) {
throw new InvalidSettingsException("No filter column selected.");
}
if (!spec.getDataTableSpec().containsName(columnName)) {
throw new InvalidSettingsException("Can't filter according to " + "selected column \"" + columnName + "\".");
}
DatabaseQueryConnectionSettings conn = spec.getConnectionSettings(getCredentialsProvider());
String newQuery = createQuery(conn.getQuery(), conn.getUtility().getStatementManipulator());
conn = createDBQueryConnection(spec, newQuery);
return new PortObjectSpec[] { new DatabasePortObjectSpec(spec.getDataTableSpec(), conn.createConnectionModel()) };
}
use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.
the class WritePNGNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
String outPath = m_fileOutSettings.getStringValue();
boolean overwriteOK = m_overwriteOKBoolean.getBooleanValue();
if (outPath == null || outPath.length() == 0) {
throw new InvalidSettingsException("No output path specified");
}
File f = new File(outPath);
if (f.isDirectory()) {
throw new InvalidSettingsException("Can't write to \"" + outPath + "\": it is a directory");
}
if (f.isFile() && !overwriteOK) {
throw new InvalidSettingsException("Can't write to \"" + outPath + "\": file exists (configure overwrite in dialog)");
}
File directory = f.getParentFile();
if (directory == null || !directory.isDirectory()) {
throw new InvalidSettingsException("Can't write to \"" + outPath + "\": parent directory does not exist");
}
ImagePortObjectSpec imageInObject = (ImagePortObjectSpec) inSpecs[0];
DataType dataType = imageInObject.getDataType();
if (!dataType.isCompatible(PNGImageValue.class)) {
throw new InvalidSettingsException("Unsupported image type, " + "expecting PNG input, got " + dataType);
}
return new PortObjectSpec[0];
}
use of org.knime.core.node.port.PortObjectSpec in project GenericKnimeNodes by genericworkflownodes.
the class GenericKnimeNodeModel method createOutSpec.
protected PortObjectSpec[] createOutSpec() {
int nOut = m_fileEndingsOutPorts.length;
PortObjectSpec[] out_spec = new PortObjectSpec[nOut];
// set selected MIMEURIPortObjectSpecs at output ports
for (int i = 0; i < nOut; i++) {
// selected output MIMEType
int selectedMIMETypeIndex = getOutputTypeIndex(i);
// TODO: check
String mt = m_fileEndingsOutPorts[i][selectedMIMETypeIndex];
if (!mt.toLowerCase().equals("inactive")) {
out_spec[i] = new URIPortObjectSpec(mt);
} else {
out_spec[i] = InactiveBranchPortObjectSpec.INSTANCE;
}
}
return out_spec;
}
use of org.knime.core.node.port.PortObjectSpec in project GenericKnimeNodes by genericworkflownodes.
the class FileMergerNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
// check not null
checkNotNullSpecs(inSpecs);
// check equal MIMEType
checkEqualMIMETypes(inSpecs);
// create output spec
URIPortObjectSpec outSpec = new URIPortObjectSpec(((URIPortObjectSpec) inSpecs[0]).getFileExtensions());
return new PortObjectSpec[] { outSpec };
}
Aggregations