|
|
|
@ -6,6 +6,7 @@ import com.fr.base.ParameterMapNameSpace;
|
|
|
|
|
import com.fr.data.impl.DBTableData; |
|
|
|
|
import com.fr.data.impl.EscapeSqlHelper; |
|
|
|
|
import com.fr.data.operator.DataOperator; |
|
|
|
|
import com.fr.decision.config.PreventSqlInjConfig; |
|
|
|
|
import com.fr.decision.webservice.v10.config.ConfigService; |
|
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
|
import com.fr.design.dialog.link.MessageWithLink; |
|
|
|
@ -18,6 +19,7 @@ import com.fr.design.parameter.ParameterInputPane;
|
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.plugin.injectable.PluginModule; |
|
|
|
|
import com.fr.script.Calculator; |
|
|
|
@ -46,6 +48,8 @@ import java.awt.Frame;
|
|
|
|
|
import java.awt.datatransfer.StringSelection; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.WindowAdapter; |
|
|
|
|
import java.awt.event.WindowEvent; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
@ -144,6 +148,12 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
|
|
|
|
|
this.add(centerPanel, BorderLayout.CENTER); |
|
|
|
|
this.add(bottomPanel, BorderLayout.SOUTH); |
|
|
|
|
this.setSize(600, 400); |
|
|
|
|
this.addWindowListener(new WindowAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
|
close(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
GUICoreUtils.centerWindow(this); |
|
|
|
|
} |
|
|
|
@ -167,27 +177,24 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
|
|
|
|
|
parameterMap.put(parameter.getName(), parameter.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
boolean showOriginSql = true; |
|
|
|
|
for (ParameterProvider parameter : DataOperator.getInstance().getTableDataParameters(tableData)) { |
|
|
|
|
if (parameterMap.containsKey(parameter.getName())) { |
|
|
|
|
Object value = parameterMap.get(parameter.getName()); |
|
|
|
|
if (value != null && !StringUtils.EMPTY.equals(value)) { |
|
|
|
|
showOriginSql = false; |
|
|
|
|
} |
|
|
|
|
parameter.setValue(value); |
|
|
|
|
parameter.setValue(parameterMap.get(parameter.getName())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String sql; |
|
|
|
|
// 计算高亮文本位置
|
|
|
|
|
List<int[]> specialCharParamIndex = null; |
|
|
|
|
boolean highlight = true; |
|
|
|
|
if (showOriginSql) { |
|
|
|
|
sql = tableData.getQuery(); |
|
|
|
|
} else { |
|
|
|
|
NameSpace ns = ParameterMapNameSpace.create(parameterMap); |
|
|
|
|
calculator.pushNameSpace(ns); |
|
|
|
|
Parameter[] paras = processParameters(tableData, calculator); |
|
|
|
|
// 所有被转义参数的集合
|
|
|
|
|
// 远程时如何获取服务器上的转义字符?这里比较恶心
|
|
|
|
|
// 方法1是新增rpc接口,交由服务器去获取转义字符。但是要考虑兼容问题:
|
|
|
|
|
// 新设计器jar远程老服务器jar,需要提供Compatible实现,但是这个实现能做什么呢?目前没有老的接口可以去获取服务器的转义字符,仍然啥也做不了;
|
|
|
|
|
// 现在采用方法2,通过反射调用PreventSqlInjConfig的刷新方法(因为它是decision模块的private方法,直接改成public仍然有兼容问题)
|
|
|
|
|
Reflect.on(PreventSqlInjConfig.class).call("refreshPreventSqlInjConfig"); |
|
|
|
|
Set<String> specialCharParam = EscapeSqlHelper.getInstance().getSpecialCharParam(paras); |
|
|
|
|
// 将参数转义等
|
|
|
|
|
Set<TableDataProvider> tableDataProviders = getTableDataProviders(); |
|
|
|
@ -203,7 +210,6 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
|
|
|
|
|
if (!StringUtils.equals(oldSql, sql)) { |
|
|
|
|
highlight = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// sql内容复制到剪切板
|
|
|
|
|
StringSelection selection = new StringSelection(sql); |
|
|
|
|
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); |
|
|
|
@ -274,4 +280,8 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
this.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void close() { |
|
|
|
|
this.dispose(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|