Changes between Initial Version and Version 1 of UseCase0002


Ignore:
Timestamp:
03/16/26 20:41:35 (5 days ago)
Author:
221511
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase0002

    v1 v1  
     1= UC0002: Make a Resource Reservation =
     2
     3'''Initiating actor:''' Teaching Staff
     4
     5'''Other actors:''' Faculty Administrator (receives the pending reservation for approval)
     6
     7A teaching staff member wants to reserve a resource (e.g., a classroom or lab) for a specific date and time to conduct a lecture. The system verifies the resource is available during the requested time, checks for scheduling conflicts with existing reservations, and if the slot is free, creates a new reservation with status ''pending'' that an administrator will later approve or reject.
     8
     9== Scenario ==
     10
     11 1. The teaching staff member (Elena Stojanova, user_id = 3) navigates to the reservation form and selects the resource ''Classroom 101'' (resource_id = 1). The system displays the resource details and existing reservations for the target week.
     12{{{
     13SELECT r.resource_id, r.name, r.description,
     14       r.available_from, r.available_to, r.available_weekends,
     15       rt.type_name, l.building, l.room
     16FROM project.resources r
     17JOIN project.resource_types rt ON r.type_id = rt.type_id
     18LEFT JOIN project.locations l ON r.location_id = l.location_id
     19WHERE r.resource_id = 1;
     20}}}
     21 The system also retrieves existing reservations for the target week:
     22{{{
     23SELECT res.reservation_id, res.start_time, res.end_time,
     24       res.status, res.purpose,
     25       u.first_name || ' ' || u.last_name AS reserved_by
     26FROM project.reservations res
     27JOIN project.users u ON res.user_id = u.user_id
     28WHERE res.resource_id = 1
     29  AND res.status IN ('approved', 'pending')
     30  AND res.start_time >= '2026-02-09'
     31  AND res.start_time < '2026-02-16'
     32ORDER BY res.start_time;
     33}}}
     34
     35 2. The teaching staff member enters the desired reservation: date 2026-02-13, time 10:00 to 12:00, purpose ''Operating Systems Lecture''.
     36
     37 3. The system validates that the requested time falls within the resource's daily availability window and that the day is a valid weekday.
     38{{{
     39SELECT r.resource_id
     40FROM project.resources r
     41WHERE r.resource_id = 1
     42  AND r.available_from <= '10:00'::TIME
     43  AND r.available_to >= '12:00'::TIME
     44  AND (r.available_weekends = TRUE
     45       OR EXTRACT(ISODOW FROM DATE '2026-02-13') <= 5);
     46}}}
     47
     48 4. The system checks for conflicting reservations on the same resource at the requested time. No conflicts are found.
     49{{{
     50SELECT res.reservation_id, res.start_time, res.end_time,
     51       res.purpose,
     52       u.first_name || ' ' || u.last_name AS reserved_by
     53FROM project.reservations res
     54JOIN project.users u ON res.user_id = u.user_id
     55WHERE res.resource_id = 1
     56  AND res.status IN ('approved', 'pending')
     57  AND res.start_time < '2026-02-13 12:00:00'
     58  AND res.end_time > '2026-02-13 10:00:00';
     59}}}
     60
     61 5. Since no conflicts exist, the system creates the reservation with status ''pending''.
     62{{{
     63INSERT INTO project.reservations
     64    (start_time, end_time, status, purpose, created_at, user_id, resource_id)
     65VALUES
     66    ('2026-02-13 10:00:00', '2026-02-13 12:00:00', 'pending',
     67     'Operating Systems Lecture', CURRENT_TIMESTAMP, 3, 1)
     68RETURNING reservation_id, status, created_at;
     69}}}
     70
     71 6. The system displays a confirmation screen with the reservation details.
     72{{{
     73SELECT res.reservation_id, res.start_time, res.end_time,
     74       res.status, res.purpose, res.created_at,
     75       r.name AS resource_name,
     76       l.building, l.room
     77FROM project.reservations res
     78JOIN project.resources r ON res.resource_id = r.resource_id
     79LEFT JOIN project.locations l ON r.location_id = l.location_id
     80WHERE res.reservation_id = currval('project.reservations_reservation_id_seq');
     81}}}
     82
     83== Alternative Scenario: Conflict Detected ==
     84
     85 4a. If the teaching staff member had instead requested 2026-02-06 from 09:00 to 11:00, the conflict check would find an overlapping reservation.
     86{{{
     87SELECT res.reservation_id, res.start_time, res.end_time,
     88       res.purpose,
     89       u.first_name || ' ' || u.last_name AS reserved_by
     90FROM project.reservations res
     91JOIN project.users u ON res.user_id = u.user_id
     92WHERE res.resource_id = 1
     93  AND res.status IN ('approved', 'pending')
     94  AND res.start_time < '2026-02-06 11:00:00'
     95  AND res.end_time > '2026-02-06 09:00:00';
     96}}}
     97
     98 4b. The system displays the conflicting reservation (''Morning lecture - Operating Systems'', 08:00-10:00, by Elena Stojanova) and informs the user that the time slot is not available. The user is asked to choose a different time.