View Javadoc
1   package org.example.customerdao;
2   
3   /*
4   * This is free and unencumbered software released into the public domain.
5   * Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, 
6   * either in source code form or as a compiled binary, for any purpose, commercial or 
7   * non-commercial, and by any means.
8   * 
9   * In jurisdictions that recognize copyright laws, the author or authors of this 
10  * software dedicate any and all copyright interest in the software to the public domain. 
11  * We make this dedication for the benefit of the public at large and to the detriment of 
12  * our heirs and successors. We intend this dedication to be an overt act of relinquishment in 
13  * perpetuity of all present and future rights to this software under copyright law.
14  * 
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
17  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES 
18  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20  * 
21  * For more information, please refer to: https://unlicense.org/
22  */
23  
24  import java.util.List;
25  
26  import javax.sql.DataSource;
27  
28  import org.example.customer.Customer;
29  import org.example.customer.Order;
30  import org.example.customer.OrderItem;
31  import org.example.customerdao.utility.Deleteable;
32  import org.example.websecurity.UserCredentials;
33  
34  
35  
36  /**
37   * This is the OrderDAO Interface for the Customer DAO component of the Customer Web Application.
38   * This will be the primary Order database exposure for the Customer Web Layer.
39   * 
40   * @author Jonathan Earl
41   * @since 1.0
42   * 
43   */
44  public interface OrderDAO extends Deleteable
45  {
46      /**
47       * Sets the Read Only DataSource for this DAO Implication.
48       * 
49       * @param readOnlyDS the readOnlyDS to set
50       */
51      void setReadOnlyDS(DataSource readOnlyDS);
52      
53      /**
54       * Sets the Read/Write DataSource for this DAO Implication.
55       * 
56       * @param readWriteDS the readWriteDS to set
57       */
58      void setReadWriteDS(DataSource readWriteDS);
59      
60      /**
61       * Finds all Orders.
62       * 
63       * @param credentials the UserCredentials for this Database operation
64       * @return a list of Orders, this list may be empty
65       * @throws IllegalArgumentException 
66       *              if there is a connection or permission problem
67       */
68      List<Order> findAllOrders(UserCredentials credentials);  
69      
70      /**
71       * Finds all Order_Items by Order.
72       * 
73       * @param credentials the UserCredentials for this Database operation
74       * @param order the order to search for
75       * @return a list of OrderItems, this list may be empty
76       * @throws IllegalArgumentException 
77       *              if there is a connection or permission problem
78       */
79      List<OrderItem> findAllOrderItems(UserCredentials credentials, Order order);  
80      
81      /**
82       * Find Order by Id.
83       * <p>
84       * This will return null if the Order cannot be found.
85       * 
86       * @param credentials the UserCredentials for this Database operation
87       * @param id the Order ID to search for
88       * @return a Order or null if the Order is not found
89       * @throws IllegalArgumentException 
90       *              if there is a connection or permission problem
91       */
92      Order findOrderById(UserCredentials credentials, int id);
93      
94      /**
95       * Find Orders by Customer.
96       * 
97       * @param credentials the UserCredentials for this Database operation
98       * @param customer the Customer to search for
99       * @return a list of Orders, this list may be empty
100      * @throws IllegalArgumentException 
101      *              if there is a connection or permission problem
102      */
103     List<Order> findOrdersByCustomer(UserCredentials credentials, Customer customer);
104     
105     /**
106      * Adds a Order.
107      * 
108      * @param credentials the UserCredentials for this Database operation
109      * @param order the Order object to add
110      * @return the id of the new Order record
111      * @throws IllegalArgumentException 
112      *              if there is a connection or permission problem
113      */
114     int addOrder(UserCredentials credentials, Order order);
115     
116     /**
117      * Updates a Order.
118      * 
119      * @param credentials the UserCredentials for this Database operation
120      * @param order the Order object to update
121      * @throws IllegalArgumentException 
122      *              if there is a connection or permission problem
123      */
124     void updateOrder(UserCredentials credentials, Order order);
125 }