This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/causeway-app-petclinic.git

commit 4ebe45133fa5beebee8b3359286b1042ecc1bf70
Author: Dan Haywood <[email protected]>
AuthorDate: Sun May 26 12:51:17 2024 +0100

    adds 'addPet' action
---
 .../domainapp/modules/petowner/dom/petowner/PetOwner.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git 
a/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
 
b/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
index d845dd3..0547b0d 100644
--- 
a/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
+++ 
b/module-petowner/src/main/java/domainapp/modules/petowner/dom/petowner/PetOwner.java
@@ -69,6 +69,7 @@ import domainapp.modules.petowner.PetOwnerModule;
 import domainapp.modules.petowner.dom.pet.Pet;
 import domainapp.modules.petowner.types.Name;
 import domainapp.modules.petowner.types.Notes;
+import domainapp.modules.petowner.types.PetName;
 import domainapp.modules.petowner.types.PhoneNumber;
 import domainapp.modules.petowner.value.EmailAddress;
 
@@ -160,6 +161,17 @@ public class PetOwner implements Comparable<PetOwner>, 
CalendarEventable {
     @OneToMany(mappedBy = "petOwner", cascade = CascadeType.ALL, orphanRemoval 
= true)
     private Set<Pet> pets = new TreeSet<>();
 
+    @Action
+    @ActionLayout(associateWith = "pets", sequence = "1")
+    public PetOwner addPet(@PetName final String name) {
+        final var pet = new Pet();
+        pet.setName(name);
+        pet.setPetOwner(this);
+        pets.add(pet);
+        return this;
+    }
+
+
     @AttributeOverrides({
             @AttributeOverride(name="name",    
column=@Column(name="attachment_name")),
             
@AttributeOverride(name="mimeType",column=@Column(name="attachment_mimeType")),

Reply via email to