diff --git a/pom.xml b/pom.xml
index 780b38b9a94..ca90fc7ba29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,260 +1,261 @@
-
-
- 4.0.0
- org.springframework.samples
- spring-petclinic
- 2.2.0.BUILD-SNAPSHOT
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.2.4.RELEASE
-
- petclinic
-
-
-
-
- 1.8
- UTF-8
- UTF-8
-
-
- 3.3.6
- 1.11.4
- 2.2.4
- 1.8.0
-
- 0.8.5
- 0.0.19
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-cache
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.security
- spring-security-taglibs
-
-
-
-
- com.h2database
- h2
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
-
- javax.cache
- cache-api
-
-
- org.ehcache
- ehcache
-
-
-
- javax.servlet
- jstl
-
-
- org.apache.tomcat.embed
- tomcat-embed-jasper
- provided
-
-
-
- org.webjars
- webjars-locator-core
-
-
- org.webjars
- jquery
- ${webjars-jquery.version}
-
-
- org.webjars
- jquery-ui
- ${webjars-jquery-ui.version}
-
-
- org.webjars
- bootstrap
- ${webjars-bootstrap.version}
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
-
- org.springframework.security
- spring-security-test
- test
-
-
- junit
- junit
-
-
-
- org.projectlombok
- lombok
-
-
- org.springframework.boot
- spring-boot-devtools
- true
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
- build-info
-
-
-
- ${project.build.sourceEncoding}
- ${project.reporting.outputEncoding}
- ${maven.compiler.source}
- ${maven.compiler.target}
-
-
-
-
-
-
- org.jacoco
- jacoco-maven-plugin
- ${jacoco.version}
-
-
-
- prepare-agent
-
-
-
- report
- prepare-package
-
- report
-
-
-
-
-
-
-
- pl.project13.maven
- git-commit-id-plugin
-
-
-
- revision
-
-
-
-
- true
- yyyy-MM-dd'T'HH:mm:ssZ
- true
- ${project.build.outputDirectory}/git.properties
-
- false
-
-
-
-
- ro.isdc.wro4j
- wro4j-maven-plugin
- ${wro4j.version}
-
-
- generate-resources
-
- run
-
-
-
-
- ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
- ${project.build.directory}/classes/static/resources/css
- ${basedir}/src/main/wro/wro.xml
- ${basedir}/src/main/wro/wro.properties
- ${basedir}/src/main/less
-
-
-
- org.webjars
- bootstrap
- ${webjars-bootstrap.version}
-
-
- org.mockito
- mockito-core
- ${mockito.version}
-
-
-
-
-
-
-
-
-
- Apache License, Version 2.0
- https://www.apache.org/licenses/LICENSE-2.0
-
-
-
-
-
-
+
+
+ 4.0.0
+ org.springframework.samples
+ spring-petclinic
+ 2.2.0.BUILD-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.4.RELEASE
+
+ petclinic
+
+
+
+
+ 1.8
+ UTF-8
+ UTF-8
+
+
+ 3.3.6
+ 1.11.4
+ 2.2.4
+ 1.8.0
+
+ 0.8.5
+ 0.0.19
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.security
+ spring-security-taglibs
+
+
+
+
+ com.h2database
+ h2
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+
+
+ javax.cache
+ cache-api
+
+
+ org.ehcache
+ ehcache
+
+
+
+ javax.servlet
+ jstl
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-jasper
+ provided
+
+
+
+ org.webjars
+ webjars-locator-core
+
+
+ org.webjars
+ jquery
+ ${webjars-jquery.version}
+
+
+ org.webjars
+ jquery-ui
+ ${webjars-jquery-ui.version}
+
+
+ org.webjars
+ bootstrap
+ ${webjars-bootstrap.version}
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
+ junit
+ junit
+
+
+
+ org.projectlombok
+ lombok
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ true
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+ build-info
+
+
+
+ ${project.build.sourceEncoding}
+ ${project.reporting.outputEncoding}
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco.version}
+
+
+
+ prepare-agent
+
+
+
+ report
+
+ test
+
+ report
+
+
+
+
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+
+
+
+ revision
+
+
+
+
+ true
+ yyyy-MM-dd'T'HH:mm:ssZ
+ true
+ ${project.build.outputDirectory}/git.properties
+
+ false
+
+
+
+
+ ro.isdc.wro4j
+ wro4j-maven-plugin
+ ${wro4j.version}
+
+
+ generate-resources
+
+ run
+
+
+
+
+ ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
+ ${project.build.directory}/classes/static/resources/css
+ ${basedir}/src/main/wro/wro.xml
+ ${basedir}/src/main/wro/wro.properties
+ ${basedir}/src/main/less
+
+
+
+ org.webjars
+ bootstrap
+ ${webjars-bootstrap.version}
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+
+
+
+
+
+
+
+
+
+ Apache License, Version 2.0
+ https://www.apache.org/licenses/LICENSE-2.0
+
+
+
+
+
+
diff --git a/src/main/java/org/springframework/samples/petclinic/PetclinicApplication.java b/src/main/java/org/springframework/samples/petclinic/PetclinicApplication.java
index f33503dddbe..509be34133b 100644
--- a/src/main/java/org/springframework/samples/petclinic/PetclinicApplication.java
+++ b/src/main/java/org/springframework/samples/petclinic/PetclinicApplication.java
@@ -1,13 +1,13 @@
+
package org.springframework.samples.petclinic;
import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication()
public class PetclinicApplication {
- public static void main(String[] args) {
+ public static void main(final String[] args) {
SpringApplication.run(PetclinicApplication.class, args);
}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Appointment.java b/src/main/java/org/springframework/samples/petclinic/model/Appointment.java
new file mode 100644
index 00000000000..75a3894085e
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Appointment.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2002-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.samples.petclinic.model;
+
+import java.time.LocalDate;
+import java.time.LocalTime;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * Simple JavaBean domain object representing a Appointment.
+ *
+ * @author Ken Krebs
+ */
+@Entity
+@Table(name = "appointment")
+public class Appointment extends BaseEntity {
+
+ /**
+ * Holds value of property date.
+ */
+ @Column(name = "date")
+ @DateTimeFormat(pattern = "yyyy/MM/dd")
+ private LocalDate Date;
+
+ @Column(name = "start_time")
+ @DateTimeFormat(pattern = "HH:mm:ss")
+ private LocalTime startTime;
+
+ @Column(name = "end_time")
+ @DateTimeFormat(pattern = "HH:mm:ss")
+ private LocalTime endTime;
+
+ /**
+ * Holds value of property reason.
+ */
+ @NotEmpty
+ @Column(name = "reason")
+ private String reason;
+
+ @ManyToOne
+ @JoinColumn(name = "type_id")
+ private AppointmentType type;
+
+
+ /**
+ * Holds value of property pet.
+ */
+
+ /**
+ * Creates a new instance of Appointment for the current date
+ */
+ public Appointment() {
+ this.Date = LocalDate.now();
+ }
+
+ /**
+ * Getter for property date.
+ *
+ * @return Value of property date.
+ */
+ public LocalTime getStartTime() {
+ return this.startTime;
+ }
+
+ /**
+ * Setter for property date.
+ *
+ * @param date
+ * New value of property date.
+ */
+ public void setStartTime(final LocalTime startTime) {
+ this.startTime = startTime;
+ }
+
+ public LocalTime getEndTime() {
+ return this.endTime;
+ }
+
+ public void setEndTime(final LocalTime endTime) {
+ this.endTime = endTime;
+ }
+ /**
+ * Getter for property reason.
+ *
+ * @return Value of property reason.
+ */
+ public String getReason() {
+ return this.reason;
+ }
+
+ /**
+ * Setter for property description.
+ *
+ * @param description
+ * New value of property description.
+ */
+ public void setReason(final String reason) {
+ this.reason = reason;
+ }
+
+ /**
+ * Getter for property pet.
+ *
+ * @return Value of property pet.
+ */
+ public Client getClient() {
+ return this.client;
+ }
+
+ /**
+ * Setter for property pet.
+ *
+ * @param pet
+ * New value of property pet.
+ */
+ public void setClient(final Client client) {
+ this.client = client;
+ }
+
+ public AppointmentType getType() {
+ return this.type;
+ }
+
+ public void setType(final AppointmentType type) {
+ this.type = type;
+ }
+
+ public Professional getProfessional() {
+ return this.professional;
+ }
+
+ public void setProfessional(final Professional professional) {
+ this.professional = professional;
+ }
+
+ public Center getCenter() {
+ return this.center;
+ }
+
+ public void setCenter(final Center center) {
+ this.center = center;
+ }
+
+ public LocalDate getDate() {
+ return this.Date;
+ }
+
+ public void setDate(final LocalDate date) {
+ this.Date = date;
+ }
+
+ public Diagnosis getDiagnosis() {
+ return this.diagnosis;
+ }
+
+ public void setDiagnosis(final Diagnosis diagnosis) {
+ this.diagnosis = diagnosis;
+ }
+
+ public Receipt getReceipt() {
+ return this.receipt;
+ }
+
+ public void setReceipt(final Receipt receipt) {
+ this.receipt = receipt;
+ }
+
+ //Relations
+
+
+ @ManyToOne
+ @JoinColumn(name = "client_id")
+ private Client client;
+
+ @ManyToOne
+ @JoinColumn(name = "professional_id")
+ private Professional professional;
+
+ @ManyToOne
+ @JoinColumn(name = "center_id")
+ private Center center;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "diagnosis_id")
+ private Diagnosis diagnosis;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "receipt_id")
+ private Receipt receipt;
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/AppointmentType.java b/src/main/java/org/springframework/samples/petclinic/model/AppointmentType.java
new file mode 100644
index 00000000000..297857eca9d
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/AppointmentType.java
@@ -0,0 +1,11 @@
+
+package org.springframework.samples.petclinic.model;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "types")
+public class AppointmentType extends NamedEntity {
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Bill.java b/src/main/java/org/springframework/samples/petclinic/model/Bill.java
new file mode 100644
index 00000000000..bce45c57e07
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Bill.java
@@ -0,0 +1,98 @@
+
+package org.springframework.samples.petclinic.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Entity
+@Table(name = "bills")
+public class Bill extends NamedEntity {
+
+ @Column(name = "last_name")
+ @NotEmpty
+ protected String lastName;
+
+ @Column(name = "document")
+ @NotEmpty
+ protected String document;
+
+ @Column(name = "type_document")
+ @NotEmpty
+ protected String typeDocument;
+
+ @Column(name = "price")
+ @NotNull
+ protected Double price;
+
+ @Column(name = "iva")
+ @NotNull
+ protected Double iva;
+
+ @Column(name = "final_price")
+ @NotNull
+ protected Double finalPrice;
+
+ //Relations
+
+ @ManyToOne
+ @JoinColumn(name = "receipt_id")
+ private Receipt receipt;
+
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public void setLastName(final String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getDocument() {
+ return this.document;
+ }
+
+ public void setDocument(final String document) {
+ this.document = document;
+ }
+
+ public String getTypeDocument() {
+ return this.typeDocument;
+ }
+
+ public void setTypeDocument(final String typeDocument) {
+ this.typeDocument = typeDocument;
+ }
+
+ public Double getPrice() {
+ return this.price;
+ }
+
+ public void setPrice(final Double price) {
+ this.price = price;
+ }
+
+ public Double getIva() {
+ return this.iva;
+ }
+
+ public void setIva(final Double iva) {
+ this.iva = iva;
+ }
+
+ public Receipt getReceipt() {
+ return this.receipt;
+ }
+
+ public void setReceipt(final Receipt receipt) {
+ this.receipt = receipt;
+ }
+
+ public Double getFinalPrice() {
+ return this.iva / 100 * this.price + this.price;
+ }
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Center.java b/src/main/java/org/springframework/samples/petclinic/model/Center.java
new file mode 100644
index 00000000000..a8f5149b794
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Center.java
@@ -0,0 +1,82 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+@Entity
+@Table(name = "center")
+public class Center extends NamedEntity {
+
+ @Column(name = "adress")
+ @NotEmpty
+ private String adress;
+
+
+ public String getAdress() {
+ return this.adress;
+ }
+
+ public void setAdress(final String adress) {
+ this.adress = adress;
+ }
+
+
+ //Relations
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "center", fetch = FetchType.EAGER)
+ private Set schedules;
+
+
+ protected Set getSchedulesInternal() {
+ if (this.schedules == null) {
+ this.schedules = new HashSet<>();
+ }
+ return this.schedules;
+ }
+
+ public void setSchedules(final Set schedules) {
+ this.schedules = schedules;
+ }
+
+ public List getSchedules() {
+ List sortedSchedules = new ArrayList<>(this.getSchedulesInternal());
+ PropertyComparator.sort(sortedSchedules, new MutableSortDefinition("date", true, true));
+ return Collections.unmodifiableList(sortedSchedules);
+ }
+
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "center", fetch = FetchType.EAGER)
+ private Set appointments;
+
+
+ protected Set getAppointmentsInternal() {
+ if (this.appointments == null) {
+ this.appointments = new HashSet<>();
+ }
+ return this.appointments;
+ }
+
+ public void setAppointments(final Set appointments) {
+ this.appointments = appointments;
+ }
+
+ public List getAppointments() {
+ List sortedAppointments = new ArrayList<>(this.getAppointmentsInternal());
+ PropertyComparator.sort(sortedAppointments, new MutableSortDefinition("type", true, true));
+ return Collections.unmodifiableList(sortedAppointments);
+ }
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Client.java b/src/main/java/org/springframework/samples/petclinic/model/Client.java
new file mode 100644
index 00000000000..02d70318d3e
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Client.java
@@ -0,0 +1,77 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+
+@Entity
+@Table(name = "clients")
+
+public class Client extends User {
+
+ @Column(name = "healthInsurance")
+ @NotEmpty(message = "*")
+ private String healthInsurance;
+
+ @Column(name = "healthCardNumber")
+ @NotEmpty(message = "*")
+ private String healthCardNumber;
+
+
+ public String getHealthInsurance() {
+ return this.healthInsurance;
+ }
+
+ public void setHealthInsurance(final String healthInsurance) {
+ this.healthInsurance = healthInsurance;
+ }
+
+ public String getHealthCardNumber() {
+ return this.healthCardNumber;
+ }
+
+ public void setHealthCardNumber(final String healthCardNumber) {
+ this.healthCardNumber = healthCardNumber;
+ }
+
+
+ //Relations
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "client", fetch = FetchType.EAGER)
+ private Set appointments;
+
+
+ protected Set getAppointmentsInternal() {
+ if (this.appointments == null) {
+ this.appointments = new HashSet<>();
+ }
+ return this.appointments;
+ }
+
+ public void setAppointments(final Set appointments) {
+ this.appointments = appointments;
+ }
+
+ public List getAppointments() {
+ List sortedAppointments = new ArrayList<>(this.getAppointmentsInternal());
+ PropertyComparator.sort(sortedAppointments, new MutableSortDefinition("type", true, true));
+ return Collections.unmodifiableList(sortedAppointments);
+ }
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Desease.java b/src/main/java/org/springframework/samples/petclinic/model/Desease.java
new file mode 100644
index 00000000000..d25a777ca48
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Desease.java
@@ -0,0 +1,67 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+@Entity
+@Table(name = "deseases")
+public class Desease extends NamedEntity {
+
+ @ManyToMany(fetch = FetchType.EAGER)
+ @JoinTable(name = "deseases_medicines", joinColumns = @JoinColumn(name = "desease_id"), inverseJoinColumns = @JoinColumn(name = "medicine_id"))
+ private Set medicines;
+
+ @ManyToMany(fetch = FetchType.EAGER)
+ @JoinTable(name = "deseases_diagnosis", joinColumns = @JoinColumn(name = "desease_id"), inverseJoinColumns = @JoinColumn(name = "diagnosis_id"))
+ private Set diagnosis;
+
+
+ protected Set getMedicinesInternal() {
+ if (this.medicines == null) {
+ this.medicines = new HashSet<>();
+ }
+ return this.medicines;
+ }
+
+ public void setMedicines(final Set medicines) {
+ this.medicines = medicines;
+ }
+
+ public List getMedicines() {
+ List sortedMedicines = new ArrayList<>(this.getMedicinesInternal());
+ PropertyComparator.sort(sortedMedicines, new MutableSortDefinition("name", true, true));
+ return Collections.unmodifiableList(sortedMedicines);
+ }
+
+ protected Set getDiagnosisInternal() {
+ if (this.diagnosis == null) {
+ this.diagnosis = new HashSet<>();
+ }
+ return this.diagnosis;
+ }
+
+ public void setDiagnosis(final Set diagnosis) {
+ this.diagnosis = diagnosis;
+ }
+
+ public List getDiagnosis() {
+ List sortedDiagnosis = new ArrayList<>(this.getDiagnosisInternal());
+ PropertyComparator.sort(sortedDiagnosis, new MutableSortDefinition("date", true, true));
+ return Collections.unmodifiableList(sortedDiagnosis);
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Diagnosis.java b/src/main/java/org/springframework/samples/petclinic/model/Diagnosis.java
new file mode 100644
index 00000000000..b9974a90703
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Diagnosis.java
@@ -0,0 +1,110 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+import org.springframework.format.annotation.DateTimeFormat;
+
+@Entity
+@Table(name = "diagnosis")
+public class Diagnosis extends BaseEntity {
+
+ @Column(name = "date")
+ @DateTimeFormat(pattern = "yyyy/MM/dd")
+ private LocalDate date;
+
+ @Column(name = "description")
+ @NotEmpty
+ private String description;
+
+ //Relations
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "appointment_id")
+ private Appointment appointment;
+
+ @ManyToMany(fetch = FetchType.EAGER)
+ @JoinTable(name = "diagnosis_medicines", joinColumns = @JoinColumn(name = "diagnosis_id"), inverseJoinColumns = @JoinColumn(name = "medicine_id"))
+ private Set medicines;
+
+ // @ManyToMany(fetch = FetchType.EAGER)
+ // @JoinTable(name = "desease_id")
+ // private Set deseases;
+
+
+ protected Set getMedicinesInternal() {
+ if (this.medicines == null) {
+ this.medicines = new HashSet<>();
+ }
+ return this.medicines;
+ }
+
+ public void setMedicines(final Set medicines) {
+ this.medicines = medicines;
+ }
+
+ public List getMedicines() {
+ List sortedMedicines = new ArrayList<>(this.getMedicinesInternal());
+ PropertyComparator.sort(sortedMedicines, new MutableSortDefinition("name", true, true));
+ return Collections.unmodifiableList(sortedMedicines);
+ }
+
+ // protected Set getDeseasesInternal() {
+ // if (this.deseases == null) {
+ // this.deseases = new HashSet<>();
+ // }
+ // return this.deseases;
+ // }
+ //
+ // public void setDeseases(final Set deseases) {
+ // this.deseases = deseases;
+ // }
+ //
+ // public List getDeseases() {
+ // List sortedDeseases = new ArrayList<>(this.getDeseasesInternal());
+ // PropertyComparator.sort(sortedDeseases, new MutableSortDefinition("name", true, true));
+ // return Collections.unmodifiableList(sortedDeseases);
+ // }
+
+ public LocalDate getDate() {
+ return this.date;
+ }
+
+ public void setDate(final LocalDate date) {
+ this.date = date;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public Appointment getAppointment() {
+ return this.appointment;
+ }
+
+ public void setAppointment(final Appointment appointment) {
+ this.appointment = appointment;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/DocumentType.java b/src/main/java/org/springframework/samples/petclinic/model/DocumentType.java
new file mode 100644
index 00000000000..b2a2d75dd6c
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/DocumentType.java
@@ -0,0 +1,6 @@
+
+package org.springframework.samples.petclinic.model;
+
+public enum DocumentType {
+ nif, nie, passport
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Medicine.java b/src/main/java/org/springframework/samples/petclinic/model/Medicine.java
new file mode 100644
index 00000000000..cb47611ffac
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Medicine.java
@@ -0,0 +1,70 @@
+
+package org.springframework.samples.petclinic.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+@Entity
+@Table(name = "medicines")
+public class Medicine extends NamedEntity {
+
+ @Column(name = "price")
+ @NotNull
+ private Double price;
+
+ //Relations
+
+ // @ManyToMany(fetch = FetchType.EAGER)
+ // @JoinTable(name = "diagnosis_id")
+ // private Set diagnosis;
+ //
+ // @ManyToMany(fetch = FetchType.EAGER)
+ // @JoinTable(name = "desease_id")
+ // private Set deseases;
+
+
+ public Double getPrice() {
+ return this.price;
+ }
+
+ public void setPrice(final Double price) {
+ this.price = price;
+ }
+
+ // protected Set getDiagnosisInternal() {
+ // if (this.diagnosis == null) {
+ // this.diagnosis = new HashSet<>();
+ // }
+ // return this.diagnosis;
+ // }
+ //
+ // public void setDiagnosis(final Set diagnosis) {
+ // this.diagnosis = diagnosis;
+ // }
+ //
+ // public List getDiagnosis() {
+ // List sortedDiagnosis = new ArrayList<>(this.getDiagnosisInternal());
+ // PropertyComparator.sort(sortedDiagnosis, new MutableSortDefinition("date", true, true));
+ // return Collections.unmodifiableList(sortedDiagnosis);
+ // }
+ //
+ // protected Set getDeseasesInternal() {
+ // if (this.deseases == null) {
+ // this.deseases = new HashSet<>();
+ // }
+ // return this.deseases;
+ // }
+ //
+ // public void setDeseases(final Set deseases) {
+ // this.deseases = deseases;
+ // }
+ //
+ // public List getDeseases() {
+ // List sortedDeseases = new ArrayList<>(this.getDeseasesInternal());
+ // PropertyComparator.sort(sortedDeseases, new MutableSortDefinition("name", true, true));
+ // return Collections.unmodifiableList(sortedDeseases);
+ // }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Owner.java b/src/main/java/org/springframework/samples/petclinic/model/Owner.java
index 31b311aa9a6..a4a42dac4b8 100644
--- a/src/main/java/org/springframework/samples/petclinic/model/Owner.java
+++ b/src/main/java/org/springframework/samples/petclinic/model/Owner.java
@@ -66,19 +66,19 @@ public class Owner extends Person {
//
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "username", referencedColumnName = "username")
- private User user;
+ private UserPet userPet;
//
public String getAddress() {
return this.address;
}
- public User getUser() {
- return user;
+ public UserPet getUser() {
+ return userPet;
}
- public void setUser(User user) {
- this.user = user;
+ public void setUser(UserPet userPet) {
+ this.userPet = userPet;
}
public void setAddress(String address) {
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Professional.java b/src/main/java/org/springframework/samples/petclinic/model/Professional.java
new file mode 100644
index 00000000000..0cd479ca3b7
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Professional.java
@@ -0,0 +1,98 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+@Entity
+@Table(name = "professionals")
+public class Professional extends User {
+
+
+ @Column(name = "specialty")
+ @NotEmpty(message = "*")
+ private String specialty;
+
+ @Column(name = "collegiateNumber")
+ @NotEmpty(message = "*")
+ private Integer collegiateNumber;
+
+
+ public String getSpecialty() {
+ return this.specialty;
+ }
+
+ public void setSpecialty(final String specialty) {
+ this.specialty = specialty;
+ }
+
+ public Integer getCollegiateNumber() {
+ return this.collegiateNumber;
+ }
+
+ public void setCollegiateNumber(final Integer collegiateNumber) {
+ this.collegiateNumber = collegiateNumber;
+ }
+
+
+ //Relations
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "professional", fetch = FetchType.EAGER)
+ private Set schedules;
+
+
+ protected Set getSchedulesInternal() {
+ if (this.schedules == null) {
+ this.schedules = new HashSet<>();
+ }
+ return this.schedules;
+ }
+
+ public void setSchedules(final Set schedules) {
+ this.schedules = schedules;
+ }
+
+ public List getSchedules() {
+ List sortedSchedules = new ArrayList<>(this.getSchedulesInternal());
+ PropertyComparator.sort(sortedSchedules, new MutableSortDefinition("date", true, true));
+ return Collections.unmodifiableList(sortedSchedules);
+ }
+
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "professional", fetch = FetchType.EAGER)
+ private Set appointments;
+
+
+ protected Set getAppointmentsInternal() {
+ if (this.appointments == null) {
+ this.appointments = new HashSet<>();
+ }
+ return this.appointments;
+ }
+
+ public void setAppointments(final Set appointments) {
+ this.appointments = appointments;
+ }
+
+ public List getAppointments() {
+ List sortedAppointments = new ArrayList<>(this.getAppointmentsInternal());
+ PropertyComparator.sort(sortedAppointments, new MutableSortDefinition("type", true, true));
+ return Collections.unmodifiableList(sortedAppointments);
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Receipt.java b/src/main/java/org/springframework/samples/petclinic/model/Receipt.java
new file mode 100644
index 00000000000..42c1486ce63
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Receipt.java
@@ -0,0 +1,107 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+
+import org.springframework.beans.support.MutableSortDefinition;
+import org.springframework.beans.support.PropertyComparator;
+
+@Entity
+@Table(name = "receipts")
+public class Receipt extends BaseEntity {
+
+ @Column(name = "price")
+ @NotNull
+ private Double price;
+
+ @Column(name = "state")
+ @Enumerated
+ private State state;
+
+ //Relations
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "appointment_id")
+ private Appointment appointment;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "receipt", fetch = FetchType.EAGER)
+ private Set transactions;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "receipt", fetch = FetchType.EAGER)
+ private Set bills;
+
+
+ public Double getPrice() {
+ return this.price;
+ }
+
+ public void setPrice(final Double price) {
+ this.price = price;
+ }
+
+ public State getState() {
+ return this.state;
+ }
+
+ public void setState(final State state) {
+ this.state = state;
+ }
+
+ public Appointment getAppointment() {
+ return this.appointment;
+ }
+
+ public void setAppointment(final Appointment appointment) {
+ this.appointment = appointment;
+ }
+
+ protected Set getTransactionsInternal() {
+ if (this.transactions == null) {
+ this.transactions = new HashSet<>();
+ }
+ return this.transactions;
+ }
+
+ public void setTransactions(final Set transactions) {
+ this.transactions = transactions;
+ }
+
+ public List getTransactions() {
+ List sortedTransactions = new ArrayList<>(this.getTransactionsInternal());
+ PropertyComparator.sort(sortedTransactions, new MutableSortDefinition("type", true, true));
+ return Collections.unmodifiableList(sortedTransactions);
+ }
+
+ protected Set getBillsInternal() {
+ if (this.bills == null) {
+ this.bills = new HashSet<>();
+ }
+ return this.bills;
+ }
+
+ public void setBills(final Set bills) {
+ this.bills = bills;
+ }
+
+ public List getBills() {
+ List sortedBills = new ArrayList<>(this.getBillsInternal());
+ PropertyComparator.sort(sortedBills, new MutableSortDefinition("name", true, true));
+ return Collections.unmodifiableList(sortedBills);
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Schedule.java b/src/main/java/org/springframework/samples/petclinic/model/Schedule.java
new file mode 100644
index 00000000000..ce71e123836
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Schedule.java
@@ -0,0 +1,84 @@
+
+package org.springframework.samples.petclinic.model;
+
+import java.time.LocalDate;
+import java.time.LocalTime;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+@Entity
+@Table(name = "schedule")
+public class Schedule extends BaseEntity {
+
+ @Column(name = "date")
+ @DateTimeFormat(pattern = "yyyy/MM/dd")
+ private LocalDate Date;
+
+ @Column(name = "start_time")
+ @DateTimeFormat(pattern = "HH:mm:ss")
+ private LocalTime startTime;
+
+ @Column(name = "end_time")
+ @DateTimeFormat(pattern = "HH:mm:ss")
+ private LocalTime endTime;
+
+
+ public LocalDate getDate() {
+ return this.Date;
+ }
+
+ public void setDate(final LocalDate date) {
+ this.Date = date;
+ }
+
+ public LocalTime getStartTime() {
+ return this.startTime;
+ }
+
+ public void setStartTime(final LocalTime startTime) {
+ this.startTime = startTime;
+ }
+
+ public LocalTime getEndTime() {
+ return this.endTime;
+ }
+
+ public void setEndTime(final LocalTime endTime) {
+ this.endTime = endTime;
+ }
+
+
+ //Relations
+
+ @ManyToOne
+ @JoinColumn(name = "professional_id")
+ private Professional professional;
+
+ @ManyToOne
+ @JoinColumn(name = "center_id")
+ private Center center;
+
+
+ public Professional getProfessional() {
+ return this.professional;
+ }
+
+ public void setProfessional(final Professional professional) {
+ this.professional = professional;
+ }
+
+ public Center getCenter() {
+ return this.center;
+ }
+
+ public void setCenter(final Center center) {
+ this.center = center;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/State.java b/src/main/java/org/springframework/samples/petclinic/model/State.java
new file mode 100644
index 00000000000..e381147a98f
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/State.java
@@ -0,0 +1,7 @@
+
+package org.springframework.samples.petclinic.model;
+
+public enum State {
+
+ PENDING, REFUNDED, PAID
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/Transaction.java b/src/main/java/org/springframework/samples/petclinic/model/Transaction.java
new file mode 100644
index 00000000000..44c03207721
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/Transaction.java
@@ -0,0 +1,68 @@
+
+package org.springframework.samples.petclinic.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Enumerated;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Entity
+@Table(name = "transactions")
+public class Transaction extends BaseEntity {
+
+ @Column(name = "type")
+ @Enumerated
+ private TransactionType type;
+
+ @Column(name = "amount")
+ @NotNull
+ private Double amount;
+
+ @Column(name = "token")
+ @NotEmpty
+ private String token;
+
+ //Relations
+
+ @ManyToOne
+ @JoinColumn(name = "receipt_id")
+ private Receipt receipt;
+
+
+ public TransactionType getType() {
+ return this.type;
+ }
+
+ public void setType(final TransactionType type) {
+ this.type = type;
+ }
+
+ public Double getAmount() {
+ return this.amount;
+ }
+
+ public void setAmount(final Double amount) {
+ this.amount = amount;
+ }
+
+ public String getToken() {
+ return this.token;
+ }
+
+ public void setToken(final String token) {
+ this.token = token;
+ }
+
+ public Receipt getReceipt() {
+ return this.receipt;
+ }
+
+ public void setReceipt(final Receipt receipt) {
+ this.receipt = receipt;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/TransactionType.java b/src/main/java/org/springframework/samples/petclinic/model/TransactionType.java
new file mode 100644
index 00000000000..aa6991ddf76
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/TransactionType.java
@@ -0,0 +1,7 @@
+
+package org.springframework.samples.petclinic.model;
+
+public enum TransactionType {
+
+ CHARGE, REFUND
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/User.java b/src/main/java/org/springframework/samples/petclinic/model/User.java
index ac2cdd2c4ea..8d7d79cf8e2 100644
--- a/src/main/java/org/springframework/samples/petclinic/model/User.java
+++ b/src/main/java/org/springframework/samples/petclinic/model/User.java
@@ -1,19 +1,191 @@
-package org.springframework.samples.petclinic.model;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import lombok.Data;
-
-@Data
-@Entity
-@Table(name = "users")
-public class User{
- @Id
- String username;
-
- String password;
-
- boolean enabled;
-}
+
+package org.springframework.samples.petclinic.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Table;
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.Past;
+
+import org.hibernate.annotations.Formula;
+import org.hibernate.validator.constraints.Length;
+import org.springframework.format.annotation.DateTimeFormat;
+
+@Entity
+@Table(name = "usuarios")
+@MappedSuperclass
+public class User extends BaseEntity {
+
+ // Attributes
+ @Column(name = "name")
+ @NotEmpty(message = "*")
+ private String name;
+
+ @Column(name = "surname")
+ @NotEmpty(message = "*")
+ private String surname;
+
+ @Column(name = "email")
+ @NotEmpty(message = "*")
+ @Email(message = "Enter a valid email address.")
+ private String email;
+
+ @Column(name = "birth_date")
+ @DateTimeFormat(pattern = "yyyy/MM/dd")
+ @NotEmpty(message = "*")
+ @Past
+ private Date birthDate;
+
+ @Column(name = "registration_date")
+ @Past
+ @NotEmpty(message = "*")
+ private Date registrationDate;
+
+ @Column(name = "document")
+ @NotEmpty(message = "*")
+ private String document;
+
+ @Column(name = "document_type")
+ @NotEmpty(message = "*")
+ private DocumentType documentType;
+
+ @Column(name = "avatar")
+ @NotEmpty(message = "*")
+ private String avatar;
+
+ @Column(name = "password")
+ @NotEmpty(message = "*")
+ @Length(min = 5, max = 60)
+ private String password;
+
+ @Column(name = "age")
+ @Formula("(TIMESTAMPDIFF(YEAR,birth_date,CURDATE()))")
+ @NotEmpty(message = "*")
+ private String age;
+
+ @Column(name = "address")
+ @NotEmpty(message = "*")
+ private String address;
+
+ @Column(name = "city")
+ @NotEmpty(message = "*")
+ private String city;
+
+ @Column(name = "telephone")
+ @NotEmpty(message = "*")
+ @Digits(fraction = 0, integer = 10)
+ private String telephone;
+
+
+ // Getters & Setters
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getSurname() {
+ return this.surname;
+ }
+
+ public void setSurname(final String surname) {
+ this.surname = surname;
+ }
+
+ public String getEmail() {
+ return this.email;
+ }
+
+ public void setEmail(final String email) {
+ this.email = email;
+ }
+
+ public Date getRegistrationDate() {
+ return this.registrationDate;
+ }
+
+ public void setRegistrationDate(final Date registrationDate) {
+ this.registrationDate = registrationDate;
+ }
+
+ public String getDocument() {
+ return this.document;
+ }
+
+ public void setDocument(final String document) {
+ this.document = document;
+ }
+
+ public DocumentType getDocumentType() {
+ return this.documentType;
+ }
+
+ public void setDocumentType(final DocumentType documentType) {
+ this.documentType = documentType;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ public String getAvatar() {
+ return this.avatar;
+ }
+
+ public void setAvatar(final String avatar) {
+ this.avatar = avatar;
+ }
+
+ public Date getBirthDate() {
+ return this.birthDate;
+ }
+
+ public void setBirthDate(final Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+ public String getAge() {
+ return this.age;
+ }
+
+ public void setAge(final String age) {
+ this.age = age;
+ }
+
+ public String getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(final String address) {
+ this.address = address;
+ }
+
+ public String getCity() {
+ return this.city;
+ }
+
+ public void setCity(final String city) {
+ this.city = city;
+ }
+
+ public String getTelephone() {
+ return this.telephone;
+ }
+
+ public void setTelephone(final String telephone) {
+ this.telephone = telephone;
+ }
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/model/UserPet.java b/src/main/java/org/springframework/samples/petclinic/model/UserPet.java
new file mode 100644
index 00000000000..defedd32666
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/model/UserPet.java
@@ -0,0 +1,19 @@
+package org.springframework.samples.petclinic.model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import lombok.Data;
+
+@Data
+@Entity
+@Table(name = "users")
+public class UserPet{
+ @Id
+ String username;
+
+ String password;
+
+ boolean enabled;
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/ClientRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/ClientRepository.java
new file mode 100644
index 00000000000..b17903fc974
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/repository/ClientRepository.java
@@ -0,0 +1,9 @@
+
+package org.springframework.samples.petclinic.repository;
+
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.samples.petclinic.model.Client;
+
+public interface ClientRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/UserRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/UserRepository.java
index c85d5c0bc51..d52231eba0e 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/UserRepository.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/UserRepository.java
@@ -1,9 +1,9 @@
package org.springframework.samples.petclinic.repository;
import org.springframework.data.repository.CrudRepository;
-import org.springframework.samples.petclinic.model.User;
+import org.springframework.samples.petclinic.model.UserPet;
-public interface UserRepository extends CrudRepository{
+public interface UserRepository extends CrudRepository{
}
diff --git a/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java b/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java
index dc1669d1191..de1dabdc9f3 100644
--- a/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java
+++ b/src/main/java/org/springframework/samples/petclinic/repository/VisitRepository.java
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.samples.petclinic.repository;
import java.util.List;
@@ -36,7 +37,9 @@ public interface VisitRepository {
/**
* Save a Visit
to the data store, either inserting or updating it.
- * @param visit the Visit
to save
+ *
+ * @param visit
+ * the Visit
to save
* @see BaseEntity#isNew
*/
void save(Visit visit) throws DataAccessException;
diff --git a/src/main/java/org/springframework/samples/petclinic/service/ClientService.java b/src/main/java/org/springframework/samples/petclinic/service/ClientService.java
new file mode 100644
index 00000000000..e63ccf2909d
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/service/ClientService.java
@@ -0,0 +1,21 @@
+
+package org.springframework.samples.petclinic.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.samples.petclinic.repository.ClientRepository;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class ClientService {
+
+ @Autowired
+ private ClientRepository clientRepository;
+
+
+ @Transactional
+ public int clientCount() {
+
+ return (int) this.clientRepository.count();
+ }
+}
diff --git a/src/main/java/org/springframework/samples/petclinic/service/UserService.java b/src/main/java/org/springframework/samples/petclinic/service/UserService.java
index 21eec789e5c..952b5de7634 100644
--- a/src/main/java/org/springframework/samples/petclinic/service/UserService.java
+++ b/src/main/java/org/springframework/samples/petclinic/service/UserService.java
@@ -18,7 +18,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
-import org.springframework.samples.petclinic.model.User;
+import org.springframework.samples.petclinic.model.UserPet;
import org.springframework.samples.petclinic.repository.UserRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,8 +40,8 @@ public UserService(UserRepository userRepository) {
}
@Transactional
- public void saveUser(User user) throws DataAccessException {
- user.setEnabled(true);
- userRepository.save(user);
+ public void saveUser(UserPet userPet) throws DataAccessException {
+ userPet.setEnabled(true);
+ userRepository.save(userPet);
}
}
diff --git a/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java b/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java
index b57ffa5a097..4fb8fe2e682 100644
--- a/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java
+++ b/src/main/java/org/springframework/samples/petclinic/web/WelcomeController.java
@@ -6,7 +6,7 @@
import org.springframework.samples.petclinic.repository.UserRepository;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.samples.petclinic.model.User;
+import org.springframework.samples.petclinic.model.UserPet;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
diff --git a/src/main/webapp/WEB-INF/tags/htmlHeader.tag b/src/main/webapp/WEB-INF/tags/htmlHeader.tag
index 79f7feeb91f..1637a3dc8b0 100644
--- a/src/main/webapp/WEB-INF/tags/htmlHeader.tag
+++ b/src/main/webapp/WEB-INF/tags/htmlHeader.tag
@@ -20,7 +20,10 @@ PetClinic :: a Spring Framework demonstration
-
+ <%--Bootstrap CSS and JS--%>
+
+
+
<%-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --%>