use of io.cdap.cdap.etl.api.connector.DirectConnector in project cdap by caskdata.
the class ConnectionUtils method getSampleResponse.
/**
* Return {@link SampleResponse} for the connector
*
* @throws IOException
*/
public static SampleResponse getSampleResponse(Connector connector, ConnectorContext connectorContext, SampleRequest sampleRequest, ConnectorDetail detail, ServicePluginConfigurer pluginConfigurer) throws IOException {
if (connector instanceof DirectConnector) {
DirectConnector directConnector = (DirectConnector) connector;
List<StructuredRecord> sample = directConnector.sample(connectorContext, sampleRequest);
return new SampleResponse(detail, sample.isEmpty() ? null : sample.get(0).getSchema(), sample);
}
if (connector instanceof BatchConnector) {
LimitingConnector limitingConnector = new LimitingConnector((BatchConnector) connector, pluginConfigurer);
List<StructuredRecord> sample = limitingConnector.sample(connectorContext, sampleRequest);
return new SampleResponse(detail, sample.isEmpty() ? null : sample.get(0).getSchema(), sample);
}
throw new ConnectionBadRequestException("Connector is not supported. " + "The supported connector should be DirectConnector or BatchConnector.");
}
use of io.cdap.cdap.etl.api.connector.DirectConnector in project cdap by cdapio.
the class ConnectionUtils method getSampleResponse.
/**
* Return {@link SampleResponse} for the connector
*
* @throws IOException
*/
public static SampleResponse getSampleResponse(Connector connector, ConnectorContext connectorContext, SampleRequest sampleRequest, ConnectorDetail detail, ServicePluginConfigurer pluginConfigurer) throws IOException {
if (connector instanceof DirectConnector) {
DirectConnector directConnector = (DirectConnector) connector;
List<StructuredRecord> sample = directConnector.sample(connectorContext, sampleRequest);
return new SampleResponse(detail, sample.isEmpty() ? null : sample.get(0).getSchema(), sample);
}
if (connector instanceof BatchConnector) {
LimitingConnector limitingConnector = new LimitingConnector((BatchConnector) connector, pluginConfigurer);
List<StructuredRecord> sample = limitingConnector.sample(connectorContext, sampleRequest);
return new SampleResponse(detail, sample.isEmpty() ? null : sample.get(0).getSchema(), sample);
}
throw new ConnectionBadRequestException("Connector is not supported. " + "The supported connector should be DirectConnector or BatchConnector.");
}
Aggregations