diff --git a/backend/src/main/java/com/petshop/backend/DevStackApplication.java b/backend/src/main/java/com/petshop/backend/DevStackApplication.java index 38846aaa..27933d4b 100644 --- a/backend/src/main/java/com/petshop/backend/DevStackApplication.java +++ b/backend/src/main/java/com/petshop/backend/DevStackApplication.java @@ -33,6 +33,7 @@ public class DevStackApplication { docker.ensureDockerAvailable(); docker.startDatabase(); context = new SpringApplicationBuilder(BackendApplication.class) + .profiles("local") .initializers(new FlywayContextInitializer()) .run(args); context.addApplicationListener(event -> { diff --git a/backend/src/main/java/com/petshop/backend/config/LocalCatalogSeedInitializer.java b/backend/src/main/java/com/petshop/backend/config/LocalCatalogSeedInitializer.java new file mode 100644 index 00000000..18e64f05 --- /dev/null +++ b/backend/src/main/java/com/petshop/backend/config/LocalCatalogSeedInitializer.java @@ -0,0 +1,37 @@ +package com.petshop.backend.config; + +import com.petshop.backend.repository.PetRepository; +import com.petshop.backend.repository.ProductRepository; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Profile; +import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; +import org.springframework.stereotype.Component; + +import javax.sql.DataSource; + +@Component +@Profile("local") +public class LocalCatalogSeedInitializer implements CommandLineRunner { + + private final DataSource dataSource; + private final PetRepository petRepository; + private final ProductRepository productRepository; + + public LocalCatalogSeedInitializer(DataSource dataSource, PetRepository petRepository, ProductRepository productRepository) { + this.dataSource = dataSource; + this.petRepository = petRepository; + this.productRepository = productRepository; + } + + @Override + public void run(String... args) { + if (petRepository.count() > 6 || productRepository.count() > 6) { + return; + } + + ResourceDatabasePopulator populator = new ResourceDatabasePopulator(false, false, "UTF-8", + new ClassPathResource("dev/expand_pet_product_seed.sql")); + populator.execute(dataSource); + } +} diff --git a/backend/src/main/java/com/petshop/backend/controller/DropdownController.java b/backend/src/main/java/com/petshop/backend/controller/DropdownController.java index 16763b8a..c942eae8 100644 --- a/backend/src/main/java/com/petshop/backend/controller/DropdownController.java +++ b/backend/src/main/java/com/petshop/backend/controller/DropdownController.java @@ -82,6 +82,29 @@ public class DropdownController { ); } + @GetMapping("/product-categories") + public ResponseEntity> getProductCategories() { + return ResponseEntity.ok( + categoryRepository.findAll().stream() + .filter(c -> "product".equalsIgnoreCase(c.getCategoryType())) + .map(c -> new DropdownOption(c.getCategoryId(), c.getCategoryName())) + .collect(Collectors.toList()) + ); + } + + @GetMapping("/pet-species") + public ResponseEntity> getPetSpecies() { + return ResponseEntity.ok( + petRepository.findAll().stream() + .map(p -> p.getPetSpecies()) + .filter(species -> species != null && !species.isBlank()) + .distinct() + .sorted(String.CASE_INSENSITIVE_ORDER) + .map(species -> new DropdownOption(null, species)) + .collect(Collectors.toList()) + ); + } + @GetMapping("/stores") public ResponseEntity> getStores() { return ResponseEntity.ok( diff --git a/backend/src/main/resources/db/migration/V11__expand_pet_product_seed.sql b/backend/src/main/resources/db/migration/V11__expand_pet_product_seed.sql deleted file mode 100644 index f2ca3259..00000000 --- a/backend/src/main/resources/db/migration/V11__expand_pet_product_seed.sql +++ /dev/null @@ -1,389 +0,0 @@ --- Expand pet and product seed data - -INSERT INTO pet (petName, petSpecies, petBreed, petAge, petStatus, petPrice) -VALUES -('Rocky', 'Dog', 'German Shepherd', 1, 'Available', 475.00), -('Daisy', 'Dog', 'Poodle', 2, 'Available', 512.00), -('Cooper', 'Dog', 'Bulldog', 3, 'Available', 560.00), -('Ruby', 'Dog', 'Boxer', 4, 'Available', 575.00), -('Tucker', 'Dog', 'Dachshund', 5, 'Available', 634.00), -('Rosie', 'Dog', 'Shih Tzu', 1, 'Available', 660.00), -('Bear', 'Dog', 'Rottweiler', 2, 'Available', 686.00), -('Maggie', 'Dog', 'Corgi', 3, 'Available', 745.00), -('Leo', 'Dog', 'Husky', 4, 'Available', 749.00), -('Penny', 'Dog', 'Border Collie', 5, 'Available', 808.00), -('Jax', 'Dog', 'German Shepherd', 1, 'Available', 823.00), -('Nala', 'Dog', 'Poodle', 2, 'Available', 871.00), -('Finn', 'Dog', 'Bulldog', 3, 'Available', 447.00), -('Sadie', 'Dog', 'Boxer', 4, 'Available', 495.00), -('Ace', 'Dog', 'Dachshund', 5, 'Available', 510.00), -('Zoe', 'Dog', 'Shih Tzu', 1, 'Available', 547.00), -('Ollie', 'Dog', 'Rottweiler', 2, 'Available', 606.00), -('Millie', 'Dog', 'Corgi', 3, 'Available', 654.00), -('Murphy', 'Dog', 'Husky', 4, 'Available', 691.00), -('Willow', 'Dog', 'Border Collie', 5, 'Available', 728.00), -('Bentley', 'Dog', 'German Shepherd', 1, 'Available', 776.00), -('Lily', 'Dog', 'Poodle', 2, 'Available', 780.00), -('Scout', 'Dog', 'Bulldog', 3, 'Available', 828.00), -('Gracie', 'Dog', 'Boxer', 4, 'Available', 876.00), -('Ranger', 'Dog', 'Dachshund', 5, 'Available', 452.00), -('Hazel', 'Dog', 'Shih Tzu', 1, 'Available', 478.00), -('Moose', 'Dog', 'Rottweiler', 2, 'Available', 515.00), -('Mia', 'Dog', 'Corgi', 3, 'Available', 530.00), -('Simba', 'Cat', 'Ragdoll', 1, 'Available', 295.00), -('Cleo', 'Cat', 'Bengal', 2, 'Available', 321.00), -('Oreo', 'Cat', 'British Shorthair', 3, 'Available', 358.00), -('Pepper', 'Cat', 'Sphynx', 4, 'Available', 417.00), -('Jasper', 'Cat', 'Scottish Fold', 5, 'Available', 454.00), -('Phoebe', 'Cat', 'Russian Blue', 1, 'Available', 491.00), -('Shadow', 'Cat', 'Abyssinian', 2, 'Available', 528.00), -('Mochi', 'Cat', 'Birman', 3, 'Available', 554.00), -('Louie', 'Cat', 'Ragdoll', 4, 'Available', 591.00), -('Ivy', 'Cat', 'Bengal', 5, 'Available', 606.00), -('Theo', 'Cat', 'British Shorthair', 1, 'Available', 654.00), -('Piper', 'Cat', 'Sphynx', 2, 'Available', 251.00), -('Nova', 'Cat', 'Scottish Fold', 3, 'Available', 277.00), -('Archie', 'Cat', 'Russian Blue', 4, 'Available', 336.00), -('Olive', 'Cat', 'Abyssinian', 5, 'Available', 362.00), -('Boots', 'Cat', 'Birman', 1, 'Available', 399.00), -('Maple', 'Cat', 'Ragdoll', 2, 'Available', 436.00), -('Gizmo', 'Cat', 'Bengal', 3, 'Available', 473.00), -('Nina', 'Cat', 'British Shorthair', 4, 'Available', 499.00), -('Salem', 'Cat', 'Sphynx', 5, 'Available', 547.00), -('Stella', 'Cat', 'Scottish Fold', 1, 'Available', 595.00), -('Kiki', 'Cat', 'Russian Blue', 2, 'Available', 610.00), -('Sunny', 'Cat', 'Abyssinian', 3, 'Available', 658.00), -('Mabel', 'Cat', 'Birman', 4, 'Available', 244.00), -('Coco', 'Bird', 'Cockatiel', 1, 'Available', 119.00), -('Sky', 'Bird', 'Parakeet', 2, 'Available', 145.00), -('Sunny', 'Bird', 'Canary', 3, 'Available', 204.00), -('Kiwi', 'Bird', 'Lovebird', 1, 'Available', 230.00), -('Pico', 'Bird', 'Finch', 2, 'Available', 81.00), -('Blue', 'Bird', 'Conure', 3, 'Available', 118.00), -('Rio', 'Bird', 'Cockatiel', 1, 'Available', 144.00), -('Angel', 'Bird', 'Parakeet', 2, 'Available', 203.00), -('Chirpy', 'Bird', 'Canary', 3, 'Available', 251.00), -('Peach', 'Bird', 'Lovebird', 1, 'Available', 91.00), -('Mango', 'Bird', 'Finch', 2, 'Available', 128.00), -('Pearl', 'Bird', 'Conure', 3, 'Available', 165.00), -('Bubbles', 'Fish', 'Goldfish', 1, 'Available', 30.00), -('Splash', 'Fish', 'Betta', 2, 'Available', 56.00), -('Coral', 'Fish', 'Guppy', 1, 'Available', 23.00), -('Neptune', 'Fish', 'Molly', 2, 'Available', 23.00), -('Marlin', 'Fish', 'Tetra', 1, 'Available', 49.00), -('Finley', 'Fish', 'Angelfish', 2, 'Available', 27.00), -('Pebble', 'Fish', 'Goldfish', 1, 'Available', 64.00), -('Wave', 'Fish', 'Betta', 2, 'Available', 20.00), -('Aqua', 'Fish', 'Guppy', 1, 'Available', 57.00), -('Flash', 'Fish', 'Molly', 2, 'Available', 46.00), -('Nemo', 'Fish', 'Tetra', 1, 'Available', 13.00), -('Pearl', 'Fish', 'Angelfish', 2, 'Available', 61.00), -('Thumper', 'Rabbit', 'Mini Lop', 1, 'Available', 147.00), -('Clover', 'Rabbit', 'Netherland Dwarf', 2, 'Available', 173.00), -('Biscuit', 'Rabbit', 'Lionhead', 3, 'Adopted', 110.00), -('Hazel', 'Rabbit', 'Rex', 1, 'Adopted', 125.00), -('Juniper', 'Rabbit', 'Mini Lop', 2, 'Adopted', 73.00), -('Poppy', 'Rabbit', 'Netherland Dwarf', 3, 'Adopted', 88.00), -('Snowball', 'Rabbit', 'Lionhead', 1, 'Adopted', 158.00), -('Maple', 'Rabbit', 'Rex', 2, 'Adopted', 162.00), -('Peanut', 'Hamster', 'Syrian', 1, 'Adopted', 36.00), -('Nibbles', 'Hamster', 'Dwarf', 2, 'Adopted', 36.00), -('Pumpkin', 'Hamster', 'Roborovski', 1, 'Adopted', 25.00), -('Mocha', 'Hamster', 'Syrian', 2, 'Adopted', 40.00), -('Buttons', 'Hamster', 'Dwarf', 1, 'Pending', 51.00), -('Teddy', 'Hamster', 'Roborovski', 2, 'Pending', 18.00), -('Pip', 'Hamster', 'Syrian', 1, 'Pending', 33.00), -('Toffee', 'Hamster', 'Dwarf', 2, 'Pending', 55.00), -('Sprout', 'Hamster', 'Roborovski', 1, 'Pending', 44.00), -('Bean', 'Hamster', 'Syrian', 2, 'Pending', 59.00); - -INSERT INTO product (prodName, prodPrice, categoryId, prodDesc) -VALUES -('Chicken Recipe Dog Food', 42.00, 1, 'Nutritious food and treats for dogs'), -('Beef Feast Dog Food', 51.00, 1, 'Nutritious food and treats for dogs'), -('Salmon Blend Dog Food', 66.00, 1, 'Nutritious food and treats for dogs'), -('Lamb Dinner Dog Food', 78.00, 1, 'Nutritious food and treats for dogs'), -('Puppy Starter Kibble', 24.00, 1, 'Nutritious food and treats for dogs'), -('Senior Care Dog Food', 37.00, 1, 'Nutritious food and treats for dogs'), -('Small Breed Kibble', 48.00, 1, 'Nutritious food and treats for dogs'), -('Large Breed Kibble', 61.00, 1, 'Nutritious food and treats for dogs'), -('Grain Free Dog Food', 75.00, 1, 'Nutritious food and treats for dogs'), -('Turkey Rice Formula', 21.00, 1, 'Nutritious food and treats for dogs'), -('Duck Sweet Potato Meal', 37.00, 1, 'Nutritious food and treats for dogs'), -('Venison Protein Blend', 49.00, 1, 'Nutritious food and treats for dogs'), -('Healthy Weight Dog Food', 64.00, 1, 'Nutritious food and treats for dogs'), -('Sensitive Stomach Kibble', 78.00, 1, 'Nutritious food and treats for dogs'), -('High Energy Dog Food', 20.00, 1, 'Nutritious food and treats for dogs'), -('Organic Dog Biscuits', 33.00, 1, 'Nutritious food and treats for dogs'), -('Peanut Butter Dog Treats', 50.00, 1, 'Nutritious food and treats for dogs'), -('Dental Chew Sticks', 57.00, 1, 'Nutritious food and treats for dogs'), -('Training Treat Bites', 72.00, 1, 'Nutritious food and treats for dogs'), -('Soft Chicken Treats', 17.00, 1, 'Nutritious food and treats for dogs'), -('Pumpkin Fiber Treats', 31.00, 1, 'Nutritious food and treats for dogs'), -('Joint Support Biscuits', 46.00, 1, 'Nutritious food and treats for dogs'), -('Mini Breed Dinner', 54.00, 1, 'Nutritious food and treats for dogs'), -('Farmhouse Dog Meal', 68.00, 1, 'Nutritious food and treats for dogs'), -('Feather Teaser Wand', 8.00, 2, 'Play items for active cats'), -('Catnip Mouse Toy', 18.00, 2, 'Play items for active cats'), -('Jingle Ball Set', 30.00, 2, 'Play items for active cats'), -('Scratching Post Small', 20.00, 2, 'Play items for active cats'), -('Crinkle Tunnel', 26.00, 2, 'Play items for active cats'), -('Laser Pointer Toy', 13.00, 2, 'Play items for active cats'), -('Plush Fish Toy', 23.00, 2, 'Play items for active cats'), -('Spring Coil Pack', 9.00, 2, 'Play items for active cats'), -('Hanging Door Toy', 22.00, 2, 'Play items for active cats'), -('Interactive Puzzle Toy', 12.00, 2, 'Play items for active cats'), -('Catnip Kicker Toy', 20.00, 2, 'Play items for active cats'), -('Rolling Bell Ball', 4.00, 2, 'Play items for active cats'), -('Ribbon Chase Toy', 16.00, 2, 'Play items for active cats'), -('Mini Plush Mouse', 29.00, 2, 'Play items for active cats'), -('Treat Dispensing Ball', 18.00, 2, 'Play items for active cats'), -('Double Pom Toy', 24.00, 2, 'Play items for active cats'), -('Window Perch Toy', 10.00, 2, 'Play items for active cats'), -('Scratch Pad Refill', 25.00, 2, 'Play items for active cats'), -('Rainbow Wand Toy', 7.00, 2, 'Play items for active cats'), -('Carpet Scratcher', 20.00, 2, 'Play items for active cats'), -('Bird Perch Set', 41.00, 3, 'Care supplies for pet birds'), -('Parakeet Seed Mix', 57.00, 3, 'Care supplies for pet birds'), -('Canary Food Blend', 70.00, 3, 'Care supplies for pet birds'), -('Mineral Cuttlebone', 84.00, 3, 'Care supplies for pet birds'), -('Bird Ladder Toy', 94.00, 3, 'Care supplies for pet birds'), -('Mirror Bell Combo', 109.00, 3, 'Care supplies for pet birds'), -('Clip On Food Cup', 121.00, 3, 'Care supplies for pet birds'), -('Bird Cage Liner Pack', 18.00, 3, 'Care supplies for pet birds'), -('Nesting Material Pack', 32.00, 3, 'Care supplies for pet birds'), -('Treat Spray Millet', 42.00, 3, 'Care supplies for pet birds'), -('Wooden Swing Perch', 55.00, 3, 'Care supplies for pet birds'), -('Foraging Ball Toy', 67.00, 3, 'Care supplies for pet birds'), -('Cage Cleaning Spray', 82.00, 3, 'Care supplies for pet birds'), -('Parrot Rope Perch', 93.00, 3, 'Care supplies for pet birds'), -('Bird Bath Dish', 103.00, 3, 'Care supplies for pet birds'), -('Songbird Vitamin Drops', 124.00, 3, 'Care supplies for pet birds'), -('Aquarium Filter Cartridge', 58.00, 4, 'Essential aquarium equipment and accessories'), -('Decorative Aquarium Gravel', 72.00, 4, 'Essential aquarium equipment and accessories'), -('Fish Net Medium', 74.00, 4, 'Essential aquarium equipment and accessories'), -('Water Conditioner', 89.00, 4, 'Essential aquarium equipment and accessories'), -('Aquarium Thermometer', 105.00, 4, 'Essential aquarium equipment and accessories'), -('LED Tank Light', 112.00, 4, 'Essential aquarium equipment and accessories'), -('Air Stone Pack', 125.00, 4, 'Essential aquarium equipment and accessories'), -('Aquarium Heater 50W', 143.00, 4, 'Essential aquarium equipment and accessories'), -('Aquarium Heater 100W', 157.00, 4, 'Essential aquarium equipment and accessories'), -('Fish Flake Food', 165.00, 4, 'Essential aquarium equipment and accessories'), -('Algae Scraper', 176.00, 4, 'Essential aquarium equipment and accessories'), -('Aquarium Plant Set', 194.00, 4, 'Essential aquarium equipment and accessories'), -('Bubble Curtain Kit', 207.00, 4, 'Essential aquarium equipment and accessories'), -('Breeder Box Insert', 14.00, 4, 'Essential aquarium equipment and accessories'), -('Filter Sponge Pack', 27.00, 4, 'Essential aquarium equipment and accessories'), -('Aquarium Background Roll', 46.00, 4, 'Essential aquarium equipment and accessories'), -('Glass Lid Clips', 50.00, 4, 'Essential aquarium equipment and accessories'), -('Submersible Pump', 64.00, 4, 'Essential aquarium equipment and accessories'), -('Hamster Bedding Pack', 60.00, 5, 'Supplies for small pets'), -('Rabbit Hay Bundle', 6.00, 5, 'Supplies for small pets'), -('Guinea Pig Pellets', 20.00, 5, 'Supplies for small pets'), -('Small Pet Water Bottle', 37.00, 5, 'Supplies for small pets'), -('Hamster Hideout Hut', 47.00, 5, 'Supplies for small pets'), -('Chew Stick Bundle', 58.00, 5, 'Supplies for small pets'), -('Rabbit Litter Tray', 8.00, 5, 'Supplies for small pets'), -('Exercise Ball Large', 22.00, 5, 'Supplies for small pets'), -('Small Pet Food Bowl', 35.00, 5, 'Supplies for small pets'), -('Timothy Hay Cubes', 46.00, 5, 'Supplies for small pets'), -('Guinea Pig Tunnel', 59.00, 5, 'Supplies for small pets'), -('Hamster Nesting Fluff', 12.00, 5, 'Supplies for small pets'), -('Rabbit Grooming Brush', 25.00, 5, 'Supplies for small pets'), -('Small Pet Carrier', 34.00, 5, 'Supplies for small pets'), -('Hay Rack Feeder', 45.00, 5, 'Supplies for small pets'), -('Wooden Chew Blocks', 61.00, 5, 'Supplies for small pets'); - -INSERT INTO productSupplier (supId, prodId, cost) -VALUES -(1, 7, 26.04), -(2, 8, 33.15), -(3, 9, 44.88), -(4, 10, 55.38), -(5, 11, 17.76), -(1, 12, 22.94), -(2, 13, 31.20), -(3, 14, 41.48), -(4, 15, 53.25), -(5, 16, 15.54), -(1, 17, 22.94), -(2, 18, 31.85), -(3, 19, 43.52), -(4, 20, 55.38), -(5, 21, 14.80), -(1, 22, 20.46), -(2, 23, 32.50), -(3, 24, 38.76), -(4, 25, 51.12), -(5, 26, 12.58), -(1, 27, 19.22), -(2, 28, 29.90), -(3, 29, 36.72), -(4, 30, 48.28), -(5, 31, 5.92), -(1, 32, 11.16), -(2, 33, 19.50), -(3, 34, 13.60), -(4, 35, 18.46), -(5, 36, 9.62), -(1, 37, 14.26), -(2, 38, 5.85), -(3, 39, 14.96), -(4, 40, 8.52), -(5, 41, 14.80), -(1, 42, 2.48), -(2, 43, 10.40), -(3, 44, 19.72), -(4, 45, 12.78), -(5, 46, 17.76), -(1, 47, 6.20), -(2, 48, 16.25), -(3, 49, 4.76), -(4, 50, 14.20), -(5, 51, 30.34), -(1, 52, 35.34), -(2, 53, 45.50), -(3, 54, 57.12), -(4, 55, 66.74), -(5, 56, 80.66), -(1, 57, 75.02), -(2, 58, 11.70), -(3, 59, 21.76), -(4, 60, 29.82), -(5, 61, 40.70), -(1, 62, 41.54), -(2, 63, 53.30), -(3, 64, 63.24), -(4, 65, 73.13), -(5, 66, 91.76), -(1, 67, 35.96), -(2, 68, 46.80), -(3, 69, 50.32), -(4, 70, 63.19), -(5, 71, 77.70), -(1, 72, 69.44), -(2, 73, 81.25), -(3, 74, 97.24), -(4, 75, 111.47), -(5, 76, 122.10), -(1, 77, 109.12), -(2, 78, 126.10), -(3, 79, 140.76), -(4, 80, 9.94), -(5, 81, 19.98), -(1, 82, 28.52), -(2, 83, 32.50), -(3, 84, 43.52), -(4, 85, 42.60), -(5, 86, 4.44), -(1, 87, 12.40), -(2, 88, 24.05), -(3, 89, 31.96), -(4, 90, 41.18), -(5, 91, 5.92), -(1, 92, 13.64), -(2, 93, 22.75), -(3, 94, 31.28), -(4, 95, 41.89), -(5, 96, 8.88), -(1, 97, 15.50), -(2, 98, 22.10), -(3, 99, 30.60), -(4, 100, 43.31); - -INSERT INTO inventory (prodId, quantity) -VALUES -(7, 120), -(8, 137), -(9, 154), -(10, 171), -(11, 128), -(12, 145), -(13, 162), -(14, 179), -(15, 136), -(16, 153), -(17, 170), -(18, 127), -(19, 144), -(20, 161), -(21, 178), -(22, 135), -(23, 152), -(24, 169), -(25, 126), -(26, 143), -(27, 160), -(28, 177), -(29, 134), -(30, 151), -(31, 228), -(32, 185), -(33, 202), -(34, 219), -(35, 236), -(36, 193), -(37, 210), -(38, 227), -(39, 184), -(40, 201), -(41, 218), -(42, 235), -(43, 192), -(44, 209), -(45, 226), -(46, 183), -(47, 200), -(48, 217), -(49, 234), -(50, 191), -(51, 98), -(52, 115), -(53, 72), -(54, 89), -(55, 106), -(56, 123), -(57, 80), -(58, 97), -(59, 114), -(60, 71), -(61, 88), -(62, 105), -(63, 122), -(64, 79), -(65, 96), -(66, 113), -(67, 45), -(68, 62), -(69, 79), -(70, 96), -(71, 53), -(72, 70), -(73, 87), -(74, 104), -(75, 61), -(76, 78), -(77, 95), -(78, 52), -(79, 69), -(80, 86), -(81, 103), -(82, 60), -(83, 77), -(84, 94), -(85, 101), -(86, 118), -(87, 135), -(88, 152), -(89, 109), -(90, 126), -(91, 143), -(92, 100), -(93, 117), -(94, 134), -(95, 151), -(96, 108), -(97, 125), -(98, 142), -(99, 99), -(100, 116); diff --git a/backend/src/main/resources/dev/expand_pet_product_seed.sql b/backend/src/main/resources/dev/expand_pet_product_seed.sql new file mode 100644 index 00000000..63736dda --- /dev/null +++ b/backend/src/main/resources/dev/expand_pet_product_seed.sql @@ -0,0 +1,226 @@ +-- Expand pet and product seed data + +INSERT INTO pet (petName, petSpecies, petBreed, petAge, petStatus, petPrice) +VALUES +('Rocky', 'Dog', 'German Shepherd', 1, 'Available', 475.00), +('Daisy', 'Dog', 'Poodle', 2, 'Available', 512.00), +('Cooper', 'Dog', 'Bulldog', 3, 'Available', 560.00), +('Ruby', 'Dog', 'Boxer', 4, 'Available', 575.00), +('Tucker', 'Dog', 'Dachshund', 5, 'Available', 634.00), +('Rosie', 'Dog', 'Shih Tzu', 1, 'Available', 660.00), +('Bear', 'Dog', 'Rottweiler', 2, 'Available', 686.00), +('Maggie', 'Dog', 'Corgi', 3, 'Available', 745.00), +('Leo', 'Dog', 'Husky', 4, 'Available', 749.00), +('Penny', 'Dog', 'Border Collie', 5, 'Available', 808.00), +('Jax', 'Dog', 'German Shepherd', 1, 'Available', 823.00), +('Nala', 'Dog', 'Poodle', 2, 'Available', 871.00), +('Finn', 'Dog', 'Bulldog', 3, 'Available', 447.00), +('Sadie', 'Dog', 'Boxer', 4, 'Available', 495.00), +('Ace', 'Dog', 'Dachshund', 5, 'Available', 510.00), +('Zoe', 'Dog', 'Shih Tzu', 1, 'Available', 547.00), +('Ollie', 'Dog', 'Rottweiler', 2, 'Available', 606.00), +('Millie', 'Dog', 'Corgi', 3, 'Available', 654.00), +('Murphy', 'Dog', 'Husky', 4, 'Available', 691.00), +('Willow', 'Dog', 'Border Collie', 5, 'Available', 728.00), +('Bentley', 'Dog', 'German Shepherd', 1, 'Available', 776.00), +('Lily', 'Dog', 'Poodle', 2, 'Available', 780.00), +('Scout', 'Dog', 'Bulldog', 3, 'Available', 828.00), +('Gracie', 'Dog', 'Boxer', 4, 'Available', 876.00), +('Ranger', 'Dog', 'Dachshund', 5, 'Available', 452.00), +('Hazel', 'Dog', 'Shih Tzu', 1, 'Available', 478.00), +('Moose', 'Dog', 'Rottweiler', 2, 'Available', 515.00), +('Mia', 'Dog', 'Corgi', 3, 'Available', 530.00), +('Simba', 'Cat', 'Ragdoll', 1, 'Available', 295.00), +('Cleo', 'Cat', 'Bengal', 2, 'Available', 321.00), +('Oreo', 'Cat', 'British Shorthair', 3, 'Available', 358.00), +('Pepper', 'Cat', 'Sphynx', 4, 'Available', 417.00), +('Jasper', 'Cat', 'Scottish Fold', 5, 'Available', 454.00), +('Phoebe', 'Cat', 'Russian Blue', 1, 'Available', 491.00), +('Shadow', 'Cat', 'Abyssinian', 2, 'Available', 528.00), +('Mochi', 'Cat', 'Birman', 3, 'Available', 554.00), +('Louie', 'Cat', 'Ragdoll', 4, 'Available', 591.00), +('Ivy', 'Cat', 'Bengal', 5, 'Available', 606.00), +('Theo', 'Cat', 'British Shorthair', 1, 'Available', 654.00), +('Piper', 'Cat', 'Sphynx', 2, 'Available', 251.00), +('Nova', 'Cat', 'Scottish Fold', 3, 'Available', 277.00), +('Archie', 'Cat', 'Russian Blue', 4, 'Available', 336.00), +('Olive', 'Cat', 'Abyssinian', 5, 'Available', 362.00), +('Boots', 'Cat', 'Birman', 1, 'Available', 399.00), +('Maple', 'Cat', 'Ragdoll', 2, 'Available', 436.00), +('Gizmo', 'Cat', 'Bengal', 3, 'Available', 473.00), +('Nina', 'Cat', 'British Shorthair', 4, 'Available', 499.00), +('Salem', 'Cat', 'Sphynx', 5, 'Available', 547.00), +('Stella', 'Cat', 'Scottish Fold', 1, 'Available', 595.00), +('Kiki', 'Cat', 'Russian Blue', 2, 'Available', 610.00), +('Sunny', 'Cat', 'Abyssinian', 3, 'Available', 658.00), +('Mabel', 'Cat', 'Birman', 4, 'Available', 244.00), +('Coco', 'Bird', 'Cockatiel', 1, 'Available', 119.00), +('Sky', 'Bird', 'Parakeet', 2, 'Available', 145.00), +('Sunny', 'Bird', 'Canary', 3, 'Available', 204.00), +('Kiwi', 'Bird', 'Lovebird', 1, 'Available', 230.00), +('Pico', 'Bird', 'Finch', 2, 'Available', 81.00), +('Blue', 'Bird', 'Conure', 3, 'Available', 118.00), +('Rio', 'Bird', 'Cockatiel', 1, 'Available', 144.00), +('Angel', 'Bird', 'Parakeet', 2, 'Available', 203.00), +('Chirpy', 'Bird', 'Canary', 3, 'Available', 251.00), +('Peach', 'Bird', 'Lovebird', 1, 'Available', 91.00), +('Mango', 'Bird', 'Finch', 2, 'Available', 128.00), +('Pearl', 'Bird', 'Conure', 3, 'Available', 165.00), +('Bubbles', 'Fish', 'Goldfish', 1, 'Available', 30.00), +('Splash', 'Fish', 'Betta', 2, 'Available', 56.00), +('Coral', 'Fish', 'Guppy', 1, 'Available', 23.00), +('Neptune', 'Fish', 'Molly', 2, 'Available', 23.00), +('Marlin', 'Fish', 'Tetra', 1, 'Available', 49.00), +('Finley', 'Fish', 'Angelfish', 2, 'Available', 27.00), +('Pebble', 'Fish', 'Goldfish', 1, 'Available', 64.00), +('Wave', 'Fish', 'Betta', 2, 'Available', 20.00), +('Aqua', 'Fish', 'Guppy', 1, 'Available', 57.00), +('Flash', 'Fish', 'Molly', 2, 'Available', 46.00), +('Nemo', 'Fish', 'Tetra', 1, 'Available', 13.00), +('Pearl', 'Fish', 'Angelfish', 2, 'Available', 61.00), +('Thumper', 'Rabbit', 'Mini Lop', 1, 'Adopted', 147.00), +('Clover', 'Rabbit', 'Netherland Dwarf', 2, 'Adopted', 138.00), +('Biscuit', 'Rabbit', 'Lionhead', 3, 'Adopted', 177.00), +('Hazel', 'Rabbit', 'Rex', 1, 'Adopted', 91.00), +('Juniper', 'Rabbit', 'Mini Lop', 2, 'Adopted', 83.00), +('Poppy', 'Rabbit', 'Netherland Dwarf', 3, 'Adopted', 111.00), +('Snowball', 'Rabbit', 'Lionhead', 1, 'Adopted', 172.00), +('Maple', 'Rabbit', 'Rex', 2, 'Adopted', 150.00), +('Peanut', 'Hamster', 'Syrian', 1, 'Adopted', 29.00), +('Nibbles', 'Hamster', 'Dwarf', 2, 'Adopted', 42.00), +('Pumpkin', 'Hamster', 'Roborovski', 1, 'Pending', 49.00), +('Mocha', 'Hamster', 'Syrian', 2, 'Pending', 48.00), +('Buttons', 'Hamster', 'Dwarf', 1, 'Pending', 61.00), +('Teddy', 'Hamster', 'Roborovski', 2, 'Pending', 35.00), +('Pip', 'Hamster', 'Syrian', 1, 'Pending', 39.00), +('Toffee', 'Hamster', 'Dwarf', 2, 'Pending', 52.00), +('Sprout', 'Hamster', 'Roborovski', 1, 'Available', 26.00), +('Bean', 'Hamster', 'Syrian', 2, 'Available', 28.00); + +INSERT INTO product (prodName, prodPrice, categoryId, prodDesc) +VALUES +('Chicken Recipe Dog Food', 42.00, 1, 'Nutritious food and treats for dogs'), +('Beef Feast Dog Food', 51.00, 1, 'Nutritious food and treats for dogs'), +('Salmon Blend Dog Food', 17.00, 1, 'Nutritious food and treats for dogs'), +('Lamb Dinner Dog Food', 28.00, 1, 'Nutritious food and treats for dogs'), +('Puppy Starter Kibble', 39.00, 1, 'Nutritious food and treats for dogs'), +('Senior Care Dog Food', 40.00, 1, 'Nutritious food and treats for dogs'), +('Small Breed Kibble', 44.00, 1, 'Nutritious food and treats for dogs'), +('Large Breed Kibble', 57.00, 1, 'Nutritious food and treats for dogs'), +('Grain Free Dog Food', 68.00, 1, 'Nutritious food and treats for dogs'), +('Turkey Rice Formula', 79.00, 1, 'Nutritious food and treats for dogs'), +('Duck Sweet Potato Meal', 25.00, 1, 'Nutritious food and treats for dogs'), +('Venison Protein Blend', 36.00, 1, 'Nutritious food and treats for dogs'), +('Healthy Weight Dog Food', 48.00, 1, 'Nutritious food and treats for dogs'), +('Sensitive Stomach Kibble', 62.00, 1, 'Nutritious food and treats for dogs'), +('High Energy Dog Food', 72.00, 1, 'Nutritious food and treats for dogs'), +('Organic Dog Biscuits', 18.00, 1, 'Nutritious food and treats for dogs'), +('Peanut Butter Dog Treats', 33.00, 1, 'Nutritious food and treats for dogs'), +('Dental Chew Sticks', 38.00, 1, 'Nutritious food and treats for dogs'), +('Training Treat Bites', 48.00, 1, 'Nutritious food and treats for dogs'), +('Soft Chicken Treats', 57.00, 1, 'Nutritious food and treats for dogs'), +('Pumpkin Fiber Treats', 70.00, 1, 'Nutritious food and treats for dogs'), +('Joint Support Biscuits', 14.00, 1, 'Nutritious food and treats for dogs'), +('Mini Breed Dinner', 17.00, 1, 'Nutritious food and treats for dogs'), +('Farmhouse Dog Meal', 30.00, 1, 'Nutritious food and treats for dogs'), +('Feather Teaser Wand', 30.00, 2, 'Play items for active cats'), +('Catnip Mouse Toy', 24.00, 2, 'Play items for active cats'), +('Jingle Ball Set', 18.00, 2, 'Play items for active cats'), +('Scratching Post Small', 6.00, 2, 'Play items for active cats'), +('Crinkle Tunnel', 31.00, 2, 'Play items for active cats'), +('Laser Pointer Toy', 6.00, 2, 'Play items for active cats'), +('Plush Fish Toy', 19.00, 2, 'Play items for active cats'), +('Spring Coil Pack', 20.00, 2, 'Play items for active cats'), +('Hanging Door Toy', 12.00, 2, 'Play items for active cats'), +('Interactive Puzzle Toy', 22.00, 2, 'Play items for active cats'), +('Catnip Kicker Toy', 20.00, 2, 'Play items for active cats'), +('Rolling Bell Ball', 20.00, 2, 'Play items for active cats'), +('Ribbon Chase Toy', 19.00, 2, 'Play items for active cats'), +('Mini Plush Mouse', 21.00, 2, 'Play items for active cats'), +('Treat Dispensing Ball', 16.00, 2, 'Play items for active cats'), +('Double Pom Toy', 12.00, 2, 'Play items for active cats'), +('Window Perch Toy', 10.00, 2, 'Play items for active cats'), +('Scratch Pad Refill', 8.00, 2, 'Play items for active cats'), +('Rainbow Wand Toy', 23.00, 2, 'Play items for active cats'), +('Carpet Scratcher', 23.00, 2, 'Play items for active cats'), +('Bird Perch Set', 27.00, 3, 'Care supplies for pet birds'), +('Parakeet Seed Mix', 40.00, 3, 'Care supplies for pet birds'), +('Canary Food Blend', 53.00, 3, 'Care supplies for pet birds'), +('Mineral Cuttlebone', 57.00, 3, 'Care supplies for pet birds'), +('Bird Ladder Toy', 68.00, 3, 'Care supplies for pet birds'), +('Mirror Bell Combo', 80.00, 3, 'Care supplies for pet birds'), +('Clip On Food Cup', 92.00, 3, 'Care supplies for pet birds'), +('Bird Cage Liner Pack', 108.00, 3, 'Care supplies for pet birds'), +('Nesting Material Pack', 121.00, 3, 'Care supplies for pet birds'), +('Treat Spray Millet', 8.00, 3, 'Care supplies for pet birds'), +('Wooden Swing Perch', 22.00, 3, 'Care supplies for pet birds'), +('Foraging Ball Toy', 32.00, 3, 'Care supplies for pet birds'), +('Cage Cleaning Spray', 47.00, 3, 'Care supplies for pet birds'), +('Parrot Rope Perch', 54.00, 3, 'Care supplies for pet birds'), +('Bird Bath Dish', 54.00, 3, 'Care supplies for pet birds'), +('Songbird Vitamin Drops', 78.00, 3, 'Care supplies for pet birds'), +('Aquarium Filter Cartridge', 36.00, 4, 'Essential aquarium equipment and accessories'), +('Decorative Aquarium Gravel', 49.00, 4, 'Essential aquarium equipment and accessories'), +('Fish Net Medium', 34.00, 4, 'Essential aquarium equipment and accessories'), +('Water Conditioner', 45.00, 4, 'Essential aquarium equipment and accessories'), +('Aquarium Thermometer', 59.00, 4, 'Essential aquarium equipment and accessories'), +('LED Tank Light', 67.00, 4, 'Essential aquarium equipment and accessories'), +('Air Stone Pack', 76.00, 4, 'Essential aquarium equipment and accessories'), +('Aquarium Heater 50W', 92.00, 4, 'Essential aquarium equipment and accessories'), +('Aquarium Heater 100W', 106.00, 4, 'Essential aquarium equipment and accessories'), +('Fish Flake Food', 95.00, 4, 'Essential aquarium equipment and accessories'), +('Algae Scraper', 105.00, 4, 'Essential aquarium equipment and accessories'), +('Aquarium Plant Set', 122.00, 4, 'Essential aquarium equipment and accessories'), +('Bubble Curtain Kit', 136.00, 4, 'Essential aquarium equipment and accessories'), +('Breeder Box Insert', 149.00, 4, 'Essential aquarium equipment and accessories'), +('Filter Sponge Pack', 164.00, 4, 'Essential aquarium equipment and accessories'), +('Aquarium Background Roll', 183.00, 4, 'Essential aquarium equipment and accessories'), +('Glass Lid Clips', 174.00, 4, 'Essential aquarium equipment and accessories'), +('Submersible Pump', 191.00, 4, 'Essential aquarium equipment and accessories'), +('Hamster Bedding Pack', 50.00, 5, 'Supplies for small pets'), +('Rabbit Hay Bundle', 49.00, 5, 'Supplies for small pets'), +('Guinea Pig Pellets', 15.00, 5, 'Supplies for small pets'), +('Small Pet Water Bottle', 31.00, 5, 'Supplies for small pets'), +('Hamster Hideout Hut', 40.00, 5, 'Supplies for small pets'), +('Chew Stick Bundle', 48.00, 5, 'Supplies for small pets'), +('Rabbit Litter Tray', 58.00, 5, 'Supplies for small pets'), +('Exercise Ball Large', 68.00, 5, 'Supplies for small pets'), +('Small Pet Food Bowl', 20.00, 5, 'Supplies for small pets'), +('Timothy Hay Cubes', 28.00, 5, 'Supplies for small pets'), +('Guinea Pig Tunnel', 38.00, 5, 'Supplies for small pets'), +('Hamster Nesting Fluff', 47.00, 5, 'Supplies for small pets'), +('Rabbit Grooming Brush', 60.00, 5, 'Supplies for small pets'), +('Small Pet Carrier', 7.00, 5, 'Supplies for small pets'), +('Hay Rack Feeder', 11.00, 5, 'Supplies for small pets'), +('Wooden Chew Blocks', 27.00, 5, 'Supplies for small pets'); + +INSERT INTO productSupplier (supId, prodId, cost) +SELECT CASE MOD(p.prodId - 7, 5) + WHEN 0 THEN 1 + WHEN 1 THEN 2 + WHEN 2 THEN 3 + WHEN 3 THEN 4 + ELSE 5 + END, + p.prodId, + ROUND(p.prodPrice * (0.62 + (MOD(p.prodId - 7, 5) * 0.03)), 2) +FROM product p +WHERE p.prodId >= 7 + AND NOT EXISTS ( + SELECT 1 FROM productSupplier ps WHERE ps.prodId = p.prodId + ); + +INSERT INTO inventory (prodId, quantity) +SELECT p.prodId, + CASE p.categoryId + WHEN 1 THEN 120 + MOD((p.prodId - 7) * 17, 60) + WHEN 2 THEN 180 + MOD((p.prodId - 7) * 17, 60) + WHEN 3 THEN 70 + MOD((p.prodId - 7) * 17, 60) + WHEN 4 THEN 45 + MOD((p.prodId - 7) * 17, 60) + ELSE 95 + MOD((p.prodId - 7) * 17, 60) + END +FROM product p +WHERE p.prodId >= 7 + AND NOT EXISTS ( + SELECT 1 FROM inventory i WHERE i.prodId = p.prodId + ); diff --git a/desktop/src/main/java/org/example/petshopdesktop/api/endpoints/DropdownApi.java b/desktop/src/main/java/org/example/petshopdesktop/api/endpoints/DropdownApi.java index 6c20526e..30fcb0b8 100644 --- a/desktop/src/main/java/org/example/petshopdesktop/api/endpoints/DropdownApi.java +++ b/desktop/src/main/java/org/example/petshopdesktop/api/endpoints/DropdownApi.java @@ -26,6 +26,22 @@ public class DropdownApi { return apiClient.getObjectMapper().readValue(response, new TypeReference>() {}); } + public List getProductCategories() throws Exception { + String response = apiClient.getRawResponse("/api/v1/dropdowns/product-categories"); + if (response == null || response.isEmpty()) { + throw new IllegalStateException("Empty response from product categories endpoint"); + } + return apiClient.getObjectMapper().readValue(response, new TypeReference>() {}); + } + + public List getPetSpecies() throws Exception { + String response = apiClient.getRawResponse("/api/v1/dropdowns/pet-species"); + if (response == null || response.isEmpty()) { + throw new IllegalStateException("Empty response from pet species endpoint"); + } + return apiClient.getObjectMapper().readValue(response, new TypeReference>() {}); + } + public List getProducts() throws Exception { String response = apiClient.getRawResponse("/api/v1/dropdowns/products"); if (response == null || response.isEmpty()) { diff --git a/desktop/src/main/java/org/example/petshopdesktop/controllers/PetController.java b/desktop/src/main/java/org/example/petshopdesktop/controllers/PetController.java index 7c5d13c8..bd76c9ce 100644 --- a/desktop/src/main/java/org/example/petshopdesktop/controllers/PetController.java +++ b/desktop/src/main/java/org/example/petshopdesktop/controllers/PetController.java @@ -15,6 +15,8 @@ import javafx.scene.layout.StackPane; import javafx.stage.Modality; import javafx.stage.Stage; import org.example.petshopdesktop.api.dto.pet.PetResponse; +import org.example.petshopdesktop.api.dto.common.DropdownOption; +import org.example.petshopdesktop.api.endpoints.DropdownApi; import org.example.petshopdesktop.api.endpoints.PetApi; import org.example.petshopdesktop.controllers.dialogcontrollers.PetDialogController; import org.example.petshopdesktop.models.Pet; @@ -156,8 +158,7 @@ public class PetController { colPetPrice.setCellValueFactory(new PropertyValueFactory("petPrice")); configureImageColumn(colPetImage); - cbSpeciesFilter.setItems(FXCollections.observableArrayList("All Species", "Dog", "Cat", "Bird", "Fish", "Rabbit", "Hamster")); - cbSpeciesFilter.getSelectionModel().selectFirst(); + loadSpeciesFilter(); cbStatusFilter.setItems(FXCollections.observableArrayList("All Statuses", "Available", "Adopted", "Pending")); cbStatusFilter.getSelectionModel().selectFirst(); @@ -245,6 +246,26 @@ public class PetController { displayFilteredPet(txtSearch.getText()); } + private void loadSpeciesFilter() { + new Thread(() -> { + try { + List values = DropdownApi.getInstance().getPetSpecies().stream() + .map(DropdownOption::getLabel) + .collect(Collectors.toList()); + values.add(0, "All Species"); + Platform.runLater(() -> { + cbSpeciesFilter.setItems(FXCollections.observableArrayList(values)); + cbSpeciesFilter.getSelectionModel().selectFirst(); + }); + } catch (Exception e) { + Platform.runLater(() -> ActivityLogger.getInstance().logException( + "PetController.loadSpeciesFilter", + e, + "Loading species filter options")); + } + }).start(); + } + private String selectedSpecies() { String value = cbSpeciesFilter.getValue(); return value == null || value.equals("All Species") ? null : value; diff --git a/desktop/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/desktop/src/main/java/org/example/petshopdesktop/controllers/ProductController.java index 8bb51296..84cfb8ce 100644 --- a/desktop/src/main/java/org/example/petshopdesktop/controllers/ProductController.java +++ b/desktop/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -269,7 +269,7 @@ public class ProductController { all.setId(null); all.setLabel("All Categories"); options.add(all); - options.addAll(DropdownApi.getInstance().getCategories()); + options.addAll(DropdownApi.getInstance().getProductCategories()); Platform.runLater(() -> { cbCategoryFilter.setItems(FXCollections.observableArrayList(options)); cbCategoryFilter.getSelectionModel().selectFirst(); diff --git a/desktop/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java b/desktop/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java index 7b354a9d..2a51e42a 100644 --- a/desktop/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java +++ b/desktop/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java @@ -89,7 +89,7 @@ public class ProductDialogController { //Set up combobox for selecting category try { - List categories = DropdownApi.getInstance().getCategories(); + List categories = DropdownApi.getInstance().getProductCategories(); if (categories != null) { ObservableList categoriesObs = FXCollections.observableArrayList(categories); cbProdCategory.setItems(categoriesObs);