Ejemplo n.º 1
0
  /**
   * Insert a new record in the table.
   *
   * @param rule The rule object
   */
  public synchronized void insert(Rule rule) {
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_INSERT);
    rule.setId(newPrimaryKey());
    daoUtil.setInt(1, rule.getId());
    daoUtil.setString(2, rule.getRuleTypeId());

    daoUtil.executeUpdate();
    daoUtil.free();

    // Rule attributes
    insertAttributes(rule);
  }
Ejemplo n.º 2
0
  /**
   * Load the list of rules specified by rule type key
   *
   * @param strRuleTypeKey The rule type key
   * @param ruleTypesSet The rule types set
   * @return The Collection of the Rules
   */
  public List<Rule> selectRuleListByRuleTypeKey(String strRuleTypeKey, IRuleTypesSet ruleTypesSet) {
    List<Rule> listRules = new ArrayList<Rule>();
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECT_BY_RULE_TYPE_KEY);
    daoUtil.setString(1, strRuleTypeKey);
    daoUtil.executeQuery();

    while (daoUtil.next()) {
      Rule rule = ruleTypesSet.newInstance(strRuleTypeKey);
      rule.setId(daoUtil.getInt(1));
      rule.setRuleTypeId(strRuleTypeKey);
      loadAttributes(rule);
      listRules.add(rule);
    }

    daoUtil.free();

    return listRules;
  }
Ejemplo n.º 3
0
  /**
   * Load the data of Rule from the table
   *
   * @param nRuleId The identifier of Rule
   * @param ruleTypesSet The rule type set object
   * @return the instance of the Rule
   */
  public Rule load(int nRuleId, IRuleTypesSet ruleTypesSet) {
    Rule rule = null;
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECT);
    daoUtil.setInt(1, nRuleId);
    daoUtil.executeQuery();

    if (daoUtil.next()) {
      String strRuleTypeId = daoUtil.getString(2);
      rule = ruleTypesSet.newInstance(strRuleTypeId);
      rule.setId(nRuleId);
      rule.setRuleTypeId(strRuleTypeId);
      loadAttributes(rule);
    }

    daoUtil.free();

    return rule;
  }