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