From 81f863f19174dedf359e12a35eb2a8edac4f1581 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 11 Jun 2018 15:51:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?CORE-87=20VT4FR=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/help/alphafine/AlphaFineConfigManager.java | 2 +- designer-chart/src/com/fr/design/chart/ChartTypePane.java | 2 +- .../com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index b601a34298..1e2308f37c 100644 --- a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -75,7 +75,7 @@ public class AlphaFineConfigManager implements XMLable { public static boolean isALPHALicAvailable() { - return FRContext.getCurrentEnv() != null && VT4FR.AlphaFine.support(); + return FRContext.getCurrentEnv() != null && VT4FR.AlphaFine.isSupport(); } @Override diff --git a/designer-chart/src/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/com/fr/design/chart/ChartTypePane.java index 6f221922b8..995b8370b7 100644 --- a/designer-chart/src/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/com/fr/design/chart/ChartTypePane.java @@ -172,7 +172,7 @@ public class ChartTypePane extends ChartCommonWizardPane { } private boolean supportMap() { - return VT4FR.ChartMap.support(); + return VT4FR.ChartMap.isSupport(); } public void update(ChartCollection cc) { diff --git a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 8e54715713..e470745be4 100644 --- a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -69,7 +69,7 @@ public class ErrorInfoUploader { // 从云中心更新最新的解决方案文件 private void checkUpdateSolution() { - if (!VT4FR.AlphaFine.support()) { + if (!VT4FR.AlphaFine.isSupport()) { return; } From 3fa8978e30394ecba24f1ed38bdfb94152afaa25 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 11 Jun 2018 19:22:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E5=88=A0?= =?UTF-8?q?=E6=8E=89env=E4=B9=8B=E5=89=8D=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/com/fr/env/RemoteEnv.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index e50da31692..9034d6c36a 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -5,7 +5,6 @@ import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; -import com.fr.base.operator.file.SimpleFileOperator; import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.remote.RemoteDeziConstants; import com.fr.common.rpc.RemoteCallServerConfig; @@ -127,11 +126,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); } - @Override - public SimpleFileOperator getSimpleFileOperator() throws Exception { - return MessageSendExecutor.getInstance().execute(SimpleFileOperator.class); - } - @Override public RemoteEnvConfig getEnvConfig() { return config; From 2c1faac12d4c8d6926e597ee983d40013f88018d Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 11 Jun 2018 23:08:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=201?= =?UTF-8?q?=E3=80=81=E5=AF=86=E7=A0=81=E4=B8=BA=E7=A9=BA=E6=97=B6=E6=9C=89?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=8B=202?= =?UTF-8?q?=E3=80=81=E6=8A=BD=E5=87=BADataOperator=EF=BC=88=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E8=B7=91=E9=80=9A=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E8=A7=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 16 ++-- .../fr/design/data/datapane/ChoosePane.java | 7 +- .../connect/DatabaseConnectionPane.java | 4 +- .../datapane/preview/PreviewTablePane.java | 3 +- .../tabledatapane/ProcedureDataPane.java | 38 +++----- .../wrapper/StoreProcedureDataWrapper.java | 18 ++-- .../com/fr/design/file/TemplateTreePane.java | 2 +- .../fr/design/gui/ilist/TableViewList.java | 15 ++- designer-base/src/com/fr/env/RemoteEnv.java | 94 +++++-------------- 9 files changed, 75 insertions(+), 122 deletions(-) diff --git a/designer-base/src/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/com/fr/design/data/DesignTableDataManager.java index 91becffa88..635ba239a7 100644 --- a/designer-base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/com/fr/design/data/DesignTableDataManager.java @@ -1,6 +1,5 @@ package com.fr.design.data; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; @@ -10,6 +9,7 @@ import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedureConstants; +import com.fr.data.operator.DataOperator; import com.fr.design.DesignModelAdapter; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; @@ -417,8 +417,7 @@ public abstract class DesignTableDataManager { */ private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); - Env currentEnv = FRContext.getCurrentEnv(); - ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); + ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tabledata); if (ArrayUtils.isEmpty(parameters)) { parameters = tabledata.getParameters(Calculator.createCalculator()); } @@ -440,13 +439,13 @@ public abstract class DesignTableDataManager { loadingBar.start(); } try { - for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { + for (ParameterProvider parameter : DataOperator.getInstance().getTableDataParameters(tabledata)) { if (parameterMap.containsKey(parameter.getName())) { parameter.setValue(parameterMap.get(parameter.getName())); } } - return currentEnv.previewTableData(tableDataSource, tabledata, parameterMap, rowCount); - } catch (TableDataException e) { + return DataOperator.getInstance().previewTableData(tableDataSource, tabledata, parameterMap, rowCount); + } catch (Exception e) { throw new TableDataException(e.getMessage(), e); } finally { new Timer().schedule(new TimerTask() { @@ -510,11 +509,10 @@ public abstract class DesignTableDataManager { XMLPrintWriter writer = XMLPrintWriter.create(out); // 把storeProcedure写成xml文件到out DataCoreXmlUtils.writeXMLStoreProcedure(writer, storeProcedure, null); - Env currentEnv = FRContext.getCurrentEnv(); if (storeProcedure.getDataModelSize() > 0 && !storeProcedure.isFirstExpand()) { return storeProcedure.creatLazyDataModel(); } - ParameterProvider[] inParameters = currentEnv.getStoreProcedureParameters(storeProcedure); + ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure); final Map parameterMap = new HashMap(); if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. final ParameterInputPane pPane = new ParameterInputPane(inParameters); @@ -529,7 +527,7 @@ public abstract class DesignTableDataManager { if (needLoadingBar) { StoreProcedureDataWrapper.loadingBar.start(); } - return FRContext.getCurrentEnv().previewProcedureDataModel(storeProcedure, parameterMap, 0); + return DataOperator.getInstance().previewProcedureDataModel(storeProcedure, parameterMap, 0); } public static void setThreadLocal(String value) { diff --git a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java index 5fabd7c2b8..8db0957339 100644 --- a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java @@ -9,6 +9,7 @@ import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.impl.Connection; import com.fr.data.impl.DBTableData; +import com.fr.data.operator.DataOperator; import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; @@ -449,7 +450,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha return TableData.EMPTY_TABLEDATA; } try { - connect = FRContext.getCurrentEnv().testConnection(database); + connect = DataOperator.getInstance().testConnection(database); } catch (Exception ignored) { } if (!connect) { @@ -468,7 +469,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } else { try { TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); - tableData = FRContext.getCurrentEnv().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP, + tableData = DataOperator.getInstance().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP, DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow()); } catch (Exception e) { failedToFindTable(); @@ -524,7 +525,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } try { // daniel:增加参数 - colNames = FRContext.getCurrentEnv().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject); + colNames = DataOperator.getInstance().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject); } catch (Exception e2) { FRContext.getLogger().error(e2.getMessage(), e2); } diff --git a/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 94b38f681a..c5666b81f5 100644 --- a/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -3,9 +3,9 @@ */ package com.fr.design.data.datapane.connect; -import com.fr.base.FRContext; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; +import com.fr.data.operator.DataOperator; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; @@ -118,7 +118,7 @@ public abstract class DatabaseConnectionPane implements ResponseDataSourceChange { private static final String[] DRIVERS = { "oracle.jdbc.driver.OracleDriver", @@ -194,7 +191,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp try { storeProcedureContext.setText(StringUtils.EMPTY); String connectionname = connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); - String procedureText = FRContext.getCurrentEnv().getProcedureText(connectionname, storeprocedure.getQuery()); + String procedureText = DataOperator.getInstance().getProcedureText(connectionname, storeprocedure.getQuery()); storeProcedureContext.setText(procedureText); warningLabel.setText(StringUtils.EMPTY); } catch (Exception ex) { @@ -301,7 +298,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp text = text.trim(); String connectionname = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); try { - String procedureText = FRContext.getCurrentEnv().getProcedureText(this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(), text); + String procedureText = DataOperator.getInstance().getProcedureText(this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(), text); // 获取参数默认值,例如:NAME in varchar2 default 'SCOTT',默认值为SCOTT String parameterDefaultValue = ""; @@ -315,22 +312,17 @@ public class ProcedureDataPane extends AbstractTableDataPane imp } StoreProcedureParameter[] newparameters; - newparameters = FRContext.getCurrentEnv().getStoreProcedureDeclarationParameters(connectionname, text, parameterDefaultValue); + newparameters = DataOperator.getInstance().getStoreProcedureDeclarationParameters(connectionname, text, parameterDefaultValue); editorPane.populate(newparameters); storeProcedureContext.setText(procedureText); warningLabel.setText(""); - } catch (SQLException sql) { - warningLabel.setText(Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"})); - storeProcedureContext.setText(""); - editorPane.populate(new StoreProcedureParameter[0]); } catch (Exception e) { - warningLabel.setText(e.getMessage()); + warningLabel.setText(Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"})); storeProcedureContext.setText(""); editorPane.populate(new StoreProcedureParameter[0]); } - return; } /** diff --git a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java index d1ddeb502f..845f03e320 100644 --- a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java +++ b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java @@ -1,19 +1,11 @@ package com.fr.design.data.tabledata.wrapper; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CancellationException; - -import javax.swing.Icon; -import javax.swing.JOptionPane; -import javax.swing.SwingWorker; - import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.TableData; import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.data.operator.DataOperator; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.dialog.BasicDialog; @@ -24,6 +16,12 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import javax.swing.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CancellationException; + /** * StoreProcedureDataWrappe :存储过程的一个返回数据集,不是它本身。
* Oracle数据库肯定有它。SQL SERVER就不一定有了,大部分情况下都没有. @@ -191,7 +189,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { worker = new SwingWorker() { protected Void doInBackground() throws Exception { connectionBar.start(); - boolean status = FRContext.getCurrentEnv().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); + boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); if (!status) { connectionBar.close(); // bug 61345 预览失败时,关闭窗口 diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index afb2a006ad..a095595cf8 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -182,7 +182,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { } if (nodeFile.exists()) { String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()); - FileAssistUtils.moveToTrash(path); + FileAssistUtils.moveToTrash(nodeFile.getPath()); deleteHistory(path.replaceAll("/", "\\\\")); } else { JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME, diff --git a/designer-base/src/com/fr/design/gui/ilist/TableViewList.java b/designer-base/src/com/fr/design/gui/ilist/TableViewList.java index 9f6014e331..01a951ea06 100644 --- a/designer-base/src/com/fr/design/gui/ilist/TableViewList.java +++ b/designer-base/src/com/fr/design/gui/ilist/TableViewList.java @@ -7,6 +7,7 @@ import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.core.db.dialect.OracleDialect; import com.fr.data.impl.Connection; +import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.dnd.SerializableTransferable; @@ -17,7 +18,11 @@ import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; -import java.awt.dnd.*; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.MouseAdapter; @@ -90,7 +95,7 @@ public class TableViewList extends UIList { int count = 3; //总共给3次连接的机会 while (!status && count > 0) { - status = FRContext.getCurrentEnv().testConnection(datasource); + status = DataOperator.getInstance().testConnection(datasource); count--; } if (!status) { @@ -133,9 +138,9 @@ public class TableViewList extends UIList { String[] schemas = DataCoreUtils.getDatabaseSchema(datasource); searchFilter = searchFilter.toLowerCase(); - - - boolean isOracle = FRContext.getCurrentEnv().isOracle(datasource); + + + boolean isOracle = DataOperator.getInstance().isOracle(datasource); boolean isOracleSystemSpace = DesignerEnvManager.getEnvManager().isOracleSystemSpace(); // oracleb不勾选显示所有表,则只显示用户下的(包括存储过程和table表) if (isOracle && !isOracleSystemSpace) { diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 9034d6c36a..d2f178aeaa 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -1,7 +1,6 @@ package com.fr.env; import com.fr.base.EnvException; -import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; @@ -12,8 +11,6 @@ import com.fr.common.rpc.netty.MessageSendExecutor; import com.fr.common.rpc.netty.RemoteCallClient; import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvContext; -import com.fr.data.TableDataSource; -import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.dav.AbstractEnv; import com.fr.dav.DavXMLUtils; @@ -23,6 +20,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.file.CacheManager; import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; +import com.fr.general.EnvProxyFactory; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.http.HttpToolbox; @@ -110,9 +108,28 @@ public class RemoteEnv extends AbstractEnv implements DesignAut MessageSendExecutor.getInstance().stop(); return true; } - + + @Override + public EnvProxyFactory getProxyFactory() { + + return new EnvProxyFactory() { + + @Override + public T get(Class clazz, T obj) { + + assert clazz != null; + try { + return MessageSendExecutor.getInstance().execute(clazz); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + } + @Override public FileOperator getFileOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(FileOperator.class); } @@ -125,7 +142,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAut public OrganizationOperator getOrganizationOperator() throws Exception { return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); } - + @Override public RemoteEnvConfig getEnvConfig() { return config; @@ -205,7 +222,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAut * @param in InputStream输入流 * @return 转换后的字符串 */ - public static String stream2String(InputStream in) { + private static String stream2String(InputStream in) { if (in == null) { return null; } @@ -224,7 +241,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAut * @return 测试连接成功返回true * @throws Exception 异常 */ - public boolean testServerConnection() throws Exception { + private boolean testServerConnection() throws Exception { return testConnection(true, true, DesignerContext.getDesignerFrame()); } @@ -426,67 +443,8 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } - - @Override - public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception { - return previewTableData(null, tableData, parameterMap, rowCount); - } - - /** - * 根据指定的参数生成一个实际可预览的数据集 - * - * @param tableData 带参数的数据集 - * @param parameterMap 参数键值对 - * @param rowCount 需要获取的行数 - * @return 实际的二维数据集 - * @throws Exception 如果生成数据失败则抛出此异常 - */ - @Override - public EmbeddedTableData previewTableData(TableDataSource dataSource, Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - // 把tableData写成xml文件到out - DavXMLUtils.writeXMLFileTableDataAndSource((TableData) tableData, out); - - // 把parameterMap转成JSON格式的字符串 - JSONObject jo = new JSONObject(parameterMap); - String jsonParameter = jo.toString(); - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_preview_td"); - para.put("pars", jsonParameter); - para.put("rowcount", String.valueOf(rowCount)); - InputStream input = postBytes2ServerB(out.toByteArray(), para); - - if (input == null) { - return null; - } - - return (EmbeddedTableData) DavXMLUtils.readXMLTableData(input); - } - - /** - * 根据指定的参数生成一个实际可预览的数据集 - * - * @param tableData 带参数的数据集 - * @param parameterMap 参数键值对 - * @param start 开始 - * @param end 结尾 - * @param cols 列名 - * @param colIdx 列序号 - * @return 实际的二位数据条 - * @throws Exception 异常 - */ - @Override - public Object previewTableData(Object tableData, java.util.Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { - return previewTableData(tableData, parameterMap, -1); - } - - @Override - public Object previewTableData(TableDataSource dataSource, Object tableData, Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { - return previewTableData(dataSource, tableData, parameterMap, -1); - } - + + /** * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 *