| | 1 | = UC0001: Browse Available Resources = |
| | 2 | |
| | 3 | '''Initiating actor:''' Student |
| | 4 | |
| | 5 | '''Other actors:''' None |
| | 6 | |
| | 7 | A student wants to find resources available for use within the faculty. The student can browse all resources, filter them by resource type or building location, view details of a specific resource including its current reservations, and check whether the resource is free at a desired date and time. |
| | 8 | |
| | 9 | == Scenario == |
| | 10 | |
| | 11 | 1. The student opens the resource browser page. The system retrieves all resources grouped by type and displays them. |
| | 12 | {{{ |
| | 13 | SELECT r.resource_id, r.name, r.description, |
| | 14 | r.available_from, r.available_to, r.available_weekends, |
| | 15 | rt.type_name, rt.is_physical, |
| | 16 | l.building, l.room |
| | 17 | FROM project.resources r |
| | 18 | JOIN project.resource_types rt ON r.type_id = rt.type_id |
| | 19 | LEFT JOIN project.locations l ON r.location_id = l.location_id |
| | 20 | ORDER BY rt.type_name, r.name; |
| | 21 | }}} |
| | 22 | |
| | 23 | 2. The student selects the filter for resource type ''Computer Laboratory''. The system queries and returns only computer labs. |
| | 24 | {{{ |
| | 25 | SELECT r.resource_id, r.name, r.description, |
| | 26 | r.available_from, r.available_to, r.available_weekends, |
| | 27 | l.building, l.room |
| | 28 | FROM project.resources r |
| | 29 | JOIN project.resource_types rt ON r.type_id = rt.type_id |
| | 30 | LEFT JOIN project.locations l ON r.location_id = l.location_id |
| | 31 | WHERE rt.type_name = 'Computer Laboratory' |
| | 32 | ORDER BY r.name; |
| | 33 | }}} |
| | 34 | |
| | 35 | 3. The student further filters to show only resources in building ''FINKI-B''. The system narrows the results. |
| | 36 | {{{ |
| | 37 | SELECT r.resource_id, r.name, r.description, |
| | 38 | r.available_from, r.available_to, r.available_weekends, |
| | 39 | l.building, l.room |
| | 40 | FROM project.resources r |
| | 41 | JOIN project.resource_types rt ON r.type_id = rt.type_id |
| | 42 | JOIN project.locations l ON r.location_id = l.location_id |
| | 43 | WHERE rt.type_name = 'Computer Laboratory' |
| | 44 | AND l.building = 'FINKI-B' |
| | 45 | ORDER BY r.name; |
| | 46 | }}} |
| | 47 | |
| | 48 | 4. The student selects ''Programming Lab 1'' (resource_id = 5) to view its details. The system shows the resource information and its upcoming reservations. |
| | 49 | {{{ |
| | 50 | SELECT r.resource_id, r.name, r.description, |
| | 51 | r.available_from, r.available_to, r.available_weekends, |
| | 52 | rt.type_name, l.building, l.room |
| | 53 | FROM project.resources r |
| | 54 | JOIN project.resource_types rt ON r.type_id = rt.type_id |
| | 55 | LEFT JOIN project.locations l ON r.location_id = l.location_id |
| | 56 | WHERE r.resource_id = 5; |
| | 57 | }}} |
| | 58 | |
| | 59 | {{{ |
| | 60 | SELECT res.reservation_id, res.start_time, res.end_time, |
| | 61 | res.status, res.purpose |
| | 62 | FROM project.reservations res |
| | 63 | WHERE res.resource_id = 5 |
| | 64 | AND res.status IN ('approved', 'pending') |
| | 65 | AND res.end_time > CURRENT_TIMESTAMP |
| | 66 | ORDER BY res.start_time; |
| | 67 | }}} |
| | 68 | |
| | 69 | 5. The student wants to check if the lab is available on 2026-02-20 from 14:00 to 16:00. The system first verifies the time falls within the resource's daily availability window and that the day is not a weekend (or the resource allows weekends). Then it checks for conflicting reservations. |
| | 70 | {{{ |
| | 71 | SELECT r.resource_id, r.name |
| | 72 | FROM project.resources r |
| | 73 | WHERE r.resource_id = 5 |
| | 74 | AND r.available_from <= '14:00'::TIME |
| | 75 | AND r.available_to >= '16:00'::TIME |
| | 76 | AND (r.available_weekends = TRUE |
| | 77 | OR EXTRACT(ISODOW FROM DATE '2026-02-20') <= 5); |
| | 78 | }}} |
| | 79 | |
| | 80 | {{{ |
| | 81 | SELECT COUNT(*) AS conflict_count |
| | 82 | FROM project.reservations res |
| | 83 | WHERE res.resource_id = 5 |
| | 84 | AND res.status IN ('approved', 'pending') |
| | 85 | AND res.start_time < '2026-02-20 16:00:00' |
| | 86 | AND res.end_time > '2026-02-20 14:00:00'; |
| | 87 | }}} |
| | 88 | |
| | 89 | 6. The system reports that the resource is available (conflict_count = 0 and the availability window check returned a row). The student can now proceed to make a reservation if permitted. |