mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:25:50 +00:00
Merge cb85d87ee3
into 6148ddd967
This commit is contained in:
commit
0a0741026f
3 changed files with 47 additions and 3 deletions
8
pom.xml
8
pom.xml
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.springframework.samples.petclinic.owner;
|
|||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -42,7 +43,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||
*/
|
||||
@Controller
|
||||
@RequestMapping("/owners/{ownerId}")
|
||||
class PetController {
|
||||
class privatePetController {
|
||||
|
||||
private static final String VIEWS_PETS_CREATE_OR_UPDATE_FORM = "pets/createOrUpdatePetForm";
|
||||
|
||||
|
@ -128,7 +129,7 @@ class PetController {
|
|||
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);
|
||||
|
@ -146,10 +147,34 @@ class PetController {
|
|||
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();
|
||||
for(int i=0 ; i<petlist.size() ; i++)
|
||||
{
|
||||
if(petlist.get(i).getId().equals(pet.getId()))
|
||||
{
|
||||
petlist.set(i,pet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> 588fd808f860ff0896eb2e4cb841f8cacd19855b
|
||||
this.owners.save(owner);
|
||||
redirectAttributes.addFlashAttribute("message", "Pet details has been edited");
|
||||
return "redirect:/owners/{ownerId}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue