use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.
the class BaseComprehendNodeModel method createStreamableOperator.
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
final DataTableSpec spec = (DataTableSpec) inSpecs[DATA_PORT_IDX];
final ConnectionInformationPortObjectSpec cnxSpec = (ConnectionInformationPortObjectSpec) inSpecs[CNX_PORT_IDX];
final int textColIdx = spec.findColumnIndex(m_textColumnName.getStringValue());
final CloudConnectionInformation cxnInfo = (CloudConnectionInformation) cnxSpec.getConnectionInformation();
final ComprehendOperation op = getOperationInstance(cxnInfo, generateOutputTableSpec(((DataTableSpec) inSpecs[DATA_PORT_IDX])), m_textColumnName.getStringValue());
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
final RowInput input = (RowInput) inputs[DATA_PORT_IDX];
final RowOutput output = (RowOutput) outputs[0];
final ComprehendConnection connection = new ComprehendConnection(cxnInfo);
final AmazonComprehend comprehendClient = connection.getClient();
op.compute(input, output, comprehendClient, textColIdx, exec, 0L);
input.close();
output.close();
}
};
}
use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.
the class TranslateNodeModel method createStreamableOperator.
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
final DataTableSpec dataSpec = (DataTableSpec) inSpecs[DATA_PORT_IDX];
final ConnectionInformationPortObjectSpec cnxSpec = (ConnectionInformationPortObjectSpec) inSpecs[CNX_PORT_IDX];
final CloudConnectionInformation cxnInfo = (CloudConnectionInformation) cnxSpec.getConnectionInformation();
final TranslateOperation translateOp = new TranslateOperation(cxnInfo, m_textColumnName.getStringValue(), TranslateUtils.getTargetLanguageMap().getOrDefault(m_sourceLanguage.getStringValue(), "auto"), TranslateUtils.getSourceLanguageMap().getOrDefault(m_targetLanguage.getStringValue(), "en"), createNewDataTableSpec(dataSpec));
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
RowInput input = (RowInput) inputs[1];
RowOutput output = (RowOutput) outputs[0];
translateOp.compute(input, output, exec, 0L);
input.close();
output.close();
}
};
}
use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.
the class TranslateNodeModel method configure.
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
if (inSpecs[CNX_PORT_IDX] != null) {
final ConnectionInformationPortObjectSpec object = (ConnectionInformationPortObjectSpec) inSpecs[CNX_PORT_IDX];
final ConnectionInformation cxnInfo = object.getConnectionInformation();
// Check if the port object has connection information
if (cxnInfo == null) {
throw new InvalidSettingsException("No connection information available");
}
if (!ConnectionUtils.regionSupported(cxnInfo.getHost(), AmazonTranslate.ENDPOINT_PREFIX)) {
throw new InvalidSettingsException("Unsupported region for the Amazon Translate service: " + cxnInfo.getHost());
}
} else {
throw new InvalidSettingsException("No connection information available");
}
TranslateUtils.checkPair(m_sourceLanguage.getStringValue(), m_targetLanguage.getStringValue());
final DataTableSpec tblSpec = (DataTableSpec) inSpecs[DATA_PORT_IDX];
checkDataTableSpec(tblSpec);
return new DataTableSpec[] { createNewDataTableSpec(tblSpec) };
}
use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.
the class S3FilePickerNodeDialog method checkConnectionInformation.
/**
* {@inheritDoc}
*/
@Override
protected void checkConnectionInformation(PortObjectSpec spec) throws NotConfigurableException {
if (spec != null) {
final ConnectionInformationPortObjectSpec object = (ConnectionInformationPortObjectSpec) spec;
final ConnectionInformation connectionInformation = object.getConnectionInformation();
// Check if the port object has connection information
if (connectionInformation == null || !connectionInformation.getProtocol().equals(AmazonS3.ENDPOINT_PREFIX)) {
throw new NotConfigurableException("No S3 connection information is available");
}
m_connectionInformation = connectionInformation;
} else {
throw new NotConfigurableException("No S3 connection information available");
}
}
use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.
the class AbstractFilePickerNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
if (inSpecs[0] != null) {
final ConnectionInformationPortObjectSpec object = (ConnectionInformationPortObjectSpec) inSpecs[0];
m_connectionInformation = object.getConnectionInformation();
// Check if the port object has connection information
if (m_connectionInformation == null || !m_connectionInformation.getProtocol().equals(getEndpointPrefix())) {
throw new InvalidSettingsException("No " + getEndpointPrefix() + " connection information available");
}
} else {
throw new InvalidSettingsException("No " + getEndpointPrefix() + "connection information available");
}
/*
* Validate the selected file. The file cannot be empty, must start with
* "/", cannot end with "/" and must have at least two "/" which
* indicates that at least the bucket path is defined
*/
if (StringUtils.isBlank(m_fileSelection) || !m_fileSelection.startsWith("/") || m_fileSelection.endsWith("/") || m_fileSelection.indexOf("/", 1) < 0) {
throw new InvalidSettingsException("The selected file is not valid");
}
if (m_expirationModel.getExpirationMode().equals(ExpirationMode.DATE.name()) && m_expirationModel.getDate().before(new Date())) {
throw new InvalidSettingsException("Expiration time: " + m_expirationModel.getDate().toString() + " is in the past. (" + new Date().toString() + ")");
}
getLogger().debug("Current Time Configure: " + new Date());
return new PortObjectSpec[] { FlowVariablePortObjectSpec.INSTANCE };
}
Aggregations