Browse Source

新增查询脚本

master
richie 4 years ago
parent
commit
bc560e3605
  1. BIN
      lib/finekit-10.0.jar
  2. 3
      plugin.xml
  3. 5
      src/main/java/com/fr/plugin/db/es/fun/ElasticsearchDataModel.java
  4. 92
      src/main/java/com/fr/plugin/db/es/fun/ElasticsearchTableData.java
  5. 40
      src/main/java/com/fr/plugin/db/es/fun/help/RenderUtils.java
  6. 93
      src/main/java/com/fr/plugin/db/es/fun/query/QueryBuilder.java
  7. 30
      src/main/java/com/fr/plugin/db/es/fun/type/ParaType.java
  8. 26
      src/main/java/com/fr/plugin/db/es/ui/ElasticsearchQueryPane.java
  9. 2
      src/main/java/com/fr/plugin/db/es/ui/ElasticsearchTableDataPane.java
  10. 5
      src/main/resources/com/fr/plugin/db/es/locale/es.properties
  11. 5
      src/main/resources/com/fr/plugin/db/es/locale/es_en_US.properties
  12. 5
      src/main/resources/com/fr/plugin/db/es/locale/es_zh_CN.properties

BIN
lib/finekit-10.0.jar

Binary file not shown.

3
plugin.xml

@ -3,12 +3,13 @@
<id>com.fr.plugin.db.es.v10</id> <id>com.fr.plugin.db.es.v10</id>
<name><![CDATA[Elasticsearch数据集]]></name> <name><![CDATA[Elasticsearch数据集]]></name>
<active>yes</active> <active>yes</active>
<version>1.5</version> <version>1.5.5</version>
<env-version>10.0</env-version> <env-version>10.0</env-version>
<jartime>2019-10-25</jartime> <jartime>2019-10-25</jartime>
<vendor>fanruan.richie</vendor> <vendor>fanruan.richie</vendor>
<description><![CDATA[Elasticsearch数据查询。]]></description> <description><![CDATA[Elasticsearch数据查询。]]></description>
<change-notes><![CDATA[ <change-notes><![CDATA[
[2020-09-09]查询语句中可以使用函数拼接。<br>
[2020-03-18]默认使用$..*查询语句获取所有值。<br/> [2020-03-18]默认使用$..*查询语句获取所有值。<br/>
[2020-03-11]新增查询请求类型。<br/> [2020-03-11]新增查询请求类型。<br/>
[2020-03-07]远程设计序列化问题。<br/> [2020-03-07]远程设计序列化问题。<br/>

5
src/main/java/com/fr/plugin/db/es/fun/ElasticsearchDataModel.java

@ -3,6 +3,9 @@ package com.fr.plugin.db.es.fun;
import com.fanruan.api.data.open.BaseDataModel; import com.fanruan.api.data.open.BaseDataModel;
import com.fanruan.api.err.TableDataException; import com.fanruan.api.err.TableDataException;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.plugin.db.es.fun.assist.SimpleDataModel; 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.category.ResultStandardizeSelector;
import com.fr.plugin.db.es.fun.type.ConverterType; import com.fr.plugin.db.es.fun.type.ConverterType;
@ -77,7 +80,7 @@ public class ElasticsearchDataModel extends BaseDataModel {
String text; String text;
if (StringKit.isNotBlank(endPoint)) { if (StringKit.isNotBlank(endPoint)) {
Request request = new Request(queryType.getType(), endPoint); Request request = new Request(queryType.getType(), endPoint);
request.setJsonEntity(query); request.setJsonEntity(JSONFactory.createJSON(JSON.OBJECT, query).toString());
Response response = client.performRequest(request); Response response = client.performRequest(request);
text = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); text = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
} else { } else {

92
src/main/java/com/fr/plugin/db/es/fun/ElasticsearchTableData.java

@ -1,8 +1,10 @@
package com.fr.plugin.db.es.fun; package com.fr.plugin.db.es.fun;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.conf.HolderKit; import com.fanruan.api.conf.HolderKit;
import com.fanruan.api.data.ConnectionKit; import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.open.BaseTableData; import com.fanruan.api.data.open.BaseTableData;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.AssistKit; import com.fanruan.api.util.AssistKit;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fanruan.api.xml.XmlKit; import com.fanruan.api.xml.XmlKit;
@ -12,17 +14,28 @@ import com.fr.config.holder.Conf;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.intelli.record.Focus; import com.fr.intelli.record.Focus;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.db.es.fun.help.RenderUtils; import com.fr.plugin.db.es.fun.help.RenderUtils;
import com.fr.plugin.db.es.fun.query.QueryBuilder;
import com.fr.plugin.db.es.fun.type.ConverterType; import com.fr.plugin.db.es.fun.type.ConverterType;
import com.fr.plugin.db.es.fun.type.ParaType;
import com.fr.plugin.db.es.fun.type.QueryType; import com.fr.plugin.db.es.fun.type.QueryType;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.NameReference; import com.fr.stable.NameReference;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.fasterxml.jackson.annotation.JsonInclude;
import com.fr.third.fasterxml.jackson.databind.JsonNode;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import com.fr.third.fasterxml.jackson.databind.SerializationFeature;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* @author richie * @author richie
@ -38,6 +51,8 @@ public class ElasticsearchTableData extends BaseTableData {
private Conf<Connection> database = HolderKit.obj(null, Connection.class); private Conf<Connection> database = HolderKit.obj(null, Connection.class);
@Identifier("endPoint") @Identifier("endPoint")
private Conf<String> endPoint = HolderKit.simple(StringKit.EMPTY); private Conf<String> endPoint = HolderKit.simple(StringKit.EMPTY);
@Identifier("paraType")
private Conf<String> paraType = HolderKit.simple(ParaType.PLAIN.getType());
@Identifier("query") @Identifier("query")
private Conf<String> query = HolderKit.simple(StringKit.EMPTY); private Conf<String> query = HolderKit.simple(StringKit.EMPTY);
@Identifier("queryType") @Identifier("queryType")
@ -69,6 +84,14 @@ public class ElasticsearchTableData extends BaseTableData {
this.endPoint.set(endPoint); this.endPoint.set(endPoint);
} }
public ParaType getParaType() {
return ParaType.parse(paraType.get());
}
public void setParaType(ParaType paraType) {
this.paraType.set(paraType.getType());
}
public String getQuery() { public String getQuery() {
return query.get(); return query.get();
} }
@ -118,17 +141,21 @@ public class ElasticsearchTableData extends BaseTableData {
@Focus(id = "com.fr.plugin.db.es.v10", text = "Plugin_Elasticsearch_Table_Data") @Focus(id = "com.fr.plugin.db.es.v10", text = "Plugin_Elasticsearch_Table_Data")
public DataModel createDataModel(Calculator calculator, int rowCount) { public DataModel createDataModel(Calculator calculator, int rowCount) {
ElasticsearchConnection connection = getConnection(); ElasticsearchConnection connection = getConnection();
Collection parameterCollection = this.parameters.get(); Collection<ParameterProvider> parameterCollection = this.parameters.get();
ParameterProvider[] parameterProviders = (ParameterProvider[]) parameterCollection.toArray(new ParameterProvider[0]); if (parameterCollection.isEmpty()) {
this.parameters.set(Arrays.asList(ParameterKit.analyze4Parameters(query.get(), false)));
}
ParameterProvider[] parameterProviders = processParameters(calculator);
ParameterProvider[] ps = Calculator.processParameters(calculator, parameterProviders); ParameterProvider[] ps = Calculator.processParameters(calculator, parameterProviders);
String realQueryText = new QueryBuilder().build(ps, query.get(), getParaType());
if (connection != null) { if (connection != null) {
return new ElasticsearchDataModel( return new ElasticsearchDataModel(
calculator, calculator,
connection, connection,
RenderUtils.calculateQuery(endPoint.get(), ps), RenderUtils.renderPlainText(endPoint.get(), ps),
RenderUtils.calculateQuery(query.get(), ps), realQueryText,
getQueryType(), getQueryType(),
RenderUtils.calculateQuery(script.get(), ps), RenderUtils.renderPlainText(script.get(), ps),
getConverterType(), getConverterType(),
getConfigAttribute(), getConfigAttribute(),
rowCount rowCount
@ -137,6 +164,49 @@ public class ElasticsearchTableData extends BaseTableData {
return null; return null;
} }
private String removeEmptyQuery(String realQueryText) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
String jsonText = realQueryText.replaceAll(":\\s*}", ":null}");
try {
JsonNode obj = mapper.readTree(jsonText);
AtomicInteger status = new AtomicInteger(0);
int i;
do {
i = stripEmpty(obj, status);
status.decrementAndGet();
} while (i != 0);
String txt = mapper.writeValueAsString(obj);
LogKit.info("[Elasticsearch]Query is:{}", txt);
return txt;
} catch (Exception e) {
LogKit.error(e, "[Elasticsearch]{}", e.getMessage());
}
return realQueryText;
}
private int stripEmpty(JsonNode node, AtomicInteger counter) {
Iterator<JsonNode> it = node.iterator();
while (it.hasNext()) {
JsonNode child = it.next();
if (child.isNull()
|| child.isEmpty(null)
|| (child.isTextual() && StringUtils.isEmpty(child.asText()))) {
it.remove();
counter.incrementAndGet();
} else {
stripEmpty(child, counter);
}
}
return counter.get();
}
private ElasticsearchConnection getConnection() { private ElasticsearchConnection getConnection() {
if (database.get() instanceof NameReference) { if (database.get() instanceof NameReference) {
String name = ((NameReference) database.get()).getName(); String name = ((NameReference) database.get()).getName();
@ -156,6 +226,10 @@ public class ElasticsearchTableData extends BaseTableData {
Connection con = XmlKit.readXMLConnection(reader); Connection con = XmlKit.readXMLConnection(reader);
this.setDatabase(con); this.setDatabase(con);
} }
} else if ("ParaType".equals(tmpName)) {
if ((tmpVal = reader.getElementValue()) != null) {
this.setParaType(ParaType.parse(tmpVal));
}
} else if ("Query".equals(tmpName)) { } else if ("Query".equals(tmpName)) {
if ((tmpVal = reader.getElementValue()) != null) { if ((tmpVal = reader.getElementValue()) != null) {
this.setQuery(tmpVal); this.setQuery(tmpVal);
@ -186,6 +260,7 @@ public class ElasticsearchTableData extends BaseTableData {
if (configAttribute.get() != null) { if (configAttribute.get() != null) {
XmlKit.writeXMLable(writer, configAttribute.get(), ConfigAttribute.XML_TAG); XmlKit.writeXMLable(writer, configAttribute.get(), ConfigAttribute.XML_TAG);
} }
writer.startTAG("ParaType").textNode(getParaType().getType()).end();
writer.startTAG("Query").textNode(getQuery()).end(); writer.startTAG("Query").textNode(getQuery()).end();
writer.startTAG("QueryType").textNode(getQueryType().getType()).end(); writer.startTAG("QueryType").textNode(getQueryType().getType()).end();
writer.startTAG("Script").textNode(getScript()).end(); writer.startTAG("Script").textNode(getScript()).end();
@ -200,6 +275,7 @@ public class ElasticsearchTableData extends BaseTableData {
ElasticsearchTableData cloned = (ElasticsearchTableData) super.clone(); ElasticsearchTableData cloned = (ElasticsearchTableData) super.clone();
cloned.database = (Conf<Connection>) database.clone(); cloned.database = (Conf<Connection>) database.clone();
cloned.endPoint = (Conf<String>) endPoint.clone(); cloned.endPoint = (Conf<String>) endPoint.clone();
cloned.paraType = (Conf<String>) paraType.clone();
cloned.converterType = (Conf<Integer>) converterType.clone(); cloned.converterType = (Conf<Integer>) converterType.clone();
cloned.query = (Conf<String>) query.clone(); cloned.query = (Conf<String>) query.clone();
cloned.queryType = (Conf<String>) queryType.clone(); cloned.queryType = (Conf<String>) queryType.clone();
@ -212,13 +288,17 @@ public class ElasticsearchTableData extends BaseTableData {
return obj instanceof ElasticsearchTableData return obj instanceof ElasticsearchTableData
&& AssistKit.equals(database, ((ElasticsearchTableData) obj).database) && AssistKit.equals(database, ((ElasticsearchTableData) obj).database)
&& AssistKit.equals(endPoint, ((ElasticsearchTableData) obj).endPoint) && AssistKit.equals(endPoint, ((ElasticsearchTableData) obj).endPoint)
&& AssistKit.equals(converterType, ((ElasticsearchTableData) obj).converterType) && AssistKit.equals(converterType, ((ElasticsearchTableData) obj).converterType)
&& AssistKit.equals(paraType, ((ElasticsearchTableData) obj).paraType)
&& AssistKit.equals(query, ((ElasticsearchTableData) obj).query) && AssistKit.equals(query, ((ElasticsearchTableData) obj).query)
&& AssistKit.equals(script, ((ElasticsearchTableData) obj).script); && AssistKit.equals(script, ((ElasticsearchTableData) obj).script);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return AssistKit.hashCode(database.get(), endPoint.get(), converterType.get(), query.get(), script.get()); return AssistKit.hashCode(database.get(), endPoint.get(), converterType.get(), paraType.get(), query.get(), script.get());
} }
} }

40
src/main/java/com/fr/plugin/db/es/fun/help/RenderUtils.java

@ -1,8 +1,12 @@
package com.fr.plugin.db.es.fun.help; package com.fr.plugin.db.es.fun.help;
import com.fanruan.api.script.ScriptKit;
import com.fanruan.api.util.ArrayKit; import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.RenderKit; import com.fanruan.api.util.RenderKit;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.third.fasterxml.jackson.annotation.JsonInclude;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import com.fr.third.fasterxml.jackson.databind.SerializationFeature;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -14,7 +18,7 @@ import java.util.Map;
*/ */
public class RenderUtils { public class RenderUtils {
public static String calculateQuery(String query, ParameterProvider[] ps) { public static String renderPlainText(String query, ParameterProvider[] ps) {
if (ArrayKit.isEmpty(ps)) { if (ArrayKit.isEmpty(ps)) {
return query; return query;
} }
@ -28,4 +32,38 @@ public class RenderUtils {
return query; return query;
} }
} }
public static String clearEmptyQueryNode(String query) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
String jsonText = query.replaceAll(":}", ":null}");
try {
Object obj = mapper.readValue(jsonText, Object.class);
String r = mapper.writeValueAsString(obj);
Object rt = ScriptKit.newScriptEngine().eval(String.format("(function ($) {\n" +
" function clearEmpties(o) {\n" +
" for (var k in o) {\n" +
" if (!o[k] || typeof o[k] !== \"object\") {\n" +
" continue\n" +
" }\n" +
" clearEmpties(o[k]);\n" +
" if (Object.keys(o[k]).length === 0) {\n" +
" delete o[k];\n" +
" }\n" +
" }\n" +
" }\n" +
" var obj = JSON.parse($);\n" +
" clearEmpties(obj);\n" +
" return obj;\n" +
"})('%s')", r));
return mapper.writeValueAsString(rt);
} catch (Exception e) {
return query;
}
}
} }

93
src/main/java/com/fr/plugin/db/es/fun/query/QueryBuilder.java

@ -0,0 +1,93 @@
package com.fr.plugin.db.es.fun.query;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.script.ScriptKit;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.util.RenderKit;
import com.fr.general.FArray;
import com.fr.plugin.db.es.fun.help.RenderUtils;
import com.fr.plugin.db.es.fun.type.ParaType;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import javax.script.ScriptException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2020/9/11
*/
public class QueryBuilder {
public String build(ParameterProvider[] ps, String query, ParaType paraType) {
if (ParaType.PLAIN == paraType) {
return RenderUtils.renderPlainText(query, ps);
}
int len = ArrayUtils.getLength(ps);
StringBuilder sb = new StringBuilder();
sb.append("JSON.stringify((function(");
String[] paras = new String[len];
Object[] values = new Object[len];
for (int i = 0; i < len;i ++) {
paras[i] = ps[i].getName();
Object value = ps[i].getValue();
if (value instanceof String) {
values[i] = "\"" + value + "\"";
} else if (value instanceof Iterable) {
List<Object> objects = new ArrayList<>();
((Iterable)value).forEach(el-> {
if (el instanceof String) {
objects.add("\"" + el + "\"");
} else {
objects.add(el);
}
});
values[i] = "[" + GeneralKit.join(objects.toArray(new Object[0]), ",") + "]";
} else {
values[i] = value;
}
}
sb.append(GeneralKit.join(paras, ","));
sb.append("){");
sb.append(renderQuery(ps, query));
sb.append("}(");
sb.append(GeneralKit.join(values, ","));
sb.append(")))");
try {
return GeneralKit.objectToString(ScriptKit.newScriptEngine().eval(sb.toString()));
} catch (ScriptException e) {
LogKit.error(e.getMessage(), e);
}
return RenderUtils.renderPlainText(query, ps);
}
private String renderQuery(ParameterProvider[] ps, String query) {
int len = ArrayUtils.getLength(ps);
Map<String, Object> map = new HashMap<>();
for (int i = 0; i < len; i ++) {
map.put(ps[i].getName(), ps[i].getName());
}
try {
return RenderKit.renderParameter4Tpl(query, map);
} catch (Exception e) {
return query;
}
}
public static void main(String... args) {
ParameterProvider[] ps = new ParameterProvider[] {
ParameterKit.newParameter("aa", 1),
ParameterKit.newParameter("bb", "xxx"),
ParameterKit.newParameter("cc", null),
ParameterKit.newParameter("dd", new FArray(new String[]{"qqq","qq","zzz"})),
};
QueryBuilder builder = new QueryBuilder();
String r = builder.build(ps, "return {\"aa\":aa};", ParaType.ECMASCRIPT);
System.out.println(r);
}
}

30
src/main/java/com/fr/plugin/db/es/fun/type/ParaType.java

@ -0,0 +1,30 @@
package com.fr.plugin.db.es.fun.type;
/**
* @author richie
* @version 10.0
* Created by richie on 2020/9/11
*/
public enum ParaType {
PLAIN("PLAIN"), ECMASCRIPT("SCRIPT");
private String type;
ParaType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public static ParaType parse(String text) {
for (ParaType qt : values()) {
if (qt.type.equals(text)) {
return qt;
}
}
return PLAIN;
}
}

26
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.design.dialog.BasicPane;
import com.fr.plugin.db.es.fun.ConfigAttribute; 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.ConverterType;
import com.fr.plugin.db.es.fun.type.ParaType;
import com.fr.plugin.db.es.fun.type.QueryType; import com.fr.plugin.db.es.fun.type.QueryType;
import javax.swing.*; import javax.swing.*;
@ -30,6 +31,8 @@ public class ElasticsearchQueryPane extends BasicPane {
private UITextField endPointTextField; private UITextField endPointTextField;
private UIDictionaryComboBox<ConverterType> converterTypeComboBox; private UIDictionaryComboBox<ConverterType> converterTypeComboBox;
private UIDictionaryComboBox<QueryType> queryTypeComboBox; private UIDictionaryComboBox<QueryType> queryTypeComboBox;
private UIDictionaryComboBox<ParaType> paraTypeComboBox;
private UISyntaxTextArea queryTextPane; private UISyntaxTextArea queryTextPane;
private UISyntaxTextArea scriptTextPane; private UISyntaxTextArea scriptTextPane;
private UIDictionaryComboBox<Boolean> sortedComboBox; private UIDictionaryComboBox<Boolean> sortedComboBox;
@ -46,7 +49,7 @@ public class ElasticsearchQueryPane extends BasicPane {
double p = TableLayoutKit.PREFERRED; double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL; double f = TableLayoutKit.FILL;
double[] rowSize = {p, p, p, p, p, p, p}; double[] rowSize = {p, p, p, p, p, p, p, p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};
endPointTextField = new UITextField(); endPointTextField = new UITextField();
@ -55,6 +58,14 @@ public class ElasticsearchQueryPane extends BasicPane {
new QueryType[]{QueryType.GET, QueryType.POST}, new QueryType[]{QueryType.GET, QueryType.POST},
new String[]{QueryType.GET.getType(), QueryType.POST.getType()}); new String[]{QueryType.GET.getType(), QueryType.POST.getType()});
paraTypeComboBox = new UIDictionaryComboBox<>(
new ParaType[]{ParaType.PLAIN, ParaType.ECMASCRIPT},
new String[] {
DesignKit.i18nText("Plugin-Elasticsearch_Para_Type_Plain"),
DesignKit.i18nText("Plugin-Elasticsearch_Para_Type_ECMAScript")
}
);
queryTextPane = new UISyntaxTextArea(); queryTextPane = new UISyntaxTextArea();
converterTypeComboBox = new UIDictionaryComboBox<>(new ConverterType[]{ converterTypeComboBox = new UIDictionaryComboBox<>(new ConverterType[]{
@ -75,14 +86,15 @@ public class ElasticsearchQueryPane extends BasicPane {
sortedComboBox = new UIDictionaryComboBox<>( sortedComboBox = new UIDictionaryComboBox<>(
new Boolean[]{false, true}, new Boolean[]{false, true},
new String[]{DesignKit.i18nText("Plugin-Elasticsearch_Sort_Default"), com.fr.design.i18n.Toolkit.i18nText("Plugin-JSON_Sort_Open")}); new String[]{DesignKit.i18nText("Plugin-Elasticsearch_Sort_Default"), com.fr.design.i18n.Toolkit.i18nText("Plugin-Elasticsearch_Sort_Open")});
prepareComboBox = new UIDictionaryComboBox<>( prepareComboBox = new UIDictionaryComboBox<>(
new Boolean[]{false, true}, new Boolean[]{false, true},
new String[]{DesignKit.i18nText("Plugin-Elasticsearch_Prepare_Keys_Default"), com.fr.design.i18n.Toolkit.i18nText("Plugin-JSON_Prepare_Keys_Open")} new String[]{DesignKit.i18nText("Plugin-Elasticsearch_Prepare_Keys_Default"), com.fr.design.i18n.Toolkit.i18nText("Plugin-Elasticsearch_Prepare_Keys_Open")}
); );
Component[][] coms = new Component[][]{ Component[][] coms = new Component[][]{
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Endpoint") + ":"), endPointTextField}, {new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Endpoint") + ":"), endPointTextField},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Query_Type") + ":"), queryTypeComboBox}, {new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Query_Type") + ":"), queryTypeComboBox},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Para_Type") + ":"), paraTypeComboBox},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Query") + ":"), createConditionTextPane(queryTextPane)}, {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_Type")+ ":"), converterTypeComboBox},
{new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Result_Script")+ ":"), createConditionTextPane(scriptTextPane)}, {new UILabel(DesignKit.i18nText("Plugin-Elasticsearch_Result_Script")+ ":"), createConditionTextPane(scriptTextPane)},
@ -123,6 +135,14 @@ public class ElasticsearchQueryPane extends BasicPane {
converterTypeComboBox.setSelectedItem(converterType); converterTypeComboBox.setSelectedItem(converterType);
} }
public ParaType getParaType() {
return paraTypeComboBox.getSelectedItem();
}
public void setParaType(ParaType paraType) {
paraTypeComboBox.setSelectedItem(paraType);
}
public QueryType getQueryType() { public QueryType getQueryType() {
return queryTypeComboBox.getSelectedItem(); return queryTypeComboBox.getSelectedItem();
} }

2
src/main/java/com/fr/plugin/db/es/ui/ElasticsearchTableDataPane.java

@ -164,6 +164,7 @@ public class ElasticsearchTableDataPane extends BaseTableDataPane<ElasticsearchT
queryPane.setEndPoint(tableData.getEndPoint()); queryPane.setEndPoint(tableData.getEndPoint());
queryPane.setConfigAttr(tableData.getConfigAttribute()); queryPane.setConfigAttr(tableData.getConfigAttribute());
queryPane.setQuery(tableData.getQuery()); queryPane.setQuery(tableData.getQuery());
queryPane.setParaType(tableData.getParaType());
queryPane.setQueryType(tableData.getQueryType()); queryPane.setQueryType(tableData.getQueryType());
queryPane.setConverterTypeComboBox(tableData.getConverterType()); queryPane.setConverterTypeComboBox(tableData.getConverterType());
queryPane.setScript(tableData.getScript()); queryPane.setScript(tableData.getScript());
@ -180,6 +181,7 @@ public class ElasticsearchTableDataPane extends BaseTableDataPane<ElasticsearchT
tableData.setParameters(providerList.toArray(new ParameterProvider[0])); tableData.setParameters(providerList.toArray(new ParameterProvider[0]));
tableData.setEndPoint(queryPane.getEndPoint()); tableData.setEndPoint(queryPane.getEndPoint());
tableData.setQueryType(queryPane.getQueryType()); tableData.setQueryType(queryPane.getQueryType());
tableData.setParaType(queryPane.getParaType());
tableData.setQuery(queryPane.getQuery()); tableData.setQuery(queryPane.getQuery());
tableData.setConverterType(queryPane.getConverterType()); tableData.setConverterType(queryPane.getConverterType());
tableData.setConfigAttribute(queryPane.getConfigAttr()); tableData.setConfigAttribute(queryPane.getConfigAttr());

5
src/main/resources/com/fr/plugin/db/es/locale/es.properties

@ -15,8 +15,13 @@ Plugin-Elasticsearch_Endpoint=Endpoint
Plugin-Elasticsearch_Query=Query Plugin-Elasticsearch_Query=Query
Plugin-Elasticsearch_Query_Type=Method Plugin-Elasticsearch_Query_Type=Method
Plugin-Elasticsearch_Sort_Key=Sort key Plugin-Elasticsearch_Sort_Key=Sort key
Plugin-Elasticsearch_Sort_Open=Open
Plugin-Elasticsearch_Key_Prepare=Key Prepare Plugin-Elasticsearch_Key_Prepare=Key Prepare
Plugin-Elasticsearch_Prepare_Keys_Open=Open
Plugin-Elasticsearch_Result_Type=Processor Type Plugin-Elasticsearch_Result_Type=Processor Type
Plugin-Elasticsearch_Result_Script=Processor Script Plugin-Elasticsearch_Result_Script=Processor Script
Plugin-Elasticsearch_Host_Cluster=Cluster Plugin-Elasticsearch_Host_Cluster=Cluster
Plugin-Elasticsearch_Host_Cluster_Description=Hosts and Ports must be the same count. Plugin-Elasticsearch_Host_Cluster_Description=Hosts and Ports must be the same count.
Plugin-Elasticsearch_Para_Type=Para Type
Plugin-Elasticsearch_Para_Type_Plain=Plain
Plugin-Elasticsearch_Para_Type_ECMAScript=ECMAScript

5
src/main/resources/com/fr/plugin/db/es/locale/es_en_US.properties

@ -15,8 +15,13 @@ Plugin-Elasticsearch_Endpoint=Endpoint
Plugin-Elasticsearch_Query=Query Plugin-Elasticsearch_Query=Query
Plugin-Elasticsearch_Query_Type=Method Plugin-Elasticsearch_Query_Type=Method
Plugin-Elasticsearch_Sort_Key=Sort key Plugin-Elasticsearch_Sort_Key=Sort key
Plugin-Elasticsearch_Sort_Open=Open
Plugin-Elasticsearch_Key_Prepare=Key Prepare Plugin-Elasticsearch_Key_Prepare=Key Prepare
Plugin-Elasticsearch_Prepare_Keys_Open=Open
Plugin-Elasticsearch_Result_Type=Processor Type Plugin-Elasticsearch_Result_Type=Processor Type
Plugin-Elasticsearch_Result_Script=Processor Script Plugin-Elasticsearch_Result_Script=Processor Script
Plugin-Elasticsearch_Host_Cluster=Cluster Plugin-Elasticsearch_Host_Cluster=Cluster
Plugin-Elasticsearch_Host_Cluster_Description=Hosts and Ports must be the same count. Plugin-Elasticsearch_Host_Cluster_Description=Hosts and Ports must be the same count.
Plugin-Elasticsearch_Para_Type=Para Type
Plugin-Elasticsearch_Para_Type_Plain=Plain
Plugin-Elasticsearch_Para_Type_ECMAScript=ECMAScript

5
src/main/resources/com/fr/plugin/db/es/locale/es_zh_CN.properties

@ -15,8 +15,13 @@ Plugin-Elasticsearch_Endpoint=\u7AEF\u70B9
Plugin-Elasticsearch_Query=\u67E5\u8BE2\u8BED\u53E5 Plugin-Elasticsearch_Query=\u67E5\u8BE2\u8BED\u53E5
Plugin-Elasticsearch_Query_Type=\u8BF7\u6C42\u7C7B\u578B Plugin-Elasticsearch_Query_Type=\u8BF7\u6C42\u7C7B\u578B
Plugin-Elasticsearch_Sort_Key=\u952E\u6392\u5E8F Plugin-Elasticsearch_Sort_Key=\u952E\u6392\u5E8F
Plugin-Elasticsearch_Sort_Open=\u5F00\u542F
Plugin-Elasticsearch_Key_Prepare=\u9884\u8BFB\u5217\u540D Plugin-Elasticsearch_Key_Prepare=\u9884\u8BFB\u5217\u540D
Plugin-Elasticsearch_Prepare_Keys_Open=\u5F00\u542F
Plugin-Elasticsearch_Result_Type=\u89C4\u6574\u7C7B\u578B Plugin-Elasticsearch_Result_Type=\u89C4\u6574\u7C7B\u578B
Plugin-Elasticsearch_Result_Script=\u89C4\u6574\u811A\u672C Plugin-Elasticsearch_Result_Script=\u89C4\u6574\u811A\u672C
Plugin-Elasticsearch_Host_Cluster=\u96C6\u7FA4\u914D\u7F6E\u8BF4\u660E Plugin-Elasticsearch_Host_Cluster=\u96C6\u7FA4\u914D\u7F6E\u8BF4\u660E
Plugin-Elasticsearch_Host_Cluster_Description=1\u3001\u4F7F\u7528\u9017\u53F7\u5206\u5272\u96C6\u7FA4\u4E2D\u7684\u591A\u4E2A\u6570\u636E\u5E93\u5730\u5740\u548C\u7AEF\u53E3\uFF0C\u5FC5\u987B\u8981\u6C42\u5730\u5740\u548C\u7AEF\u53E3\u6570\u91CF\u4E00\u81F4\uFF1B\n2\u3001\u6240\u6709elasticsearch\u8282\u70B9\u7684\u7528\u6237\u540D\u548C\u5BC6\u7801\u5FC5\u987B\u76F8\u540C\u3002 Plugin-Elasticsearch_Host_Cluster_Description=1\u3001\u4F7F\u7528\u9017\u53F7\u5206\u5272\u96C6\u7FA4\u4E2D\u7684\u591A\u4E2A\u6570\u636E\u5E93\u5730\u5740\u548C\u7AEF\u53E3\uFF0C\u5FC5\u987B\u8981\u6C42\u5730\u5740\u548C\u7AEF\u53E3\u6570\u91CF\u4E00\u81F4\uFF1B\n2\u3001\u6240\u6709elasticsearch\u8282\u70B9\u7684\u7528\u6237\u540D\u548C\u5BC6\u7801\u5FC5\u987B\u76F8\u540C\u3002
Plugin-Elasticsearch_Para_Type=\u67E5\u8BE2\u7C7B\u578B
Plugin-Elasticsearch_Para_Type_Plain=\u9ED8\u8BA4
Plugin-Elasticsearch_Para_Type_ECMAScript=ECMAScript

Loading…
Cancel
Save