コード例 #1
0
  /**
   * @param conn
   * @param documentPK
   * @return
   * @throws SQLException
   * @throws VersioningRuntimeException
   */
  public static List<Worker> getWorkers(Connection conn, DocumentPK documentPK)
      throws SQLException, VersioningRuntimeException {
    if (conn == null) {
      throw new VersioningRuntimeException(
          "WorkListDAO.getWorkers", SilverTrace.TRACE_LEVEL_DEBUG, "root.EX_NO_CONNECTION");
    }
    if (documentPK == null) {
      throw new VersioningRuntimeException(
          "WorkListDAO.getWorkers",
          SilverTrace.TRACE_LEVEL_DEBUG,
          "root.EX_NULL_VALUE_OBJECT_OR_PK");
    }

    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    List<Worker> result = new ArrayList<Worker>();

    try {
      prepStmt = conn.prepareStatement(GET_WORKERS_QUERY);
      try {
        prepStmt.setInt(1, Integer.parseInt(documentPK.getId()));
      } catch (NumberFormatException e) {
        throw new VersioningRuntimeException(
            "WorkListDAO.getWorkers",
            SilverTrace.TRACE_LEVEL_DEBUG,
            "root.EX_WRONG_PK",
            documentPK.toString(),
            e);
      }

      rs = prepStmt.executeQuery();

      while (rs.next()) {
        Worker worker = new Worker();

        worker.setDocumentId(rs.getInt(1));
        worker.setId(rs.getInt(2));
        worker.setOrder(rs.getInt(3));
        worker.setWriter(rs.getString(4).trim().equalsIgnoreCase("Y"));
        worker.setApproval(rs.getString(5).trim().equalsIgnoreCase("Y"));
        worker.setInstanceId(rs.getString(6));
        worker.setType(rs.getString(7));
        worker.setSaved(rs.getInt(8) == 1 ? true : false);
        worker.setUsed(rs.getInt(9) == 1 ? true : false);
        worker.setListType(rs.getInt(10));
        result.add(worker);
      }

    } finally {
      DBUtil.close(rs, prepStmt);
    }

    return result;
  }
コード例 #2
0
  /**
   * @param con
   * @param componentId
   * @return * @return ArrayList of workers (users)
   * @throws SQLException
   * @throws VersioningRuntimeException
   */
  public static List<Worker> getWorkersAccessListUsers(Connection con, String componentId)
      throws SQLException, VersioningRuntimeException {
    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    List<Worker> result = new ArrayList<Worker>();

    try {
      prepStmt = con.prepareStatement(GET_WORKERS_ACCESS_LIST_USERS);
      try {
        prepStmt.setString(1, componentId);
      } catch (NumberFormatException e) {
        throw new VersioningRuntimeException(
            "WorkListDAO.getWorkersAccessListUsers",
            SilverTrace.TRACE_LEVEL_DEBUG,
            "root.EX_WRONG_PK",
            componentId,
            e);
      }

      rs = prepStmt.executeQuery();

      while (rs.next()) {
        Worker worker = new Worker();
        worker.setDocumentId(rs.getInt(1));
        worker.setId(rs.getInt(2));
        worker.setOrder(rs.getInt(3));
        worker.setWriter(rs.getString(4).trim().equalsIgnoreCase("Y"));
        worker.setApproval(rs.getString(5).trim().equalsIgnoreCase("Y"));
        worker.setInstanceId(rs.getString(6));
        worker.setType(rs.getString(7));
        worker.setSaved(rs.getInt(8) == 1 ? true : false);
        worker.setUsed(rs.getInt(9) == 1 ? true : false);
        worker.setListType(rs.getInt(10));
        result.add(worker);
      }

    } finally {
      DBUtil.close(rs, prepStmt);
    }
    return result;
  }