mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 11:22:48 +00:00
Example of using RAG in Vets retreival, as well as refactoring, bug fixes and enhancements
This commit is contained in:
parent
290bb439d1
commit
809e6f1c1c
30 changed files with 3072 additions and 118 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -16,3 +16,6 @@ _site/
|
|||
*.css
|
||||
!petclinic.css
|
||||
**/creds.yaml
|
||||
.tanzu/
|
||||
tanzu.yml
|
||||
**/.DS_Store
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.3.3</version>
|
||||
</parent>
|
||||
<name>petclinic</name>
|
||||
|
||||
|
|
|
@ -2,10 +2,12 @@ package org.springframework.samples.petclinic.genai;
|
|||
|
||||
import org.springframework.ai.chat.memory.ChatMemory;
|
||||
import org.springframework.ai.chat.memory.InMemoryChatMemory;
|
||||
import org.springframework.ai.embedding.EmbeddingModel;
|
||||
import org.springframework.ai.vectorstore.SimpleVectorStore;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
/**
|
||||
* A Configuration class for beans used by the Chat Client.
|
||||
|
@ -14,16 +16,16 @@ import org.springframework.web.client.RestClient;
|
|||
*/
|
||||
@Configuration
|
||||
@Profile("openai")
|
||||
public class PetclinicAIConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestClient restClient() {
|
||||
return RestClient.create();
|
||||
}
|
||||
public class AIBeanConfiguration {
|
||||
|
||||
@Bean
|
||||
public ChatMemory chatMemory() {
|
||||
return new InMemoryChatMemory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
VectorStore vectorStore(EmbeddingModel embeddingModel) {
|
||||
return new SimpleVectorStore(embeddingModel);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package org.springframework.samples.petclinic.genai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.vectorstore.SearchRequest;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.samples.petclinic.owner.Owner;
|
||||
import org.springframework.samples.petclinic.owner.OwnerRepository;
|
||||
import org.springframework.samples.petclinic.vet.VetRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* Functions that are invoked by the LLM will use this bean to query the system of record
|
||||
* for information such as listing owners and vers, or adding pets to an owner.
|
||||
*
|
||||
* @author Oded Shopen
|
||||
*/
|
||||
@Service
|
||||
@Profile("openai")
|
||||
public class AIDataProvider {
|
||||
|
||||
private final OwnerRepository ownerRepository;
|
||||
|
||||
private final VectorStore vectorStore;
|
||||
|
||||
public AIDataProvider(OwnerRepository ownerRepository, VetRepository vetRepository, VectorStore vectorStore) {
|
||||
this.ownerRepository = ownerRepository;
|
||||
this.vectorStore = vectorStore;
|
||||
}
|
||||
|
||||
public OwnersResponse getAllOwners() {
|
||||
Pageable pageable = PageRequest.of(0, 100);
|
||||
Page<Owner> ownerPage = ownerRepository.findAll(pageable);
|
||||
return new OwnersResponse(ownerPage.getContent());
|
||||
}
|
||||
|
||||
public VetResponse getVets(VetRequest request) throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String vetAsJson = objectMapper.writeValueAsString(request.vet());
|
||||
|
||||
SearchRequest sr = SearchRequest.from(SearchRequest.defaults()).withQuery(vetAsJson).withTopK(20);
|
||||
if (request.vet() == null) {
|
||||
// Provide a limit of 50 results when zero parameters are sent
|
||||
sr = sr.withTopK(50);
|
||||
}
|
||||
|
||||
List<Document> topMatches = this.vectorStore.similaritySearch(sr);
|
||||
List<String> results = topMatches.stream().map(document -> document.getContent()).toList();
|
||||
return new VetResponse(results);
|
||||
}
|
||||
|
||||
public AddedPetResponse addPetToOwner(AddPetRequest request) {
|
||||
Owner owner = ownerRepository.findById(request.ownerId());
|
||||
owner.addPet(request.pet());
|
||||
this.ownerRepository.save(owner);
|
||||
return new AddedPetResponse(owner);
|
||||
}
|
||||
|
||||
public OwnerResponse addOwnerToPetclinic(OwnerRequest ownerRequest) {
|
||||
ownerRepository.save(ownerRequest.owner());
|
||||
return new OwnerResponse(ownerRequest.owner());
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,8 @@ import org.springframework.samples.petclinic.owner.Owner;
|
|||
import org.springframework.samples.petclinic.owner.Pet;
|
||||
import org.springframework.samples.petclinic.vet.Vet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
/**
|
||||
* This class defines the @Bean functions that the LLM provider will invoke when it
|
||||
* requires more Information on a given topic. The currently available functions enable
|
||||
|
@ -26,7 +28,7 @@ class AIFunctionConfiguration {
|
|||
// The @Description annotation helps the model understand when to call the function
|
||||
@Bean
|
||||
@Description("List the owners that the pet clinic has")
|
||||
public Function<OwnerRequest, OwnersResponse> listOwners(PetclinicAIProvider petclinicAiProvider) {
|
||||
public Function<OwnerRequest, OwnersResponse> listOwners(AIDataProvider petclinicAiProvider) {
|
||||
return request -> {
|
||||
return petclinicAiProvider.getAllOwners();
|
||||
};
|
||||
|
@ -34,9 +36,15 @@ class AIFunctionConfiguration {
|
|||
|
||||
@Bean
|
||||
@Description("List the veterinarians that the pet clinic has")
|
||||
public Function<VetRequest, VetResponse> listVets(PetclinicAIProvider petclinicAiProvider) {
|
||||
public Function<VetRequest, VetResponse> listVets(AIDataProvider petclinicAiProvider) {
|
||||
return request -> {
|
||||
return petclinicAiProvider.getAllVets();
|
||||
try {
|
||||
return petclinicAiProvider.getVets(request);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -44,15 +52,25 @@ class AIFunctionConfiguration {
|
|||
@Description("Add a pet with the specified petTypeId, " + "to an owner identified by the ownerId. "
|
||||
+ "The allowed Pet types IDs are only: " + "1 - cat" + "2 - dog" + "3 - lizard" + "4 - snake" + "5 - bird"
|
||||
+ "6 - hamster")
|
||||
public Function<AddPetRequest, AddedPetResponse> addPetToOwner(PetclinicAIProvider petclinicAiProvider) {
|
||||
public Function<AddPetRequest, AddedPetResponse> addPetToOwner(AIDataProvider petclinicAiProvider) {
|
||||
return request -> {
|
||||
return petclinicAiProvider.addPetToOwner(request);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Description("Add a new pet owner to the pet clinic. "
|
||||
+ "The Owner must include a first name and a last name as two separate words, "
|
||||
+ "plus an address and a 10-digit phone number")
|
||||
public Function<OwnerRequest, OwnerResponse> addOwnerToPetclinic(AIDataProvider petclinicAiDataProvider) {
|
||||
return request -> {
|
||||
return petclinicAiDataProvider.addOwnerToPetclinic(request);
|
||||
};
|
||||
}
|
||||
|
||||
record AddPetRequest(Pet pet, String petType, Integer ownerId) {
|
||||
}
|
||||
|
||||
record AddPetRequest(Pet pet, Integer ownerId) {
|
||||
};
|
||||
|
||||
record OwnerRequest(Owner owner) {
|
||||
|
@ -61,10 +79,13 @@ record OwnerRequest(Owner owner) {
|
|||
record OwnersResponse(List<Owner> owners) {
|
||||
};
|
||||
|
||||
record OwnerResponse(Owner owner) {
|
||||
};
|
||||
|
||||
record AddedPetResponse(Owner owner) {
|
||||
};
|
||||
|
||||
record VetResponse(List<Vet> vet) {
|
||||
record VetResponse(List<String> vet) {
|
||||
};
|
||||
|
||||
record VetRequest(Vet vet) {
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package org.springframework.samples.petclinic.genai;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ai.chat.client.AdvisedRequest;
|
||||
import org.springframework.ai.chat.client.RequestResponseAdvisor;
|
||||
|
||||
/**
|
||||
* A ChatClient Advisor that adds logs on the requests being sent to the LLM.
|
||||
*
|
||||
* @author Oded Shopen
|
||||
*/
|
||||
public class LoggingAdvisor implements RequestResponseAdvisor {
|
||||
|
||||
private static final Log log = LogFactory.getLog(LoggingAdvisor.class);
|
||||
|
||||
@Override
|
||||
public AdvisedRequest adviseRequest(AdvisedRequest request, Map<String, Object> context) {
|
||||
log.info("Received Spring AI Request: " + request);
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package org.springframework.samples.petclinic.genai;
|
||||
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.samples.petclinic.owner.Owner;
|
||||
import org.springframework.samples.petclinic.owner.OwnerRepository;
|
||||
import org.springframework.samples.petclinic.vet.Vet;
|
||||
import org.springframework.samples.petclinic.vet.VetRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Functions that are invoked by the LLM will use this bean to query the system of record
|
||||
* for information such as listing owners and vers, or adding pets to an owner.
|
||||
*
|
||||
* @author Oded Shopen
|
||||
*/
|
||||
@Service
|
||||
@Profile("openai")
|
||||
public class PetclinicAIProvider {
|
||||
|
||||
OwnerRepository ownerRepository;
|
||||
|
||||
VetRepository vetRepository;
|
||||
|
||||
public PetclinicAIProvider(OwnerRepository ownerRepository, VetRepository vetRepository) {
|
||||
this.ownerRepository = ownerRepository;
|
||||
this.vetRepository = vetRepository;
|
||||
}
|
||||
|
||||
public OwnersResponse getAllOwners() {
|
||||
Pageable pageable = PageRequest.of(0, Integer.MAX_VALUE);
|
||||
Page<Owner> ownerPage = ownerRepository.findAll(pageable);
|
||||
return new OwnersResponse(ownerPage.getContent());
|
||||
}
|
||||
|
||||
public VetResponse getAllVets() {
|
||||
Pageable pageable = PageRequest.of(0, Integer.MAX_VALUE);
|
||||
Page<Vet> vetsPage = vetRepository.findAll(pageable);
|
||||
return new VetResponse(vetsPage.getContent());
|
||||
}
|
||||
|
||||
public AddedPetResponse addPetToOwner(AddPetRequest request) {
|
||||
Owner owner = ownerRepository.findById(request.ownerId());
|
||||
owner.addPet(request.pet());
|
||||
this.ownerRepository.save(owner);
|
||||
return new AddedPetResponse(owner);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvis
|
|||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
|
||||
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
|
||||
import org.springframework.ai.chat.memory.ChatMemory;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -32,16 +33,19 @@ public class PetclinicChatClient {
|
|||
this.chatClient = builder
|
||||
.defaultSystem("""
|
||||
You are a friendly AI assistant designed to help with the management of a veterinarian pet clinic called Spring Petclinic.
|
||||
Your job is to answer questions about the existing veterinarians and to perform actions on the customer's behalf, mainly around
|
||||
pet owners, their pets and their visits.
|
||||
You are required to answer an a professional manner. If you don't know the answer, politely tell the customer
|
||||
you don't know the answer, then ask the customer a followup qusetion to try and clarify the question they are asking.
|
||||
If you do know the answer, provide the answer but do not provide any additional helpful followup questions.
|
||||
Your job is to answer questions about and to perform actions on the user's behalf, mainly around
|
||||
veterinarians, owners, owners' pets and owners' visits.
|
||||
You are required to answer an a professional manner. If you don't know the answer, politely tell the user
|
||||
you don't know the answer, then ask the user a followup question to try and clarify the question they are asking.
|
||||
If you do know the answer, provide the answer but do not provide any additional followup questions.
|
||||
When dealing with vets, if the user is unsure about the returned results, explain that there may be additional data that was not returned.
|
||||
Only if the user is asking about the total number of all vets, answer that there are a lot and ask for some additional criteria.
|
||||
For owners, pets or visits - provide the correct data.
|
||||
""")
|
||||
.defaultAdvisors(
|
||||
// Chat memory helps us keep context when using the chatbot for up to 10 previous messages.
|
||||
new MessageChatMemoryAdvisor(chatMemory, DEFAULT_CHAT_MEMORY_CONVERSATION_ID, 10), // CHAT MEMORY
|
||||
new LoggingAdvisor()
|
||||
new SimpleLoggerAdvisor()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package org.springframework.samples.petclinic.genai;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.document.DocumentReader;
|
||||
import org.springframework.ai.reader.JsonReader;
|
||||
import org.springframework.ai.vectorstore.SimpleVectorStore;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.samples.petclinic.vet.Vet;
|
||||
import org.springframework.samples.petclinic.vet.VetRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* Loads the veterinarians data into a vector store for the purpose of RAG functionality.
|
||||
*
|
||||
* @author Oded Shopen
|
||||
*/
|
||||
@Component
|
||||
@Profile("openai")
|
||||
public class VectorStoreController {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(VectorStoreController.class);
|
||||
|
||||
private final VectorStore vectorStore;
|
||||
|
||||
private final VetRepository vetRepository;
|
||||
|
||||
public VectorStoreController(VectorStore vectorStore, VetRepository vetRepository) throws IOException {
|
||||
this.vectorStore = vectorStore;
|
||||
this.vetRepository = vetRepository;
|
||||
}
|
||||
|
||||
@EventListener
|
||||
public void loadVetDataToVectorStoreOnStartup(ApplicationStartedEvent event) throws IOException {
|
||||
Resource resource = new ClassPathResource("vectorstore.json");
|
||||
|
||||
// Check if file exists
|
||||
if (resource.exists()) {
|
||||
// In order to save on AI credits, use a pre-embedded database that was saved
|
||||
// to
|
||||
// disk based on the current data in the h2 data.sql file
|
||||
File file = resource.getFile();
|
||||
((SimpleVectorStore) this.vectorStore).load(file);
|
||||
logger.info("vector store loaded from existing vectorstore.json file in the classpath");
|
||||
return;
|
||||
}
|
||||
|
||||
// If vectorstore.json is deleted, the data will be loaded on startup every time.
|
||||
// Warning - this can be costly in terms of credits used with the AI provider.
|
||||
// Fetches all Vet entites and creates a document per vet
|
||||
Pageable pageable = PageRequest.of(0, Integer.MAX_VALUE);
|
||||
Page<Vet> vetsPage = vetRepository.findAll(pageable);
|
||||
|
||||
Resource vetsAsJson = convertListToJsonResource(vetsPage.getContent());
|
||||
DocumentReader reader = new JsonReader(vetsAsJson);
|
||||
|
||||
List<Document> documents = reader.get();
|
||||
// add the documents to the vector store
|
||||
this.vectorStore.add(documents);
|
||||
|
||||
if (vectorStore instanceof SimpleVectorStore) {
|
||||
var file = File.createTempFile("vectorstore", ".json");
|
||||
((SimpleVectorStore) this.vectorStore).save(file);
|
||||
logger.info("vector store contents written to {}", file.getAbsolutePath());
|
||||
}
|
||||
|
||||
logger.info("vector store loaded with {} documents", documents.size());
|
||||
}
|
||||
|
||||
public Resource convertListToJsonResource(List<Vet> vets) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
// Convert List<Vet> to JSON string
|
||||
String json = objectMapper.writeValueAsString(vets);
|
||||
|
||||
// Convert JSON string to byte array
|
||||
byte[] jsonBytes = json.getBytes();
|
||||
|
||||
// Create a ByteArrayResource from the byte array
|
||||
return new ByteArrayResource(jsonBytes);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -32,6 +32,8 @@ import jakarta.persistence.MappedSuperclass;
|
|||
@MappedSuperclass
|
||||
public class BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3856744164839586177L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
|
|
@ -28,6 +28,8 @@ import jakarta.persistence.MappedSuperclass;
|
|||
@MappedSuperclass
|
||||
public class NamedEntity extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = -1827620691768236760L;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import jakarta.validation.constraints.NotBlank;
|
|||
@MappedSuperclass
|
||||
public class Person extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = -5934070342233945557L;
|
||||
|
||||
@Column(name = "first_name")
|
||||
@NotBlank
|
||||
private String firstName;
|
||||
|
|
|
@ -46,6 +46,8 @@ import jakarta.validation.constraints.NotBlank;
|
|||
@Table(name = "owners")
|
||||
public class Owner extends Person {
|
||||
|
||||
private static final long serialVersionUID = 7676019169107660494L;
|
||||
|
||||
@Column(name = "address")
|
||||
@NotBlank
|
||||
private String address;
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.springframework.samples.petclinic.owner;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -32,9 +32,9 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
|
|
|
@ -44,6 +44,8 @@ import jakarta.persistence.Table;
|
|||
@Table(name = "pets")
|
||||
public class Pet extends NamedEntity {
|
||||
|
||||
private static final long serialVersionUID = 622048308893169889L;
|
||||
|
||||
@Column(name = "birth_date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate birthDate;
|
||||
|
|
|
@ -27,4 +27,6 @@ import jakarta.persistence.Table;
|
|||
@Table(name = "types")
|
||||
public class PetType extends NamedEntity {
|
||||
|
||||
private static final long serialVersionUID = -7611995145056548231L;
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import jakarta.validation.constraints.NotBlank;
|
|||
@Table(name = "visits")
|
||||
public class Visit extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = -8061148591973721283L;
|
||||
|
||||
@Column(name = "visit_date")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
|
|
|
@ -29,4 +29,6 @@ import jakarta.persistence.Table;
|
|||
@Table(name = "specialties")
|
||||
public class Specialty extends NamedEntity {
|
||||
|
||||
private static final long serialVersionUID = 5551869401872945493L;
|
||||
|
||||
}
|
||||
|
|
|
@ -25,13 +25,16 @@ import org.springframework.beans.support.MutableSortDefinition;
|
|||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.samples.petclinic.model.Person;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* Simple JavaBean domain object representing a veterinarian.
|
||||
|
@ -45,6 +48,8 @@ import jakarta.xml.bind.annotation.XmlElement;
|
|||
@Table(name = "vets")
|
||||
public class Vet extends Person {
|
||||
|
||||
private static final long serialVersionUID = 2216866745632621103L;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
||||
|
@ -61,17 +66,20 @@ public class Vet extends Person {
|
|||
this.specialties = specialties;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
@JsonProperty("specialties")
|
||||
@JsonSerialize(as = ArrayList.class)
|
||||
public List<Specialty> getSpecialties() {
|
||||
List<Specialty> sortedSpecs = new ArrayList<>(getSpecialtiesInternal());
|
||||
PropertyComparator.sort(sortedSpecs, new MutableSortDefinition("name", true, true));
|
||||
return Collections.unmodifiableList(sortedSpecs);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getNrOfSpecialties() {
|
||||
return getSpecialtiesInternal().size();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void addSpecialty(Specialty specialty) {
|
||||
getSpecialtiesInternal().add(specialty);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class VetController {
|
|||
}
|
||||
|
||||
private Page<Vet> findPaginated(int page) {
|
||||
int pageSize = 5;
|
||||
int pageSize = 20;
|
||||
Pageable pageable = PageRequest.of(page - 1, pageSize);
|
||||
return vetRepository.findAll(pageable);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.springframework.cache.annotation.Cacheable;
|
|||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -45,6 +46,13 @@ public interface VetRepository extends Repository<Vet, Integer> {
|
|||
@Cacheable("vets")
|
||||
Collection<Vet> findAll() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Count the number of <code>Vet</code>s in the data store.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Query("SELECT COUNT(v) FROM Vet v")
|
||||
Integer countVets() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Retrieve all <code>Vet</code>s from data store in Pages
|
||||
* @param pageable
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
spring.config.import=optional:classpath:/creds.yaml
|
||||
|
||||
#These apply when using spring-ai-azure-openai-spring-boot-starter
|
||||
spring.ai.azure.openai.chat.options.functions=listOwners,listVets,addPetToOwner
|
||||
spring.ai.azure.openai.chat.options.functions=listOwners,listVets,addPetToOwner,addOwnerToPetclinic
|
||||
spring.ai.azure.openai.chat.options.temperature: 0.7
|
||||
|
||||
#These apply when using spring-ai-openai-spring-boot-starter
|
||||
spring.ai.openai.chat.options.functions=listOwners,listVets,addPetToOwner
|
||||
#spring.ai.openai.chat.options.functions=listOwners,listVets,addPetToOwner
|
||||
#spring.ai.openai.chat.options.functions=addOwnerToPetclinic
|
||||
spring.ai.openai.chat.options.temperature: 0.7
|
||||
|
||||
#Enable Spring AI by default
|
||||
spring.ai.chat.client.enabled=true
|
||||
|
||||
logging.level.org.springframework.ai.chat.client.advisor=DEBUG
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# database init, supports mysql too
|
||||
database=h2
|
||||
|
||||
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql
|
||||
spring.sql.init.data-locations=classpath*:db/${database}/data.sql
|
||||
|
||||
|
|
|
@ -4,16 +4,523 @@ INSERT INTO vets VALUES (default, 'Linda', 'Douglas');
|
|||
INSERT INTO vets VALUES (default, 'Rafael', 'Ortega');
|
||||
INSERT INTO vets VALUES (default, 'Henry', 'Stevens');
|
||||
INSERT INTO vets VALUES (default, 'Sharon', 'Jenkins');
|
||||
INSERT INTO vets VALUES (default, 'Matthew', 'Alexander');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Anderson');
|
||||
INSERT INTO vets VALUES (default, 'James', 'Rogers');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Butler');
|
||||
INSERT INTO vets VALUES (default, 'Cheryl', 'Rodriguez');
|
||||
INSERT INTO vets VALUES (default, 'Laura', 'Martin');
|
||||
INSERT INTO vets VALUES (default, 'Ashley', 'Henderson');
|
||||
INSERT INTO vets VALUES (default, 'Walter', 'Moore');
|
||||
INSERT INTO vets VALUES (default, 'Benjamin', 'Hill');
|
||||
INSERT INTO vets VALUES (default, 'Matthew', 'Myers');
|
||||
INSERT INTO vets VALUES (default, 'Jean', 'Henderson');
|
||||
INSERT INTO vets VALUES (default, 'David', 'Phillips');
|
||||
INSERT INTO vets VALUES (default, 'Jacqueline', 'Ross');
|
||||
INSERT INTO vets VALUES (default, 'Jacqueline', 'Perry');
|
||||
INSERT INTO vets VALUES (default, 'William', 'Walker');
|
||||
INSERT INTO vets VALUES (default, 'Christine', 'Garcia');
|
||||
INSERT INTO vets VALUES (default, 'Patricia', 'Myers');
|
||||
INSERT INTO vets VALUES (default, 'Michael', 'Gonzalez');
|
||||
INSERT INTO vets VALUES (default, 'Joseph', 'Ross');
|
||||
INSERT INTO vets VALUES (default, 'Paul', 'Walker');
|
||||
INSERT INTO vets VALUES (default, 'Tyler', 'Reed');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Allen');
|
||||
INSERT INTO vets VALUES (default, 'Julia', 'Allen');
|
||||
INSERT INTO vets VALUES (default, 'Walter', 'Cox');
|
||||
INSERT INTO vets VALUES (default, 'Samantha', 'Walker');
|
||||
INSERT INTO vets VALUES (default, 'Marie', 'Rodriguez');
|
||||
INSERT INTO vets VALUES (default, 'Andrew', 'Taylor');
|
||||
INSERT INTO vets VALUES (default, 'Dorothy', 'Turner');
|
||||
INSERT INTO vets VALUES (default, 'Aaron', 'Bryant');
|
||||
INSERT INTO vets VALUES (default, 'Rose', 'Sanders');
|
||||
INSERT INTO vets VALUES (default, 'Patrick', 'Bell');
|
||||
INSERT INTO vets VALUES (default, 'Melissa', 'Hall');
|
||||
INSERT INTO vets VALUES (default, 'Joshua', 'Stewart');
|
||||
INSERT INTO vets VALUES (default, 'Teresa', 'Walker');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Taylor');
|
||||
INSERT INTO vets VALUES (default, 'Thomas', 'Perez');
|
||||
INSERT INTO vets VALUES (default, 'Evelyn', 'Ward');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Smith');
|
||||
INSERT INTO vets VALUES (default, 'Ashley', 'Morgan');
|
||||
INSERT INTO vets VALUES (default, 'Helen', 'Wood');
|
||||
INSERT INTO vets VALUES (default, 'Deborah', 'Russell');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Bennett');
|
||||
INSERT INTO vets VALUES (default, 'Timothy', 'Jackson');
|
||||
INSERT INTO vets VALUES (default, 'Marie', 'Williams');
|
||||
INSERT INTO vets VALUES (default, 'Aaron', 'Richardson');
|
||||
INSERT INTO vets VALUES (default, 'Donna', 'Davis');
|
||||
INSERT INTO vets VALUES (default, 'Daniel', 'Richardson');
|
||||
INSERT INTO vets VALUES (default, 'Julia', 'Butler');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Russell');
|
||||
INSERT INTO vets VALUES (default, 'Paul', 'Baker');
|
||||
INSERT INTO vets VALUES (default, 'Mary', 'Jones');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Peterson');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Robinson');
|
||||
INSERT INTO vets VALUES (default, 'Henry', 'Smith');
|
||||
INSERT INTO vets VALUES (default, 'Scott', 'Ford');
|
||||
INSERT INTO vets VALUES (default, 'Jeffrey', 'King');
|
||||
INSERT INTO vets VALUES (default, 'Laura', 'Baker');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Ross');
|
||||
INSERT INTO vets VALUES (default, 'Patrick', 'Howard');
|
||||
INSERT INTO vets VALUES (default, 'Hannah', 'Price');
|
||||
INSERT INTO vets VALUES (default, 'Dennis', 'Price');
|
||||
INSERT INTO vets VALUES (default, 'Joshua', 'Jackson');
|
||||
INSERT INTO vets VALUES (default, 'Kenneth', 'White');
|
||||
INSERT INTO vets VALUES (default, 'Mildred', 'Jones');
|
||||
INSERT INTO vets VALUES (default, 'Evelyn', 'Stewart');
|
||||
INSERT INTO vets VALUES (default, 'Jacob', 'Stewart');
|
||||
INSERT INTO vets VALUES (default, 'Douglas', 'Bryant');
|
||||
INSERT INTO vets VALUES (default, 'Walter', 'Bailey');
|
||||
INSERT INTO vets VALUES (default, 'Linda', 'Bennett');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Thomas');
|
||||
INSERT INTO vets VALUES (default, 'Rose', 'Allen');
|
||||
INSERT INTO vets VALUES (default, 'Daniel', 'White');
|
||||
INSERT INTO vets VALUES (default, 'Rebecca', 'Rogers');
|
||||
INSERT INTO vets VALUES (default, 'Melissa', 'Garcia');
|
||||
INSERT INTO vets VALUES (default, 'Jennifer', 'Phillips');
|
||||
INSERT INTO vets VALUES (default, 'Tyler', 'Bailey');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Thomas');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Gonzalez');
|
||||
INSERT INTO vets VALUES (default, 'Sandra', 'Scott');
|
||||
INSERT INTO vets VALUES (default, 'Helen', 'Ford');
|
||||
INSERT INTO vets VALUES (default, 'Helen', 'Jackson');
|
||||
INSERT INTO vets VALUES (default, 'Richard', 'Miller');
|
||||
INSERT INTO vets VALUES (default, 'Jacob', 'Brooks');
|
||||
INSERT INTO vets VALUES (default, 'Richard', 'Hill');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Bailey');
|
||||
INSERT INTO vets VALUES (default, 'Jason', 'Morgan');
|
||||
INSERT INTO vets VALUES (default, 'Laura', 'Young');
|
||||
INSERT INTO vets VALUES (default, 'Susan', 'Cooper');
|
||||
INSERT INTO vets VALUES (default, 'Gary', 'Torres');
|
||||
INSERT INTO vets VALUES (default, 'Julia', 'James');
|
||||
INSERT INTO vets VALUES (default, 'Stephanie', 'Young');
|
||||
INSERT INTO vets VALUES (default, 'Patrick', 'Hayes');
|
||||
INSERT INTO vets VALUES (default, 'Megan', 'Roberts');
|
||||
INSERT INTO vets VALUES (default, 'Stephen', 'Rivera');
|
||||
INSERT INTO vets VALUES (default, 'David', 'Thompson');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Adams');
|
||||
INSERT INTO vets VALUES (default, 'Samuel', 'Wilson');
|
||||
INSERT INTO vets VALUES (default, 'Rose', 'Edwards');
|
||||
INSERT INTO vets VALUES (default, 'Janet', 'Jones');
|
||||
INSERT INTO vets VALUES (default, 'Cheryl', 'Smith');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Roberts');
|
||||
INSERT INTO vets VALUES (default, 'Nicholas', 'Walker');
|
||||
INSERT INTO vets VALUES (default, 'Nicholas', 'Rodriguez');
|
||||
INSERT INTO vets VALUES (default, 'Carol', 'Ford');
|
||||
INSERT INTO vets VALUES (default, 'Thomas', 'Hughes');
|
||||
INSERT INTO vets VALUES (default, 'Dennis', 'Brooks');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Phillips');
|
||||
INSERT INTO vets VALUES (default, 'Timothy', 'Ford');
|
||||
INSERT INTO vets VALUES (default, 'Susan', 'Howard');
|
||||
INSERT INTO vets VALUES (default, 'Janet', 'Stewart');
|
||||
INSERT INTO vets VALUES (default, 'Helen', 'Martin');
|
||||
INSERT INTO vets VALUES (default, 'Rose', 'Jenkins');
|
||||
INSERT INTO vets VALUES (default, 'Rebecca', 'Parker');
|
||||
INSERT INTO vets VALUES (default, 'Ryan', 'Barnes');
|
||||
INSERT INTO vets VALUES (default, 'Ruth', 'Nguyen');
|
||||
INSERT INTO vets VALUES (default, 'Samantha', 'Rivera');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Roberts');
|
||||
INSERT INTO vets VALUES (default, 'Keith', 'Howard');
|
||||
INSERT INTO vets VALUES (default, 'Charles', 'Simmons');
|
||||
INSERT INTO vets VALUES (default, 'Ryan', 'Kelly');
|
||||
INSERT INTO vets VALUES (default, 'Martha', 'Campbell');
|
||||
INSERT INTO vets VALUES (default, 'Mary', 'Thompson');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Wilson');
|
||||
INSERT INTO vets VALUES (default, 'Charles', 'Russell');
|
||||
INSERT INTO vets VALUES (default, 'David', 'Rodriguez');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Watson');
|
||||
INSERT INTO vets VALUES (default, 'Margaret', 'Wright');
|
||||
INSERT INTO vets VALUES (default, 'Dennis', 'Robinson');
|
||||
INSERT INTO vets VALUES (default, 'Margaret', 'Turner');
|
||||
INSERT INTO vets VALUES (default, 'Cheryl', 'Garcia');
|
||||
INSERT INTO vets VALUES (default, 'Scott', 'Alexander');
|
||||
INSERT INTO vets VALUES (default, 'Aaron', 'Price');
|
||||
INSERT INTO vets VALUES (default, 'Patrick', 'Anderson');
|
||||
INSERT INTO vets VALUES (default, 'Justin', 'Bell');
|
||||
INSERT INTO vets VALUES (default, 'Melissa', 'Ward');
|
||||
INSERT INTO vets VALUES (default, 'Paul', 'Perry');
|
||||
INSERT INTO vets VALUES (default, 'David', 'Clark');
|
||||
INSERT INTO vets VALUES (default, 'Marie', 'Robinson');
|
||||
INSERT INTO vets VALUES (default, 'Sandra', 'Cooper');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Price');
|
||||
INSERT INTO vets VALUES (default, 'Ashley', 'Martin');
|
||||
INSERT INTO vets VALUES (default, 'Ruth', 'Jenkins');
|
||||
INSERT INTO vets VALUES (default, 'Daniel', 'Morris');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Nguyen');
|
||||
INSERT INTO vets VALUES (default, 'Charles', 'Torres');
|
||||
INSERT INTO vets VALUES (default, 'Justin', 'Griffin');
|
||||
INSERT INTO vets VALUES (default, 'Douglas', 'Jackson');
|
||||
INSERT INTO vets VALUES (default, 'Gloria', 'Henderson');
|
||||
INSERT INTO vets VALUES (default, 'Martha', 'Parker');
|
||||
INSERT INTO vets VALUES (default, 'Jean', 'Martin');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Griffin');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Wood');
|
||||
INSERT INTO vets VALUES (default, 'Gary', 'Coleman');
|
||||
INSERT INTO vets VALUES (default, 'Larry', 'Robinson');
|
||||
INSERT INTO vets VALUES (default, 'William', 'Cook');
|
||||
INSERT INTO vets VALUES (default, 'Jacob', 'Jackson');
|
||||
INSERT INTO vets VALUES (default, 'George', 'Kelly');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Perez');
|
||||
INSERT INTO vets VALUES (default, 'Margaret', 'Hall');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Ross');
|
||||
INSERT INTO vets VALUES (default, 'Adam', 'Miller');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Richardson');
|
||||
INSERT INTO vets VALUES (default, 'John', 'Thomas');
|
||||
INSERT INTO vets VALUES (default, 'Robert', 'Ross');
|
||||
INSERT INTO vets VALUES (default, 'William', 'Martin');
|
||||
INSERT INTO vets VALUES (default, 'Maria', 'Sanchez');
|
||||
INSERT INTO vets VALUES (default, 'Teresa', 'Morgan');
|
||||
INSERT INTO vets VALUES (default, 'Janet', 'Perry');
|
||||
INSERT INTO vets VALUES (default, 'Ruby', 'Rogers');
|
||||
INSERT INTO vets VALUES (default, 'Rose', 'Patterson');
|
||||
INSERT INTO vets VALUES (default, 'Alexander', 'Ramirez');
|
||||
INSERT INTO vets VALUES (default, 'Ruth', 'Ross');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Campbell');
|
||||
INSERT INTO vets VALUES (default, 'Patrick', 'Alexander');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Cox');
|
||||
INSERT INTO vets VALUES (default, 'Rebecca', 'Myers');
|
||||
INSERT INTO vets VALUES (default, 'Mildred', 'Long');
|
||||
INSERT INTO vets VALUES (default, 'Rebecca', 'Ramirez');
|
||||
INSERT INTO vets VALUES (default, 'Jeffrey', 'Butler');
|
||||
INSERT INTO vets VALUES (default, 'James', 'Walker');
|
||||
INSERT INTO vets VALUES (default, 'Melissa', 'Rodriguez');
|
||||
INSERT INTO vets VALUES (default, 'David', 'Williams');
|
||||
INSERT INTO vets VALUES (default, 'Megan', 'Henderson');
|
||||
INSERT INTO vets VALUES (default, 'Patricia', 'Phillips');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Jackson');
|
||||
INSERT INTO vets VALUES (default, 'Carol', 'Wood');
|
||||
INSERT INTO vets VALUES (default, 'Andrew', 'Wright');
|
||||
INSERT INTO vets VALUES (default, 'Anthony', 'Gonzalez');
|
||||
INSERT INTO vets VALUES (default, 'Shirley', 'Martinez');
|
||||
INSERT INTO vets VALUES (default, 'Janet', 'Foster');
|
||||
INSERT INTO vets VALUES (default, 'Justin', 'Watson');
|
||||
INSERT INTO vets VALUES (default, 'Janet', 'Thomas');
|
||||
INSERT INTO vets VALUES (default, 'Melissa', 'Taylor');
|
||||
INSERT INTO vets VALUES (default, 'Angela', 'Cook');
|
||||
INSERT INTO vets VALUES (default, 'Jeffrey', 'Perez');
|
||||
INSERT INTO vets VALUES (default, 'Matthew', 'Thomas');
|
||||
INSERT INTO vets VALUES (default, 'Joshua', 'Adams');
|
||||
INSERT INTO vets VALUES (default, 'Walter', 'Wright');
|
||||
INSERT INTO vets VALUES (default, 'Henry', 'Diaz');
|
||||
INSERT INTO vets VALUES (default, 'Melissa', 'Simmons');
|
||||
INSERT INTO vets VALUES (default, 'Mary', 'Perez');
|
||||
INSERT INTO vets VALUES (default, 'Carol', 'Collins');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'Henderson');
|
||||
INSERT INTO vets VALUES (default, 'Marie', 'Allen');
|
||||
INSERT INTO vets VALUES (default, 'Linda', 'Robinson');
|
||||
INSERT INTO vets VALUES (default, 'Samantha', 'Simmons');
|
||||
INSERT INTO vets VALUES (default, 'Jennifer', 'Peterson');
|
||||
INSERT INTO vets VALUES (default, 'Henry', 'Wright');
|
||||
INSERT INTO vets VALUES (default, 'Angela', 'Russell');
|
||||
INSERT INTO vets VALUES (default, 'Jean', 'Wilson');
|
||||
INSERT INTO vets VALUES (default, 'George', 'Clark');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Johnson');
|
||||
INSERT INTO vets VALUES (default, 'Alice', 'James');
|
||||
INSERT INTO vets VALUES (default, 'Dorothy', 'Lewis');
|
||||
INSERT INTO vets VALUES (default, 'Carolyn', 'Hayes');
|
||||
INSERT INTO vets VALUES (default, 'Lauren', 'Coleman');
|
||||
INSERT INTO vets VALUES (default, 'Evelyn', 'Ramirez');
|
||||
INSERT INTO vets VALUES (default, 'Alexander', 'Stewart');
|
||||
INSERT INTO vets VALUES (default, 'John', 'Peterson');
|
||||
INSERT INTO vets VALUES (default, 'Patrick', 'Edwards');
|
||||
INSERT INTO vets VALUES (default, 'Evelyn', 'Collins');
|
||||
INSERT INTO vets VALUES (default, 'Anthony', 'Perez');
|
||||
INSERT INTO vets VALUES (default, 'Andrew', 'Lewis');
|
||||
INSERT INTO vets VALUES (default, 'Richard', 'James');
|
||||
INSERT INTO vets VALUES (default, 'William', 'Garcia');
|
||||
INSERT INTO vets VALUES (default, 'Helen', 'Patterson');
|
||||
INSERT INTO vets VALUES (default, 'Walter', 'Lewis');
|
||||
INSERT INTO vets VALUES (default, 'Doris', 'Hill');
|
||||
INSERT INTO vets VALUES (default, 'Scott', 'Phillips');
|
||||
INSERT INTO vets VALUES (default, 'Elizabeth', 'Wood');
|
||||
INSERT INTO vets VALUES (default, 'Paul', 'Hayes');
|
||||
INSERT INTO vets VALUES (default, 'Mark', 'Howard');
|
||||
INSERT INTO vets VALUES (default, 'Barbara', 'Coleman');
|
||||
INSERT INTO vets VALUES (default, 'Andrew', 'Wood');
|
||||
INSERT INTO vets VALUES (default, 'Ruth', 'Moore');
|
||||
INSERT INTO vets VALUES (default, 'Sandra', 'Brooks');
|
||||
INSERT INTO vets VALUES (default, 'Eric', 'Garcia');
|
||||
INSERT INTO vets VALUES (default, 'Deborah', 'Ward');
|
||||
INSERT INTO vets VALUES (default, 'James', 'Davis');
|
||||
INSERT INTO vets VALUES (default, 'Samantha', 'Adams');
|
||||
INSERT INTO vets VALUES (default, 'Nicholas', 'Johnson');
|
||||
INSERT INTO vets VALUES (default, 'Joshua', 'Murphy');
|
||||
INSERT INTO vets VALUES (default, 'Rebecca', 'Flores');
|
||||
INSERT INTO vets VALUES (default, 'Emma', 'Bell');
|
||||
INSERT INTO vets VALUES (default, 'Jerry', 'Nelson');
|
||||
INSERT INTO vets VALUES (default, 'Ruth', 'Cox');
|
||||
INSERT INTO vets VALUES (default, 'Gloria', 'Powell');
|
||||
INSERT INTO vets VALUES (default, 'Shirley', 'Clark');
|
||||
INSERT INTO vets VALUES (default, 'Larry', 'Bryant');
|
||||
INSERT INTO vets VALUES (default, 'George', 'Brown');
|
||||
|
||||
INSERT INTO specialties VALUES (default, 'radiology');
|
||||
INSERT INTO specialties VALUES (default, 'surgery');
|
||||
INSERT INTO specialties VALUES (default, 'dentistry');
|
||||
|
||||
INSERT INTO vet_specialties VALUES (2, 1);
|
||||
INSERT INTO vet_specialties VALUES (3, 2);
|
||||
INSERT INTO vet_specialties VALUES (3, 3);
|
||||
INSERT INTO vet_specialties VALUES (4, 2);
|
||||
INSERT INTO vet_specialties VALUES (5, 1);
|
||||
-- First, let's make sure we have 5 specialties
|
||||
INSERT INTO specialties (name) VALUES ('radiology');
|
||||
INSERT INTO specialties (name) VALUES ('surgery');
|
||||
INSERT INTO specialties (name) VALUES ('dentistry');
|
||||
INSERT INTO specialties (name) VALUES ('cardiology');
|
||||
INSERT INTO specialties (name) VALUES ('anesthesia');
|
||||
|
||||
INSERT INTO vet_specialties VALUES ('220', '2');
|
||||
INSERT INTO vet_specialties VALUES ('131', '1');
|
||||
INSERT INTO vet_specialties VALUES ('58', '3');
|
||||
INSERT INTO vet_specialties VALUES ('43', '4');
|
||||
INSERT INTO vet_specialties VALUES ('110', '3');
|
||||
INSERT INTO vet_specialties VALUES ('63', '5');
|
||||
INSERT INTO vet_specialties VALUES ('206', '4');
|
||||
INSERT INTO vet_specialties VALUES ('29', '3');
|
||||
INSERT INTO vet_specialties VALUES ('189', '3');
|
||||
INSERT INTO vet_specialties VALUES ('202', '4');
|
||||
INSERT INTO vet_specialties VALUES ('75', '4');
|
||||
INSERT INTO vet_specialties VALUES ('156', '3');
|
||||
INSERT INTO vet_specialties VALUES ('218', '5');
|
||||
INSERT INTO vet_specialties VALUES ('152', '4');
|
||||
INSERT INTO vet_specialties VALUES ('173', '2');
|
||||
INSERT INTO vet_specialties VALUES ('251', '2');
|
||||
INSERT INTO vet_specialties VALUES ('99', '3');
|
||||
INSERT INTO vet_specialties VALUES ('157', '2');
|
||||
INSERT INTO vet_specialties VALUES ('250', '3');
|
||||
INSERT INTO vet_specialties VALUES ('37', '1');
|
||||
INSERT INTO vet_specialties VALUES ('197', '3');
|
||||
INSERT INTO vet_specialties VALUES ('121', '3');
|
||||
INSERT INTO vet_specialties VALUES ('176', '1');
|
||||
INSERT INTO vet_specialties VALUES ('72', '3');
|
||||
INSERT INTO vet_specialties VALUES ('160', '1');
|
||||
INSERT INTO vet_specialties VALUES ('56', '5');
|
||||
INSERT INTO vet_specialties VALUES ('248', '4');
|
||||
INSERT INTO vet_specialties VALUES ('49', '5');
|
||||
INSERT INTO vet_specialties VALUES ('61', '5');
|
||||
INSERT INTO vet_specialties VALUES ('29', '4');
|
||||
INSERT INTO vet_specialties VALUES ('238', '2');
|
||||
INSERT INTO vet_specialties VALUES ('176', '4');
|
||||
INSERT INTO vet_specialties VALUES ('46', '4');
|
||||
INSERT INTO vet_specialties VALUES ('189', '5');
|
||||
INSERT INTO vet_specialties VALUES ('56', '2');
|
||||
INSERT INTO vet_specialties VALUES ('200', '5');
|
||||
INSERT INTO vet_specialties VALUES ('70', '3');
|
||||
INSERT INTO vet_specialties VALUES ('213', '5');
|
||||
INSERT INTO vet_specialties VALUES ('106', '2');
|
||||
INSERT INTO vet_specialties VALUES ('219', '2');
|
||||
INSERT INTO vet_specialties VALUES ('81', '3');
|
||||
INSERT INTO vet_specialties VALUES ('126', '5');
|
||||
INSERT INTO vet_specialties VALUES ('255', '2');
|
||||
INSERT INTO vet_specialties VALUES ('175', '4');
|
||||
INSERT INTO vet_specialties VALUES ('71', '2');
|
||||
INSERT INTO vet_specialties VALUES ('206', '1');
|
||||
INSERT INTO vet_specialties VALUES ('85', '2');
|
||||
INSERT INTO vet_specialties VALUES ('177', '1');
|
||||
INSERT INTO vet_specialties VALUES ('118', '2');
|
||||
INSERT INTO vet_specialties VALUES ('256', '4');
|
||||
INSERT INTO vet_specialties VALUES ('136', '3');
|
||||
INSERT INTO vet_specialties VALUES ('44', '5');
|
||||
INSERT INTO vet_specialties VALUES ('236', '4');
|
||||
INSERT INTO vet_specialties VALUES ('2', '5');
|
||||
INSERT INTO vet_specialties VALUES ('88', '1');
|
||||
INSERT INTO vet_specialties VALUES ('86', '1');
|
||||
INSERT INTO vet_specialties VALUES ('155', '2');
|
||||
INSERT INTO vet_specialties VALUES ('122', '5');
|
||||
INSERT INTO vet_specialties VALUES ('61', '3');
|
||||
INSERT INTO vet_specialties VALUES ('24', '5');
|
||||
INSERT INTO vet_specialties VALUES ('14', '4');
|
||||
INSERT INTO vet_specialties VALUES ('159', '2');
|
||||
INSERT INTO vet_specialties VALUES ('67', '4');
|
||||
INSERT INTO vet_specialties VALUES ('182', '2');
|
||||
INSERT INTO vet_specialties VALUES ('10', '1');
|
||||
INSERT INTO vet_specialties VALUES ('174', '4');
|
||||
INSERT INTO vet_specialties VALUES ('166', '5');
|
||||
INSERT INTO vet_specialties VALUES ('91', '3');
|
||||
INSERT INTO vet_specialties VALUES ('244', '5');
|
||||
INSERT INTO vet_specialties VALUES ('135', '2');
|
||||
INSERT INTO vet_specialties VALUES ('222', '1');
|
||||
INSERT INTO vet_specialties VALUES ('151', '3');
|
||||
INSERT INTO vet_specialties VALUES ('79', '4');
|
||||
INSERT INTO vet_specialties VALUES ('182', '3');
|
||||
INSERT INTO vet_specialties VALUES ('249', '1');
|
||||
INSERT INTO vet_specialties VALUES ('133', '1');
|
||||
INSERT INTO vet_specialties VALUES ('127', '4');
|
||||
INSERT INTO vet_specialties VALUES ('123', '5');
|
||||
INSERT INTO vet_specialties VALUES ('248', '5');
|
||||
INSERT INTO vet_specialties VALUES ('99', '1');
|
||||
INSERT INTO vet_specialties VALUES ('252', '5');
|
||||
INSERT INTO vet_specialties VALUES ('221', '1');
|
||||
INSERT INTO vet_specialties VALUES ('123', '2');
|
||||
INSERT INTO vet_specialties VALUES ('16', '3');
|
||||
INSERT INTO vet_specialties VALUES ('180', '2');
|
||||
INSERT INTO vet_specialties VALUES ('198', '3');
|
||||
INSERT INTO vet_specialties VALUES ('214', '3');
|
||||
INSERT INTO vet_specialties VALUES ('144', '2');
|
||||
INSERT INTO vet_specialties VALUES ('140', '4');
|
||||
INSERT INTO vet_specialties VALUES ('233', '2');
|
||||
INSERT INTO vet_specialties VALUES ('87', '5');
|
||||
INSERT INTO vet_specialties VALUES ('12', '4');
|
||||
INSERT INTO vet_specialties VALUES ('2', '3');
|
||||
INSERT INTO vet_specialties VALUES ('156', '4');
|
||||
INSERT INTO vet_specialties VALUES ('105', '4');
|
||||
INSERT INTO vet_specialties VALUES ('144', '3');
|
||||
INSERT INTO vet_specialties VALUES ('31', '2');
|
||||
INSERT INTO vet_specialties VALUES ('228', '5');
|
||||
INSERT INTO vet_specialties VALUES ('232', '3');
|
||||
INSERT INTO vet_specialties VALUES ('33', '1');
|
||||
INSERT INTO vet_specialties VALUES ('195', '2');
|
||||
INSERT INTO vet_specialties VALUES ('12', '1');
|
||||
INSERT INTO vet_specialties VALUES ('180', '1');
|
||||
INSERT INTO vet_specialties VALUES ('122', '2');
|
||||
INSERT INTO vet_specialties VALUES ('101', '1');
|
||||
INSERT INTO vet_specialties VALUES ('211', '2');
|
||||
INSERT INTO vet_specialties VALUES ('175', '2');
|
||||
INSERT INTO vet_specialties VALUES ('246', '1');
|
||||
INSERT INTO vet_specialties VALUES ('251', '4');
|
||||
INSERT INTO vet_specialties VALUES ('13', '4');
|
||||
INSERT INTO vet_specialties VALUES ('217', '2');
|
||||
INSERT INTO vet_specialties VALUES ('171', '3');
|
||||
INSERT INTO vet_specialties VALUES ('125', '5');
|
||||
INSERT INTO vet_specialties VALUES ('129', '3');
|
||||
INSERT INTO vet_specialties VALUES ('217', '3');
|
||||
INSERT INTO vet_specialties VALUES ('68', '4');
|
||||
INSERT INTO vet_specialties VALUES ('13', '2');
|
||||
INSERT INTO vet_specialties VALUES ('214', '2');
|
||||
INSERT INTO vet_specialties VALUES ('128', '1');
|
||||
INSERT INTO vet_specialties VALUES ('253', '2');
|
||||
INSERT INTO vet_specialties VALUES ('36', '1');
|
||||
INSERT INTO vet_specialties VALUES ('210', '2');
|
||||
INSERT INTO vet_specialties VALUES ('81', '5');
|
||||
INSERT INTO vet_specialties VALUES ('237', '5');
|
||||
INSERT INTO vet_specialties VALUES ('78', '3');
|
||||
INSERT INTO vet_specialties VALUES ('244', '1');
|
||||
INSERT INTO vet_specialties VALUES ('37', '4');
|
||||
INSERT INTO vet_specialties VALUES ('230', '2');
|
||||
INSERT INTO vet_specialties VALUES ('9', '3');
|
||||
INSERT INTO vet_specialties VALUES ('249', '5');
|
||||
INSERT INTO vet_specialties VALUES ('210', '5');
|
||||
INSERT INTO vet_specialties VALUES ('33', '5');
|
||||
INSERT INTO vet_specialties VALUES ('177', '2');
|
||||
INSERT INTO vet_specialties VALUES ('92', '3');
|
||||
INSERT INTO vet_specialties VALUES ('18', '5');
|
||||
INSERT INTO vet_specialties VALUES ('82', '4');
|
||||
INSERT INTO vet_specialties VALUES ('185', '1');
|
||||
INSERT INTO vet_specialties VALUES ('70', '1');
|
||||
INSERT INTO vet_specialties VALUES ('146', '2');
|
||||
INSERT INTO vet_specialties VALUES ('60', '2');
|
||||
INSERT INTO vet_specialties VALUES ('157', '4');
|
||||
INSERT INTO vet_specialties VALUES ('43', '1');
|
||||
INSERT INTO vet_specialties VALUES ('124', '4');
|
||||
INSERT INTO vet_specialties VALUES ('185', '2');
|
||||
INSERT INTO vet_specialties VALUES ('92', '2');
|
||||
INSERT INTO vet_specialties VALUES ('152', '5');
|
||||
INSERT INTO vet_specialties VALUES ('161', '3');
|
||||
INSERT INTO vet_specialties VALUES ('178', '3');
|
||||
INSERT INTO vet_specialties VALUES ('53', '2');
|
||||
INSERT INTO vet_specialties VALUES ('93', '5');
|
||||
INSERT INTO vet_specialties VALUES ('168', '2');
|
||||
INSERT INTO vet_specialties VALUES ('19', '4');
|
||||
INSERT INTO vet_specialties VALUES ('158', '2');
|
||||
INSERT INTO vet_specialties VALUES ('240', '4');
|
||||
INSERT INTO vet_specialties VALUES ('246', '5');
|
||||
INSERT INTO vet_specialties VALUES ('166', '4');
|
||||
INSERT INTO vet_specialties VALUES ('134', '5');
|
||||
INSERT INTO vet_specialties VALUES ('151', '4');
|
||||
INSERT INTO vet_specialties VALUES ('113', '1');
|
||||
INSERT INTO vet_specialties VALUES ('114', '4');
|
||||
INSERT INTO vet_specialties VALUES ('107', '3');
|
||||
INSERT INTO vet_specialties VALUES ('200', '2');
|
||||
INSERT INTO vet_specialties VALUES ('17', '4');
|
||||
INSERT INTO vet_specialties VALUES ('140', '5');
|
||||
INSERT INTO vet_specialties VALUES ('196', '2');
|
||||
INSERT INTO vet_specialties VALUES ('108', '1');
|
||||
INSERT INTO vet_specialties VALUES ('102', '3');
|
||||
INSERT INTO vet_specialties VALUES ('83', '4');
|
||||
INSERT INTO vet_specialties VALUES ('79', '1');
|
||||
INSERT INTO vet_specialties VALUES ('91', '4');
|
||||
INSERT INTO vet_specialties VALUES ('30', '4');
|
||||
INSERT INTO vet_specialties VALUES ('165', '3');
|
||||
INSERT INTO vet_specialties VALUES ('34', '1');
|
||||
INSERT INTO vet_specialties VALUES ('204', '4');
|
||||
INSERT INTO vet_specialties VALUES ('30', '5');
|
||||
INSERT INTO vet_specialties VALUES ('84', '5');
|
||||
INSERT INTO vet_specialties VALUES ('187', '5');
|
||||
INSERT INTO vet_specialties VALUES ('127', '1');
|
||||
INSERT INTO vet_specialties VALUES ('229', '5');
|
||||
INSERT INTO vet_specialties VALUES ('71', '1');
|
||||
INSERT INTO vet_specialties VALUES ('253', '3');
|
||||
INSERT INTO vet_specialties VALUES ('102', '1');
|
||||
INSERT INTO vet_specialties VALUES ('195', '1');
|
||||
INSERT INTO vet_specialties VALUES ('149', '3');
|
||||
INSERT INTO vet_specialties VALUES ('238', '5');
|
||||
INSERT INTO vet_specialties VALUES ('113', '3');
|
||||
INSERT INTO vet_specialties VALUES ('105', '1');
|
||||
INSERT INTO vet_specialties VALUES ('111', '2');
|
||||
INSERT INTO vet_specialties VALUES ('20', '1');
|
||||
INSERT INTO vet_specialties VALUES ('52', '4');
|
||||
INSERT INTO vet_specialties VALUES ('226', '5');
|
||||
INSERT INTO vet_specialties VALUES ('216', '1');
|
||||
INSERT INTO vet_specialties VALUES ('136', '5');
|
||||
INSERT INTO vet_specialties VALUES ('250', '2');
|
||||
INSERT INTO vet_specialties VALUES ('229', '2');
|
||||
INSERT INTO vet_specialties VALUES ('198', '4');
|
||||
INSERT INTO vet_specialties VALUES ('73', '1');
|
||||
INSERT INTO vet_specialties VALUES ('128', '4');
|
||||
INSERT INTO vet_specialties VALUES ('161', '4');
|
||||
INSERT INTO vet_specialties VALUES ('111', '1');
|
||||
INSERT INTO vet_specialties VALUES ('146', '1');
|
||||
INSERT INTO vet_specialties VALUES ('60', '5');
|
||||
INSERT INTO vet_specialties VALUES ('235', '5');
|
||||
INSERT INTO vet_specialties VALUES ('174', '2');
|
||||
INSERT INTO vet_specialties VALUES ('225', '5');
|
||||
INSERT INTO vet_specialties VALUES ('224', '1');
|
||||
INSERT INTO vet_specialties VALUES ('256', '1');
|
||||
INSERT INTO vet_specialties VALUES ('132', '3');
|
||||
INSERT INTO vet_specialties VALUES ('211', '4');
|
||||
INSERT INTO vet_specialties VALUES ('104', '4');
|
||||
INSERT INTO vet_specialties VALUES ('112', '3');
|
||||
INSERT INTO vet_specialties VALUES ('213', '1');
|
||||
INSERT INTO vet_specialties VALUES ('108', '5');
|
||||
INSERT INTO vet_specialties VALUES ('143', '2');
|
||||
INSERT INTO vet_specialties VALUES ('141', '5');
|
||||
INSERT INTO vet_specialties VALUES ('159', '1');
|
||||
INSERT INTO vet_specialties VALUES ('228', '3');
|
||||
INSERT INTO vet_specialties VALUES ('75', '5');
|
||||
INSERT INTO vet_specialties VALUES ('36', '5');
|
||||
INSERT INTO vet_specialties VALUES ('237', '1');
|
||||
INSERT INTO vet_specialties VALUES ('83', '5');
|
||||
INSERT INTO vet_specialties VALUES ('124', '1');
|
||||
INSERT INTO vet_specialties VALUES ('133', '2');
|
||||
INSERT INTO vet_specialties VALUES ('121', '5');
|
||||
INSERT INTO vet_specialties VALUES ('240', '5');
|
||||
INSERT INTO vet_specialties VALUES ('142', '3');
|
||||
INSERT INTO vet_specialties VALUES ('193', '3');
|
||||
INSERT INTO vet_specialties VALUES ('252', '3');
|
||||
INSERT INTO vet_specialties VALUES ('118', '4');
|
||||
INSERT INTO vet_specialties VALUES ('26', '3');
|
||||
INSERT INTO vet_specialties VALUES ('197', '2');
|
||||
INSERT INTO vet_specialties VALUES ('17', '2');
|
||||
INSERT INTO vet_specialties VALUES ('78', '2');
|
||||
INSERT INTO vet_specialties VALUES ('26', '5');
|
||||
INSERT INTO vet_specialties VALUES ('196', '1');
|
||||
INSERT INTO vet_specialties VALUES ('141', '2');
|
||||
INSERT INTO vet_specialties VALUES ('224', '2');
|
||||
INSERT INTO vet_specialties VALUES ('223', '5');
|
||||
INSERT INTO vet_specialties VALUES ('170', '3');
|
||||
INSERT INTO vet_specialties VALUES ('9', '2');
|
||||
INSERT INTO vet_specialties VALUES ('94', '1');
|
||||
INSERT INTO vet_specialties VALUES ('230', '3');
|
||||
INSERT INTO vet_specialties VALUES ('131', '5');
|
||||
INSERT INTO vet_specialties VALUES ('117', '3');
|
||||
INSERT INTO vet_specialties VALUES ('223', '4');
|
||||
INSERT INTO vet_specialties VALUES ('236', '2');
|
||||
INSERT INTO vet_specialties VALUES ('97', '2');
|
||||
INSERT INTO vet_specialties VALUES ('143', '1');
|
||||
INSERT INTO vet_specialties VALUES ('173', '1');
|
||||
INSERT INTO vet_specialties VALUES ('132', '5');
|
||||
INSERT INTO vet_specialties VALUES ('138', '1');
|
||||
INSERT INTO vet_specialties VALUES ('80', '5');
|
||||
INSERT INTO vet_specialties VALUES ('6', '5');
|
||||
INSERT INTO vet_specialties VALUES ('216', '3');
|
||||
INSERT INTO vet_specialties VALUES ('135', '5');
|
||||
INSERT INTO vet_specialties VALUES ('160', '3');
|
||||
INSERT INTO vet_specialties VALUES ('97', '4');
|
||||
|
||||
|
||||
INSERT INTO types VALUES (default, 'cat');
|
||||
INSERT INTO types VALUES (default, 'dog');
|
||||
|
@ -51,3 +558,5 @@ INSERT INTO visits VALUES (default, 7, '2013-01-01', 'rabies shot');
|
|||
INSERT INTO visits VALUES (default, 8, '2013-01-02', 'rabies shot');
|
||||
INSERT INTO visits VALUES (default, 8, '2013-01-03', 'neutered');
|
||||
INSERT INTO visits VALUES (default, 7, '2013-01-04', 'spayed');
|
||||
|
||||
|
||||
|
|
262
src/main/resources/db/h2/generate_records.sql
Normal file
262
src/main/resources/db/h2/generate_records.sql
Normal file
|
@ -0,0 +1,262 @@
|
|||
-- Create a list of first names and last names
|
||||
WITH first_names AS (
|
||||
SELECT 'James' AS name UNION ALL
|
||||
SELECT 'Mary' UNION ALL
|
||||
SELECT 'John' UNION ALL
|
||||
SELECT 'Patricia' UNION ALL
|
||||
SELECT 'Robert' UNION ALL
|
||||
SELECT 'Linda' UNION ALL
|
||||
SELECT 'Michael' UNION ALL
|
||||
SELECT 'Barbara' UNION ALL
|
||||
SELECT 'William' UNION ALL
|
||||
SELECT 'Elizabeth' UNION ALL
|
||||
SELECT 'David' UNION ALL
|
||||
SELECT 'Jennifer' UNION ALL
|
||||
SELECT 'Richard' UNION ALL
|
||||
SELECT 'Maria' UNION ALL
|
||||
SELECT 'Charles' UNION ALL
|
||||
SELECT 'Susan' UNION ALL
|
||||
SELECT 'Joseph' UNION ALL
|
||||
SELECT 'Margaret' UNION ALL
|
||||
SELECT 'Thomas' UNION ALL
|
||||
SELECT 'Dorothy' UNION ALL
|
||||
SELECT 'Daniel' UNION ALL
|
||||
SELECT 'Helen' UNION ALL
|
||||
SELECT 'Matthew' UNION ALL
|
||||
SELECT 'Sandra' UNION ALL
|
||||
SELECT 'Anthony' UNION ALL
|
||||
SELECT 'Ashley' UNION ALL
|
||||
SELECT 'Mark' UNION ALL
|
||||
SELECT 'Donna' UNION ALL
|
||||
SELECT 'Paul' UNION ALL
|
||||
SELECT 'Carol' UNION ALL
|
||||
SELECT 'Andrew' UNION ALL
|
||||
SELECT 'Ruth' UNION ALL
|
||||
SELECT 'Joshua' UNION ALL
|
||||
SELECT 'Shirley' UNION ALL
|
||||
SELECT 'Kenneth' UNION ALL
|
||||
SELECT 'Angela' UNION ALL
|
||||
SELECT 'Kevin' UNION ALL
|
||||
SELECT 'Melissa' UNION ALL
|
||||
SELECT 'Brian' UNION ALL
|
||||
SELECT 'Deborah' UNION ALL
|
||||
SELECT 'George' UNION ALL
|
||||
SELECT 'Stephanie' UNION ALL
|
||||
SELECT 'Edward' UNION ALL
|
||||
SELECT 'Rebecca' UNION ALL
|
||||
SELECT 'Ronald' UNION ALL
|
||||
SELECT 'Laura' UNION ALL
|
||||
SELECT 'Timothy' UNION ALL
|
||||
SELECT 'Helen' UNION ALL
|
||||
SELECT 'Jason' UNION ALL
|
||||
SELECT 'Alice' UNION ALL
|
||||
SELECT 'Jeffrey' UNION ALL
|
||||
SELECT 'Judith' UNION ALL
|
||||
SELECT 'Ryan' UNION ALL
|
||||
SELECT 'Jacqueline' UNION ALL
|
||||
SELECT 'Jacob' UNION ALL
|
||||
SELECT 'Frances' UNION ALL
|
||||
SELECT 'Gary' UNION ALL
|
||||
SELECT 'Martha' UNION ALL
|
||||
SELECT 'Nicholas' UNION ALL
|
||||
SELECT 'Teresa' UNION ALL
|
||||
SELECT 'Eric' UNION ALL
|
||||
SELECT 'Doris' UNION ALL
|
||||
SELECT 'Stephen' UNION ALL
|
||||
SELECT 'Gloria' UNION ALL
|
||||
SELECT 'Larry' UNION ALL
|
||||
SELECT 'Evelyn' UNION ALL
|
||||
SELECT 'Justin' UNION ALL
|
||||
SELECT 'Jean' UNION ALL
|
||||
SELECT 'Scott' UNION ALL
|
||||
SELECT 'Cheryl' UNION ALL
|
||||
SELECT 'Brandon' UNION ALL
|
||||
SELECT 'Mildred' UNION ALL
|
||||
SELECT 'Benjamin' UNION ALL
|
||||
SELECT 'Katherine' UNION ALL
|
||||
SELECT 'Adam' UNION ALL
|
||||
SELECT 'Samantha' UNION ALL
|
||||
SELECT 'Samuel' UNION ALL
|
||||
SELECT 'Janet' UNION ALL
|
||||
SELECT 'Alexander' UNION ALL
|
||||
SELECT 'Megan' UNION ALL
|
||||
SELECT 'Patrick' UNION ALL
|
||||
SELECT 'Carolyn' UNION ALL
|
||||
SELECT 'Jack' UNION ALL
|
||||
SELECT 'Hannah' UNION ALL
|
||||
SELECT 'Dennis' UNION ALL
|
||||
SELECT 'Christine' UNION ALL
|
||||
SELECT 'Jerry' UNION ALL
|
||||
SELECT 'Emma' UNION ALL
|
||||
SELECT 'Tyler' UNION ALL
|
||||
SELECT 'Lauren' UNION ALL
|
||||
SELECT 'Aaron' UNION ALL
|
||||
SELECT 'Alice' UNION ALL
|
||||
SELECT 'Henry' UNION ALL
|
||||
SELECT 'Julia' UNION ALL
|
||||
SELECT 'Douglas' UNION ALL
|
||||
SELECT 'Marie' UNION ALL
|
||||
SELECT 'Keith' UNION ALL
|
||||
SELECT 'Ruby' UNION ALL
|
||||
SELECT 'Walter' UNION ALL
|
||||
SELECT 'Rose'
|
||||
),
|
||||
last_names AS (
|
||||
SELECT 'Smith' AS name UNION ALL
|
||||
SELECT 'Johnson' UNION ALL
|
||||
SELECT 'Williams' UNION ALL
|
||||
SELECT 'Jones' UNION ALL
|
||||
SELECT 'Brown' UNION ALL
|
||||
SELECT 'Davis' UNION ALL
|
||||
SELECT 'Miller' UNION ALL
|
||||
SELECT 'Wilson' UNION ALL
|
||||
SELECT 'Moore' UNION ALL
|
||||
SELECT 'Taylor' UNION ALL
|
||||
SELECT 'Anderson' UNION ALL
|
||||
SELECT 'Thomas' UNION ALL
|
||||
SELECT 'Jackson' UNION ALL
|
||||
SELECT 'White' UNION ALL
|
||||
SELECT 'Harris' UNION ALL
|
||||
SELECT 'Martin' UNION ALL
|
||||
SELECT 'Thompson' UNION ALL
|
||||
SELECT 'Garcia' UNION ALL
|
||||
SELECT 'Martinez' UNION ALL
|
||||
SELECT 'Robinson' UNION ALL
|
||||
SELECT 'Clark' UNION ALL
|
||||
SELECT 'Rodriguez' UNION ALL
|
||||
SELECT 'Lewis' UNION ALL
|
||||
SELECT 'Lee' UNION ALL
|
||||
SELECT 'Walker' UNION ALL
|
||||
SELECT 'Hall' UNION ALL
|
||||
SELECT 'Allen' UNION ALL
|
||||
SELECT 'Young' UNION ALL
|
||||
SELECT 'King' UNION ALL
|
||||
SELECT 'Wright' UNION ALL
|
||||
SELECT 'Scott' UNION ALL
|
||||
SELECT 'Torres' UNION ALL
|
||||
SELECT 'Nguyen' UNION ALL
|
||||
SELECT 'Hill' UNION ALL
|
||||
SELECT 'Adams' UNION ALL
|
||||
SELECT 'Baker' UNION ALL
|
||||
SELECT 'Nelson' UNION ALL
|
||||
SELECT 'Carter' UNION ALL
|
||||
SELECT 'Mitchell' UNION ALL
|
||||
SELECT 'Perez' UNION ALL
|
||||
SELECT 'Roberts' UNION ALL
|
||||
SELECT 'Turner' UNION ALL
|
||||
SELECT 'Phillips' UNION ALL
|
||||
SELECT 'Campbell' UNION ALL
|
||||
SELECT 'Parker' UNION ALL
|
||||
SELECT 'Evans' UNION ALL
|
||||
SELECT 'Edwards' UNION ALL
|
||||
SELECT 'Collins' UNION ALL
|
||||
SELECT 'Stewart' UNION ALL
|
||||
SELECT 'Sanchez' UNION ALL
|
||||
SELECT 'Morris' UNION ALL
|
||||
SELECT 'Rogers' UNION ALL
|
||||
SELECT 'Reed' UNION ALL
|
||||
SELECT 'Cook' UNION ALL
|
||||
SELECT 'Morgan' UNION ALL
|
||||
SELECT 'Bell' UNION ALL
|
||||
SELECT 'Murphy' UNION ALL
|
||||
SELECT 'Bailey' UNION ALL
|
||||
SELECT 'Rivera' UNION ALL
|
||||
SELECT 'Cooper' UNION ALL
|
||||
SELECT 'Richardson' UNION ALL
|
||||
SELECT 'Cox' UNION ALL
|
||||
SELECT 'Howard' UNION ALL
|
||||
SELECT 'Ward' UNION ALL
|
||||
SELECT 'Torres' UNION ALL
|
||||
SELECT 'Peterson' UNION ALL
|
||||
SELECT 'Gray' UNION ALL
|
||||
SELECT 'Ramirez' UNION ALL
|
||||
SELECT 'James' UNION ALL
|
||||
SELECT 'Watson' UNION ALL
|
||||
SELECT 'Brooks' UNION ALL
|
||||
SELECT 'Kelly' UNION ALL
|
||||
SELECT 'Sanders' UNION ALL
|
||||
SELECT 'Price' UNION ALL
|
||||
SELECT 'Bennett' UNION ALL
|
||||
SELECT 'Wood' UNION ALL
|
||||
SELECT 'Barnes' UNION ALL
|
||||
SELECT 'Ross' UNION ALL
|
||||
SELECT 'Henderson' UNION ALL
|
||||
SELECT 'Coleman' UNION ALL
|
||||
SELECT 'Jenkins' UNION ALL
|
||||
SELECT 'Perry' UNION ALL
|
||||
SELECT 'Powell' UNION ALL
|
||||
SELECT 'Long' UNION ALL
|
||||
SELECT 'Patterson' UNION ALL
|
||||
SELECT 'Hughes' UNION ALL
|
||||
SELECT 'Flores' UNION ALL
|
||||
SELECT 'Washington' UNION ALL
|
||||
SELECT 'Butler' UNION ALL
|
||||
SELECT 'Simmons' UNION ALL
|
||||
SELECT 'Foster' UNION ALL
|
||||
SELECT 'Gonzalez' UNION ALL
|
||||
SELECT 'Bryant' UNION ALL
|
||||
SELECT 'Alexander' UNION ALL
|
||||
SELECT 'Russell' UNION ALL
|
||||
SELECT 'Griffin' UNION ALL
|
||||
SELECT 'Diaz' UNION ALL
|
||||
SELECT 'Hayes' UNION ALL
|
||||
SELECT 'Myers' UNION ALL
|
||||
SELECT 'Ford'
|
||||
),
|
||||
random_names AS (
|
||||
SELECT
|
||||
first_names.name AS first_name,
|
||||
last_names.name AS last_name
|
||||
FROM
|
||||
first_names
|
||||
CROSS JOIN
|
||||
last_names
|
||||
ORDER BY
|
||||
RAND()
|
||||
LIMIT 250
|
||||
)
|
||||
INSERT INTO vets (first_name, last_name)
|
||||
SELECT first_name, last_name FROM random_names;
|
||||
|
||||
|
||||
|
||||
|
||||
-- Add specialties for 80% of the vets
|
||||
WITH vet_ids AS (
|
||||
SELECT id
|
||||
FROM vets
|
||||
ORDER BY RAND()
|
||||
LIMIT 200 -- 80% of 1000
|
||||
),
|
||||
specialties AS (
|
||||
SELECT id
|
||||
FROM specialties
|
||||
),
|
||||
random_specialties AS (
|
||||
SELECT
|
||||
vet_ids.id AS vet_id,
|
||||
specialties.id AS specialty_id
|
||||
FROM
|
||||
vet_ids
|
||||
CROSS JOIN
|
||||
specialties
|
||||
ORDER BY
|
||||
RAND()
|
||||
LIMIT 300 -- 2 specialties per vet on average
|
||||
)
|
||||
INSERT INTO vet_specialties (vet_id, specialty_id)
|
||||
SELECT
|
||||
vet_id,
|
||||
specialty_id
|
||||
FROM (
|
||||
SELECT
|
||||
vet_id,
|
||||
specialty_id,
|
||||
ROW_NUMBER() OVER (PARTITION BY vet_id ORDER BY RAND()) AS rn
|
||||
FROM
|
||||
random_specialties
|
||||
) tmp
|
||||
WHERE
|
||||
rn <= 2; -- Assign at most 2 specialties per vet
|
||||
|
||||
-- The remaining 20% of vets will have no specialties, so no need for additional insertion commands
|
|
@ -9387,6 +9387,99 @@ table td.action-column {
|
|||
hr {
|
||||
border-top: 1px dotted #34302D; }
|
||||
|
||||
/* Chatbox container */
|
||||
.chatbox {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
width: 300px;
|
||||
background-color: #f1f1f1;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
flex-direction: column; }
|
||||
.chatbox.minimized .chatbox-content {
|
||||
height: 40px;
|
||||
/* Height when minimized (header only) */ }
|
||||
.chatbox.minimized .chatbox-messages,
|
||||
.chatbox.minimized .chatbox-footer {
|
||||
display: none; }
|
||||
|
||||
/* Header styling */
|
||||
.chatbox-header {
|
||||
background-color: #075E54;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
cursor: pointer; }
|
||||
|
||||
/* Chatbox content styling */
|
||||
.chatbox-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 400px;
|
||||
/* Adjust to desired height */
|
||||
overflow: hidden;
|
||||
/* Hide overflow to make it scrollable */ }
|
||||
|
||||
.chatbox-messages {
|
||||
flex-grow: 1;
|
||||
overflow-y: auto;
|
||||
/* Allows vertical scrolling */
|
||||
padding: 10px; }
|
||||
|
||||
/* Chat bubbles styling */
|
||||
.chat-bubble {
|
||||
max-width: 80%;
|
||||
padding: 10px;
|
||||
border-radius: 20px;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
word-wrap: break-word;
|
||||
font-size: 14px; }
|
||||
.chat-bubble strong {
|
||||
font-weight: bold; }
|
||||
.chat-bubble em {
|
||||
font-style: italic; }
|
||||
.chat-bubble.user {
|
||||
background-color: #dcf8c6;
|
||||
/* WhatsApp-style light green */
|
||||
margin-left: auto;
|
||||
text-align: right;
|
||||
border-bottom-right-radius: 0; }
|
||||
.chat-bubble.bot {
|
||||
background-color: #ffffff;
|
||||
margin-right: auto;
|
||||
text-align: left;
|
||||
border-bottom-left-radius: 0;
|
||||
border: 1px solid #e1e1e1; }
|
||||
|
||||
/* Input field and button */
|
||||
.chatbox-footer {
|
||||
padding: 10px;
|
||||
background-color: #f9f9f9;
|
||||
display: flex; }
|
||||
|
||||
.chatbox-footer input {
|
||||
flex-grow: 1;
|
||||
padding: 10px;
|
||||
border-radius: 20px;
|
||||
border: 1px solid #ccc;
|
||||
margin-right: 10px;
|
||||
outline: none; }
|
||||
|
||||
.chatbox-footer button {
|
||||
background-color: #075E54;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
border-radius: 50%;
|
||||
cursor: pointer; }
|
||||
.chatbox-footer button:hover {
|
||||
background-color: #128C7E; }
|
||||
|
||||
@font-face {
|
||||
font-family: 'varela_roundregular';
|
||||
src: url("../fonts/varela_round-webfont.eot");
|
||||
|
|
1794
src/main/resources/vectorstore.json
Normal file
1794
src/main/resources/vectorstore.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -21,6 +21,20 @@ $spring-brown: #34302D;
|
|||
$spring-grey: #838789;
|
||||
$spring-light-grey: #f1f1f1;
|
||||
|
||||
$chatbox-bg-color: #f1f1f1;
|
||||
$chatbox-header-bg-color: #075E54;
|
||||
$chatbox-header-text-color: white;
|
||||
$chatbox-height: 400px;
|
||||
$chatbox-border-radius: 10px;
|
||||
$chatbox-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
||||
$chatbox-bubble-user-bg-color: #dcf8c6;
|
||||
$chatbox-bubble-bot-bg-color: #ffffff;
|
||||
$chatbox-bubble-border-color: #e1e1e1;
|
||||
$chatbox-footer-bg-color: #f9f9f9;
|
||||
$chatbox-input-border-color: #ccc;
|
||||
$chatbox-button-bg-color: #075E54;
|
||||
$chatbox-button-hover-bg-color: #128C7E;
|
||||
|
||||
$body-bg: $spring-light-grey;
|
||||
$text-color: $spring-brown;
|
||||
$link-color: $spring-dark-green;
|
||||
|
@ -209,6 +223,117 @@ hr {
|
|||
border-top: 1px dotted $spring-brown;
|
||||
}
|
||||
|
||||
/* Chatbox container */
|
||||
.chatbox {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
width: 300px;
|
||||
background-color: $chatbox-bg-color;
|
||||
border-radius: $chatbox-border-radius;
|
||||
box-shadow: $chatbox-box-shadow;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&.minimized {
|
||||
.chatbox-content {
|
||||
height: 40px; /* Height when minimized (header only) */
|
||||
}
|
||||
.chatbox-messages,
|
||||
.chatbox-footer {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Header styling */
|
||||
.chatbox-header {
|
||||
background-color: $chatbox-header-bg-color;
|
||||
color: $chatbox-header-text-color;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
border-top-left-radius: $chatbox-border-radius;
|
||||
border-top-right-radius: $chatbox-border-radius;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Chatbox content styling */
|
||||
.chatbox-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: $chatbox-height; /* Adjust to desired height */
|
||||
overflow: hidden; /* Hide overflow to make it scrollable */
|
||||
}
|
||||
|
||||
.chatbox-messages {
|
||||
flex-grow: 1;
|
||||
overflow-y: auto; /* Allows vertical scrolling */
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Chat bubbles styling */
|
||||
.chat-bubble {
|
||||
max-width: 80%;
|
||||
padding: 10px;
|
||||
border-radius: 20px;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
word-wrap: break-word;
|
||||
font-size: 14px;
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
&.user {
|
||||
background-color: $chatbox-bubble-user-bg-color; /* WhatsApp-style light green */
|
||||
margin-left: auto;
|
||||
text-align: right;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
&.bot {
|
||||
background-color: $chatbox-bubble-bot-bg-color;
|
||||
margin-right: auto;
|
||||
text-align: left;
|
||||
border-bottom-left-radius: 0;
|
||||
border: 1px solid $chatbox-bubble-border-color;
|
||||
}
|
||||
}
|
||||
|
||||
/* Input field and button */
|
||||
.chatbox-footer {
|
||||
padding: 10px;
|
||||
background-color: $chatbox-footer-bg-color;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.chatbox-footer input {
|
||||
flex-grow: 1;
|
||||
padding: 10px;
|
||||
border-radius: 20px;
|
||||
border: 1px solid $chatbox-input-border-color;
|
||||
margin-right: 10px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.chatbox-footer button {
|
||||
background-color: $chatbox-button-bg-color;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background-color: $chatbox-button-hover-bg-color;
|
||||
}
|
||||
}
|
||||
|
||||
@import "typography.scss";
|
||||
@import "header.scss";
|
||||
@import "responsive.scss";
|
||||
|
|
|
@ -82,11 +82,15 @@ class PetTypeFormatterTests {
|
|||
private List<PetType> makePetTypes() {
|
||||
List<PetType> petTypes = new ArrayList<>();
|
||||
petTypes.add(new PetType() {
|
||||
private static final long serialVersionUID = 4182992965923515553L;
|
||||
|
||||
{
|
||||
setName("Dog");
|
||||
}
|
||||
});
|
||||
petTypes.add(new PetType() {
|
||||
private static final long serialVersionUID = 1823182409934678856L;
|
||||
|
||||
{
|
||||
setName("Bird");
|
||||
}
|
||||
|
|
|
@ -186,11 +186,11 @@ class ClinicServiceTests {
|
|||
void shouldFindVets() {
|
||||
Collection<Vet> vets = this.vets.findAll();
|
||||
|
||||
Vet vet = EntityUtils.getById(vets, Vet.class, 3);
|
||||
assertThat(vet.getLastName()).isEqualTo("Douglas");
|
||||
Vet vet = EntityUtils.getById(vets, Vet.class, 2);
|
||||
assertThat(vet.getLastName()).isEqualTo("Leary");
|
||||
assertThat(vet.getNrOfSpecialties()).isEqualTo(2);
|
||||
assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("dentistry");
|
||||
assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("surgery");
|
||||
assertThat(vet.getSpecialties().get(0).getName()).isEqualTo("anesthesia");
|
||||
assertThat(vet.getSpecialties().get(1).getName()).isEqualTo("dentistry");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue