diff --git a/plugin.xml b/plugin.xml
index 6a5a5aa..63903f5 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,13 +3,14 @@
com.fr.plugin.db.es.v10
yes
- 1.3
+ 1.4
10.0
2019-10-25
fanruan.richie
+ [2020-03-11]新增查询请求类型。
+ [2020-03-07]远程设计序列化问题。
[2020-01-07]修复一个写xml的错误。
[2020-01-02]完成插件大部分功能,正式发布。
[2019-12-31]初始化插件。
diff --git a/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchDataModel.java b/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchDataModel.java
index b1654fa..183d00c 100644
--- a/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchDataModel.java
+++ b/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchDataModel.java
@@ -6,6 +6,7 @@ import com.fanruan.api.util.StringKit;
import com.fr.plugin.db.es.fun.assist.SimpleDataModel;
import com.fr.plugin.db.es.fun.category.ResultStandardizeSelector;
import com.fr.plugin.db.es.fun.type.ConverterType;
+import com.fr.plugin.db.es.fun.type.QueryType;
import com.fr.script.Calculator;
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
@@ -26,6 +27,7 @@ public class ElasticsearchDataModel extends BaseDataModel {
private transient ElasticsearchConnection connection;
private transient String endPoint;
private transient String query;
+ private transient QueryType queryType;
private transient String script;
private transient ConverterType converterType;
private transient RestClient client;
@@ -39,6 +41,7 @@ public class ElasticsearchDataModel extends BaseDataModel {
ElasticsearchConnection connection,
String endPoint,
String query,
+ QueryType queryType,
String script,
ConverterType converterType,
ConfigAttribute configAttribute,
@@ -47,6 +50,7 @@ public class ElasticsearchDataModel extends BaseDataModel {
this.connection = connection;
this.endPoint = endPoint;
this.query = query;
+ this.queryType = queryType;
this.script = script;
this.converterType = converterType;
this.configAttribute = configAttribute;
@@ -72,7 +76,7 @@ public class ElasticsearchDataModel extends BaseDataModel {
client = connection.createClient();
String text;
if (StringKit.isNotBlank(endPoint)) {
- Request request = new Request("GET", endPoint);
+ Request request = new Request(queryType.getType(), endPoint);
request.setJsonEntity(query);
Response response = client.performRequest(request);
text = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
diff --git a/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchTableData.java b/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchTableData.java
index 39d6c54..80532f8 100644
--- a/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchTableData.java
+++ b/src/main/java/com/fr/plugin/db/es/fun/ElasticsearchTableData.java
@@ -14,6 +14,7 @@ import com.fr.general.data.DataModel;
import com.fr.intelli.record.Focus;
import com.fr.plugin.db.es.fun.help.RenderUtils;
import com.fr.plugin.db.es.fun.type.ConverterType;
+import com.fr.plugin.db.es.fun.type.QueryType;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator;
import com.fr.stable.NameReference;
@@ -39,6 +40,8 @@ public class ElasticsearchTableData extends BaseTableData {
private Conf endPoint = HolderKit.simple(StringKit.EMPTY);
@Identifier("query")
private Conf query = HolderKit.simple(StringKit.EMPTY);
+ @Identifier("queryType")
+ private Conf queryType = HolderKit.simple(QueryType.GET.getType());
@Identifier("script")
private Conf script = HolderKit.simple(StringKit.EMPTY);
@Identifier("converterType")
@@ -74,6 +77,14 @@ public class ElasticsearchTableData extends BaseTableData {
this.query.set(query);
}
+ public QueryType getQueryType() {
+ return QueryType.parse(queryType.get());
+ }
+
+ public void setQueryType(QueryType queryType) {
+ this.queryType.set(queryType.getType());
+ }
+
public String getScript() {
return script.get();
}
@@ -116,6 +127,7 @@ public class ElasticsearchTableData extends BaseTableData {
connection,
RenderUtils.calculateQuery(endPoint.get(), ps),
RenderUtils.calculateQuery(query.get(), ps),
+ getQueryType(),
RenderUtils.calculateQuery(script.get(), ps),
getConverterType(),
getConfigAttribute(),
@@ -148,6 +160,10 @@ public class ElasticsearchTableData extends BaseTableData {
if ((tmpVal = reader.getElementValue()) != null) {
this.setQuery(tmpVal);
}
+ } else if ("QueryType".equals(tmpName)) {
+ if ((tmpVal = reader.getElementValue()) != null) {
+ this.setQueryType(QueryType.parse(tmpVal));
+ }
} if ("Script".equals(tmpName)) {
if ((tmpVal = reader.getElementValue()) != null) {
this.setScript(tmpVal);
@@ -171,6 +187,7 @@ public class ElasticsearchTableData extends BaseTableData {
XmlKit.writeXMLable(writer, configAttribute.get(), ConfigAttribute.XML_TAG);
}
writer.startTAG("Query").textNode(getQuery()).end();
+ writer.startTAG("QueryType").textNode(getQueryType().getType()).end();
writer.startTAG("Script").textNode(getScript()).end();
writer.startTAG("Attr");
writer.attr("endPoint", getEndPoint());
@@ -185,6 +202,7 @@ public class ElasticsearchTableData extends BaseTableData {
cloned.endPoint = (Conf) endPoint.clone();
cloned.converterType = (Conf) converterType.clone();
cloned.query = (Conf) query.clone();
+ cloned.queryType = (Conf) queryType.clone();
cloned.script = (Conf) script.clone();
return cloned;
}
diff --git a/src/main/java/com/fr/plugin/db/es/fun/type/QueryType.java b/src/main/java/com/fr/plugin/db/es/fun/type/QueryType.java
new file mode 100644
index 0000000..57c81d2
--- /dev/null
+++ b/src/main/java/com/fr/plugin/db/es/fun/type/QueryType.java
@@ -0,0 +1,30 @@
+package com.fr.plugin.db.es.fun.type;
+
+/**
+ * @author richie
+ * @version 10.0
+ * Created by richie on 2020/3/11
+ */
+public enum QueryType {
+
+ GET("GET"), POST("POST");
+
+ private String type;
+
+ QueryType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public static QueryType parse(String text) {
+ for (QueryType qt : values()) {
+ if (qt.type.equals(text)) {
+ return qt;
+ }
+ }
+ return GET;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchQueryPane.java b/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchQueryPane.java
index 939f58b..6725b39 100644
--- a/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchQueryPane.java
+++ b/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchQueryPane.java
@@ -13,6 +13,7 @@ import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fr.design.dialog.BasicPane;
import com.fr.plugin.db.es.fun.ConfigAttribute;
import com.fr.plugin.db.es.fun.type.ConverterType;
+import com.fr.plugin.db.es.fun.type.QueryType;
import javax.swing.*;
import java.awt.*;
@@ -28,6 +29,7 @@ public class ElasticsearchQueryPane extends BasicPane {
private UITextField endPointTextField;
private UIDictionaryComboBox converterTypeComboBox;
+ private UIDictionaryComboBox queryTypeComboBox;
private UISyntaxTextArea queryTextPane;
private UISyntaxTextArea scriptTextPane;
private UIDictionaryComboBox sortedComboBox;
@@ -44,11 +46,15 @@ public class ElasticsearchQueryPane extends BasicPane {
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
- double[] rowSize = {p, p, p, p, p, p};
+ double[] rowSize = {p, p, p, p, p, p, p};
double[] columnSize = {p, f};
endPointTextField = new UITextField();
+ queryTypeComboBox = new UIDictionaryComboBox<>(
+ new QueryType[]{QueryType.GET, QueryType.POST},
+ new String[]{QueryType.GET.getType(), QueryType.POST.getType()});
+
queryTextPane = new UISyntaxTextArea();
converterTypeComboBox = new UIDictionaryComboBox<>(new ConverterType[]{
@@ -76,6 +82,7 @@ public class ElasticsearchQueryPane extends BasicPane {
);
Component[][] coms = new Component[][]{
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Endpoint") + ":"), endPointTextField},
+ {new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Query_Type") + ":"), queryTypeComboBox},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Query") + ":"), createConditionTextPane(queryTextPane)},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Result_Type")+ ":"), converterTypeComboBox},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Result_Script")+ ":"), createConditionTextPane(scriptTextPane)},
@@ -116,6 +123,14 @@ public class ElasticsearchQueryPane extends BasicPane {
converterTypeComboBox.setSelectedItem(converterType);
}
+ public QueryType getQueryType() {
+ return queryTypeComboBox.getSelectedItem();
+ }
+
+ public void setQueryType(QueryType queryType) {
+ queryTypeComboBox.setSelectedItem(queryType);
+ }
+
public String getQuery() {
return queryTextPane.getText();
}
diff --git a/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchTableDataPane.java b/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchTableDataPane.java
index 1e44c73..25252d3 100644
--- a/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchTableDataPane.java
+++ b/src/main/java/com/fr/plugin/db/es/ui/ElasticsearchTableDataPane.java
@@ -164,6 +164,7 @@ public class ElasticsearchTableDataPane extends BaseTableDataPane providerList = editorPane.update();
tableData.setParameters(providerList.toArray(new ParameterProvider[0]));
tableData.setEndPoint(queryPane.getEndPoint());
+ tableData.setQueryType(queryPane.getQueryType());
tableData.setQuery(queryPane.getQuery());
tableData.setConverterType(queryPane.getConverterType());
tableData.setConfigAttribute(queryPane.getConfigAttr());
diff --git a/src/main/resources/com/fr/plugin/db/es/locale/es.properties b/src/main/resources/com/fr/plugin/db/es/locale/es.properties
index 7663a6e..7a0bd25 100644
--- a/src/main/resources/com/fr/plugin/db/es/locale/es.properties
+++ b/src/main/resources/com/fr/plugin/db/es/locale/es.properties
@@ -13,6 +13,7 @@ Plugin-Elasticsearch_Sort_Default=Default
Plugin-Elasticsearch_Prepare_Keys_Default=Default
Plugin-Elasticsearch_Endpoint=Endpoint
Plugin-Elasticsearch_Query=Query
+Plugin-Elasticsearch_Query_Type=Method
Plugin-Elasticsearch_Sort_Key=Sort key
Plugin-Elasticsearch_Key_Prepare=Key Prepare
Plugin-Elasticsearch_Result_Type=Processor Type
diff --git a/src/main/resources/com/fr/plugin/db/es/locale/es_en_US.properties b/src/main/resources/com/fr/plugin/db/es/locale/es_en_US.properties
index 7663a6e..7a0bd25 100644
--- a/src/main/resources/com/fr/plugin/db/es/locale/es_en_US.properties
+++ b/src/main/resources/com/fr/plugin/db/es/locale/es_en_US.properties
@@ -13,6 +13,7 @@ Plugin-Elasticsearch_Sort_Default=Default
Plugin-Elasticsearch_Prepare_Keys_Default=Default
Plugin-Elasticsearch_Endpoint=Endpoint
Plugin-Elasticsearch_Query=Query
+Plugin-Elasticsearch_Query_Type=Method
Plugin-Elasticsearch_Sort_Key=Sort key
Plugin-Elasticsearch_Key_Prepare=Key Prepare
Plugin-Elasticsearch_Result_Type=Processor Type
diff --git a/src/main/resources/com/fr/plugin/db/es/locale/es_zh_CN.properties b/src/main/resources/com/fr/plugin/db/es/locale/es_zh_CN.properties
index ff94079..e55a1d3 100644
--- a/src/main/resources/com/fr/plugin/db/es/locale/es_zh_CN.properties
+++ b/src/main/resources/com/fr/plugin/db/es/locale/es_zh_CN.properties
@@ -13,6 +13,7 @@ Plugin-Elasticsearch_Sort_Default=\u9ED8\u8BA4
Plugin-Elasticsearch_Prepare_Keys_Default=\u9ED8\u8BA4
Plugin-Elasticsearch_Endpoint=\u7AEF\u70B9
Plugin-Elasticsearch_Query=\u67E5\u8BE2\u8BED\u53E5
+Plugin-Elasticsearch_Query_Type=\u8BF7\u6C42\u7C7B\u578B
Plugin-Elasticsearch_Sort_Key=\u952E\u6392\u5E8F
Plugin-Elasticsearch_Key_Prepare=\u9884\u8BFB\u5217\u540D
Plugin-Elasticsearch_Result_Type=\u89C4\u6574\u7C7B\u578B