Package com.founder.fix.bpmn2extensions.sqlmappingconfig

Examples of com.founder.fix.bpmn2extensions.sqlmappingconfig.Rule


    scriptLanguageMgmt.setVariable("parameter", persistentObject);
    // 设置数据库操作对象
    scriptLanguageMgmt.setVariable("sqlCommand", sqlCommand);

    // 获取指定的规则
    Rule rule = processEngineConfiguration.getRule(statement);
    // 获取规则执行的执行类,如果有执行类则优先执行执行类,没有的话执行脚本。
    String classPath = rule.getClassPath();

    if (StringUtil.isNotEmpty(classPath)) {

      LOG.debug("规则: {} 开始执行,规则执行类为: {}", statement, classPath);

      Class<?> classObj = processEngineConfiguration.getRuleClass(rule.getId());
      if (classObj != null) {
        try {
          InsertRulesScript insertRulesScript = (InsertRulesScript) classObj.newInstance();
          insertRulesScript.execute(persistentObject, 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 {
      String ruleText = rule.getSqlValue();
      if (StringUtil.isNotEmpty(ruleText)) {
        try {

          scriptLanguageMgmt.execute(rule.getSqlValue());

        } catch (Exception e) {

          LOG.error("规则: " + statement + " 执行出错,错误信息: " + e.getMessage() + "\n 规则内容: \n" + rule.getSqlValue(), e);

          throw new FixFlowException(ExceptionCode.RULEEXCEPTION_RULESCRIPTEXEC, e, statement, e.getMessage());

        }
View Full Code Here


    Object parameterOld = scriptLanguageMgmt.getVariable("parameter");

    scriptLanguageMgmt.setVariable("parameter", persistentObject);
    scriptLanguageMgmt.setVariable("sqlCommand", sqlCommand);
    Rule rule = processEngineConfiguration.getRule(statement);
    String classPath = rule.getClassPath();
    if (StringUtil.isNotEmpty(classPath)) {
      Class<?> classObj = processEngineConfiguration.getRuleClass(rule.getId());
      if (classObj != null) {
        try {
          UpdateRulesScript updateRulesScript = (UpdateRulesScript) classObj.newInstance();
          updateRulesScript.execute(persistentObject, 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 {

      String ruleText = rule.getSqlValue();
      if (StringUtil.isNotEmpty(ruleText)) {
        try {

          scriptLanguageMgmt.execute(rule.getSqlValue());

        } catch (Exception e) {

          LOG.error("规则: " + statement + " 执行出错,错误信息: " + e.getMessage() + "\n 规则内容: \n" + rule.getSqlValue(), e);

          throw new FixFlowException(ExceptionCode.RULEEXCEPTION_RULESCRIPTEXEC, e, statement, e.getMessage());

        }
View Full Code Here

  public void delete(String statement, Object parameter) {
    Object parameterOld = scriptLanguageMgmt.getVariable("parameter");
    scriptLanguageMgmt.setVariable("parameter", parameter);
    scriptLanguageMgmt.setVariable("sqlCommand", sqlCommand);
    Rule rule = processEngineConfiguration.getRule(statement);
    String classPath = rule.getClassPath();
    if (StringUtil.isNotEmpty(classPath)) {
      Class<?> classObj = processEngineConfiguration.getRuleClass(rule.getId());
      if (classObj != null) {
        try {

          DeleteRulesScript deleteRulesScript = (DeleteRulesScript) classObj.newInstance();
          deleteRulesScript.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 {

      String ruleText = rule.getSqlValue();
      if (StringUtil.isNotEmpty(ruleText)) {
        try {

          scriptLanguageMgmt.execute(rule.getSqlValue());

        } catch (Exception e) {

          LOG.error("规则: " + statement + " 执行出错,错误信息: " + e.getMessage() + "\n 规则内容: \n" + rule.getSqlValue(), e);

          throw new FixFlowException(ExceptionCode.RULEEXCEPTION_RULESCRIPTEXEC, e, statement, e.getMessage());

        }
View Full Code Here

  public void delete(String statement, PersistentObject persistentObject) {
    Object parameterOld = scriptLanguageMgmt.getVariable("parameter");
    scriptLanguageMgmt.setVariable("parameter", persistentObject);
    scriptLanguageMgmt.setVariable("sqlCommand", sqlCommand);
    Rule rule = processEngineConfiguration.getRule(statement);

    String classPath = rule.getClassPath();
    if (StringUtil.isNotEmpty(classPath)) {
      Class<?> classObj = processEngineConfiguration.getRuleClass(rule.getId());
      if (classObj != null) {
        try {
          DeleteRulesScript deleteRulesScript = (DeleteRulesScript) classObj.newInstance();
          deleteRulesScript.execute(persistentObject, 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 {
      String ruleText = rule.getSqlValue();
      if (StringUtil.isNotEmpty(ruleText)) {
        try {

          scriptLanguageMgmt.execute(rule.getSqlValue());

        } catch (Exception e) {

          LOG.error("规则: " + statement + " 执行出错,错误信息: " + e.getMessage() + "\n 规则内容: \n" + rule.getSqlValue(), e);

          throw new FixFlowException(ExceptionCode.RULEEXCEPTION_RULESCRIPTEXEC, e, statement, e.getMessage());

        }
View Full Code Here

  @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());

          }
        }
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Object selectOne(String statement, Object parameter) {
    Object parameterOld = scriptLanguageMgmt.getVariable("parameter");
    scriptLanguageMgmt.setVariable("parameter", parameter);
    scriptLanguageMgmt.setVariable("sqlCommand", sqlCommand);
    Rule rule = processEngineConfiguration.getRule(statement);

    Object returnObjList = null;

    String classPath = rule.getClassPath();
    if (StringUtil.isNotEmpty(classPath)) {
      Class<?> classObj = processEngineConfiguration.getRuleClass(rule.getId());
      if (classObj != null) {

        try {

          Object classObjInstance = classObj.newInstance();

          if (classObjInstance instanceof SelectRulesScript) {
            SelectRulesScript selectRulesScript = (SelectRulesScript) classObjInstance;
            returnObjList = (Object) selectRulesScript.execute(parameter, sqlCommand, processEngineConfiguration);
          }
          if (classObjInstance instanceof BusinessRulesScript) {
            BusinessRulesScript businessRulesScript = (BusinessRulesScript) classObjInstance;
            returnObjList = (Object) businessRulesScript.execute(parameter, sqlCommand, processEngineConfiguration);
          }
        } catch (Exception e) {
          e.printStackTrace();
          throw new FixFlowException("执行Rule异常: " + e.getMessage(), e);
        }
      } else {
        throw new FixFlowException("Class : " + classPath + "未找到!");
      }
    } else {

      returnObjList = (Object) scriptLanguageMgmt.execute(rule.getSqlValue());

      if (returnObjList instanceof SqlQuery) {

        SqlQuery sqlQuery = (SqlQuery) returnObjList;
        QueryList queryList = sqlQuery.getQueryList();
View Full Code Here

        for (String mapKey : configMap.keySet()) {
          interpreter.set(mapKey, configMap.get(mapKey));
        }
       
      }
      Rule rule = processEngineConfiguration.getRule(ruleId);
      T returnObj =  (T)interpreter.eval(rule.getSqlValue());
      return returnObj;
    } catch (EvalError e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      throw new FixFlowException("表达式计算错误! 错误信息: " + e.getErrorText(), e);
View Full Code Here

        for (String mapKey : configMap.keySet()) {
          interpreter.set(mapKey, configMap.get(mapKey));
        }
       
      }
      Rule rule = processEngineConfiguration.getRule(ruleId);
      Object returnObj =  (Object)interpreter.eval(rule.getSqlValue());
      return returnObj;
    } catch (EvalError e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      throw new FixFlowException("表达式计算错误! 错误信息: " + e.getErrorText(), e);
View Full Code Here

      for (String mapKey : configMap.keySet()) {
        groovyShell.setVariable(mapKey, configMap.get(mapKey));
      }
     
    }
    Rule rule = processEngineConfiguration.getRule(ruleId);
    T returnObj =  (T)groovyShell.evaluate(rule.getSqlValue());
    return returnObj;
  }
View Full Code Here

      for (String mapKey : configMap.keySet()) {
        groovyShell.setVariable(mapKey, configMap.get(mapKey));
      }
     
    }
    Rule rule = processEngineConfiguration.getRule(ruleId);
    Object returnObj =  groovyShell.evaluate(rule.getSqlValue());
    return returnObj;
  }
View Full Code Here

TOP

Related Classes of com.founder.fix.bpmn2extensions.sqlmappingconfig.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.