Browse Source

Pull request #61: 无jira任务,release/10.0合到persist/10.0

Merge in PG/plugin-report-doc-demo from ~BRUCE.DENG/plugin-report-doc-demo:release/10.0 to persist/10.0

* commit '65312af3b270f2da4c47a5f887bd842840c0e33c':
  REPORT-88257 导出API代码适配11.0
  https://work.fineres.com/browse/REPORT-65524 修改DEMO代码
  REPORT-64392 这个任务再看下产品端报错侧有没有能优化的
  REPORT-65380 引擎API>保存模板至数据库代码编译出错
  1
  REPORT-65118 REPORT-64392 这个任务再看下产品端报错侧有没有能优化的
  DEMO-20364 导出excel2003文档刊误
  无jira任务 demo插件打包失败
persist/10.0
Bruce.Deng-邓铖臻 2 years ago committed by Icey.Zhang-张洁
parent
commit
3c84822025
  1. 4
      build.xml
  2. 2
      src/main/java/com/fr/data/XMLDemoTableData.java
  3. 12
      src/main/java/com/fr/demo/NewReadFrmFromDatabase.java
  4. 4
      src/main/java/com/fr/demo/ReadFromDatabase.java
  5. 8
      src/main/java/com/fr/demo/ReadfrmFromDatabase.java
  6. 30
      src/main/java/com/fr/io/ExportApi.java
  7. 78
      src/main/java/com/fr/io/SaveReportToDatabase.java
  8. 2
      src/test/main/java/com/fr/demo/ExportApiTest.java
  9. 2
      src/test/main/java/com/fr/demo/ModuleStartTest.java

4
build.xml

@ -84,8 +84,8 @@
<param name="resources_from" value="${basedir}"/> <param name="resources_from" value="${basedir}"/>
</antcall> </antcall>
<antcall target="compile_javas"> <antcall target="compile_javas">
<param name="source_jdk_version" value="1.6"/> <param name="source_jdk_version" value="1.8"/>
<param name="target_jdk_version" value="1.6"/> <param name="target_jdk_version" value="1.8"/>
<param name="compile_jdk_version" value="${jdk.home}"/> <param name="compile_jdk_version" value="${jdk.home}"/>
<param name="compile_files" value="${basedir}/src"/> <param name="compile_files" value="${basedir}/src"/>
</antcall> </antcall>

2
src/main/java/com/fr/data/XMLDemoTableData.java

@ -77,6 +77,8 @@ public class XMLDemoTableData extends AbstractParameterTableData {
try { try {
in = new BufferedInputStream(new FileInputStream(new File(filePath))); in = new BufferedInputStream(new FileInputStream(new File(filePath)));
XMLEventReader reader = inputFactory.createXMLEventReader(in); XMLEventReader reader = inputFactory.createXMLEventReader(in);
deep=0;
flag=false;
readCol(reader,list); readCol(reader,list);
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {

12
src/main/java/com/fr/demo/NewReadFrmFromDatabase.java

@ -1,16 +1,18 @@
package com.fr.demo; package com.fr.demo;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.web.weblet.DBFormlet;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import com.fr.web.weblet.DBFormlet;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.Map; import java.util.Map;
@ -43,12 +45,12 @@ public class NewReadFrmFromDatabase extends DBFormlet {
return form; return form;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw SessionLocalManager.createLogPackedException(e);
}finally { }finally {
DBUtils.closeConnection(connection); DBUtils.closeConnection(connection);
} }
return null; return form;
} }
private static Connection getConnection() throws ClassNotFoundException, SQLException { private static Connection getConnection() throws ClassNotFoundException, SQLException {

4
src/main/java/com/fr/demo/ReadFromDatabase.java

@ -5,6 +5,8 @@ import com.fr.main.impl.WorkBook;
import com.fr.web.core.Reportlet; import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest; import com.fr.web.request.ReportletRequest;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
@ -40,7 +42,7 @@ public class ReadFromDatabase extends Reportlet {
workbook.readStream(ins); workbook.readStream(ins);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw SessionLocalManager.createLogPackedException(e);
} }
return workbook; return workbook;
} }

8
src/main/java/com/fr/demo/ReadfrmFromDatabase.java

@ -1,10 +1,12 @@
package com.fr.demo; package com.fr.demo;
import com.fr.form.main.Form;
import com.fr.io.utils.ResourceIOUtils; import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import com.fr.web.weblet.Formlet; import com.fr.web.weblet.Formlet;
import com.fr.form.main.Form;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.fr.log.FineLoggerFactory;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
@ -42,7 +44,7 @@ public class ReadfrmFromDatabase extends Formlet {
form.readStream(ins); form.readStream(ins);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw SessionLocalManager.createLogPackedException(e);
} }
System.out.println(ResourceIOUtils.getRealPath("assets")); System.out.println(ResourceIOUtils.getRealPath("assets"));
return form; return form;

30
src/main/java/com/fr/io/ExportApi.java

@ -7,8 +7,6 @@ import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator; import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource; import com.fr.general.I18nResource;
import com.fr.general.log.Log4jConfig;
import com.fr.general.log.parser.ExtraPatternParserManager;
import com.fr.health.activator.ModuleHealActivator; import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.exporter.CSVExporter; import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.EmbeddedTableDataExporter; import com.fr.io.exporter.EmbeddedTableDataExporter;
@ -27,25 +25,18 @@ import com.fr.report.module.ReportBaseActivator;
import com.fr.report.write.WriteActivator; import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator; import com.fr.scheduler.SchedulerActivator;
import com.fr.stable.WriteActor; import com.fr.stable.WriteActor;
import com.fr.stable.resource.ResourceLoader;
import com.fr.store.StateServiceActivator; import com.fr.store.StateServiceActivator;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.PropertyConfigurator;
import com.fr.workspace.simple.SimpleWork; import com.fr.workspace.simple.SimpleWork;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
public class ExportApi { public class ExportApi {
public static void main(String[] args) { public static void main(String[] args) {
initLog4j();
/**定义报表运行环境,用于执行报表*/ /**定义报表运行环境,用于执行报表*/
com.fr.module.Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), com.fr.module.Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(), new ConfigurationActivator(),
@ -91,6 +82,7 @@ public class ExportApi {
/**将结果工作薄导出为2003Excel文件*/ /**将结果工作薄导出为2003Excel文件*/
outputStream = new FileOutputStream(new java.io.File(outputUrl+"ExcelExport2003.xls")); outputStream = new FileOutputStream(new java.io.File(outputUrl+"ExcelExport2003.xls"));
ExcelExporter ExcelExport = new ExcelExporter(); ExcelExporter ExcelExport = new ExcelExporter();
ExcelExport.setVersion(true);
ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
/**将结果工作薄导出为2007Excel文件*/ /**将结果工作薄导出为2007Excel文件*/
@ -137,24 +129,4 @@ public class ExportApi {
} }
} }
private static void initLog4j() {
PropertyConfigurator.configure(loadLog4jPropertiesFromJar(Level.toLevel("INFO")));
}
private static Properties loadLog4jPropertiesFromJar(Level level) {
Properties properties = new Properties();
System.setProperty("LOG_HOME", System.getProperty("user.dir"));
System.setProperty("LOG_ROOT_LEVEL", level.toString());
ExtraPatternParserManager.setSystemProperty();
try {
properties.load(ResourceLoader.getResourceAsStream("/com/fr/general/log/log4j.properties", Log4jConfig.class));
} catch (IOException ignore) {
//do nothing
}
return properties;
}
} }

78
src/main/java/com/fr/io/SaveReportToDatabase.java

@ -1,78 +0,0 @@
package com.fr.io;
import com.fr.base.operator.common.CommonOperator;
import com.fr.chart.activator.ChartBaseActivator;
import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator;
import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.module.Module;
import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator;
import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.store.StateServiceActivator;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class SaveReportToDatabase {
public static void main(String[] args) {
SaveReport();
}
private static void SaveReport() {
try {
// 连接数据库
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://review.finedevelop.com:3306/susie";
String user = "root";
String pass = "ilovejava";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pass);
PreparedStatement presmt = conn
.prepareStatement("insert into report values(?,?)");
// 读进需要保存入库的模板文件
// 首先需要定义执行所在的环境,这样才能正确读取数据库信息
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),
new ChartBaseActivator(),
new SchedulerActivator(),
new ReportBaseActivator(),
new RestrictionActivator(),
new ReportActivator(),
new WriteActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径
SimpleWork.checkIn(envpath);
I18nResource.getInstance();
module.start();
File cptfile = new File("//doc//Primary//Parameter//Parameter.cpt");
int lens = (int) cptfile.length();
InputStream ins = new FileInputStream(cptfile);
// 将模板保存入库
presmt.setString(1, "Parameter.cpt"); // 第一个字段存放模板相对路径
presmt.setBinaryStream(2, ins, lens); // 第二个字段存放模板文件的二进制流
presmt.execute();
conn.commit();
presmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

2
src/test/main/java/com/fr/demo/ExportApiTest.java

@ -7,6 +7,8 @@ import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator; import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource; import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;

2
src/test/main/java/com/fr/demo/ModuleStartTest.java

@ -8,6 +8,8 @@ import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.I18nResource; import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler; import com.fr.log.LogHandler;

Loading…
Cancel
Save