Exemplo n.º 1
0
 public void removeByTemplate(int templateId) throws SQLException {
   String sql = "delete from wf_link where template_id = ?";
   PreparedStatement st = null;
   Connection conn = null;
   try {
     conn = ConnectionFactory.getConnection();
     st = conn.prepareStatement(sql);
     st.setInt(1, templateId);
     st.executeUpdate();
     logger.info(sql);
   } catch (SQLException e) {
     e.printStackTrace();
     throw new SQLException(e.getMessage());
   } finally {
     DBHelper.closeConnection(conn, st, null);
   }
 }
Exemplo n.º 2
0
 public void delete(int nodeLinkId) throws SQLException {
   String sql = "delete from WF_LINK where NODE_LINK_ID=?";
   PreparedStatement st = null;
   Connection conn = null;
   try {
     conn = ConnectionFactory.getConnection();
     st = conn.prepareStatement(sql);
     st.setInt(1, nodeLinkId);
     st.executeUpdate();
     logger.info(sql);
   } catch (SQLException e) {
     e.printStackTrace();
     throw new SQLException(e.getMessage());
   } finally {
     DBHelper.closeConnection(conn, st, null);
   }
 }
Exemplo n.º 3
0
 public void removeDefaultPath(int currentNodeId) throws SQLException {
   String sql =
       "update wf_link set default_path='0' where current_node_id = ? and default_path='1'";
   PreparedStatement st = null;
   Connection conn = null;
   try {
     conn = ConnectionFactory.getConnection();
     st = conn.prepareStatement(sql);
     st.setInt(1, currentNodeId);
     st.executeUpdate();
     logger.info(sql);
   } catch (SQLException e) {
     e.printStackTrace();
     throw new SQLException(e.getMessage());
   } finally {
     DBHelper.closeConnection(conn, st, null);
   }
 }
Exemplo n.º 4
0
  public int update(LinkModel model) throws SQLException {
    String sql = null;
    String updateString = "";
    ArrayList strList = new ArrayList();
    ArrayList valList = new ArrayList();

    if (model.getNameModifyFlag()) {
      StringUtil.makeDynaParam("NAME = ", convertSQL(model.getName()), strList, valList);
    }
    if (model.getDescriptionModifyFlag()) {
      StringUtil.makeDynaParam(
          "DESCRIPTION = ", convertSQL(model.getDescription()), strList, valList);
    }

    if (model.getLinkTypeModifyFlag()) {
      StringUtil.makeDynaParam("LINK_TYPE = ", convertSQL(model.getLinkType()), strList, valList);
    }
    if (model.getTemplateIdModifyFlag()) {
      StringUtil.makeDynaParam("TEMPLATE_ID = ", model.getTemplateId(), strList, valList);
    }

    if (model.getCurrentNodeIdModifyFlag()) {
      StringUtil.makeDynaParam("CURRENT_NODE_ID = ", model.getCurrentNodeId(), strList, valList);
    }
    if (model.getNextNodeIdModifyFlag()) {
      StringUtil.makeDynaParam("NEXT_NODE_ID = ", model.getNextNodeId(), strList, valList);
    }
    if (model.getExecutorRelationModifyFlag()) {
      StringUtil.makeDynaParam(
          "EXECUTOR_RELATION = ", convertSQL(model.getExecutorRelation()), strList, valList);
    }
    if (model.getExecutorsMethodModifyFlag()) {
      StringUtil.makeDynaParam(
          "EXECUTORS_METHOD = ", convertSQL(model.getExecutorsMethod()), strList, valList);
    }
    if (model.getNumberOrPercentModifyFlag()) {
      StringUtil.makeDynaParam(
          "NUMBER_OR_PERCENT = ", convertSQL(model.getNumberOrPercent()), strList, valList);
    }
    if (model.getPassValueModifyFlag()) {
      StringUtil.makeDynaParam("PASS_VALUE = ", model.getPassValue(), strList, valList);
    }
    if (model.getExpressionModifyFlag()) {
      StringUtil.makeDynaParam(
          "EXPRESSION = ", convertSQL(model.getExpression()), strList, valList);
    }
    if (model.getDefaultPathModifyFlag()) {
      StringUtil.makeDynaParam(
          "DEFAULT_PATH = ", convertSQL(model.getDefaultPath()), strList, valList);
    }
    if (model.getActionNameModifyFlag()) {
      StringUtil.makeDynaParam(
          "ACTION_NAME = ", convertSQL(model.getActionName()), strList, valList);
    }
    if (strList.size() == 0) return 0;
    valList.add(model.getNodeLinkId());
    int length = strList.size();
    if (length == 0) {
      updateString = null;
    } else {
      for (int i = 0; i <= length - 1; i++) {
        updateString += strList.get(i) + "?,";
      }
      updateString = updateString.substring(0, updateString.length() - 1);
    }
    sql = "update WF_LINK set " + updateString + " where NODE_LINK_ID= ?";
    DBHelper.executeUpdate(sql, valList.toArray());
    logger.info(sql);
    return 1;
  }
Exemplo n.º 5
0
 public int insert(LinkModel model) throws SQLException {
   String sql = null;
   ArrayList strList = new ArrayList();
   ArrayList valList = new ArrayList();
   if (model.getNodeLinkIdModifyFlag()) {
     StringUtil.makeDynaParam("NODE_LINK_ID", model.getNodeLinkId(), strList, valList);
   }
   if (model.getNameModifyFlag()) {
     StringUtil.makeDynaParam("NAME", convertSQL(model.getName()), strList, valList);
   }
   if (model.getDescriptionModifyFlag()) {
     StringUtil.makeDynaParam("DESCRIPTION", convertSQL(model.getDescription()), strList, valList);
   }
   if (model.getLinkTypeModifyFlag()) {
     StringUtil.makeDynaParam("LINK_TYPE", convertSQL(model.getLinkType()), strList, valList);
   }
   if (model.getTemplateIdModifyFlag()) {
     StringUtil.makeDynaParam("TEMPLATE_ID", model.getTemplateId(), strList, valList);
   }
   if (model.getCurrentNodeIdModifyFlag()) {
     StringUtil.makeDynaParam("CURRENT_NODE_ID", model.getCurrentNodeId(), strList, valList);
   }
   if (model.getNextNodeIdModifyFlag()) {
     StringUtil.makeDynaParam("NEXT_NODE_ID", model.getNextNodeId(), strList, valList);
   }
   if (model.getExecutorRelationModifyFlag()) {
     StringUtil.makeDynaParam(
         "EXECUTOR_RELATION", convertSQL(model.getExecutorRelation()), strList, valList);
   }
   if (model.getExecutorsMethodModifyFlag()) {
     StringUtil.makeDynaParam(
         "EXECUTORS_METHOD", convertSQL(model.getExecutorsMethod()), strList, valList);
   }
   if (model.getNumberOrPercentModifyFlag()) {
     StringUtil.makeDynaParam(
         "NUMBER_OR_PERCENT", convertSQL(model.getNumberOrPercent()), strList, valList);
   }
   if (model.getPassValueModifyFlag()) {
     StringUtil.makeDynaParam("PASS_VALUE", model.getPassValue(), strList, valList);
   }
   if (model.getExpressionModifyFlag()) {
     StringUtil.makeDynaParam("EXPRESSION", convertSQL(model.getExpression()), strList, valList);
   }
   if (model.getDefaultPathModifyFlag()) {
     StringUtil.makeDynaParam(
         "DEFAULT_PATH", convertSQL(model.getDefaultPath()), strList, valList);
   }
   if (model.getActionNameModifyFlag()) {
     StringUtil.makeDynaParam("ACTION_NAME", convertSQL(model.getActionName()), strList, valList);
   }
   String insertString = "";
   String valsString = "";
   int length = strList.size();
   if (length == 0) {
     insertString = null;
     valsString = null;
   } else {
     for (int i = 0; i <= length - 1; i++) {
       insertString += strList.get(i) + ",";
       valsString += "?,";
     }
     insertString = insertString.substring(0, insertString.length() - 1);
     valsString = valsString.substring(0, valsString.length() - 1);
   }
   sql = "insert into WF_LINK(" + insertString + ") values(" + valsString + ")";
   DBHelper.executeUpdate(sql, valList.toArray());
   logger.info(sql);
   return 1;
 }