feature #I61D1N 规则层面增加一个enable的选项,可以禁用规则
This commit is contained in:
parent
c493c8bddc
commit
7291914402
|
@ -10,15 +10,11 @@ package com.yomahub.liteflow.parser.constant;
|
|||
*/
|
||||
public class SqlReadConstant {
|
||||
|
||||
public static final String SQL_PATTERN = "SELECT {},{} FROM {} WHERE {}=?";
|
||||
|
||||
public static final String SQL_ENABLE_PATTERN = "AND {}=?";
|
||||
public static final String SQL_PATTERN = "SELECT * FROM {} WHERE {}=?";
|
||||
|
||||
public static final String SCRIPT_SQL_CHECK_PATTERN = "SELECT 1 FROM {} ";
|
||||
|
||||
public static final String SCRIPT_SQL_PATTERN = "SELECT {},{},{},{} FROM {} WHERE {}=?";
|
||||
|
||||
public static final String SCRIPT_WITH_LANGUAGE_SQL_PATTERN = "SELECT {},{},{},{},{} FROM {} WHERE {}=?";
|
||||
public static final String SCRIPT_SQL_PATTERN = "SELECT * FROM {} WHERE {}=?";
|
||||
|
||||
public static final String CHAIN_XML_PATTERN = "<chain name=\"{}\"><![CDATA[{}]]></chain>";
|
||||
|
||||
|
|
|
@ -35,11 +35,12 @@ public abstract class AbstractSqlRead implements SqlRead {
|
|||
return new HashMap<>();
|
||||
}
|
||||
|
||||
Map<String/*规则唯一键*/, String/*规则*/> result = new HashMap<>();
|
||||
checkConfig();
|
||||
String sqlCmd = buildQuerySql();
|
||||
// 如果允许,就打印 sql 语句
|
||||
logSqlIfEnable(sqlCmd);
|
||||
|
||||
Map<String/*规则唯一键*/, String/*规则*/> result = new HashMap<>();
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
|
@ -91,6 +92,8 @@ public abstract class AbstractSqlRead implements SqlRead {
|
|||
|
||||
public abstract String buildXmlElementUniqueKey(ResultSet rs) throws SQLException;
|
||||
|
||||
public abstract void checkConfig();
|
||||
|
||||
/**
|
||||
* 是否可以读取
|
||||
* chain 默认可以读取
|
||||
|
|
|
@ -39,25 +39,35 @@ public class ChainRead extends AbstractSqlRead {
|
|||
|
||||
@Override
|
||||
public String buildQuerySql() {
|
||||
String chainTableName = super.config.getChainTableName();
|
||||
String chainApplicationNameField = super.config.getChainApplicationNameField();
|
||||
|
||||
return StrUtil.format(SqlReadConstant.SQL_PATTERN, chainTableName, chainApplicationNameField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfig() {
|
||||
String chainTableName = super.config.getChainTableName();
|
||||
String elDataField = super.config.getElDataField();
|
||||
String chainNameField = super.config.getChainNameField();
|
||||
String chainApplicationNameField = super.config.getChainApplicationNameField();
|
||||
String applicationName = super.config.getApplicationName();
|
||||
|
||||
|
||||
if (StrUtil.isBlank(chainTableName)) {
|
||||
if (StrUtil.isBlank(chainTableName)){
|
||||
throw new ELSQLException("You did not define the chainTableName property");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(chainApplicationNameField)) {
|
||||
throw new ELSQLException("You did not define the applicationName or chainApplicationNameField property");
|
||||
if (StrUtil.isBlank(elDataField)){
|
||||
throw new ELSQLException("You did not define the elDataField property");
|
||||
}
|
||||
if (StrUtil.isBlank(chainNameField)){
|
||||
throw new ELSQLException("You did not define the chainNameField property");
|
||||
}
|
||||
if (StrUtil.isBlank(chainApplicationNameField)){
|
||||
throw new ELSQLException("You did not define the chainApplicationNameField property");
|
||||
}
|
||||
if (StrUtil.isBlank(applicationName)){
|
||||
throw new ELSQLException("You did not define the applicationName property");
|
||||
}
|
||||
|
||||
String sqlCmd = StrUtil.format(SqlReadConstant.SQL_PATTERN, chainNameField, elDataField, chainTableName,
|
||||
chainApplicationNameField);
|
||||
|
||||
return sqlCmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,48 +46,38 @@ public class ScriptRead extends AbstractSqlRead {
|
|||
|
||||
@Override
|
||||
public String buildQuerySql() {
|
||||
String scriptLanguageField = super.config.getScriptLanguageField();
|
||||
String scriptTableName = super.config.getScriptTableName();
|
||||
String scriptApplicationNameField = super.config.getScriptApplicationNameField();
|
||||
|
||||
return StrUtil.format(
|
||||
SqlReadConstant.SCRIPT_SQL_PATTERN,
|
||||
scriptTableName,
|
||||
scriptApplicationNameField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfig() {
|
||||
String scriptTableName = super.config.getScriptTableName();
|
||||
String scriptIdField = super.config.getScriptIdField();
|
||||
String scriptDataField = super.config.getScriptDataField();
|
||||
String scriptNameField = super.config.getScriptNameField();
|
||||
String scriptTypeField = super.config.getScriptTypeField();
|
||||
String scriptApplicationNameField = super.config.getScriptApplicationNameField();
|
||||
String applicationName = super.config.getApplicationName();
|
||||
|
||||
|
||||
if (StrUtil.isBlank(applicationName) || StrUtil.isBlank(scriptApplicationNameField)) {
|
||||
throw new ELSQLException("You did not define the applicationName or scriptApplicationNameField property");
|
||||
if(StrUtil.isBlank(scriptTableName)){
|
||||
throw new ELSQLException("You did not define the scriptTableName property");
|
||||
}
|
||||
|
||||
String sqlCmd = null;
|
||||
// 脚本节点(带语言)
|
||||
if (withLanguage()) {
|
||||
sqlCmd = StrUtil.format(
|
||||
SqlReadConstant.SCRIPT_WITH_LANGUAGE_SQL_PATTERN,
|
||||
scriptIdField,
|
||||
scriptDataField,
|
||||
scriptNameField,
|
||||
scriptTypeField,
|
||||
scriptLanguageField,
|
||||
scriptTableName,
|
||||
scriptApplicationNameField
|
||||
);
|
||||
if(StrUtil.isBlank(scriptIdField)){
|
||||
throw new ELSQLException("You did not define the scriptIdField property");
|
||||
}
|
||||
// 脚本节点(不带语言)
|
||||
else {
|
||||
sqlCmd = StrUtil.format(
|
||||
SqlReadConstant.SCRIPT_SQL_PATTERN,
|
||||
scriptIdField,
|
||||
scriptDataField,
|
||||
scriptNameField,
|
||||
scriptTypeField,
|
||||
scriptTableName,
|
||||
scriptApplicationNameField
|
||||
);
|
||||
if(StrUtil.isBlank(scriptDataField)){
|
||||
throw new ELSQLException("You did not define the scriptDataField property");
|
||||
}
|
||||
if(StrUtil.isBlank(scriptTypeField)){
|
||||
throw new ELSQLException("You did not define the scriptTypeField property");
|
||||
}
|
||||
if(StrUtil.isBlank(scriptApplicationNameField)){
|
||||
throw new ELSQLException("You did not define the scriptApplicationNameField property");
|
||||
}
|
||||
|
||||
return sqlCmd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue