@SuppressWarnings({ "rawtypes", "unchecked" })
public List selectList(String statement, ListQueryParameterObject parameter) {
Object parameterOld = scriptLanguageMgmt.getVariable("parameter");
scriptLanguageMgmt.setVariable("parameter", parameter);
scriptLanguageMgmt.setVariable("sqlCommand", sqlCommand);
Rule rule = processEngineConfiguration.getRule(statement);
List returnObjList = null;
String classPath = rule.getClassPath();
if (StringUtil.isNotEmpty(classPath)) {
Class<?> classObj = processEngineConfiguration.getRuleClass(rule.getId());
if (classObj != null) {
try {
SelectRulesScript selectRulesScript = (SelectRulesScript) classObj.newInstance();
returnObjList = (List) selectRulesScript.execute(parameter, sqlCommand, processEngineConfiguration);
} catch (Exception e) {
LOG.error("规则: " + statement + " 执行出错,规则执行类为: " + classPath + ",错误信息: " + e.getMessage(), e);
throw new FixFlowException(ExceptionCode.RULEEXCEPTION_CLASSEXEC, e, statement, classPath, e.getMessage());
}
} else {
LOG.error("规则解释类:" + classPath + " 未找到.");
throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOADEXCEPTION_RULECLASS, classPath);
}
} else {
if (StringUtil.isEmpty(rule.getSqlValue())) {
LOG.error("规则: " + statement + " 执行类、规则内容都为空.");
throw new FixFlowException(ExceptionCode.RULEEXCEPTION_CLASSANDSCRIPTEMPTY, statement);
}
Object returnObj = scriptLanguageMgmt.execute(rule.getSqlValue());
if (returnObj instanceof SqlQuery) {
SqlQuery sqlQuery = (SqlQuery) returnObj;
QueryList queryList = sqlQuery.getQueryList();
if (queryList != null) {
try {
if (queryList.getData() == null) {
returnObjList = sqlCommand.queryForList(queryList.getSqlText());
} else {
returnObjList = sqlCommand.queryForList(queryList.getSqlText(), queryList.getData());
}
} catch (Exception e) {
LOG.error("规则: " + statement + " 执行出错,错误信息: " + e.getMessage() + "\n 规则内容: \n" + rule.getSqlValue(), e);
throw new FixFlowException(ExceptionCode.RULEEXCEPTION_RULESCRIPTEXEC, e, statement, e.getMessage());
}
}