Compare commits

..

2 commits

Author SHA1 Message Date
Soumen Mallick
cb85d87ee3 Resolved merge conflicts 2024-12-22 13:19:59 +05:30
Soumen Mallick
1587384b43 updatePet meyhod added in Owner ! 2024-12-22 12:34:20 +05:30
3 changed files with 34 additions and 2 deletions

View file

@ -18,7 +18,7 @@
<properties>
<!-- Generic properties -->
<java.version>17</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Important for reproducible builds. Update using e.g. ./mvnw versions:set
@ -156,6 +156,11 @@
<build>
<plugins>
<plugin>
<groupId>com.gitlab.haynes</groupId>
<artifactId>libsass-maven-plugin</artifactId>
<version>0.2.29</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
@ -287,6 +292,7 @@
<artifactId>cyclonedx-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<licenses>

View file

@ -172,4 +172,17 @@ public class Owner extends Person {
pet.addVisit(visit);
}
public void updatePet(Pet newPet)
{
for(int i=0 ; i<pets.size() ; i++)
{
Pet existingPet = pets.get(i);
if(existingPet.getId().equals(newPet.getId()))
{
pets.set(i,newPet);
break;
}
}
}
}

View file

@ -129,7 +129,7 @@ class privatePetController {
RedirectAttributes redirectAttributes) {
String petName = pet.getName();
System.out.println(pet.getId()+" SOUMEN");
// checking if the pet name already exist for the owner
if (StringUtils.hasText(petName)) {
Pet existingPet = owner.getPet(petName, false);
@ -147,6 +147,13 @@ class privatePetController {
return VIEWS_PETS_CREATE_OR_UPDATE_FORM;
}
<<<<<<< HEAD
owner.addPet(pet);
owner.updatePet(pet);
||||||| 6148ddd
owner.addPet(pet);
=======
//owner.addPet(pet);
List<Pet> petlist = owner.getPets();
@ -159,9 +166,15 @@ class privatePetController {
}
}
>>>>>>> 588fd808f860ff0896eb2e4cb841f8cacd19855b
this.owners.save(owner);
redirectAttributes.addFlashAttribute("message", "Pet details has been edited");
return "redirect:/owners/{ownerId}";
}
}