-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataPool.java
150 lines (108 loc) · 3.83 KB
/
DataPool.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*******************************************************************************
* CSCI Assignment
* Filename: ${filename}
* Author: Nguyen Van Thanh Huy (Nick Nguyen)
* UOW Student Number: 5216746
* Description:
*
*******************************************************************************/
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.*;
import Basic.Facility;
import Basic.Member;
import Basic.TimeSlot;
import Basic.Transaction;
import Basic.User;
import Common.CreateMemberException;
import Common.DBQuery;;
public class DataPool {
private DBQuery query;
public DataPool()
{
query = new DBQuery();
}
public void addMember(Member p) throws CreateMemberException, SQLException
{
//sql insert statement
query.runAddMemberSQL(p);
}
public void removeMember(String name)
{
//sql delete statement
query.runDeleteMemberSQL(name);
}
public void updateMemberPassword(String name,String hashedPW){
query.runUpdateMemberHassedPWSQL(name,hashedPW);
}
public boolean MemberExists(String loginName) {
boolean state = true;
try{
User Member = getMember(loginName);
}catch(InvalidMemberException e){
state = false;
}
return state;
}
public User getMember(String loginName) throws InvalidMemberException
{
//sql select statement
User Member = query.getMember(loginName);
if (Member == null)
throw new InvalidMemberException();
return Member;
}
public ArrayList<Facility> getFacilityList(){
String statement = "Select * from Facility";
ArrayList<Facility> Facilities = query.runGetFacilitys(statement);
return Facilities;
}
public ArrayList<Transaction> getTransactionList(){
String statement = "Select * from Transaction where status ='1'";
ArrayList<Transaction> Transactions = query.runGetTransactions(statement);
return Transactions;
}
public ArrayList<TimeSlot> getSlotList(){
String statement = "Select * from timeslot";
ArrayList<TimeSlot> TimeSlot_ = query.runGetTimeSlot(statement);
return TimeSlot_;
}
public ArrayList<User> getMemberList(){
//select all statemenet
//sql select statement
String statement = "Select * from User";
ArrayList<User> Members = query.runGetMemberListQuery(statement);
return Members;
}
public void closeConnection(){
query.closeConnection();
}
public void saveMembersData() {
// TODO Auto-generated method stub
}
public void createBooking(String date, int member, int facility, int timeSlot, int paxCount, int price) {
// TODO Auto-generated method stub
query.runAddTransactionSQL(date, member, facility, timeSlot, paxCount, price);
}
public void createFacility(String name, String facility, int pricePeak, int priceNonPeak, int cap) {
// TODO Auto-generated method stub
query.runInsertFacility(name, facility, pricePeak, priceNonPeak, cap);
}
public void removeFacility(int idToDelete) {
// TODO Auto-generated method stub
query.runRemoveFacility(idToDelete);
}
public void updateFacility(int idToUpdate, String name, String facility, int pricePeak, int priceNonPeak, int cap) {
// TODO Auto-generated method stub
query.runUpdateFacility(idToUpdate, name, facility, pricePeak, priceNonPeak, cap);
}
public int getTotalBookingCountAt(String date, int timeSlot, int facilityID) {
// TODO Auto-generated method stub
return query.runGetTotalBookingCountAt(date, timeSlot, facilityID);
}
public void deactivateBooking(int idToDeactivate) {
// TODO Auto-generated method stub
query.runDeactivateBooking(idToDeactivate);
}
}