Example #1
0
  public LinkModel findByActivityKey(int nodeId, int nextNodeId) throws SQLException {
    LinkModel model = new LinkModel();
    String sql =
        "select NODE_LINK_ID, NAME, DESCRIPTION, LINK_TYPE, "
            + "TEMPLATE_ID, CURRENT_NODE_ID, NEXT_NODE_ID, EXECUTOR_RELATION, "
            + "EXECUTORS_METHOD, NUMBER_OR_PERCENT, PASS_VALUE, EXPRESSION, "
            + "DEFAULT_PATH, ACTION_NAME from WF_LINK where CURRENT_NODE_ID=? AND NEXT_NODE_ID=?";
    PreparedStatement st = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = ConnectionFactory.getConnection();
      st = conn.prepareStatement(sql);
      st.setInt(1, nodeId);
      st.setInt(1, nextNodeId);
      rs = st.executeQuery();
      if (rs.next()) {
        model = parseResultSet(rs);
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      DBHelper.closeConnection(conn, st, rs);
    }

    return model;
  }
Example #2
0
  public ArrayList getFollowedLinkList(int theBegin, int theEnd, int templateId, int currentNodeId)
      throws SQLException {
    ArrayList list = new ArrayList();
    String sql = "select * from wf_link where template_id = ? and current_node_id = ?";
    PreparedStatement st = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = ConnectionFactory.getConnection();
      st = conn.prepareStatement(sql);
      if (theEnd > 0) st.setFetchSize(theEnd);

      st.setInt(1, templateId);
      st.setInt(2, currentNodeId);
      rs = st.executeQuery();
      if (theBegin > 1) rs.absolute(theBegin - 1);
      while (rs.next()) {
        list.add(parseResultSet(rs));
        if (rs.getRow() == theEnd) break;
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      DBHelper.closeConnection(conn, st, rs);
    }

    return list;
  }
Example #3
0
  public ArrayList find(int theBegin, int theEnd) throws SQLException {
    ArrayList list = new ArrayList();
    String sql =
        "select NODE_LINK_ID, NAME, DESCRIPTION, LINK_TYPE, TEMPLATE_ID, CURRENT_NODE_ID, NEXT_NODE_ID, EXECUTOR_RELATION, EXECUTORS_METHOD, NUMBER_OR_PERCENT, PASS_VALUE, EXPRESSION, DEFAULT_PATH, ACTION_NAME from WF_LINK";
    PreparedStatement st = null;
    ResultSet rs = null;
    Connection conn = null;
    try {
      conn = ConnectionFactory.getConnection();
      st = conn.prepareStatement(sql);
      if (theEnd > 0) st.setFetchSize(theEnd);

      rs = st.executeQuery();
      if (theBegin > 1) rs.absolute(theBegin - 1);
      while (rs.next()) {
        list.add(parseResultSet(rs));
        if (rs.getRow() == theEnd) break;
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      DBHelper.closeConnection(conn, st, rs);
    }

    return list;
  }
Example #4
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);
   }
 }
Example #5
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);
   }
 }
Example #6
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);
   }
 }