Esempio n. 1
0
 /**
  * Extracts an order entity from the result set.
  *
  * @param rs Result set from which an order entity will be extracted.
  * @return
  */
 private Order extractOrder(ResultSet rs) throws SQLException {
   Order order = new Order();
   order.setId(rs.getInt(Fields.ENTITY_ID));
   order.setBill(rs.getInt(Fields.ORDER_BILL));
   order.setUserId(rs.getLong(Fields.ORDER_USER_ID));
   order.setStatusId(rs.getInt(Fields.ORDER_STATUS_ID));
   return order;
 }
Esempio n. 2
0
 /**
  * Returns menu items of the given order.
  *
  * @param order Order entity.
  * @return List of menu item entities.
  */
 public List<CatalogItem> findCatalogItems(Order order) throws DBException {
   // TODO: 22.08.2016 исправить, метод не изменен после рефакторинга класса CatalogItem
   List<CatalogItem> catalogItemList = new ArrayList<>();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   Connection con = null;
   try {
     con = getConnection();
     pstmt = con.prepareStatement(SQL_FIND_CATALOG_ITEMS_BY_ORDER);
     pstmt.setLong(1, order.getId());
     rs = pstmt.executeQuery();
     while (rs.next()) {
       catalogItemList.add(extractCatalogItem(rs));
     }
     con.commit();
   } catch (SQLException ex) {
     rollback(con);
     LOG.error(Messages.ERR_CANNOT_OBTAIN_MENU_ITEMS_BY_ORDER, ex);
     throw new DBException(Messages.ERR_CANNOT_OBTAIN_MENU_ITEMS_BY_ORDER, ex);
   } finally {
     close(con, pstmt, rs);
   }
   return catalogItemList;
 }