| | 1 | = Use-case 0003 Implementation - Approve or reject reservation = |
| | 2 | |
| | 3 | == Initiating actor == |
| | 4 | |
| | 5 | Reservation Approver |
| | 6 | |
| | 7 | == Other actors == |
| | 8 | |
| | 9 | Room Requester |
| | 10 | |
| | 11 | == Description of the use-case goals == |
| | 12 | |
| | 13 | The goal of this use-case is to allow a reservation approver to review pending reservation requests and record an approval or rejection decision. The system displays pending reservations, allows the approver to select a reservation, and then saves the decision in the database. |
| | 14 | |
| | 15 | This use-case demonstrates update and insert operations in the database. The reservation status is updated, and a new approval record is inserted. |
| | 16 | |
| | 17 | == Scenario == |
| | 18 | |
| | 19 | The Reservation Approver chooses the option ''Approve or reject reservation'' from the main menu. |
| | 20 | The system displays a list of all pending reservations. |
| | 21 | The Reservation Approver selects a reservation from the list. |
| | 22 | The system displays a list of users who can approve reservations. |
| | 23 | The Reservation Approver selects the approver from the list. |
| | 24 | The system asks whether the reservation should be approved or rejected. |
| | 25 | The Reservation Approver chooses the decision. |
| | 26 | The system asks for an optional decision note. |
| | 27 | The Reservation Approver enters a note. |
| | 28 | The system updates the status of the selected reservation in the ''project.reservations'' table. |
| | 29 | The system inserts a new approval record into the ''project.approvals'' table. |
| | 30 | The system displays the final reservation details, including status, decision, decision time, and approver. |
| | 31 | |
| | 32 | == Screenshots == |
| | 33 | |
| | 34 | The following screenshot shows the list of pending reservations and the approval input. |
| | 35 | |
| | 36 | [[Image(uc0003_pending_reservations.png, width=100%)]] |
| | 37 | |
| | 38 | The following screenshot shows the final approved reservation details. |
| | 39 | |
| | 40 | [[Image(uc0003_reservation_approved.png, width=100%)]] |
| | 41 | |
| | 42 | The following screenshot shows database verification in DBeaver for the approval record. |
| | 43 | |
| | 44 | [[Image(dbeaver_approvals_result.png, width=100%)]] |
| | 45 | |
| | 46 | == SQL commands used by the system == |
| | 47 | |
| | 48 | The system first lists all pending reservations. |
| | 49 | |
| | 50 | {{{ |
| | 51 | SELECT |
| | 52 | res.reservation_id, |
| | 53 | res.reservation_date, |
| | 54 | res.start_time, |
| | 55 | res.end_time, |
| | 56 | res.status, |
| | 57 | u.full_name AS requester_name, |
| | 58 | r.room_code, |
| | 59 | e.name AS requested_equipment, |
| | 60 | req.requested_quantity |
| | 61 | FROM project.reservations res |
| | 62 | JOIN project.users u |
| | 63 | ON u.user_id = res.user_id |
| | 64 | LEFT JOIN project.rooms r |
| | 65 | ON r.room_id = res.room_id |
| | 66 | LEFT JOIN project.reservation_equipment req |
| | 67 | ON req.reservation_id = res.reservation_id |
| | 68 | LEFT JOIN project.equipment e |
| | 69 | ON e.equipment_id = req.equipment_id |
| | 70 | WHERE res.status = 'pending' |
| | 71 | ORDER BY res.reservation_date, res.start_time, res.reservation_id; |
| | 72 | }}} |
| | 73 | |
| | 74 | The system then lists the possible approvers. |
| | 75 | |
| | 76 | {{{ |
| | 77 | SELECT |
| | 78 | user_id, |
| | 79 | full_name, |
| | 80 | username, |
| | 81 | role |
| | 82 | FROM project.users |
| | 83 | WHERE role IN ('approver', 'admin') |
| | 84 | ORDER BY user_id; |
| | 85 | }}} |
| | 86 | |
| | 87 | After the approver selects the reservation and the decision, the system updates the reservation status. |
| | 88 | |
| | 89 | {{{ |
| | 90 | UPDATE project.reservations |
| | 91 | SET status = ? |
| | 92 | WHERE reservation_id = ? |
| | 93 | AND status = 'pending'; |
| | 94 | }}} |
| | 95 | |
| | 96 | The system then inserts the approval decision. |
| | 97 | |
| | 98 | {{{ |
| | 99 | INSERT INTO project.approvals ( |
| | 100 | reservation_id, |
| | 101 | approver_id, |
| | 102 | decision, |
| | 103 | decision_time, |
| | 104 | note |
| | 105 | ) |
| | 106 | VALUES (?, ?, ?, CURRENT_TIMESTAMP, ?); |
| | 107 | }}} |
| | 108 | |
| | 109 | Finally, the system displays the final reservation details. |
| | 110 | |
| | 111 | {{{ |
| | 112 | SELECT |
| | 113 | res.reservation_id, |
| | 114 | res.reservation_date, |
| | 115 | res.start_time, |
| | 116 | res.end_time, |
| | 117 | res.status, |
| | 118 | u.full_name AS requester_name, |
| | 119 | r.room_code, |
| | 120 | a.decision, |
| | 121 | a.decision_time, |
| | 122 | a.note, |
| | 123 | approver.full_name AS approver_name |
| | 124 | FROM project.reservations res |
| | 125 | JOIN project.users u |
| | 126 | ON u.user_id = res.user_id |
| | 127 | LEFT JOIN project.rooms r |
| | 128 | ON r.room_id = res.room_id |
| | 129 | LEFT JOIN project.approvals a |
| | 130 | ON a.reservation_id = res.reservation_id |
| | 131 | LEFT JOIN project.users approver |
| | 132 | ON approver.user_id = a.approver_id |
| | 133 | WHERE res.reservation_id = ?; |
| | 134 | }}} |
| | 135 | |
| | 136 | == Database usage explanation == |
| | 137 | |
| | 138 | This use-case reads data from the following tables: |
| | 139 | |
| | 140 | ''project.reservations'' – to list pending reservations and display the final reservation status. |
| | 141 | ''project.users'' – to display the requester and the approver. |
| | 142 | ''project.rooms'' – to display room information. |
| | 143 | ''project.reservation_equipment'' – to display requested equipment if it exists. |
| | 144 | ''project.equipment'' – to display equipment names. |
| | 145 | ''project.approvals'' – to display and store the approval decision. |
| | 146 | |
| | 147 | This use-case modifies the database by: |
| | 148 | |
| | 149 | updating the status of the selected reservation in ''project.reservations''; |
| | 150 | inserting a new approval decision in ''project.approvals''. |
| | 151 | |
| | 152 | == Result of the implementation == |
| | 153 | |
| | 154 | The prototype successfully approved reservation ID 9. The reservation status was changed to ''approved'', and a corresponding approval record was inserted into the ''project.approvals'' table. The approval record contains the approver, decision, decision time, and decision note. |