From e5ffbcb32bab04e3db9e79f4a5d8d5cc39b55696 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 26 Mar 2019 20:13:53 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-15312=20=E5=BC=80=E6=94=BEAPI=E6=95=B4?= =?UTF-8?q?=E7=90=86=E4=BB=BB=E5=8A=A1=20=E8=A1=A5=E5=85=85=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=96=B0=E5=A2=9E=E7=9A=84api=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E6=9C=89=E9=97=AE=E9=A2=98=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin-report-doc-demo/plugin.xml | 5 +- .../src/com/fr/io/ExcuteDemo.java | 14 +--- .../src/com/fr/io/ExportApi.java | 16 +--- .../src/com/fr/io/ExportBatch.java | 13 +--- .../src/com/fr/io/ExportExcel.java | 19 ++++- .../src/com/fr/io/ExportReports.java | 20 ++++- .../src/com/fr/io/JavaPrint.java | 15 ++++ .../src/com/fr/io/SetParameterWindow.java | 13 +--- .../src/com/fr/io/SimpleDemo.java | 13 +--- .../com/fr/openapi/remote/TemplateRead.java | 73 +++++++++++++++++++ .../com/fr/plugin/core/MyLocaleFinder.java | 15 ++++ .../ResourcePathTransformerImpl.java | 18 +++++ .../core/secondary/SiteTransformerImpl.java | 23 ++++++ 13 files changed, 191 insertions(+), 66 deletions(-) create mode 100644 plugin-report-doc-demo/src/com/fr/openapi/remote/TemplateRead.java create mode 100644 plugin-report-doc-demo/src/com/fr/plugin/core/MyLocaleFinder.java create mode 100644 plugin-report-doc-demo/src/com/fr/plugin/core/secondary/ResourcePathTransformerImpl.java create mode 100644 plugin-report-doc-demo/src/com/fr/plugin/core/secondary/SiteTransformerImpl.java diff --git a/plugin-report-doc-demo/plugin.xml b/plugin-report-doc-demo/plugin.xml index 879bd29..9bcebc7 100644 --- a/plugin-report-doc-demo/plugin.xml +++ b/plugin-report-doc-demo/plugin.xml @@ -4,7 +4,7 @@ yes no - 1.1.1 + 1.2 10.0~ 2018-08-02 finereport @@ -13,8 +13,9 @@ [2018-01-25] 发布。
[2018-08-02] 插件适配10 ]]> + - + diff --git a/plugin-report-doc-demo/src/com/fr/io/ExcuteDemo.java b/plugin-report-doc-demo/src/com/fr/io/ExcuteDemo.java index d77fa1c..4c799a6 100644 --- a/plugin-report-doc-demo/src/com/fr/io/ExcuteDemo.java +++ b/plugin-report-doc-demo/src/com/fr/io/ExcuteDemo.java @@ -10,12 +10,8 @@ import com.fr.module.Module; import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.module.ReportBaseActivator; -import com.fr.serialization.SerializationActivator; import com.fr.stable.WriteActor; -import com.fr.startup.WorkspaceRegister; import com.fr.store.StateServerActivator; -import com.fr.workspace.engine.WorkspaceActivator; -import com.fr.workspace.server.ServerWorkspaceRegister; import com.fr.workspace.simple.SimpleWork; import java.io.File; @@ -26,18 +22,12 @@ public class ExcuteDemo { public static void main(String[] args) { try { // 首先需要定义执行所在的环境,这样才能正确读取数据库信息 - // 定义报表运行环境,用于执行报表 - Module module = ActivatorToolBox.simpleLink( - new WorkspaceActivator(), - new BaseDBActivator(), + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), new ConfigurationActivator(), new StateServerActivator(), new ReportBaseActivator(), new RestrictionActivator(), - new ReportActivator(), - new WorkspaceRegister(), - new ServerWorkspaceRegister(), - new SerializationActivator()); + new ReportActivator()); String envpath = "D:\\FineReport_10\\webapps\\webroot\\WEB-INF";//工程路径 SimpleWork.checkIn(envpath); module.start(); diff --git a/plugin-report-doc-demo/src/com/fr/io/ExportApi.java b/plugin-report-doc-demo/src/com/fr/io/ExportApi.java index 8786733..3523d25 100644 --- a/plugin-report-doc-demo/src/com/fr/io/ExportApi.java +++ b/plugin-report-doc-demo/src/com/fr/io/ExportApi.java @@ -20,12 +20,8 @@ import com.fr.module.Module; import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.module.ReportBaseActivator; -import com.fr.serialization.SerializationActivator; import com.fr.stable.WriteActor; -import com.fr.startup.WorkspaceRegister; import com.fr.store.StateServerActivator; -import com.fr.workspace.engine.WorkspaceActivator; -import com.fr.workspace.server.ServerWorkspaceRegister; import com.fr.workspace.simple.SimpleWork; import java.io.File; @@ -35,19 +31,13 @@ import java.io.FileOutputStream; public class ExportApi { public static void main(String[] args) { // 定义报表运行环境,才能执行报表 - // 定义报表运行环境,用于执行报表 - Module module = ActivatorToolBox.simpleLink( - new WorkspaceActivator(), - new BaseDBActivator(), + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), new ConfigurationActivator(), new StateServerActivator(), new ReportBaseActivator(), new RestrictionActivator(), - new ReportActivator(), - new WorkspaceRegister(), - new ServerWorkspaceRegister(), - new SerializationActivator()); - String envpath = "D:\\FineReport_10\\webapps\\webroot\\WEB-INF";//工程路径 + new ReportActivator()); + String envpath = "D:\\FineReport_10.0\\webapps\\webroot\\WEB-INF"; SimpleWork.checkIn(envpath); module.start(); ResultWorkBook rworkbook = null; diff --git a/plugin-report-doc-demo/src/com/fr/io/ExportBatch.java b/plugin-report-doc-demo/src/com/fr/io/ExportBatch.java index efe2a29..227c15b 100644 --- a/plugin-report-doc-demo/src/com/fr/io/ExportBatch.java +++ b/plugin-report-doc-demo/src/com/fr/io/ExportBatch.java @@ -11,13 +11,9 @@ import com.fr.module.Module; import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.module.ReportBaseActivator; -import com.fr.serialization.SerializationActivator; import com.fr.stable.StableUtils; import com.fr.stable.WriteActor; -import com.fr.startup.WorkspaceRegister; import com.fr.store.StateServerActivator; -import com.fr.workspace.engine.WorkspaceActivator; -import com.fr.workspace.server.ServerWorkspaceRegister; import com.fr.workspace.simple.SimpleWork; import java.io.BufferedReader; @@ -33,17 +29,12 @@ public class ExportBatch { public static void main(String[] args) { try { // 定义报表运行环境,用于执行报表 - Module module = ActivatorToolBox.simpleLink( - new WorkspaceActivator(), - new BaseDBActivator(), + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), new ConfigurationActivator(), new StateServerActivator(), new ReportBaseActivator(), new RestrictionActivator(), - new ReportActivator(), - new WorkspaceRegister(), - new ServerWorkspaceRegister(), - new SerializationActivator()); + new ReportActivator()); String envpath = "D:\\FineReport_10\\webapps\\webroot\\WEB-INF";//工程路径 SimpleWork.checkIn(envpath); module.start(); diff --git a/plugin-report-doc-demo/src/com/fr/io/ExportExcel.java b/plugin-report-doc-demo/src/com/fr/io/ExportExcel.java index a7a1d83..83908a7 100644 --- a/plugin-report-doc-demo/src/com/fr/io/ExportExcel.java +++ b/plugin-report-doc-demo/src/com/fr/io/ExportExcel.java @@ -1,6 +1,9 @@ package com.fr.io; import com.fr.base.Parameter; +import com.fr.config.activator.BaseDBActivator; +import com.fr.config.activator.ConfigurationActivator; +import com.fr.data.impl.config.activator.RestrictionActivator; import com.fr.general.ModuleContext; import com.fr.io.exporter.ExcelExporter; import com.fr.io.exporter.LargeDataPageExcelExporter; @@ -11,9 +14,13 @@ import com.fr.io.exporter.PageToSheetExcelExporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.main.impl.WorkBook; import com.fr.main.workbook.ResultWorkBook; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; import com.fr.report.core.ReportUtils; -import com.fr.report.module.EngineModule; +import com.fr.report.module.ReportBaseActivator; import com.fr.stable.WriteActor; +import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; import java.io.File; @@ -22,10 +29,16 @@ import java.io.FileOutputStream; public class ExportExcel { public static void main(String[] args) { - // 定义报表运行环境,才能执行报表 + // 定义报表运行环境,才能执行报表 + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), + new ConfigurationActivator(), + new StateServerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator()); String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF"; SimpleWork.checkIn(envpath); - ModuleContext.startModule(EngineModule.class.getName()); + module.start(); ResultWorkBook rworkbook = null; try { // 未执行模板工作薄 diff --git a/plugin-report-doc-demo/src/com/fr/io/ExportReports.java b/plugin-report-doc-demo/src/com/fr/io/ExportReports.java index 96a20cc..595e8a0 100644 --- a/plugin-report-doc-demo/src/com/fr/io/ExportReports.java +++ b/plugin-report-doc-demo/src/com/fr/io/ExportReports.java @@ -1,14 +1,21 @@ package com.fr.io; import com.fr.base.Parameter; +import com.fr.config.activator.BaseDBActivator; +import com.fr.config.activator.ConfigurationActivator; +import com.fr.data.impl.config.activator.RestrictionActivator; import com.fr.general.ModuleContext; import com.fr.io.exporter.PageExcelExporter; import com.fr.main.TemplateWorkBook; import com.fr.main.workbook.PageWorkBook; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; import com.fr.report.core.ReportUtils; -import com.fr.report.module.EngineModule; +import com.fr.report.module.ReportBaseActivator; import com.fr.report.report.PageReport; import com.fr.stable.PageActor; +import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; import java.io.File; @@ -17,10 +24,17 @@ import java.io.OutputStream; public class ExportReports { public static void main(String[] args) { - // ���屨�����л���,����ִ�б��� + // ���屨�����л���,����ִ�б��� + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), + new ConfigurationActivator(), + new StateServerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator()); String envpath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF"; SimpleWork.checkIn(envpath); - ModuleContext.startModule(EngineModule.class.getName()); + module.start(); + // ���г����һЩ��Ҫ��ʼ�� try { // δִ��ģ�幤���� diff --git a/plugin-report-doc-demo/src/com/fr/io/JavaPrint.java b/plugin-report-doc-demo/src/com/fr/io/JavaPrint.java index 7a7cad8..3c35be3 100644 --- a/plugin-report-doc-demo/src/com/fr/io/JavaPrint.java +++ b/plugin-report-doc-demo/src/com/fr/io/JavaPrint.java @@ -1,8 +1,16 @@ package com.fr.io; import com.fr.base.Parameter; +import com.fr.config.activator.BaseDBActivator; +import com.fr.config.activator.ConfigurationActivator; +import com.fr.data.impl.config.activator.RestrictionActivator; import com.fr.main.TemplateWorkBook; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; import com.fr.print.PrintUtils; +import com.fr.report.ReportActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; import java.util.HashMap; @@ -11,8 +19,15 @@ import java.util.HashMap; public class JavaPrint { public static void main(String[] args) { // 定义报表运行环境,才能执行报表 + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), + new ConfigurationActivator(), + new StateServerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator()); String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF"; SimpleWork.checkIn(envPath); + module.start(); try { TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("GettingStarted.cpt"); // 参数传值 diff --git a/plugin-report-doc-demo/src/com/fr/io/SetParameterWindow.java b/plugin-report-doc-demo/src/com/fr/io/SetParameterWindow.java index aec2d19..1b1af23 100644 --- a/plugin-report-doc-demo/src/com/fr/io/SetParameterWindow.java +++ b/plugin-report-doc-demo/src/com/fr/io/SetParameterWindow.java @@ -13,11 +13,7 @@ import com.fr.module.Module; import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.module.ReportBaseActivator; -import com.fr.serialization.SerializationActivator; -import com.fr.startup.WorkspaceRegister; import com.fr.store.StateServerActivator; -import com.fr.workspace.engine.WorkspaceActivator; -import com.fr.workspace.server.ServerWorkspaceRegister; import com.fr.workspace.simple.SimpleWork; import java.awt.Color; @@ -28,17 +24,12 @@ public class SetParameterWindow { public static void main(String[] args) { try { // 定义报表运行环境,用于执行报表 - Module module = ActivatorToolBox.simpleLink( - new WorkspaceActivator(), - new BaseDBActivator(), + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), new ConfigurationActivator(), new StateServerActivator(), new ReportBaseActivator(), new RestrictionActivator(), - new ReportActivator(), - new WorkspaceRegister(), - new ServerWorkspaceRegister(), - new SerializationActivator()); + new ReportActivator()); String envpath = "D:\\FineReport_10\\webapps\\webroot\\WEB-INF";//工程路径 SimpleWork.checkIn(envpath); module.start(); diff --git a/plugin-report-doc-demo/src/com/fr/io/SimpleDemo.java b/plugin-report-doc-demo/src/com/fr/io/SimpleDemo.java index 8a0357f..23f04d7 100644 --- a/plugin-report-doc-demo/src/com/fr/io/SimpleDemo.java +++ b/plugin-report-doc-demo/src/com/fr/io/SimpleDemo.java @@ -13,11 +13,7 @@ import com.fr.report.ReportActivator; import com.fr.report.cell.CellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.module.ReportBaseActivator; -import com.fr.serialization.SerializationActivator; -import com.fr.startup.WorkspaceRegister; import com.fr.store.StateServerActivator; -import com.fr.workspace.engine.WorkspaceActivator; -import com.fr.workspace.server.ServerWorkspaceRegister; import com.fr.workspace.simple.SimpleWork; import java.awt.Color; @@ -27,17 +23,12 @@ import java.io.FileOutputStream; public class SimpleDemo { public static void main(String[] args) { // 定义报表运行环境,用于执行报表 - Module module = ActivatorToolBox.simpleLink( - new WorkspaceActivator(), - new BaseDBActivator(), + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), new ConfigurationActivator(), new StateServerActivator(), new ReportBaseActivator(), new RestrictionActivator(), - new ReportActivator(), - new WorkspaceRegister(), - new ServerWorkspaceRegister(), - new SerializationActivator()); + new ReportActivator()); String envpath = "D:\\FineReport_10\\webapps\\webroot\\WEB-INF";//工程路径 SimpleWork.checkIn(envpath); module.start(); diff --git a/plugin-report-doc-demo/src/com/fr/openapi/remote/TemplateRead.java b/plugin-report-doc-demo/src/com/fr/openapi/remote/TemplateRead.java new file mode 100644 index 0000000..3775266 --- /dev/null +++ b/plugin-report-doc-demo/src/com/fr/openapi/remote/TemplateRead.java @@ -0,0 +1,73 @@ +package com.fr.openapi.remote; + +import com.fr.config.activator.ConfigurationActivator; +import com.fr.data.impl.config.activator.RestrictionActivator; +import com.fr.design.env.DesignerWorkspaceGenerator; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; +import com.fr.io.TemplateWorkBookIO; +import com.fr.log.FineLoggerFactory; +import com.fr.main.TemplateWorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.module.Activator; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.serialization.SerializationActivator; +import com.fr.stable.PageActor; +import com.fr.startup.WorkspaceRegister; +import com.fr.store.StateServerActivator; +import com.fr.workspace.WorkContext; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.WorkspaceActivator; +import com.fr.workspace.server.ServerWorkspaceRegister; + +import java.util.HashMap; + +/** + * 远程环境读取模板 + */ +public class TemplateRead { + + public static void main(String[] args) { + try { + Module module = ActivatorToolBox.simpleLink( + new WorkspaceActivator(), + new SerializationActivator(), + new Activator() { + @Override + public void start() { + WorkspaceConnectionInfo connectionInfo = new WorkspaceConnectionInfo("http://远程服务器地址:8080/webroot/decision", "admin", "ilovejava", "", ""); + try { + WorkContext.switchTo(DesignerWorkspaceGenerator.generate(RemoteDesignerWorkspaceInfo.create(connectionInfo))); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void stop() { + + } + }, + new ConfigurationActivator(), + new StateServerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator(), + new WorkspaceRegister(), + new ServerWorkspaceRegister() + ); + module.start(); + TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("12345678.cpt"); + ResultWorkBook result = workbook.execute(new HashMap(), new PageActor()); + + module.stop();//停止module + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + + } + + } + +} \ No newline at end of file diff --git a/plugin-report-doc-demo/src/com/fr/plugin/core/MyLocaleFinder.java b/plugin-report-doc-demo/src/com/fr/plugin/core/MyLocaleFinder.java new file mode 100644 index 0000000..9818a20 --- /dev/null +++ b/plugin-report-doc-demo/src/com/fr/plugin/core/MyLocaleFinder.java @@ -0,0 +1,15 @@ +package com.fr.plugin.core; + +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.stable.fun.impl.AbstractLocaleFinder; + +@EnableMetrics +public class MyLocaleFinder extends AbstractLocaleFinder { + @Override + @Focus(id = "com.fr.plugin.function", text = "插件全家桶", source = Original.PLUGIN) + public String find() { + return "com/fr/plugin/demo"; + } +} diff --git a/plugin-report-doc-demo/src/com/fr/plugin/core/secondary/ResourcePathTransformerImpl.java b/plugin-report-doc-demo/src/com/fr/plugin/core/secondary/ResourcePathTransformerImpl.java new file mode 100644 index 0000000..8749367 --- /dev/null +++ b/plugin-report-doc-demo/src/com/fr/plugin/core/secondary/ResourcePathTransformerImpl.java @@ -0,0 +1,18 @@ +package com.fr.plugin.core.secondary; + +import com.fr.stable.fun.impl.AbstractResourcePathTransformer; + +/** + * 资源路径接口 + */ +public class ResourcePathTransformerImpl extends AbstractResourcePathTransformer{ + @Override + public boolean accept(String s) { + return true; + } + + @Override + public String transform(String s) { + return s; + } +} \ No newline at end of file diff --git a/plugin-report-doc-demo/src/com/fr/plugin/core/secondary/SiteTransformerImpl.java b/plugin-report-doc-demo/src/com/fr/plugin/core/secondary/SiteTransformerImpl.java new file mode 100644 index 0000000..e962783 --- /dev/null +++ b/plugin-report-doc-demo/src/com/fr/plugin/core/secondary/SiteTransformerImpl.java @@ -0,0 +1,23 @@ +package com.fr.plugin.core.secondary; + +import com.fr.stable.fun.impl.AbstractSiteTransformer; + +/** + * cloudcenter地址接口 + */ +public class SiteTransformerImpl extends AbstractSiteTransformer{ + @Override + public boolean match(String s) { + return true; + } + + @Override + public String transform() { + return ""; + } + + @Override + public String transform(String s) { + return s; + } +} \ No newline at end of file