mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
updated
This commit is contained in:
parent
74724aa627
commit
4577763bca
5 changed files with 59 additions and 2 deletions
2
changed_codeobjects.csv
Normal file
2
changed_codeobjects.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
Class Name,Method Name
|
||||
DomainValidationService,validateDomainLogic
|
|
Binary file not shown.
|
@ -4,12 +4,17 @@ import io.opentelemetry.instrumentation.annotations.WithSpan;
|
|||
|
||||
public class DomainValidationService {
|
||||
|
||||
|
||||
public void testFunc(){
|
||||
|
||||
}
|
||||
// Main method for domain validation logic
|
||||
@WithSpan
|
||||
public boolean validateDomainLogic(String usr) {
|
||||
String domain = normalizeDomainFormat("example.com");
|
||||
|
||||
if (isValidDomain(domain)) {
|
||||
|
||||
if (!containsRestrictedWords(domain) && isValidDomainSuffix(domain)) {
|
||||
if (isDomainAvailable(domain)) {
|
||||
saveValidationResults(domain, true, true);
|
||||
|
@ -98,6 +103,7 @@ public class DomainValidationService {
|
|||
System.out.println("Notifying admin: " + notification);
|
||||
}
|
||||
|
||||
|
||||
// Fake method to check if the domain is reserved
|
||||
private boolean isReservedDomain(String domain) {
|
||||
String[] reservedDomains = { "example.com", "localhost" };
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
package org.springframework.samples.petclinic.owner;
|
||||
|
||||
import io.opentelemetry.instrumentation.annotations.WithSpan;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
@ -23,6 +25,7 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.samples.petclinic.domain.OwnerValidation;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.ErrorResponse;
|
||||
|
@ -51,6 +54,9 @@ class OwnerController {
|
|||
|
||||
private OwnerValidation validator;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
public OwnerController(OwnerRepository clinicService) {
|
||||
|
||||
this.owners = clinicService;
|
||||
|
@ -94,6 +100,49 @@ class OwnerController {
|
|||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@GetMapping("/owners/selects")
|
||||
public String deathBySelects() throws NoSuchMethodException {
|
||||
|
||||
// if (model!=null){
|
||||
// throw new RuntimeException();
|
||||
//
|
||||
// }
|
||||
var owner = this.owners.findById(3);
|
||||
for (var pet : owner.getPets()){
|
||||
System.out.println(pet.getName());
|
||||
|
||||
}
|
||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
|
||||
}
|
||||
@GetMapping("/owners/inserts")
|
||||
@Transactional
|
||||
public String deathByInserts() throws NoSuchMethodException {
|
||||
|
||||
var txn = entityManager.getTransaction();
|
||||
txn.begin();
|
||||
// if (model!=null){
|
||||
// throw new RuntimeException();
|
||||
//
|
||||
// }
|
||||
var owner = this.owners.findById(3);
|
||||
for (int i=0;i<3000;i++){
|
||||
Pet pet = new Pet();
|
||||
PetType type = new PetType();
|
||||
type.setName("dog");
|
||||
type.setId(1);
|
||||
pet.setType(type);
|
||||
pet.setName("A"+i);
|
||||
owner.addPet(pet);
|
||||
}
|
||||
|
||||
this.owners.save(owner);
|
||||
txn.commit();
|
||||
//model.put("owner", owner);
|
||||
|
||||
return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/owners/new")
|
||||
public String processCreationForm(@Valid Owner owner, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class Pet extends NamedEntity {
|
|||
return this.pet_vaccines;
|
||||
}
|
||||
|
||||
public void addVisit(Visit visit) {
|
||||
public void addVisit(Visit visit) {
|
||||
getVisits().add(visit);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue