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.Supplier;
29 import org.example.customerdao.utility.Deleteable;
30 import org.example.websecurity.UserCredentials;
31
32 /**
33 * This is the SupplierDAO Interface for the Customer DAO component of the Customer Web Application.
34 * This will be the primary Supplier database exposure for the Customer Web Layer.
35 *
36 * @author Jonathan Earl
37 * @since 1.0
38 *
39 */
40 public interface SupplierDAO extends Deleteable
41 {
42 /**
43 * Sets the Read Only DataSource for this DAO Implication.
44 *
45 * @param readOnlyDS the readOnlyDS to set
46 */
47 void setReadOnlyDS(DataSource readOnlyDS);
48
49 /**
50 * Sets the Read/Write DataSource for this DAO Implication.
51 *
52 * @param readWriteDS the readWriteDS to set
53 */
54 void setReadWriteDS(DataSource readWriteDS);
55
56 /**
57 * Finds all Suppliers.
58 *
59 * @param credentials the UserCredentials for this Database operation
60 * @return a list of Suppliers, this list may be empty
61 * @throws IllegalArgumentException
62 * if there is a connection or permission problem
63 */
64 List<Supplier> findAllSuppliers(UserCredentials credentials);
65
66 /**
67 * Find Supplier by Id.
68 * <p>
69 * This will return null if the Supplier cannot be found.
70 *
71 * @param credentials the UserCredentials for this Database operation
72 * @param id the Supplier ID to search for
73 * @return a Supplier or null if the Supplier is not found
74 * @throws IllegalArgumentException
75 * if there is a connection or permission problem
76 */
77 Supplier findSupplierById(UserCredentials credentials, int id);
78
79 /**
80 * Find Suppliers by Company name.
81 * <p>
82 * This will use a Wild Card search to find any Supplier with the provided string
83 * and a portion of their Company name.
84 *
85 * @param credentials the UserCredentials for this Database operation
86 * @param name the string to search for
87 * @return a list if Suppliers, this list may be empty
88 * @throws IllegalArgumentException
89 * if there is a connection or permission problem
90 */
91 List<Supplier> findSuppliersByCompanyName(UserCredentials credentials, String name);
92
93 /**
94 * Adds a Supplier.
95 * <p >
96 * Only a Manager is permitted to add a Supplier.
97 *
98 *
99 * @param credentials the UserCredentials for this Database operation
100 * @param supplier the Supplier object to add
101 * @return the id of the new Supplier record
102 * @throws IllegalArgumentException
103 * if there is a connection or permission problem
104 */
105 int addSupplier(UserCredentials credentials, Supplier supplier);
106
107 /**
108 * Updates a Supplier.
109 * <p >
110 * Only a Manager is permitted to update a Supplier.
111 *
112 *
113 * @param credentials the UserCredentials for this Database operation
114 * @param supplier the Supplier object to update
115 * @throws IllegalArgumentException
116 * if there is a connection or permission problem
117 */
118 void updateSupplier(UserCredentials credentials, Supplier supplier);
119 }