forked from fanruan/demo-tabledata-es
richie
5 years ago
commit
498fe0d353
18 changed files with 544 additions and 0 deletions
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project basedir="." default="jar" name="plugin"> |
||||
<!-- JDK路径,根据自己机器上实际位置修改--> |
||||
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8/Contents/Home"/> |
||||
|
||||
<property name="libs" value="${basedir}/lib"/> |
||||
<property name="publicLibs" value=""/> |
||||
<property name="reportLibs" value="${basedir}/lib/report"/> |
||||
<property name="destLoc" value="."/> |
||||
<property name="classes" value="classes"/> |
||||
<xmlproperty file="${basedir}/plugin.xml"/> |
||||
<property name="current-version" value="${plugin.version}"/> |
||||
|
||||
<!-- 插件版本--> |
||||
<property name="plugin-version" value="${current-version}"/> |
||||
<!-- 插件名字--> |
||||
<property name="plugin-name" value="elasticsearch"/> |
||||
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/> |
||||
|
||||
<target name="prepare"> |
||||
<delete dir="${classes}"/> |
||||
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||
<xmlproperty file="${basedir}/plugin.xml"/> |
||||
<delete dir="${destLoc}/${plugin.name}"/> |
||||
</target> |
||||
<path id="compile.classpath"> |
||||
<fileset dir="${libs}"> |
||||
<include name="**/*.jar"/> |
||||
</fileset> |
||||
<fileset dir="${publicLibs}"> |
||||
<include name="**/*.jar"/> |
||||
</fileset> |
||||
<fileset dir="${reportLibs}"> |
||||
<include name="**/*.jar"/> |
||||
</fileset> |
||||
</path> |
||||
<patternset id="resources4Jar"> |
||||
<exclude name="**/.settings/**"/> |
||||
<exclude name=".classpath"/> |
||||
<exclude name=".project"/> |
||||
|
||||
<exclude name="**/*.java"/> |
||||
<exclude name="**/*.db"/> |
||||
<exclude name="**/*.g"/> |
||||
<exclude name="**/package.html"/> |
||||
</patternset> |
||||
<target name="copy_resources"> |
||||
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/> |
||||
<delete dir="tmp"/> |
||||
<copy todir="tmp"> |
||||
<fileset dir="${resources_from}/src/main/resources"> |
||||
<patternset refid="resources4Jar"/> |
||||
</fileset> |
||||
</copy> |
||||
<copy todir="${classes}"> |
||||
<fileset dir="tmp"/> |
||||
</copy> |
||||
<delete dir="tmp"/> |
||||
</target> |
||||
<target name="compile_javas"> |
||||
<echo message="编译${compile_files}下的Java文件"/> |
||||
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}" |
||||
target="${target_jdk_version}" |
||||
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}" |
||||
executable="${compile_jdk_version}/bin/javac"> |
||||
<src path="${basedir}/src/main/java"/> |
||||
<exclude name="**/.svn/**"/> |
||||
<compilerarg line="-encoding UTF8 "/> |
||||
<classpath refid="compile.classpath"/> |
||||
</javac> |
||||
</target> |
||||
|
||||
<target name="jar_classes"> |
||||
<echo message="打Jar包:${jar_name}"/> |
||||
<delete file="${basedir}/${jar_name}"/> |
||||
<jar jarfile="${basedir}/${jar_name}"> |
||||
<fileset dir="${classes}"> |
||||
</fileset> |
||||
</jar> |
||||
</target> |
||||
|
||||
<target name="super_jar" depends="prepare"> |
||||
<antcall target="copy_resources"> |
||||
<param name="resources_from" value="${basedir}"/> |
||||
</antcall> |
||||
<antcall target="compile_javas"> |
||||
<param name="source_jdk_version" value="1.6"/> |
||||
<param name="target_jdk_version" value="1.6"/> |
||||
<param name="compile_jdk_version" value="${jdk.home}"/> |
||||
<param name="compile_files" value="${basedir}/src"/> |
||||
</antcall> |
||||
<echo message="compile plugin success!"/> |
||||
|
||||
<antcall target="jar_classes"> |
||||
<param name="jar_name" value="${plugin-jar}"/> |
||||
</antcall> |
||||
<delete dir="${classes}"/> |
||||
|
||||
</target> |
||||
|
||||
<target name="jar" depends="super_jar"> |
||||
<antcall target="zip"/> |
||||
</target> |
||||
|
||||
<target name="zip"> |
||||
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||
<echo message="----------zip files----------"/> |
||||
<mkdir dir="${plugin-folder}"/> |
||||
<copy todir="${plugin-folder}"> |
||||
<fileset dir="."> |
||||
<include name="${plugin-jar}"/> |
||||
<include name="plugin.xml"/> |
||||
</fileset> |
||||
<fileset dir="${libs}"> |
||||
<include name="*.jar"/> |
||||
<include name="*.dll"/> |
||||
</fileset> |
||||
</copy> |
||||
<zip destfile="${basedir}/${plugin-folder}.zip" basedir="."> |
||||
<include name="${plugin-folder}/*.jar"/> |
||||
<include name="${plugin-folder}/*.dll"/> |
||||
<include name="${plugin-folder}/plugin.xml"/> |
||||
</zip> |
||||
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/> |
||||
</target> |
||||
</project> |
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.db.es.v10</id> |
||||
<name><![CDATA[Elasticsearch数据集]]></name> |
||||
<active>yes</active> |
||||
<version>1.0</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2019-10-25</jartime> |
||||
<vendor>fanruan.richie</vendor> |
||||
<description><![CDATA[Elasticsearch数据查询。]]></description> |
||||
<change-notes><![CDATA[ |
||||
[2019-12-31]初始化插件。<br/> |
||||
]]></change-notes> |
||||
<extra-core> |
||||
<LocaleFinder class="com.fr.plugin.db.es.LocaleBridge"/> |
||||
</extra-core> |
||||
<extra-designer> |
||||
<ConnectionProvider class="com.fr.plugin.db.es.ConnectionBridge"/> |
||||
<TableDataDefineProvider class="com.fr.plugin.db.es.TableDataBridge"/> |
||||
<ServerTableDataDefineProvider class="com.fr.plugin.db.es.TableDataBridge"/> |
||||
</extra-designer> |
||||
<function-recorder class="com.fr.plugin.db.es.fun.ElasticsearchTableData"/> |
||||
</plugin> |
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>com.fr.plugin</groupId> |
||||
<artifactId>starter</artifactId> |
||||
<version>10.0</version> |
||||
</parent> |
||||
|
||||
<packaging>jar</packaging> |
||||
<artifactId>com.fr.plugin.db.es.v10</artifactId> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.fanruan.api</groupId> |
||||
<artifactId>finekit</artifactId> |
||||
<version>10.0</version> |
||||
<scope>system</scope> |
||||
<systemPath>${project.basedir}/lib/finekit-10.0.jar</systemPath> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.elasticsearch.client</groupId> |
||||
<artifactId>transport</artifactId> |
||||
<version>7.5.1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.elasticsearch</groupId> |
||||
<artifactId>elasticsearch</artifactId> |
||||
<version>7.5.1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.elasticsearch.client</groupId> |
||||
<artifactId>elasticsearch-rest-high-level-client</artifactId> |
||||
<version>7.5.1</version> |
||||
</dependency> |
||||
</dependencies> |
||||
<build> |
||||
<!---如果要更改调试插件,改这里的配置就可以了--> |
||||
<outputDirectory> |
||||
${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.db.es.v10-1.0/classes |
||||
</outputDirectory> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<configuration> |
||||
<source>6</source> |
||||
<target>6</target> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.db.es; |
||||
|
||||
import com.fr.data.impl.Connection; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractConnectionProvider; |
||||
import com.fr.plugin.db.es.fun.ElasticsearchConnection; |
||||
import com.fr.plugin.db.es.ui.ElasticsearchConnectionPane; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class ConnectionBridge extends AbstractConnectionProvider { |
||||
@Override |
||||
public String nameForConnection() { |
||||
return "ES"; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForConnection() { |
||||
return "/com/fr/plugin/db/es/images/es.png"; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Connection> classForConnection() { |
||||
return ElasticsearchConnection.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<? extends Connection>> appearanceForConnection() { |
||||
return ElasticsearchConnectionPane.class; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.plugin.db.es; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class LocaleBridge extends AbstractLocaleFinder { |
||||
|
||||
@Override |
||||
public String find() { |
||||
return "com/fr/plugin/db/es/locale/es"; |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.db.es; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; |
||||
import com.fr.plugin.db.es.fun.ElasticsearchTableData; |
||||
import com.fr.plugin.db.es.ui.ElasticsearchTableDataPane; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class TableDataBridge extends AbstractTableDataDefineProvider { |
||||
|
||||
@Override |
||||
public Class<? extends TableData> classForTableData() { |
||||
return ElasticsearchTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends TableData> classForInitTableData() { |
||||
return ElasticsearchTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends AbstractTableDataPane> appearanceForTableData() { |
||||
return ElasticsearchTableDataPane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForTableData() { |
||||
return I18nKit.getLocText("Plugin_Elasticsearch_Table_Data"); |
||||
} |
||||
|
||||
@Override |
||||
public String prefixForTableData() { |
||||
return "es"; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForTableData() { |
||||
return "/com/fr/plugin/db/es/images/es.png"; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.plugin.db.es.fun; |
||||
|
||||
import com.fanruan.api.data.open.BaseConnection; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class ElasticsearchConnection extends BaseConnection { |
||||
|
||||
@Override |
||||
public void testConnection() throws Exception { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String connectMessage(boolean b) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getDriver() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.plugin.db.es.fun; |
||||
|
||||
import com.fanruan.api.data.open.BaseDataModel; |
||||
import com.fanruan.api.err.TableDataException; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class ElasticsearchDataModel extends BaseDataModel { |
||||
|
||||
public ElasticsearchDataModel() { |
||||
|
||||
} |
||||
|
||||
private void initData() throws Exception { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public int getColumnCount() throws TableDataException { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public String getColumnName(int i) throws TableDataException { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public int getRowCount() throws TableDataException { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(int i, int i1) throws TableDataException { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void release() throws Exception { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.fr.plugin.db.es.fun; |
||||
|
||||
import com.fanruan.api.conf.HolderKit; |
||||
import com.fanruan.api.data.ConnectionKit; |
||||
import com.fanruan.api.data.open.BaseTableData; |
||||
import com.fanruan.api.util.AssistKit; |
||||
import com.fanruan.api.xml.XmlKit; |
||||
import com.fr.base.TableData; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.data.impl.Connection; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.Nameable; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
@EnableMetrics |
||||
public class ElasticsearchTableData extends BaseTableData { |
||||
|
||||
private Conf<Connection> database = HolderKit.obj(null, Connection.class); |
||||
|
||||
public ElasticsearchTableData() { |
||||
|
||||
} |
||||
|
||||
public Connection getDatabase() { |
||||
return database.get(); |
||||
} |
||||
|
||||
public void setDatabase(Connection database) { |
||||
this.database.set(database); |
||||
} |
||||
|
||||
@Override |
||||
public DataModel createDataModel(Calculator calculator) { |
||||
return createDataModel(calculator, TableData.RESULT_ALL); |
||||
} |
||||
|
||||
@Override |
||||
@Focus(id = "com.fr.plugin.db.es.v10", text = "Plugin_Elasticsearch_Table_Data") |
||||
public DataModel createDataModel(Calculator calculator, int rowCount) { |
||||
ElasticsearchConnection connection = getConnection(); |
||||
if (connection != null) { |
||||
return new ElasticsearchDataModel(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private ElasticsearchConnection getConnection() { |
||||
if (database.get() instanceof Nameable) { |
||||
String name = ((Nameable) database.get()).getName(); |
||||
return ConnectionKit.getConnection(name, ElasticsearchConnection.class); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
if (reader.isChildNode()) { |
||||
String tmpName = reader.getTagName(); |
||||
String tmpVal; |
||||
if (Connection.XML_TAG.equals(tmpName)) { |
||||
if (reader.getAttrAsString("class", null) != null) { |
||||
Connection con = XmlKit.readXMLConnection(reader); |
||||
this.setDatabase(con); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
if (this.database.get() != null) { |
||||
XmlKit.writeXMLConnection(writer, this.database.get()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
ElasticsearchTableData cloned = (ElasticsearchTableData) super.clone(); |
||||
cloned.database = (Conf<Connection>) database.clone(); |
||||
return cloned; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
return obj instanceof ElasticsearchTableData |
||||
&& AssistKit.equals(database, ((ElasticsearchTableData) obj).database); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return AssistKit.hashCode(database.get()); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.db.es.ui; |
||||
|
||||
import com.fanruan.api.design.work.DatabaseConnectionPane; |
||||
import com.fr.plugin.db.es.fun.ElasticsearchConnection; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class ElasticsearchConnectionPane extends DatabaseConnectionPane<ElasticsearchConnection> { |
||||
|
||||
@Override |
||||
protected JPanel mainPanel() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected void populateSubDatabaseConnectionBean(ElasticsearchConnection elasticsearchConnection) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected ElasticsearchConnection updateSubDatabaseConnectionBean() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.plugin.db.es.ui; |
||||
|
||||
import com.fanruan.api.design.work.BaseTableDataPane; |
||||
import com.fr.plugin.db.es.fun.ElasticsearchTableData; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/12/31 |
||||
*/ |
||||
public class ElasticsearchTableDataPane extends BaseTableDataPane<ElasticsearchTableData> { |
||||
|
||||
@Override |
||||
public void populateBean(ElasticsearchTableData elasticsearchTableData) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public ElasticsearchTableData updateBean() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1 @@
|
||||
Plugin_Elasticsearch_Table_Data=Elasticsearch |
@ -0,0 +1 @@
|
||||
Plugin_Elasticsearch_Table_Data=Elasticsearch |
Loading…
Reference in new issue