Browse Source

无JIRA任务

1、密码为空时有报错,修改下
2、抽出DataOperator(还没跑通数据集的预览)
master
ju 7 years ago
parent
commit
2c1faac12d
  1. 16
      designer-base/src/com/fr/design/data/DesignTableDataManager.java
  2. 7
      designer-base/src/com/fr/design/data/datapane/ChoosePane.java
  3. 4
      designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  4. 3
      designer-base/src/com/fr/design/data/datapane/preview/PreviewTablePane.java
  5. 38
      designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java
  6. 18
      designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  7. 2
      designer-base/src/com/fr/design/file/TemplateTreePane.java
  8. 11
      designer-base/src/com/fr/design/gui/ilist/TableViewList.java
  9. 86
      designer-base/src/com/fr/env/RemoteEnv.java

16
designer-base/src/com/fr/design/data/DesignTableDataManager.java

@ -1,6 +1,5 @@
package com.fr.design.data; package com.fr.design.data;
import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; 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.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants; import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; 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 { private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception {
final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar();
Env currentEnv = FRContext.getCurrentEnv(); ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tabledata);
ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata);
if (ArrayUtils.isEmpty(parameters)) { if (ArrayUtils.isEmpty(parameters)) {
parameters = tabledata.getParameters(Calculator.createCalculator()); parameters = tabledata.getParameters(Calculator.createCalculator());
} }
@ -440,13 +439,13 @@ public abstract class DesignTableDataManager {
loadingBar.start(); loadingBar.start();
} }
try { try {
for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { for (ParameterProvider parameter : DataOperator.getInstance().getTableDataParameters(tabledata)) {
if (parameterMap.containsKey(parameter.getName())) { if (parameterMap.containsKey(parameter.getName())) {
parameter.setValue(parameterMap.get(parameter.getName())); parameter.setValue(parameterMap.get(parameter.getName()));
} }
} }
return currentEnv.previewTableData(tableDataSource, tabledata, parameterMap, rowCount); return DataOperator.getInstance().previewTableData(tableDataSource, tabledata, parameterMap, rowCount);
} catch (TableDataException e) { } catch (Exception e) {
throw new TableDataException(e.getMessage(), e); throw new TableDataException(e.getMessage(), e);
} finally { } finally {
new Timer().schedule(new TimerTask() { new Timer().schedule(new TimerTask() {
@ -510,11 +509,10 @@ public abstract class DesignTableDataManager {
XMLPrintWriter writer = XMLPrintWriter.create(out); XMLPrintWriter writer = XMLPrintWriter.create(out);
// 把storeProcedure写成xml文件到out // 把storeProcedure写成xml文件到out
DataCoreXmlUtils.writeXMLStoreProcedure(writer, storeProcedure, null); DataCoreXmlUtils.writeXMLStoreProcedure(writer, storeProcedure, null);
Env currentEnv = FRContext.getCurrentEnv();
if (storeProcedure.getDataModelSize() > 0 && !storeProcedure.isFirstExpand()) { if (storeProcedure.getDataModelSize() > 0 && !storeProcedure.isFirstExpand()) {
return storeProcedure.creatLazyDataModel(); return storeProcedure.creatLazyDataModel();
} }
ParameterProvider[] inParameters = currentEnv.getStoreProcedureParameters(storeProcedure); ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure);
final Map<String, Object> parameterMap = new HashMap<String, Object>(); final Map<String, Object> parameterMap = new HashMap<String, Object>();
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(inParameters); final ParameterInputPane pPane = new ParameterInputPane(inParameters);
@ -529,7 +527,7 @@ public abstract class DesignTableDataManager {
if (needLoadingBar) { if (needLoadingBar) {
StoreProcedureDataWrapper.loadingBar.start(); StoreProcedureDataWrapper.loadingBar.start();
} }
return FRContext.getCurrentEnv().previewProcedureDataModel(storeProcedure, parameterMap, 0); return DataOperator.getInstance().previewProcedureDataModel(storeProcedure, parameterMap, 0);
} }
public static void setThreadLocal(String value) { public static void setThreadLocal(String value) {

7
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.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
@ -449,7 +450,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return TableData.EMPTY_TABLEDATA; return TableData.EMPTY_TABLEDATA;
} }
try { try {
connect = FRContext.getCurrentEnv().testConnection(database); connect = DataOperator.getInstance().testConnection(database);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
if (!connect) { if (!connect) {
@ -468,7 +469,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
} else { } else {
try { try {
TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); 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()); DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow());
} catch (Exception e) { } catch (Exception e) {
failedToFindTable(); failedToFindTable();
@ -524,7 +525,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
} }
try { try {
// daniel:增加参数 // daniel:增加参数
colNames = FRContext.getCurrentEnv().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject); colNames = DataOperator.getInstance().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject);
} catch (Exception e2) { } catch (Exception e2) {
FRContext.getLogger().error(e2.getMessage(), e2); FRContext.getLogger().error(e2.getMessage(), e2);
} }

4
designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -3,9 +3,9 @@
*/ */
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.FRContext;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.operator.DataOperator;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -118,7 +118,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
protected Object doInBackground() throws Exception { protected Object doInBackground() throws Exception {
try { try {
com.fr.data.impl.Connection database = DatabaseConnectionPane.this.updateBean(); com.fr.data.impl.Connection database = DatabaseConnectionPane.this.updateBean();
boolean connect = FRContext.getCurrentEnv().testConnection(database); boolean connect = DataOperator.getInstance().testConnection(database);
okButton.setEnabled(true); okButton.setEnabled(true);
message.setText(database.connectMessage(connect)); message.setText(database.connectMessage(connect));
} catch (Exception exp) { } catch (Exception exp) {

3
designer-base/src/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -10,6 +10,7 @@ import com.fr.data.TableDataSource;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -358,7 +359,7 @@ public class PreviewTablePane extends BasicPane {
protected PreviewTableModel doInBackground() throws Exception { protected PreviewTableModel doInBackground() throws Exception {
connectionBar.start(); connectionBar.start();
if (tableData instanceof DBTableData) { if (tableData instanceof DBTableData) {
boolean status = FRContext.getCurrentEnv().testConnection(((DBTableData) tableData).getDatabase()); boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase());
if (!status) { if (!status) {
connectionBar.close(); connectionBar.close();
throw new Exception(Inter.getLocText("Datasource-Connection_failed")); throw new Exception(Inter.getLocText("Datasource-Connection_failed"));

38
designer-base/src/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java

@ -1,25 +1,12 @@
package com.fr.design.data.tabledata.tabledatapane; package com.fr.design.data.tabledata.tabledatapane;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.*;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -46,6 +33,16 @@ import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> implements ResponseDataSourceChange { public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> implements ResponseDataSourceChange {
private static final String[] DRIVERS = { private static final String[] DRIVERS = {
"oracle.jdbc.driver.OracleDriver", "oracle.jdbc.driver.OracleDriver",
@ -194,7 +191,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
try { try {
storeProcedureContext.setText(StringUtils.EMPTY); storeProcedureContext.setText(StringUtils.EMPTY);
String connectionname = connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); String connectionname = connectionTableProcedurePane.getSelectedDatabaseConnnectonName();
String procedureText = FRContext.getCurrentEnv().getProcedureText(connectionname, storeprocedure.getQuery()); String procedureText = DataOperator.getInstance().getProcedureText(connectionname, storeprocedure.getQuery());
storeProcedureContext.setText(procedureText); storeProcedureContext.setText(procedureText);
warningLabel.setText(StringUtils.EMPTY); warningLabel.setText(StringUtils.EMPTY);
} catch (Exception ex) { } catch (Exception ex) {
@ -301,7 +298,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
text = text.trim(); text = text.trim();
String connectionname = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); String connectionname = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName();
try { 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 // 获取参数默认值,例如:NAME in varchar2 default 'SCOTT',默认值为SCOTT
String parameterDefaultValue = ""; String parameterDefaultValue = "";
@ -315,22 +312,17 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
} }
StoreProcedureParameter[] newparameters; StoreProcedureParameter[] newparameters;
newparameters = FRContext.getCurrentEnv().getStoreProcedureDeclarationParameters(connectionname, text, parameterDefaultValue); newparameters = DataOperator.getInstance().getStoreProcedureDeclarationParameters(connectionname, text, parameterDefaultValue);
editorPane.populate(newparameters); editorPane.populate(newparameters);
storeProcedureContext.setText(procedureText); storeProcedureContext.setText(procedureText);
warningLabel.setText(""); 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) { } catch (Exception e) {
warningLabel.setText(e.getMessage()); warningLabel.setText(Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"}));
storeProcedureContext.setText(""); storeProcedureContext.setText("");
editorPane.populate(new StoreProcedureParameter[0]); editorPane.populate(new StoreProcedureParameter[0]);
} }
return;
} }
/** /**

18
designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -1,19 +1,11 @@
package com.fr.design.data.tabledata.wrapper; 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.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.dialog.BasicDialog; 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.ComparatorUtils;
import com.fr.general.Inter; 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;
/** /**
* <code>StoreProcedureDataWrappe</code> 存储过程的一个返回数据集,不是它本身<br> * <code>StoreProcedureDataWrappe</code> 存储过程的一个返回数据集,不是它本身<br>
* Oracle数据库肯定有它SQL SERVER就不一定有了,大部分情况下都没有. * Oracle数据库肯定有它SQL SERVER就不一定有了,大部分情况下都没有.
@ -191,7 +189,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
worker = new SwingWorker<Void, Void>() { worker = new SwingWorker<Void, Void>() {
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
connectionBar.start(); connectionBar.start();
boolean status = FRContext.getCurrentEnv().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection());
if (!status) { if (!status) {
connectionBar.close(); connectionBar.close();
// bug 61345 预览失败时,关闭窗口 // bug 61345 预览失败时,关闭窗口

2
designer-base/src/com/fr/design/file/TemplateTreePane.java

@ -182,7 +182,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
} }
if (nodeFile.exists()) { if (nodeFile.exists()) {
String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()); String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath());
FileAssistUtils.moveToTrash(path); FileAssistUtils.moveToTrash(nodeFile.getPath());
deleteHistory(path.replaceAll("/", "\\\\")); deleteHistory(path.replaceAll("/", "\\\\"));
} else { } else {
JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME, JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME,

11
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.DialectFactory;
import com.fr.data.core.db.dialect.OracleDialect; import com.fr.data.core.db.dialect.OracleDialect;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.dnd.SerializableTransferable; import com.fr.design.mainframe.dnd.SerializableTransferable;
@ -17,7 +18,11 @@ import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; 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.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -90,7 +95,7 @@ public class TableViewList extends UIList {
int count = 3; int count = 3;
//总共给3次连接的机会 //总共给3次连接的机会
while (!status && count > 0) { while (!status && count > 0) {
status = FRContext.getCurrentEnv().testConnection(datasource); status = DataOperator.getInstance().testConnection(datasource);
count--; count--;
} }
if (!status) { if (!status) {
@ -135,7 +140,7 @@ public class TableViewList extends UIList {
searchFilter = searchFilter.toLowerCase(); searchFilter = searchFilter.toLowerCase();
boolean isOracle = FRContext.getCurrentEnv().isOracle(datasource); boolean isOracle = DataOperator.getInstance().isOracle(datasource);
boolean isOracleSystemSpace = DesignerEnvManager.getEnvManager().isOracleSystemSpace(); boolean isOracleSystemSpace = DesignerEnvManager.getEnvManager().isOracleSystemSpace();
// oracleb不勾选显示所有表,则只显示用户下的(包括存储过程和table表) // oracleb不勾选显示所有表,则只显示用户下的(包括存储过程和table表)
if (isOracle && !isOracleSystemSpace) { if (isOracle && !isOracleSystemSpace) {

86
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -1,7 +1,6 @@
package com.fr.env; package com.fr.env;
import com.fr.base.EnvException; import com.fr.base.EnvException;
import com.fr.base.TableData;
import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.common.CommonOperator;
import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.connect.ConnectOperator;
import com.fr.base.operator.file.FileOperator; 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.common.rpc.netty.RemoteCallClient;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext; 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.data.impl.storeproc.StoreProcedure;
import com.fr.dav.AbstractEnv; import com.fr.dav.AbstractEnv;
import com.fr.dav.DavXMLUtils; import com.fr.dav.DavXMLUtils;
@ -23,6 +20,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.file.CacheManager; import com.fr.file.CacheManager;
import com.fr.general.CommonIOUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.EnvProxyFactory;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
@ -111,8 +109,27 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return true; return true;
} }
@Override
public EnvProxyFactory getProxyFactory() {
return new EnvProxyFactory() {
@Override
public <T> T get(Class<T> clazz, T obj) {
assert clazz != null;
try {
return MessageSendExecutor.getInstance().execute(clazz);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
}
@Override @Override
public FileOperator getFileOperator() throws Exception { public FileOperator getFileOperator() throws Exception {
return MessageSendExecutor.getInstance().execute(FileOperator.class); return MessageSendExecutor.getInstance().execute(FileOperator.class);
} }
@ -205,7 +222,7 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
* @param in InputStream输入流 * @param in InputStream输入流
* @return 转换后的字符串 * @return 转换后的字符串
*/ */
public static String stream2String(InputStream in) { private static String stream2String(InputStream in) {
if (in == null) { if (in == null) {
return null; return null;
} }
@ -224,7 +241,7 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
* @return 测试连接成功返回true * @return 测试连接成功返回true
* @throws Exception 异常 * @throws Exception 异常
*/ */
public boolean testServerConnection() throws Exception { private boolean testServerConnection() throws Exception {
return testConnection(true, true, DesignerContext.getDesignerFrame()); return testConnection(true, true, DesignerContext.getDesignerFrame());
} }
@ -427,65 +444,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); 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<String, String> 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是无法得到的 * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的

Loading…
Cancel
Save