| | 1 | = Use-case 0003 Implementation - Add a Pet |
| | 2 | |
| | 3 | '''Initiating actor:''' Pet Owner |
| | 4 | |
| | 5 | '''Other actors:''' None |
| | 6 | |
| | 7 | '''Description:''' |
| | 8 | A pet owner wants to add a new animal to their profile so they can request services for it. The system provides available pet categories for them to choose from, and then saves the new pet profile into the database. |
| | 9 | |
| | 10 | '''Scenario:''' |
| | 11 | 1. Pet Owner opens the "My Pets" page and clicks "Add new pet". |
| | 12 | |
| | 13 | |
| | 14 | [[Image(1.png)]] |
| | 15 | |
| | 16 | {{{ |
| | 17 | #!sql |
| | 18 | Hibernate: |
| | 19 | select |
| | 20 | p1_0.pet_id, |
| | 21 | p1_0.age, |
| | 22 | p1_0.description, |
| | 23 | p1_0.name, |
| | 24 | p1_0.owner_id, |
| | 25 | p1_0.pettype_id, |
| | 26 | p1_0.photo, |
| | 27 | p1_0.special_needs |
| | 28 | from |
| | 29 | project.pets p1_0 |
| | 30 | left join |
| | 31 | project.pet_owners o1_0 |
| | 32 | on o1_0.user_id=p1_0.owner_id |
| | 33 | where |
| | 34 | o1_0.user_id=? |
| | 35 | Hibernate: |
| | 36 | select |
| | 37 | po1_0.user_id, |
| | 38 | po1_1.email, |
| | 39 | po1_1.first_name, |
| | 40 | po1_1.last_name, |
| | 41 | po1_1.password, |
| | 42 | po1_1.username |
| | 43 | from |
| | 44 | project.pet_owners po1_0 |
| | 45 | join |
| | 46 | project.users po1_1 |
| | 47 | on po1_0.user_id=po1_1.user_id |
| | 48 | where |
| | 49 | po1_0.user_id=? |
| | 50 | Hibernate: |
| | 51 | select |
| | 52 | pt1_0.pettype_id, |
| | 53 | pt1_0.needs_outdoor_walk, |
| | 54 | pt1_0.species |
| | 55 | from |
| | 56 | project.pet_types pt1_0 |
| | 57 | where |
| | 58 | pt1_0.pettype_id=? |
| | 59 | Hibernate: |
| | 60 | select |
| | 61 | pt1_0.pettype_id, |
| | 62 | pt1_0.needs_outdoor_walk, |
| | 63 | pt1_0.species |
| | 64 | from |
| | 65 | project.pet_types pt1_0 |
| | 66 | where |
| | 67 | pt1_0.pettype_id=? |
| | 68 | |
| | 69 | }}} |
| | 70 | |
| | 71 | 2. System fetches all available pet species so the user can select one from a dropdown menu: |
| | 72 | 3. Owner selects "Dog", fills in the pet's name, age, and needs, and submits the form. |
| | 73 | |
| | 74 | [[Image(2.png)]] |
| | 75 | |
| | 76 | 4. System creates the pet record in the database, linking it to the owner |
| | 77 | |
| | 78 | {{{ |
| | 79 | #!sql |
| | 80 | Hibernate: |
| | 81 | select |
| | 82 | po1_0.user_id, |
| | 83 | po1_1.email, |
| | 84 | po1_1.first_name, |
| | 85 | po1_1.last_name, |
| | 86 | po1_1.password, |
| | 87 | po1_1.username |
| | 88 | from |
| | 89 | project.pet_owners po1_0 |
| | 90 | join |
| | 91 | project.users po1_1 |
| | 92 | on po1_0.user_id=po1_1.user_id |
| | 93 | where |
| | 94 | po1_0.user_id=? |
| | 95 | Hibernate: |
| | 96 | select |
| | 97 | pt1_0.pettype_id, |
| | 98 | pt1_0.needs_outdoor_walk, |
| | 99 | pt1_0.species |
| | 100 | from |
| | 101 | project.pet_types pt1_0 |
| | 102 | where |
| | 103 | pt1_0.pettype_id=? |
| | 104 | Hibernate: |
| | 105 | insert |
| | 106 | into |
| | 107 | project.pets |
| | 108 | (age, description, name, owner_id, pettype_id, photo, special_needs, pet_id) |
| | 109 | values |
| | 110 | (?, ?, ?, ?, ?, ?, ?, ?) |
| | 111 | Hibernate: |
| | 112 | select |
| | 113 | p1_0.pet_id, |
| | 114 | p1_0.age, |
| | 115 | p1_0.description, |
| | 116 | p1_0.name, |
| | 117 | p1_0.owner_id, |
| | 118 | p1_0.pettype_id, |
| | 119 | p1_0.photo, |
| | 120 | p1_0.special_needs |
| | 121 | from |
| | 122 | project.pets p1_0 |
| | 123 | left join |
| | 124 | project.pet_owners o1_0 |
| | 125 | on o1_0.user_id=p1_0.owner_id |
| | 126 | where |
| | 127 | o1_0.user_id=? |
| | 128 | Hibernate: |
| | 129 | select |
| | 130 | po1_0.user_id, |
| | 131 | po1_1.email, |
| | 132 | po1_1.first_name, |
| | 133 | po1_1.last_name, |
| | 134 | po1_1.password, |
| | 135 | po1_1.username |
| | 136 | from |
| | 137 | project.pet_owners po1_0 |
| | 138 | join |
| | 139 | project.users po1_1 |
| | 140 | on po1_0.user_id=po1_1.user_id |
| | 141 | where |
| | 142 | po1_0.user_id=? |
| | 143 | Hibernate: |
| | 144 | select |
| | 145 | pt1_0.pettype_id, |
| | 146 | pt1_0.needs_outdoor_walk, |
| | 147 | pt1_0.species |
| | 148 | from |
| | 149 | project.pet_types pt1_0 |
| | 150 | where |
| | 151 | pt1_0.pettype_id=? |
| | 152 | Hibernate: |
| | 153 | select |
| | 154 | pt1_0.pettype_id, |
| | 155 | pt1_0.needs_outdoor_walk, |
| | 156 | pt1_0.species |
| | 157 | from |
| | 158 | project.pet_types pt1_0 |
| | 159 | where |
| | 160 | pt1_0.pettype_id=? |
| | 161 | Hibernate: |
| | 162 | select |
| | 163 | pt1_0.pettype_id, |
| | 164 | pt1_0.needs_outdoor_walk, |
| | 165 | pt1_0.species |
| | 166 | from |
| | 167 | project.pet_types pt1_0 |
| | 168 | where |
| | 169 | pt1_0.pettype_id=? |
| | 170 | |
| | 171 | }}} |