diff --git a/plugin/example/src/main/java/io/edurt/datacap/plugin/example/ExamplePluginModule.java b/plugin/example/src/main/java/io/edurt/datacap/plugin/example/ExamplePluginModule.java index 291996e0..1badc3ac 100644 --- a/plugin/example/src/main/java/io/edurt/datacap/plugin/example/ExamplePluginModule.java +++ b/plugin/example/src/main/java/io/edurt/datacap/plugin/example/ExamplePluginModule.java @@ -19,7 +19,7 @@ public class ExamplePluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/http/cratedb/pom.xml b/plugin/http/cratedb/pom.xml new file mode 100644 index 00000000..1e67c4a0 --- /dev/null +++ b/plugin/http/cratedb/pom.xml @@ -0,0 +1,56 @@ + + + + datacap-plugin-http + io.edurt.datacap.plugin.http + 1.2.0-SNAPSHOT + + 4.0.0 + + datacap-plugin-http-cratedb + DataCap plugin for http (CrateDB) + + + 2.6.0 + http-cratedb + + + + + io.edurt.datacap + datacap-spi + provided + + + commons-beanutils + commons-beanutils + + + + + + + maven-assembly-plugin + ${assembly-plugin.version} + + ${plugin.name} + + ../../../configure/assembly/assembly-plugin.xml + + ../../../dist/plugins/${plugin.name} + + + + make-assembly + package + + single + + + + + + + \ No newline at end of file diff --git a/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBAdapter.java b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBAdapter.java new file mode 100644 index 00000000..415c182a --- /dev/null +++ b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBAdapter.java @@ -0,0 +1,80 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import io.edurt.datacap.spi.adapter.HttpAdapter; +import io.edurt.datacap.spi.connection.HttpConfigure; +import io.edurt.datacap.spi.connection.HttpConnection; +import io.edurt.datacap.spi.connection.http.HttpClient; +import io.edurt.datacap.spi.connection.http.HttpMethod; +import io.edurt.datacap.spi.json.JSON; +import io.edurt.datacap.spi.model.Response; +import io.edurt.datacap.spi.model.Time; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang3.ObjectUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +public class CrateDBAdapter + extends HttpAdapter +{ + public CrateDBAdapter(HttpConnection httpConnection) + { + super(httpConnection); + } + + @Override + public Response handlerExecute(String content) + { + Time processorTime = new Time(); + processorTime.setStart(new Date().getTime()); + Response response = this.httpConnection.getResponse(); + HttpConfigure httpConfigure = new HttpConfigure(); + if (response.getIsConnected()) { + List headers = new ArrayList<>(); + List types = new ArrayList<>(); + List columns = new ArrayList<>(); + try { + BeanUtils.copyProperties(httpConfigure, this.httpConnection.getConfigure()); + httpConfigure.setAutoConnected(Boolean.FALSE); + httpConfigure.setRetry(0); + httpConfigure.setPath("_sql?types"); + httpConfigure.setMethod(HttpMethod.POST); + Map body = new HashMap<>(); + body.put("stmt", content); + httpConfigure.setJsonBody(JSON.toJSON(body)); + HttpConnection httpConnection = new HttpConnection(httpConfigure, new Response()); + HttpClient httpClient = HttpClient.getInstance(httpConfigure, httpConnection); + String responseBody = httpClient.execute(); + CrateDBResponse applyResponse = JSON.objectmapper.readValue(responseBody, CrateDBResponse.class); + if (ObjectUtils.isNotEmpty(applyResponse.getError())) { + throw new Exception(String.join(":", applyResponse.getError().getCode(), applyResponse.getError().getMessage())); + } + else { + headers.addAll(applyResponse.getHeaders()); + types.addAll(applyResponse.getTypes()); + List _columns = (List) applyResponse.getColumns().get(0); + columns.add(handlerFormatter(httpConfigure.getFormat(), headers, _columns)); + } + response.setIsSuccessful(Boolean.TRUE); + } + catch (Exception ex) { + log.error("Execute content failed content {} exception ", content, ex); + response.setIsSuccessful(Boolean.FALSE); + response.setMessage(ex.getMessage()); + } + finally { + response.setHeaders(headers); + response.setTypes(types); + response.setColumns(columns); + } + } + processorTime.setEnd(new Date().getTime()); + response.setProcessor(processorTime); + return response; + } +} diff --git a/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBConnection.java b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBConnection.java new file mode 100644 index 00000000..73898d1b --- /dev/null +++ b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBConnection.java @@ -0,0 +1,14 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import io.edurt.datacap.spi.connection.HttpConfigure; +import io.edurt.datacap.spi.connection.HttpConnection; +import io.edurt.datacap.spi.model.Response; + +public class CrateDBConnection + extends HttpConnection +{ + public CrateDBConnection(HttpConfigure httpConfigure, Response response) + { + super(httpConfigure, response); + } +} diff --git a/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPlugin.java b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPlugin.java new file mode 100644 index 00000000..b146c7f7 --- /dev/null +++ b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPlugin.java @@ -0,0 +1,75 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import io.edurt.datacap.spi.Plugin; +import io.edurt.datacap.spi.PluginType; +import io.edurt.datacap.spi.adapter.Adapter; +import io.edurt.datacap.spi.connection.HttpConfigure; +import io.edurt.datacap.spi.connection.HttpConnection; +import io.edurt.datacap.spi.model.Configure; +import io.edurt.datacap.spi.model.Response; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang3.ObjectUtils; + +@Slf4j +public class CrateDBPlugin + implements Plugin +{ + private HttpConfigure httpConfigure; + private HttpConnection connection; + private Response response; + + @Override + public String name() + { + return "CrateDB"; + } + + @Override + public String description() + { + return "Integrate CrateDB data sources"; + } + + @Override + public PluginType type() + { + return PluginType.HTTP; + } + + @Override + public void connect(Configure configure) + { + try { + this.response = new Response(); + this.httpConfigure = new HttpConfigure(); + BeanUtils.copyProperties(this.httpConfigure, configure); + this.connection = new CrateDBConnection(this.httpConfigure, this.response); + } + catch (Exception ex) { + this.response.setIsConnected(Boolean.FALSE); + this.response.setMessage(ex.getMessage()); + } + } + + @Override + public Response execute(String content) + { + if (ObjectUtils.isNotEmpty(this.connection)) { + log.info("Execute cratedb plugin logic started"); + this.response = this.connection.getResponse(); + Adapter processor = new CrateDBAdapter(this.connection); + this.response = processor.handlerExecute(content); + log.info("Execute cratedb plugin logic end"); + } + return this.response; + } + + @Override + public void destroy() + { + if (ObjectUtils.isNotEmpty(this.connection)) { + this.connection.destroy(); + } + } +} diff --git a/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginModule.java b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginModule.java new file mode 100644 index 00000000..451188af --- /dev/null +++ b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginModule.java @@ -0,0 +1,38 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import com.google.inject.multibindings.Multibinder; +import io.edurt.datacap.spi.AbstractPluginModule; +import io.edurt.datacap.spi.Plugin; +import io.edurt.datacap.spi.PluginModule; +import io.edurt.datacap.spi.PluginType; + +public class CrateDBPluginModule + extends AbstractPluginModule + implements PluginModule +{ + @Override + public String getName() + { + return "CrateDB"; + } + + @Override + public PluginType getType() + { + return PluginType.JDBC; + } + + @Override + public AbstractPluginModule get() + { + return this; + } + + protected void configure() + { + Multibinder module = Multibinder.newSetBinder(this.binder(), String.class); + module.addBinding().toInstance(this.getClass().getSimpleName()); + Multibinder plugin = Multibinder.newSetBinder(this.binder(), Plugin.class); + plugin.addBinding().to(CrateDBPlugin.class); + } +} diff --git a/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBResponse.java b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBResponse.java new file mode 100644 index 00000000..164643ed --- /dev/null +++ b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBResponse.java @@ -0,0 +1,30 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.util.List; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CrateDBResponse +{ + @JsonProperty(value = "cols") + private List headers; + + @JsonProperty(value = "col_types") + private List types; + + @JsonProperty(value = "rows") + private List columns; + + @JsonProperty(value = "error") + private CrateDBResponseError error; +} diff --git a/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBResponseError.java b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBResponseError.java new file mode 100644 index 00000000..65af6f2d --- /dev/null +++ b/plugin/http/cratedb/src/main/java/io/edurt/datacap/plugin/http/cratedb/CrateDBResponseError.java @@ -0,0 +1,22 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class CrateDBResponseError +{ + @JsonProperty(value = "message") + private String message; + + @JsonProperty(value = "code") + private String code; +} diff --git a/plugin/http/cratedb/src/test/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginModuleTest.java b/plugin/http/cratedb/src/test/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginModuleTest.java new file mode 100644 index 00000000..9b689c80 --- /dev/null +++ b/plugin/http/cratedb/src/test/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginModuleTest.java @@ -0,0 +1,30 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; +import io.edurt.datacap.spi.Plugin; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.Set; + +public class CrateDBPluginModuleTest +{ + private Injector injector; + + @Before + public void before() + { + this.injector = Guice.createInjector(new CrateDBPluginModule()); + } + + @Test + public void test() + { + Set plugins = injector.getInstance(Key.get(new TypeLiteral>() {})); + Assert.assertTrue(plugins.size() > 0); + } +} diff --git a/plugin/http/cratedb/src/test/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginTest.java b/plugin/http/cratedb/src/test/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginTest.java new file mode 100644 index 00000000..7ac9a502 --- /dev/null +++ b/plugin/http/cratedb/src/test/java/io/edurt/datacap/plugin/http/cratedb/CrateDBPluginTest.java @@ -0,0 +1,48 @@ +package io.edurt.datacap.plugin.http.cratedb; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; +import io.edurt.datacap.spi.FormatType; +import io.edurt.datacap.spi.Plugin; +import io.edurt.datacap.spi.model.Configure; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.Optional; +import java.util.Set; + +public class CrateDBPluginTest +{ + private Injector injector; + private Configure configure; + + @Before + public void before() + { + injector = Guice.createInjector(new CrateDBPluginModule()); + configure = new Configure(); + configure.setHost("127.0.0.1"); + configure.setPort(4200); + configure.setUsername(Optional.of("crate")); + configure.setPassword(Optional.of("")); + configure.setFormat(FormatType.JSON); + } + + @Test + public void test() + { + Set plugins = injector.getInstance(Key.get(new TypeLiteral>() {})); + Optional pluginOptional = plugins.stream() + .filter(v -> v.name().equalsIgnoreCase("CrateDB")) + .findFirst(); + if (pluginOptional.isPresent()) { + Plugin plugin = pluginOptional.get(); + plugin.connect(configure); + Assert.assertNotNull(plugin.execute(plugin.validator()).getConnection()); + plugin.destroy(); + } + } +} diff --git a/plugin/http/pom.xml b/plugin/http/pom.xml new file mode 100644 index 00000000..cbd6ae19 --- /dev/null +++ b/plugin/http/pom.xml @@ -0,0 +1,19 @@ + + + + datacap-plugin + io.edurt.datacap.plugin + 1.2.0-SNAPSHOT + + 4.0.0 + pom + datacap-plugin-http + io.edurt.datacap.plugin.http + DataCap plugin for (Http) + + + cratedb + + \ No newline at end of file diff --git a/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePlugin.java b/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePlugin.java index ee94ef91..b3875e85 100644 --- a/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePlugin.java +++ b/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePlugin.java @@ -33,7 +33,7 @@ public class ClickHousePlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePluginModule.java b/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePluginModule.java index 3c728023..66cadf89 100644 --- a/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePluginModule.java +++ b/plugin/jdbc/clickhouse/src/main/java/io/edurt/datacap/plugin/jdbc/clickhouse/ClickHousePluginModule.java @@ -19,7 +19,7 @@ public class ClickHousePluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBConnection.java b/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBConnection.java index 2be1a695..123b37ff 100644 --- a/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBConnection.java +++ b/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBConnection.java @@ -21,7 +21,6 @@ public class CrateDBConnection { JdbcConfigure jdbcConfigure = (JdbcConfigure) this.getConfigure(); StringBuffer buffer = new StringBuffer(); -// buffer.append("jdbc:"); buffer.append(jdbcConfigure.getJdbcType()); buffer.append("://"); buffer.append(jdbcConfigure.getHost()); diff --git a/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPlugin.java b/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPlugin.java index 9dba530d..75962d94 100644 --- a/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPlugin.java +++ b/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPlugin.java @@ -34,7 +34,7 @@ public class CrateDBPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPluginModule.java b/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPluginModule.java index 01f1a1a5..46738f22 100644 --- a/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPluginModule.java +++ b/plugin/jdbc/cratedb/src/main/java/io/edurt/datacap/plugin/jdbc/cratedb/CrateDBPluginModule.java @@ -19,7 +19,7 @@ public class CrateDBPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2Plugin.java b/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2Plugin.java index 552ff8fb..538fc6c0 100644 --- a/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2Plugin.java +++ b/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2Plugin.java @@ -43,7 +43,7 @@ public class Db2Plugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2PluginModule.java b/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2PluginModule.java index 23b2db1c..754cdc76 100644 --- a/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2PluginModule.java +++ b/plugin/jdbc/db2/src/main/java/io/edurt/datacap/plugin/jdbc/db2/Db2PluginModule.java @@ -19,7 +19,7 @@ public class Db2PluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPlugin.java b/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPlugin.java index 3e090d37..ff780701 100644 --- a/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPlugin.java +++ b/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPlugin.java @@ -34,7 +34,7 @@ public class DremioPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPluginModule.java b/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPluginModule.java index f7c25dce..6f0645c8 100644 --- a/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPluginModule.java +++ b/plugin/jdbc/dremio/src/main/java/io/edurt/datacap/plugin/jdbc/dremio/DremioPluginModule.java @@ -19,7 +19,7 @@ public class DremioPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPlugin.java b/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPlugin.java index 0e14a633..f17d97e6 100644 --- a/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPlugin.java +++ b/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPlugin.java @@ -39,7 +39,7 @@ public class DruidPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPluginModule.java b/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPluginModule.java index 65ffd061..1a3d0417 100644 --- a/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPluginModule.java +++ b/plugin/jdbc/druid/src/main/java/io/edurt/datacap/plugin/jdbc/druid/DruidPluginModule.java @@ -19,7 +19,7 @@ public class DruidPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPlugin.java b/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPlugin.java index a9742b90..682109c6 100644 --- a/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPlugin.java +++ b/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPlugin.java @@ -33,7 +33,7 @@ public class ElasticSearchPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPluginModule.java b/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPluginModule.java index a222236d..5d45948a 100644 --- a/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPluginModule.java +++ b/plugin/jdbc/elasticsearch/src/main/java/io/edurt/datacap/plugin/jdbc/elasticsearch/ElasticSearchPluginModule.java @@ -19,7 +19,7 @@ public class ElasticSearchPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2Plugin.java b/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2Plugin.java index b9317e5a..ed7b3932 100644 --- a/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2Plugin.java +++ b/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2Plugin.java @@ -34,7 +34,7 @@ public class H2Plugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2PluginModule.java b/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2PluginModule.java index 12065b7f..dcc4e687 100644 --- a/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2PluginModule.java +++ b/plugin/jdbc/h2/src/main/java/io/edurt/datacap/plugin/jdbc/h2/H2PluginModule.java @@ -19,7 +19,7 @@ public class H2PluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePlugin.java b/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePlugin.java index 8c742e8c..ff179e51 100644 --- a/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePlugin.java +++ b/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePlugin.java @@ -34,7 +34,7 @@ public class HivePlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePluginModule.java b/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePluginModule.java index fcae6eee..7fb08c4a 100644 --- a/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePluginModule.java +++ b/plugin/jdbc/hive/src/main/java/io/edurt/datacap/plugin/jdbc/hive/HivePluginModule.java @@ -19,7 +19,7 @@ public class HivePluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePlugin.java b/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePlugin.java index ce514715..9c4dd072 100644 --- a/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePlugin.java +++ b/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePlugin.java @@ -40,7 +40,7 @@ public class IgnitePlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePluginModule.java b/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePluginModule.java index 13edc79b..3ae2d49c 100644 --- a/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePluginModule.java +++ b/plugin/jdbc/ignite/src/main/java/io/edurt/datacap/plugin/jdbc/ignite/IgnitePluginModule.java @@ -19,7 +19,7 @@ public class IgnitePluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPlugin.java b/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPlugin.java index 31f03016..313a16b1 100644 --- a/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPlugin.java +++ b/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPlugin.java @@ -34,7 +34,7 @@ public class KylinPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPluginModule.java b/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPluginModule.java index de3708a4..f0149b46 100644 --- a/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPluginModule.java +++ b/plugin/jdbc/kylin/src/main/java/io/edurt/datacap/plugin/jdbc/kylin/KylinPluginModule.java @@ -19,7 +19,7 @@ public class KylinPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPlugin.java b/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPlugin.java index 7cc25670..099bf56d 100644 --- a/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPlugin.java +++ b/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPlugin.java @@ -34,7 +34,7 @@ public class KyuubiPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPluginModule.java b/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPluginModule.java index 42f19098..13265633 100644 --- a/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPluginModule.java +++ b/plugin/jdbc/kyuubi/src/main/java/io/edurt/datacap/plugin/jdbc/kyuubi/KyuubiPluginModule.java @@ -19,7 +19,7 @@ public class KyuubiPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPlugin.java b/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPlugin.java index d79787b6..06abd71b 100644 --- a/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPlugin.java +++ b/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPlugin.java @@ -34,7 +34,7 @@ public class MonetDBPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPluginModule.java b/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPluginModule.java index 36e1bd42..e75c3ace 100644 --- a/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPluginModule.java +++ b/plugin/jdbc/monetdb/src/main/java/io/edurt/datacap/plugin/jdbc/monetdb/MonetDBPluginModule.java @@ -19,7 +19,7 @@ public class MonetDBPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPlugin.java b/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPlugin.java index c4d8ee87..59ee5ac9 100644 --- a/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPlugin.java +++ b/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPlugin.java @@ -34,7 +34,7 @@ public class MongoPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPluginModule.java b/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPluginModule.java index ae77898a..fe77e536 100644 --- a/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPluginModule.java +++ b/plugin/jdbc/mongo/src/main/java/io/edurt/datacap/plugin/jdbc/mongo/MongoPluginModule.java @@ -19,7 +19,7 @@ public class MongoPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPlugin.java b/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPlugin.java index b4e3aa78..ff2b000b 100644 --- a/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPlugin.java +++ b/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPlugin.java @@ -33,7 +33,7 @@ public class MySQLPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPluginModule.java b/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPluginModule.java index dcee1d08..470e1b75 100644 --- a/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPluginModule.java +++ b/plugin/jdbc/mysql/src/main/java/io/edurt/datacap/plugin/jdbc/mysql/MySQLPluginModule.java @@ -19,7 +19,7 @@ public class MySQLPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePlugin.java b/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePlugin.java index 6c439f99..a78682fb 100644 --- a/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePlugin.java +++ b/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePlugin.java @@ -34,7 +34,7 @@ public class OraclePlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePluginModule.java b/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePluginModule.java index 6835ad20..d66b4056 100644 --- a/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePluginModule.java +++ b/plugin/jdbc/oracle/src/main/java/io/edurt/datacap/plugin/jdbc/oracle/OraclePluginModule.java @@ -19,7 +19,7 @@ public class OraclePluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPlugin.java b/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPlugin.java index bc122307..e9987f3b 100644 --- a/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPlugin.java +++ b/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPlugin.java @@ -34,7 +34,7 @@ public class PhoenixPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPluginModule.java b/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPluginModule.java index e9d608e4..217b2e87 100644 --- a/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPluginModule.java +++ b/plugin/jdbc/phoenix/src/main/java/io/edurt/datacap/plugin/jdbc/phoenix/PhoenixPluginModule.java @@ -19,7 +19,7 @@ public class PhoenixPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/pom.xml b/plugin/jdbc/pom.xml index b575d820..f1fa7c35 100644 --- a/plugin/jdbc/pom.xml +++ b/plugin/jdbc/pom.xml @@ -11,7 +11,7 @@ pom datacap-plugin-jdbc io.edurt.datacap.plugin.jdbc - DataCap plugin for jdbc + DataCap plugin for (JDBC) mysql diff --git a/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPlugin.java b/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPlugin.java index 9149f180..db316feb 100644 --- a/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPlugin.java +++ b/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPlugin.java @@ -33,7 +33,7 @@ public class PostgreSQLPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPluginModule.java b/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPluginModule.java index dccd6537..936ef897 100644 --- a/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPluginModule.java +++ b/plugin/jdbc/postgresql/src/main/java/io/edurt/datacap/plugin/jdbc/postgresql/PostgreSQLPluginModule.java @@ -19,7 +19,7 @@ public class PostgreSQLPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPlugin.java b/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPlugin.java index ed4c8e0b..30c6504a 100644 --- a/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPlugin.java +++ b/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPlugin.java @@ -42,7 +42,7 @@ public class PrestoPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPluginModule.java b/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPluginModule.java index c7bc1eac..fe5bb941 100644 --- a/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPluginModule.java +++ b/plugin/jdbc/presto/src/main/java/io/edurt/datacap/plugin/jdbc/presto/PrestoPluginModule.java @@ -19,7 +19,7 @@ public class PrestoPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPlugin.java b/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPlugin.java index 37fd730d..a773c3f4 100644 --- a/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPlugin.java +++ b/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPlugin.java @@ -40,7 +40,7 @@ public class RedisPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPluginModule.java b/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPluginModule.java index 0979a528..933fb279 100644 --- a/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPluginModule.java +++ b/plugin/jdbc/redis/src/main/java/io/edurt/datacap/plugin/jdbc/redis/RedisPluginModule.java @@ -19,7 +19,7 @@ public class RedisPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPlugin.java b/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPlugin.java index 707c63a1..659cbb93 100644 --- a/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPlugin.java +++ b/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPlugin.java @@ -34,7 +34,7 @@ public class SqlServerPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPluginModule.java b/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPluginModule.java index 8bd24ff2..1139d829 100644 --- a/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPluginModule.java +++ b/plugin/jdbc/sqlserver/src/main/java/io/edurt/datacap/plugin/jdbc/sqlserver/SqlServerPluginModule.java @@ -19,7 +19,7 @@ public class SqlServerPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPlugin.java b/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPlugin.java index b4bd34e5..1eab5499 100644 --- a/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPlugin.java +++ b/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPlugin.java @@ -33,7 +33,7 @@ public class TrinoPlugin @Override public PluginType type() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPluginModule.java b/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPluginModule.java index 414a6ba1..f579ff83 100644 --- a/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPluginModule.java +++ b/plugin/jdbc/trino/src/main/java/io/edurt/datacap/plugin/jdbc/trino/TrinoPluginModule.java @@ -19,7 +19,7 @@ public class TrinoPluginModule @Override public PluginType getType() { - return PluginType.SOURCE; + return PluginType.JDBC; } @Override diff --git a/plugin/pom.xml b/plugin/pom.xml index 46a927a8..e7851546 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -17,5 +17,6 @@ example jdbc + http \ No newline at end of file diff --git a/server/src/main/java/io/edurt/datacap/server/service/impl/SourceServiceImpl.java b/server/src/main/java/io/edurt/datacap/server/service/impl/SourceServiceImpl.java index 3f030e5c..3a33778a 100644 --- a/server/src/main/java/io/edurt/datacap/server/service/impl/SourceServiceImpl.java +++ b/server/src/main/java/io/edurt/datacap/server/service/impl/SourceServiceImpl.java @@ -107,7 +107,7 @@ public class SourceServiceImpl { List plugins = this.injector.getInstance(Key.get(new TypeLiteral>() {})) .stream() - .filter(plugin -> plugin.type().equals(PluginType.SOURCE)) + .filter(plugin -> plugin.type().equals(PluginType.JDBC)) .map(plugin -> { PluginEntity entity = new PluginEntity(); entity.setName(plugin.name()); diff --git a/spi/pom.xml b/spi/pom.xml index 588a2a1b..59ba8ed8 100644 --- a/spi/pom.xml +++ b/spi/pom.xml @@ -14,6 +14,7 @@ 5.1.0 + 4.9.2 @@ -46,5 +47,10 @@ org.apache.commons commons-lang3 + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + diff --git a/spi/src/main/java/io/edurt/datacap/spi/PluginType.java b/spi/src/main/java/io/edurt/datacap/spi/PluginType.java index 62023803..3d0ba6c7 100644 --- a/spi/src/main/java/io/edurt/datacap/spi/PluginType.java +++ b/spi/src/main/java/io/edurt/datacap/spi/PluginType.java @@ -2,6 +2,6 @@ package io.edurt.datacap.spi; public enum PluginType { - SOURCE, - SINK + JDBC, + HTTP } diff --git a/spi/src/main/java/io/edurt/datacap/spi/adapter/HttpAdapter.java b/spi/src/main/java/io/edurt/datacap/spi/adapter/HttpAdapter.java new file mode 100644 index 00000000..44550f20 --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/adapter/HttpAdapter.java @@ -0,0 +1,35 @@ +package io.edurt.datacap.spi.adapter; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import io.edurt.datacap.spi.FormatType; +import io.edurt.datacap.spi.connection.HttpConnection; +import io.edurt.datacap.spi.formatter.FormatterFactory; +import io.edurt.datacap.spi.model.Response; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +@Slf4j +@SuppressFBWarnings(value = {"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"}, + justification = "I prefer to suppress these FindBugs warnings") +public class HttpAdapter + implements Adapter +{ + protected HttpConnection httpConnection; + + public HttpAdapter(HttpConnection httpConnection) + { + this.httpConnection = httpConnection; + } + + protected Object handlerFormatter(FormatType format, List headers, List columns) + { + return FormatterFactory.createFormatter(format, headers, columns).formatter(); + } + + @Override + public Response handlerExecute(String content) + { + return null; + } +} diff --git a/spi/src/main/java/io/edurt/datacap/spi/connection/HttpConfigure.java b/spi/src/main/java/io/edurt/datacap/spi/connection/HttpConfigure.java new file mode 100644 index 00000000..13bd963d --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/connection/HttpConfigure.java @@ -0,0 +1,27 @@ +package io.edurt.datacap.spi.connection; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import io.edurt.datacap.spi.connection.http.HttpMethod; +import io.edurt.datacap.spi.model.Configure; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Map; + +@Data +@ToString +@EqualsAndHashCode +@SuppressFBWarnings(value = {"EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC"}, + justification = "I prefer to suppress these FindBugs warnings") +public class HttpConfigure + extends Configure +{ + private String protocol = "http"; + private String path; + private HttpMethod method; + private Integer retry = 0; + private Boolean autoConnected = Boolean.FALSE; + private Map params; + private String jsonBody; +} diff --git a/spi/src/main/java/io/edurt/datacap/spi/connection/HttpConnection.java b/spi/src/main/java/io/edurt/datacap/spi/connection/HttpConnection.java new file mode 100644 index 00000000..8fa523af --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/connection/HttpConnection.java @@ -0,0 +1,57 @@ +package io.edurt.datacap.spi.connection; + +import io.edurt.datacap.spi.model.Response; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.sql.Connection; + +@Slf4j +public class HttpConnection + extends io.edurt.datacap.spi.connection.Connection +{ + private HttpConfigure httpConfigure; + private Response response; + + public HttpConnection(HttpConfigure httpConfigure, Response response) + { + super(httpConfigure, response); + } + + public String formatJdbcUrl() + { + StringBuffer buffer = new StringBuffer(); + buffer.append(this.httpConfigure.getProtocol()); + buffer.append("://"); + buffer.append(this.httpConfigure.getHost()); + buffer.append(":"); + buffer.append(this.httpConfigure.getPort()); + if (StringUtils.isNotEmpty(this.httpConfigure.getPath())) { + buffer.append("/"); + buffer.append(this.httpConfigure.getPath()); + } + return buffer.toString(); + } + + protected Connection openConnection() + { + try { + this.httpConfigure = (HttpConfigure) getConfigure(); + this.response = getResponse(); + log.info("Connection protocol {}", this.httpConfigure.getProtocol()); + log.info("Connection url {}", formatJdbcUrl()); + response.setIsConnected(Boolean.TRUE); + } + catch (Exception ex) { + log.error("Connection failed ", ex); + response.setIsConnected(Boolean.FALSE); + response.setMessage(ex.getMessage()); + } + return null; + } + + public void destroy() + { + log.info("Connection close skip"); + } +} diff --git a/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpClient.java b/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpClient.java new file mode 100644 index 00000000..149ee49f --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpClient.java @@ -0,0 +1,110 @@ +package io.edurt.datacap.spi.connection.http; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import io.edurt.datacap.spi.connection.HttpConfigure; +import io.edurt.datacap.spi.connection.HttpConnection; +import okhttp3.ConnectionPool; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import org.apache.commons.lang3.ObjectUtils; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +@SuppressFBWarnings(value = {"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"}, + justification = "I prefer to suppress these FindBugs warnings") +public class HttpClient +{ + private static final int CONNECTION_TIME_OUT = 200000; + private static final int SOCKET_TIME_OUT = 20000; + private static final int MAX_IDLE_CONNECTIONS = 30; + private static final long KEEP_ALLIVE_TIME = 60000L; + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static volatile HttpClient httpClient; + private final OkHttpClient okHttpClient; + private final HttpConfigure configure; + private final HttpConnection httpConnection; + + public HttpClient(HttpConfigure configure, HttpConnection httpConnection) + { + this.configure = configure; + this.httpConnection = httpConnection; + ConnectionPool connectionPool = new ConnectionPool(MAX_IDLE_CONNECTIONS, KEEP_ALLIVE_TIME, TimeUnit.MILLISECONDS); + this.okHttpClient = new OkHttpClient().newBuilder() + .readTimeout(SOCKET_TIME_OUT, TimeUnit.MILLISECONDS) + .writeTimeout(SOCKET_TIME_OUT, TimeUnit.MILLISECONDS) + .connectionPool(connectionPool) + .retryOnConnectionFailure(configure.getAutoConnected()) + .connectTimeout(CONNECTION_TIME_OUT, TimeUnit.MILLISECONDS) + .addInterceptor(new HttpRetryInterceptor(configure)) + .addNetworkInterceptor(new HttpRetryInterceptor(configure)) + .build(); + } + + public static HttpClient getInstance(HttpConfigure configure, HttpConnection httpConnection) + { + httpClient = new HttpClient(configure, httpConnection); + return httpClient; + } + + public String execute() + { + switch (configure.getMethod()) { + case GET: + return this.get(); + case POST: + return this.post(); + default: + return null; + } + } + + private String get() + { + HttpUrl.Builder builder = HttpUrl.parse(httpConnection.formatJdbcUrl()).newBuilder(); + if (ObjectUtils.isNotEmpty(configure.getParams())) { + for (String key : configure.getParams().keySet()) { + builder.addQueryParameter(key, configure.getParams().get(key)); + } + } + Request request = new Request.Builder() + .addHeader("Accept-Encoding", "identity") + .url(builder.build().toString()).build(); + return execute(request); + } + + private String post() + { + RequestBody requestBody = RequestBody.create(JSON, configure.getJsonBody()); + HttpUrl.Builder builder = HttpUrl.parse(httpConnection.formatJdbcUrl()).newBuilder(); + + // Adding Path Parameters + if (ObjectUtils.isNotEmpty(configure.getParams())) { + for (String key : configure.getParams().keySet()) { + builder.addQueryParameter(key, configure.getParams().get(key)); + } + } + + Request request = new Request.Builder().post(requestBody) + .addHeader("Accept-Encoding", "identity") + .url(builder.build().toString()).build(); + return execute(request); + } + + private String execute(Request request) + { + String responseBody = null; + try { + Response response = okHttpClient.newCall(request).execute(); + responseBody = response.body().string(); + } + catch (IOException | NullPointerException e) { + e.printStackTrace(); + } + return responseBody; + } +} diff --git a/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpMethod.java b/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpMethod.java new file mode 100644 index 00000000..36952ca6 --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpMethod.java @@ -0,0 +1,9 @@ +package io.edurt.datacap.spi.connection.http; + +public enum HttpMethod +{ + POST, + PUT, + DELETE, + GET +} diff --git a/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpRetryInterceptor.java b/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpRetryInterceptor.java new file mode 100644 index 00000000..b84a9d8f --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/connection/http/HttpRetryInterceptor.java @@ -0,0 +1,45 @@ +package io.edurt.datacap.spi.connection.http; + +import io.edurt.datacap.spi.connection.HttpConfigure; +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +public class HttpRetryInterceptor + implements Interceptor +{ + private final HttpConfigure configure; + private int count = 1; + + public HttpRetryInterceptor(HttpConfigure configure) + { + this.configure = configure; + } + + @Override + public Response intercept(Chain chain) + { + return retry(chain); + } + + public Response retry(Chain chain) + { + Response response = null; + Request request = chain.request(); + try { + Thread.sleep(2000); + response = chain.proceed(request); + while (!response.isSuccessful() && count < configure.getRetry()) { + count++; + response = retry(chain); + } + } + catch (Exception e) { + while (count < configure.getRetry()) { + count++; + response = retry(chain); + } + } + return response; + } +} diff --git a/spi/src/main/java/io/edurt/datacap/spi/json/JSON.java b/spi/src/main/java/io/edurt/datacap/spi/json/JSON.java new file mode 100644 index 00000000..6522eaa6 --- /dev/null +++ b/spi/src/main/java/io/edurt/datacap/spi/json/JSON.java @@ -0,0 +1,23 @@ +package io.edurt.datacap.spi.json; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JSON +{ + public static final ObjectMapper objectmapper = new ObjectMapper(); + + private JSON() {} + + public static String toJSON(Object object) + { + String json; + try { + json = objectmapper.writeValueAsString(object); + } + catch (JsonProcessingException e) { + json = null; + } + return json; + } +} diff --git a/spi/src/test/java/io/edurt/datacap/spi/connection/http/HttpClientTest.java b/spi/src/test/java/io/edurt/datacap/spi/connection/http/HttpClientTest.java new file mode 100644 index 00000000..cf86a0b9 --- /dev/null +++ b/spi/src/test/java/io/edurt/datacap/spi/connection/http/HttpClientTest.java @@ -0,0 +1,28 @@ +package io.edurt.datacap.spi.connection.http; + +import io.edurt.datacap.spi.connection.HttpConfigure; +import io.edurt.datacap.spi.connection.HttpConnection; +import io.edurt.datacap.spi.model.Response; +import org.junit.Assert; +import org.junit.Test; + +public class HttpClientTest +{ + @Test + public void test() + { + HttpConfigure httpConfigure = new HttpConfigure(); + httpConfigure.setAutoConnected(Boolean.FALSE); + httpConfigure.setRetry(0); + httpConfigure.setParams(null); + httpConfigure.setProtocol("https"); + httpConfigure.setHost("datacap.incubator.edurt.io"); + httpConfigure.setPort(443); + httpConfigure.setMethod(HttpMethod.GET); + httpConfigure.setPath("blog/index.html"); + HttpConnection httpConnection = new HttpConnection(httpConfigure, new Response()); + HttpClient httpClient = HttpClient.getInstance(httpConfigure, httpConnection); + String response = httpClient.execute(); + Assert.assertNotNull(response); + } +}