commit abae404468595044c6fc822906bdc0686356a5b1
Author: lidongy <1879087903@qq.com>
Date: Thu Mar 4 17:37:03 2021 +0800
demo数据连接、数据集迁移
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..29c9cac
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+*.iml
+.idea/
+lib/report/*.jar
+target/
+.DS_Store
+.gradle
+build
+local.properties
+classes/
+transform-classes/
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..0013a31
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,128 @@
+
+apply plugin: 'java'
+
+
+ext {
+ /**
+ * 项目中依赖的jar的路径
+ * 1.如果依赖的jar需要打包到zip中,放置在lib根目录下
+ * 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可
+ */
+ libPath = "$projectDir/../webroot/WEB-INF/lib"
+
+ /**
+ * 是否对插件的class进行加密保护,防止反编译
+ */
+ guard = false
+
+ def pluginInfo = getPluginInfo()
+ pluginPre = "fine-plugin"
+ pluginName = pluginInfo.id
+ pluginVersion = pluginInfo.version
+
+ privateLib = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0"
+ outputPath = privateLib + "/classes"
+}
+
+group = 'com.fr.plugin'
+version = '10.0'
+sourceCompatibility = '8'
+
+sourceSets {
+ main {
+ java.outputDir = file(outputPath)
+ output.resourcesDir = file(outputPath)
+ }
+}
+
+ant.importBuild("encrypt.xml")
+//定义ant变量
+ant.projectDir = projectDir
+ant.references["compile.classpath"] = ant.path {
+ fileset(dir: libPath, includes: '**/*.jar')
+ fileset(dir: ".",includes:"**/*.jar" )
+}
+
+classes.dependsOn('clean')
+
+task copyFiles(type: Copy,dependsOn: 'classes'){
+ from outputPath
+ into "$projectDir/classes"
+}
+
+task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){
+ from "$projectDir/classes"
+ into "$projectDir/transform-classes"
+ include "**/*.*"
+}
+jar.dependsOn("preJar")
+
+task makeJar(type: Jar,dependsOn: preJar){
+ from fileTree(dir: "$projectDir/transform-classes")
+ baseName pluginPre
+ appendix pluginName
+ version pluginVersion
+ destinationDir = file("$buildDir/libs")
+
+ doLast(){
+ delete file("$projectDir/classes")
+ delete file("$projectDir/transform-classes")
+ }
+}
+
+task copyFile(type: Copy,dependsOn: ["makeJar"]){
+ from "$buildDir/libs"
+ from("$projectDir/lib") {
+ include "*.jar"
+ }
+ from "$projectDir/plugin.xml"
+ into file("$buildDir/temp/plugin")
+}
+
+task zip(type:Zip,dependsOn:["copyFile"]){
+ from "$buildDir/temp/plugin"
+ destinationDir file("$buildDir/install")
+ baseName pluginPre
+ appendix pluginName
+ version pluginVersion
+}
+
+//控制build时包含哪些文件,排除哪些文件
+processResources {
+// exclude everything
+// 用*.css没效果
+// exclude '**/*.css'
+// except this file
+// include 'xx.xml'
+}
+
+/*读取plugin.xml中的version*/
+def getPluginInfo(){
+ def xmlFile = file("plugin.xml")
+ if (!xmlFile.exists()) {
+ return ["id":"none", "version":"1.0.0"]
+ }
+ def plugin = new XmlParser().parse(xmlFile)
+ def version = plugin.version[0].text()
+ def id = plugin.id[0].text()
+ return ["id":id,"version":version]
+}
+
+repositories {
+ mavenLocal()
+ maven {
+ url = uri('http://mvn.finedevelop.com/repository/maven-public/')
+ }
+}
+
+task prepare(type: Copy) {
+ into privateLib
+ from configurations.runtimeClasspath
+}
+
+dependencies {
+ //使用本地jar
+ implementation fileTree(dir: 'lib', include: ['**/*.jar'])
+ implementation fileTree(dir: libPath, include: ['**/*.jar'])
+}
+
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..402ccdd
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/finekit-10.0.jar b/lib/finekit-10.0.jar
new file mode 100644
index 0000000..160d56e
Binary files /dev/null and b/lib/finekit-10.0.jar differ
diff --git a/lib/report/.gitkepp b/lib/report/.gitkepp
new file mode 100644
index 0000000..e69de29
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..1c796e8
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,24 @@
+
+
+ com.fr.plugin.demo.dataset.transfer
+
+ yes
+ 1.0.0
+ 10.0
+ 2020-01-20
+ dec.lidongy
+
+
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..24ecefe
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,61 @@
+
+
+ 4.0.0
+
+
+ com.fr.plugin
+ starter
+ 10.0
+
+ jar
+ demo-dataset-transfer
+
+
+ com.fanruan.api
+ finekit
+ 10.0
+ system
+ ${project.basedir}/lib/finekit-10.0.jar
+
+
+
+
+ ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.demo.dataset.transfer-1.0/classes
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 6
+
+
+
+
+
+
+ fanruan
+ fanruan
+ http://mvn.finedevelop.com/repository/maven-public/
+
+ true
+ always
+ warn
+
+
+
+
+
+ fanruan
+ fanruan
+ http://mvn.finedevelop.com/repository/maven-public/
+
+ true
+ always
+ warn
+
+
+
+
\ No newline at end of file
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..cb60e26
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,8 @@
+#帆软报表数据连接、数据源迁移demo插件
+#使用举例:
+##1,创建插件中定义的数据连接
+![connection](/screenshots/connection.png)
+##2,创建插件中定义的数据集
+![dataset](/screenshots/dataset.png)
+##3,在决策平台中即可进行资源迁移
+![transfer](/screenshots/transfer.png)
diff --git a/screenshots/connection.png b/screenshots/connection.png
new file mode 100644
index 0000000..a579179
Binary files /dev/null and b/screenshots/connection.png differ
diff --git a/screenshots/dataset.png b/screenshots/dataset.png
new file mode 100644
index 0000000..57c8445
Binary files /dev/null and b/screenshots/dataset.png differ
diff --git a/screenshots/transfer.png b/screenshots/transfer.png
new file mode 100644
index 0000000..69f4c1b
Binary files /dev/null and b/screenshots/transfer.png differ
diff --git a/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnection.java b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnection.java
new file mode 100644
index 0000000..7df299c
--- /dev/null
+++ b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnection.java
@@ -0,0 +1,51 @@
+package com.fr.plugin.demo.dataset.transfer;
+
+import com.fanruan.api.conf.HolderKit;
+import com.fanruan.api.data.open.BaseConnection;
+import com.fr.config.holder.Conf;
+
+/**
+ * Created by richie on 2017/5/15.
+ */
+public class DemoConnection extends BaseConnection {
+
+ private static final long serialVersionUID = 1450808242114897557L;
+ private Conf host = HolderKit.simple("");
+ private Conf username = HolderKit.simple("");
+
+ public String getHost() {
+ return host.get();
+ }
+
+ public void setHost(String host) {
+ this.host.set(host);
+ }
+
+ public String getUsername() {
+ return username.get();
+ }
+
+ public void setUsername(String username) {
+ this.username.set(username);
+ }
+
+ @Override
+ public String getDriver() {
+ return null;
+ }
+
+ @Override
+ public void testConnection() throws Exception {
+ return;
+ }
+
+ @Override
+ public String connectMessage(boolean status) {
+ if (status) {
+ return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully") + "!";
+ } else {
+ return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed") + "!";
+ }
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionImpl.java b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionImpl.java
new file mode 100644
index 0000000..062ed56
--- /dev/null
+++ b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionImpl.java
@@ -0,0 +1,35 @@
+package com.fr.plugin.demo.dataset.transfer;
+
+import com.fr.data.impl.Connection;
+import com.fr.design.beans.BasicBeanPane;
+import com.fr.design.fun.impl.AbstractConnectionProvider;
+import com.fr.intelli.record.Focus;
+import com.fr.intelli.record.Original;
+import com.fr.record.analyzer.EnableMetrics;
+
+/**
+ * @author lidongy
+ * @version 10.0
+ * Created by lidongy on 2021/3/4
+ */
+@EnableMetrics
+public class DemoConnectionImpl extends AbstractConnectionProvider {
+ @Override
+ @Focus(id = "com.fr.plugin.demo.dataset.transfer", text = "", source = Original.PLUGIN)
+ public String nameForConnection() {
+ return "TransferableConnection";
+ }
+
+ @Override
+ public String iconPathForConnection() {
+ return "/com/fr/plugin/demo/dataset/transfer/images/demo.png";
+ }
+
+ public Class extends Connection> classForConnection() {
+ return DemoConnection.class;
+ }
+
+ public Class extends BasicBeanPane extends Connection>> appearanceForConnection() {
+ return DemoConnectionPane.class;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionPane.java b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionPane.java
new file mode 100644
index 0000000..d8d0d5e
--- /dev/null
+++ b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionPane.java
@@ -0,0 +1,62 @@
+package com.fr.plugin.demo.dataset.transfer;
+
+import com.fanruan.api.design.ui.component.UILabel;
+import com.fanruan.api.design.ui.layout.TableLayoutKit;
+import com.fr.design.data.datapane.connect.DatabaseConnectionPane;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * Created by richie on 2017/5/15.
+ */
+public class DemoConnectionPane extends DatabaseConnectionPane {
+
+ private JTextField hostTextPane;
+ private JTextField userNameTextPane;
+
+
+ @Override
+ protected JPanel mainPanel() {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ double p = TableLayoutKit.PREFERRED;
+ double f = TableLayoutKit.FILL;
+ double[] rowSize = new double[]{p, p, p, p, p, p, p, p, p, p};
+ double[] columnSize = new double[]{p, f};
+
+ hostTextPane = new JTextField();
+ userNameTextPane = new JTextField();
+ Component[][] components = new Component[][]{
+ {new UILabel("host:"), hostTextPane},
+ {new UILabel("userName:"), userNameTextPane}
+ };
+ JPanel centerPane = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize);
+ panel.add(centerPane, BorderLayout.CENTER);
+ return panel;
+ }
+
+ @Override
+ protected boolean isFineBI() {
+ return false;
+ }
+
+ @Override
+ protected void populateSubDatabaseConnectionBean(DemoConnection demoConnection) {
+ hostTextPane.setText(demoConnection.getHost());
+ userNameTextPane.setText(demoConnection.getUsername());
+ }
+
+ @Override
+ protected DemoConnection updateSubDatabaseConnectionBean() {
+ DemoConnection connection = new DemoConnection();
+ connection.setHost(hostTextPane.getText());
+ connection.setUsername(userNameTextPane.getText());
+ return connection;
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return "demo";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionTransferManager.java b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionTransferManager.java
new file mode 100644
index 0000000..5c04f1d
--- /dev/null
+++ b/src/main/java/com/fr/plugin/demo/dataset/transfer/DemoConnectionTransferManager.java
@@ -0,0 +1,43 @@
+package com.fr.plugin.demo.dataset.transfer;
+
+import com.fr.data.impl.Connection;
+import com.fr.decision.fun.impl.AbstractTransferConnectionManagerProvider;
+import com.fr.third.fasterxml.jackson.core.type.TypeReference;
+import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author lidongy
+ * @version 10.0
+ * Created by lidongy on 2021/3/4
+ */
+public class DemoConnectionTransferManager extends AbstractTransferConnectionManagerProvider {
+
+ private static final String FIELD_HOST = "host";
+ private static final String FIELD_USERNAME = "username";
+
+ @Override
+ public Class extends Connection> getConnectionClass() {
+ return DemoConnection.class;
+ }
+
+ @Override
+ public String serialize(DemoConnection demoConnection) throws Exception {
+ Map map = new HashMap<>();
+ map.put(FIELD_HOST, demoConnection.getHost());
+ map.put(FIELD_USERNAME, demoConnection.getUsername());
+ return new ObjectMapper().writeValueAsString(map);
+ }
+
+ @Override
+ public DemoConnection deserialize(String str) throws Exception {
+ Map map = new ObjectMapper().readValue(str, new TypeReference