From 7ec47741f428a340217368bf17dc97770628e7d2 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 22 Feb 2024 15:44:32 +0100 Subject: [PATCH 01/54] crud-Client --- .../cat/udl/eps/softarch/demo/domain/Client.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java index 1ea3bc69..a41ee807 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java @@ -1,5 +1,15 @@ package cat.udl.eps.softarch.demo.domain; -public class Client { +import jakarta.persistence.Entity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity +@Data +@NoArgsConstructor +@AllArgsConstructor + +public class Client extends User { } From a5e61a476e88b961df7e425dce7b9ce82b705fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Escol=C3=A0=20Curc=C3=B3?= Date: Thu, 22 Feb 2024 15:48:42 +0100 Subject: [PATCH 02/54] Added relation --- .../udl/eps/softarch/demo/domain/SocialNetworks.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java b/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java index 73f21077..32281604 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java @@ -1,9 +1,5 @@ package cat.udl.eps.softarch.demo.domain; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,4 +12,8 @@ public class SocialNetworks extends UriEntity { Long id; String instagram; String twitter; + + @ManyToOne + Shelter belongsTo; + } From 74cae2b5284665f487b022a54ba5cdfb04b4a24f Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 22 Feb 2024 15:50:20 +0100 Subject: [PATCH 03/54] crud-Client --- .../eps/softarch/demo/domain/Location.java | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/main/java/cat/udl/eps/softarch/demo/domain/Location.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java deleted file mode 100644 index c4773b14..00000000 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java +++ /dev/null @@ -1,30 +0,0 @@ -package cat.udl.eps.softarch.demo.domain; - -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Entity -@Data -@NoArgsConstructor -@AllArgsConstructor - -public class Location extends UriEntity{ - @Id - private Long id; - - private String address; - - private float latitude; - - private float longitude; - - private String province; - - private String municipality; - - private String postalCode; - -} From a9654ac1f4af655ff4b596e97d2d6d1c76834d3d Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 15:52:43 +0100 Subject: [PATCH 04/54] labels to class --- .../demo/domain/ShelterCertificate.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java index f95d17af..56d2f3e9 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java @@ -1,11 +1,24 @@ package cat.udl.eps.softarch.demo.domain; +import java.time.ZonedDateTime; import java.util.Date; +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotNull; + +@Entity public class ShelterCertificate extends UriEntity { - + + @Id + @GeneratedValue() private Long id; - private Date expirationDate; + + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @NotNull + private ZonedDateTime expirationDate; @Override public Long getId() { From 0b41354e5d4fd61dbf02d98b55d064ac9a141997 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 15:52:51 +0100 Subject: [PATCH 05/54] pet relations (not sure it works like this) --- .../java/cat/udl/eps/softarch/demo/domain/Pet.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java index 9ae162cc..3ffdacfb 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java @@ -1,8 +1,6 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; @@ -22,4 +20,13 @@ public class Pet extends UriEntity { String age; String description; String breed; + + @OneToMany + public MedicalRecord has; + + @OneToMany + public Adoption wasAdopted; + + @ManyToOne + public Shelter isIn; } From 8b50bde940955d4dd2cfa9632a3408e9e6f9dfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Escol=C3=A0=20Curc=C3=B3?= Date: Thu, 22 Feb 2024 15:55:31 +0100 Subject: [PATCH 06/54] Merged main into --- .../cat/udl/eps/softarch/demo/domain/SocialNetworks.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java b/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java index 32281604..0247239d 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/SocialNetworks.java @@ -9,11 +9,11 @@ public class SocialNetworks extends UriEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) - Long id; - String instagram; - String twitter; + private Long id; + private String instagram; + private String twitter; @ManyToOne - Shelter belongsTo; + public Shelter belongsTo; } From f93b640b35424aa672bce3a1f847272f9e7f6fdb Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 15:55:52 +0100 Subject: [PATCH 07/54] pet relations --- src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java index 3ffdacfb..cd82c311 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java @@ -21,11 +21,6 @@ public class Pet extends UriEntity { String description; String breed; - @OneToMany - public MedicalRecord has; - - @OneToMany - public Adoption wasAdopted; @ManyToOne public Shelter isIn; From 5daed9ed4da5a373ef8040c34adc4e38e2383685 Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 15:59:03 +0100 Subject: [PATCH 08/54] labels to class sheltervolunteer --- .../cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index fbbd4f7c..df1f5f7a 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -1,5 +1,8 @@ package cat.udl.eps.softarch.demo.domain; +import jakarta.persistence.Entity; + +@Entity public class ShelterVolunteer extends User { } From f305deed9067477757615115129b975021caf727 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:00:21 +0100 Subject: [PATCH 09/54] pet repository --- .../eps/softarch/demo/repository/PetRepository.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java new file mode 100644 index 00000000..504991d8 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -0,0 +1,13 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Pet; +import cat.udl.eps.softarch.demo.domain.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface PetRepository extends CrudRepository, PagingAndSortingRepository { + List findBySize(@Param("size") String size); +} From bcbdb3bfaa7b74bab98dd73d179b473777a14b47 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:04:17 +0100 Subject: [PATCH 10/54] admin repository --- .../demo/repository/AdminRepository.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java new file mode 100644 index 00000000..c3f91a74 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java @@ -0,0 +1,25 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Admin; +import cat.udl.eps.softarch.demo.domain.User; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface AdminRepository extends CrudRepository, PagingAndSortingRepository { + + /* Interface provides automatically, as defined in + * https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html + * and + * https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/PagingAndSortingRepository.html + * the methods: count, delete, deleteAll, deleteById, existsById, findAll, findAllById, findById, save, saveAll,... + * + * Additional methods like findByUsernameContaining can be defined following: + * https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation + */ + + List findByIdContaining(@Param("text") String text); +} From 3d186c5c612a0b6f5b808dccdb18fda76ae74162 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:04:59 +0100 Subject: [PATCH 11/54] admin repository --- .../eps/softarch/demo/repository/AdminRepository.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java index c3f91a74..2ad49872 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java @@ -10,16 +10,5 @@ import java.util.List; public interface AdminRepository extends CrudRepository, PagingAndSortingRepository { - - /* Interface provides automatically, as defined in - * https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html - * and - * https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/PagingAndSortingRepository.html - * the methods: count, delete, deleteAll, deleteById, existsById, findAll, findAllById, findById, save, saveAll,... - * - * Additional methods like findByUsernameContaining can be defined following: - * https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation - */ - List findByIdContaining(@Param("text") String text); } From 6203dcad6a9a597ce9d86bfe4c74e3ed04c26ae4 Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 16:06:13 +0100 Subject: [PATCH 12/54] added relationship to shelter --- .../cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index df1f5f7a..da68c225 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -1,8 +1,12 @@ package cat.udl.eps.softarch.demo.domain; +import com.fasterxml.jackson.annotation.JsonIdentityReference; import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; @Entity public class ShelterVolunteer extends User { - + @JsonIdentityReference(alwaysAsId = true) + @ManyToOne + private Shelter userShelter; } From 63eaa32f3cdcd1886166feb4228c4b292001ef09 Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 16:07:16 +0100 Subject: [PATCH 13/54] added relationship to shelter --- .../udl/eps/softarch/demo/domain/ShelterCertificate.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java index 56d2f3e9..1210a7f2 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java @@ -3,10 +3,12 @@ import java.time.ZonedDateTime; import java.util.Date; +import com.fasterxml.jackson.annotation.JsonIdentityReference; import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; @Entity @@ -24,4 +26,8 @@ public class ShelterCertificate extends UriEntity { public Long getId() { return id; } + + @JsonIdentityReference(alwaysAsId = true) + @ManyToOne + private Shelter shelterServed; } From 63340ec49f514971c802821beef4a9f34b71af5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Escol=C3=A0=20Curc=C3=B3?= Date: Thu, 22 Feb 2024 16:08:32 +0100 Subject: [PATCH 14/54] repository created --- .../demo/repository/SocialNetworksRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/SocialNetworksRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/SocialNetworksRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/SocialNetworksRepository.java new file mode 100644 index 00000000..1eef3cda --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/SocialNetworksRepository.java @@ -0,0 +1,10 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.SocialNetworks; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource +public interface SocialNetworksRepository extends CrudRepository { + +} From 607c17fa5967c2b50717d4310068955d2dd0e97f Mon Sep 17 00:00:00 2001 From: Codinab Date: Thu, 22 Feb 2024 16:11:48 +0100 Subject: [PATCH 15/54] Added relations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Mario Fernandez -Àlex Codina --- .../cat/udl/eps/softarch/demo/domain/MedicalRecord.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java b/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java index 69a4cc3d..1d83c87f 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java @@ -1,9 +1,6 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -28,4 +25,7 @@ public class MedicalRecord extends UriEntity { @NotNull private ZonedDateTime date; + + @ManyToOne + private Pet pet; } \ No newline at end of file From c4d0595c0f7137ab26bac6ca7518826a3ef7e975 Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 16:12:08 +0100 Subject: [PATCH 16/54] created repository --- .../softarch/demo/repository/ShelterCertRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java new file mode 100644 index 00000000..4c174696 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java @@ -0,0 +1,9 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Shelter; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ShelterCertRepository extends CrudRepository, PagingAndSortingRepository { + +} From 4ce33a386513ad120b4452f6bb015e491731795f Mon Sep 17 00:00:00 2001 From: Codinab Date: Thu, 22 Feb 2024 16:12:57 +0100 Subject: [PATCH 17/54] Revert "Added relations" This reverts commit 607c17fa5967c2b50717d4310068955d2dd0e97f. --- .../cat/udl/eps/softarch/demo/domain/MedicalRecord.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java b/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java index 1d83c87f..69a4cc3d 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java @@ -1,6 +1,9 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -25,7 +28,4 @@ public class MedicalRecord extends UriEntity { @NotNull private ZonedDateTime date; - - @ManyToOne - private Pet pet; } \ No newline at end of file From 5d252519573765f96d89e3ca496d58c7d019dbcd Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 16:13:16 +0100 Subject: [PATCH 18/54] created repository --- .../demo/repository/ShelterVolunteerRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java new file mode 100644 index 00000000..9d0594df --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java @@ -0,0 +1,8 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Shelter; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ShelterVolunteerRepository extends CrudRepository, PagingAndSortingRepository { +} From 68988d01babd861b296f94fee76fa96eb95a3877 Mon Sep 17 00:00:00 2001 From: Codinab Date: Thu, 22 Feb 2024 16:16:32 +0100 Subject: [PATCH 19/54] Added relation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Mario Fernandez -Àlex Codina --- .../cat/udl/eps/softarch/demo/domain/MedicalRecord.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java b/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java index 69a4cc3d..1d83c87f 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/MedicalRecord.java @@ -1,9 +1,6 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -28,4 +25,7 @@ public class MedicalRecord extends UriEntity { @NotNull private ZonedDateTime date; + + @ManyToOne + private Pet pet; } \ No newline at end of file From 01053528e56e135bc21ec33d395e2cdbe96236e1 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 22 Feb 2024 16:18:31 +0100 Subject: [PATCH 20/54] crud-Client --- .../udl/eps/softarch/demo/domain/Client.java | 18 ++++++++----- .../demo/repository/ClientRepository.java | 26 +++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/ClientRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java index a41ee807..55cd6d47 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java @@ -1,15 +1,21 @@ package cat.udl.eps.softarch.demo.domain; +import jakarta.persistence.ElementCollection; import jakarta.persistence.Entity; -import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import java.util.Collection; + +@EqualsAndHashCode(callSuper = true) @Entity @Data -@NoArgsConstructor -@AllArgsConstructor - public class Client extends User { - + @Override + @ElementCollection + public Collection getAuthorities(){ + return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_CLIENT"); + } } diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ClientRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ClientRepository.java new file mode 100644 index 00000000..c4afb86d --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ClientRepository.java @@ -0,0 +1,26 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Client; +import cat.udl.eps.softarch.demo.domain.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +import java.util.List; + +@RepositoryRestResource +public interface ClientRepository extends CrudRepository, PagingAndSortingRepository { + + /* Interface provides automatically, as defined in + * https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html + * and + * https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/PagingAndSortingRepository.html + * the methods: count, delete, deleteAll, deleteById, existsById, findAll, findAllById, findById, save, saveAll,... + * + * Additional methods like findByUsernameContaining can be defined following: + * https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation + */ + + List findByIdContaining(@Param("text") String text); +} From 18f2f80a0192a4bac7d15d208385186bd1a7ce3e Mon Sep 17 00:00:00 2001 From: Sebastian Jitaru Date: Thu, 22 Feb 2024 16:33:21 +0100 Subject: [PATCH 21/54] Added Schedule Repository and Schedule relations created --- .../udl/eps/softarch/demo/domain/Schedule.java | 4 ++++ .../demo/repository/ScheduleRepository.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java index bd3537d3..4794123e 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java @@ -2,6 +2,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; import lombok.Data; import lombok.EqualsAndHashCode; @@ -21,4 +22,7 @@ public class Schedule extends UriEntity { @NotNull private Date finish; + + @ManyToOne + public Shelter available; } diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java new file mode 100644 index 00000000..9ee4acd8 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java @@ -0,0 +1,15 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Schedule; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.repository.PagingAndSortingRepository; + + +import java.util.List; + +public interface ScheduleRepository extends CrudRepository, PagingAndSortingRepository{ + List findByIdContaining(@Param("text") String text); + +} From 20d026c3e81884a6ab68da8adcfbd6cea6a6e2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Garc=C3=ADa?= Date: Thu, 22 Feb 2024 16:37:40 +0100 Subject: [PATCH 22/54] Fix merge issue mixing Client and ShelterVolunteer --- .../udl/eps/softarch/demo/domain/Client.java | 21 +++++++++++++++++++ .../demo/domain/ShelterVolunteer.java | 18 +--------------- 2 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/domain/Client.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java new file mode 100644 index 00000000..55cd6d47 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java @@ -0,0 +1,21 @@ +package cat.udl.eps.softarch.demo.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; + +import java.util.Collection; + +@EqualsAndHashCode(callSuper = true) +@Entity +@Data +public class Client extends User { + @Override + @ElementCollection + public Collection getAuthorities(){ + return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_CLIENT"); + } +} diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index 55cd6d47..fbbd4f7c 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -1,21 +1,5 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.AuthorityUtils; +public class ShelterVolunteer extends User { -import java.util.Collection; - -@EqualsAndHashCode(callSuper = true) -@Entity -@Data -public class Client extends User { - @Override - @ElementCollection - public Collection getAuthorities(){ - return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_CLIENT"); - } } From 05fe807d0cf73da29a90aa84e3288e31663504d8 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:44:11 +0100 Subject: [PATCH 23/54] updated PetRepository --- .../cat/udl/eps/softarch/demo/repository/PetRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index 504991d8..72b84a34 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -1,6 +1,7 @@ package cat.udl.eps.softarch.demo.repository; import cat.udl.eps.softarch.demo.domain.Pet; +import cat.udl.eps.softarch.demo.domain.Shelter; import cat.udl.eps.softarch.demo.domain.User; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; @@ -10,4 +11,5 @@ public interface PetRepository extends CrudRepository, PagingAndSortingRepository { List findBySize(@Param("size") String size); + List findByShelter(@Param("Shelter") Shelter shelter); } From 8c9314f1372b8359a8c088a6fdde4d96c14167ed Mon Sep 17 00:00:00 2001 From: Sebastian Jitaru Date: Thu, 22 Feb 2024 16:44:36 +0100 Subject: [PATCH 24/54] Updated repo --- .../udl/eps/softarch/demo/repository/ScheduleRepository.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java index 9ee4acd8..1d562cc2 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java @@ -1,6 +1,7 @@ package cat.udl.eps.softarch.demo.repository; import cat.udl.eps.softarch.demo.domain.Schedule; +import cat.udl.eps.softarch.demo.domain.Shelter; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @@ -10,6 +11,8 @@ import java.util.List; public interface ScheduleRepository extends CrudRepository, PagingAndSortingRepository{ - List findByIdContaining(@Param("text") String text); + + //Get list of scheduled of a specific shelter + List findByAvailable(@Param("shelter") Shelter shelter); } From 4658894c84788faa834d496c03ea217ca4bacd2b Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 16:45:42 +0100 Subject: [PATCH 25/54] added data and id --- .../cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index da68c225..df5d812e 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -2,10 +2,17 @@ import com.fasterxml.jackson.annotation.JsonIdentityReference; import jakarta.persistence.Entity; +import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; +import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) +@Data @Entity public class ShelterVolunteer extends User { + @Id + private long Id; @JsonIdentityReference(alwaysAsId = true) @ManyToOne private Shelter userShelter; From 78fc156a773801c3d49f158bcc1846efae3ca78d Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 16:46:26 +0100 Subject: [PATCH 26/54] added Data for Lombok --- .../udl/eps/softarch/demo/domain/ShelterCertificate.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java index 1210a7f2..647aa626 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java @@ -10,7 +10,11 @@ import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) +@Data @Entity public class ShelterCertificate extends UriEntity { @@ -22,11 +26,6 @@ public class ShelterCertificate extends UriEntity { @NotNull private ZonedDateTime expirationDate; - @Override - public Long getId() { - return id; - } - @JsonIdentityReference(alwaysAsId = true) @ManyToOne private Shelter shelterServed; From 3b3a5aca72798079041ab193d209d2f014e059ef Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:47:57 +0100 Subject: [PATCH 27/54] Admin id is a string now --- .../cat/udl/eps/softarch/demo/repository/AdminRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java index 2ad49872..73882e5f 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java @@ -9,6 +9,6 @@ import java.util.List; -public interface AdminRepository extends CrudRepository, PagingAndSortingRepository { +public interface AdminRepository extends CrudRepository, PagingAndSortingRepository { List findByIdContaining(@Param("text") String text); } From da808e6f1e58310764090a6e77279b588f63a25e Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:50:33 +0100 Subject: [PATCH 28/54] modified PetRepository implementation --- .../java/cat/udl/eps/softarch/demo/repository/PetRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index 72b84a34..a8e17cc4 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -12,4 +12,5 @@ public interface PetRepository extends CrudRepository, PagingAndSortingRepository { List findBySize(@Param("size") String size); List findByShelter(@Param("Shelter") Shelter shelter); + } From ad7bba6edb3b144e331b20c70234ef26a5342404 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:54:20 +0100 Subject: [PATCH 29/54] modified PetRepository implementation --- .../cat/udl/eps/softarch/demo/repository/PetRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index a8e17cc4..ca8b4b8f 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -11,6 +11,6 @@ public interface PetRepository extends CrudRepository, PagingAndSortingRepository { List findBySize(@Param("size") String size); - List findByShelter(@Param("Shelter") Shelter shelter); + //List findByShelter(@Param("Shelter") Shelter shelter); } From 06a1d7b972229c720889bebf4ffd748e54d6f94f Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:56:08 +0100 Subject: [PATCH 30/54] fixed findByShelter --- .../cat/udl/eps/softarch/demo/repository/PetRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index ca8b4b8f..0318a37b 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -11,6 +11,6 @@ public interface PetRepository extends CrudRepository, PagingAndSortingRepository { List findBySize(@Param("size") String size); - //List findByShelter(@Param("Shelter") Shelter shelter); + List findByShelter(@Param("Shelter") Shelter shelter); } From 6e895307d9f0684211b447302863d470e3f1275e Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:57:45 +0100 Subject: [PATCH 31/54] commented findByShelter since it's not passing the checks. i'll take a look later --- .../cat/udl/eps/softarch/demo/repository/PetRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index 0318a37b..abbbe9be 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -11,6 +11,6 @@ public interface PetRepository extends CrudRepository, PagingAndSortingRepository { List findBySize(@Param("size") String size); - List findByShelter(@Param("Shelter") Shelter shelter); + //List findByShelter(@Param("Shelter") Shelter shelter); } From 2043363a3bdabf4bc950423066b4c9a3d29b84ba Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 17:21:43 +0100 Subject: [PATCH 32/54] refactor --- .../cat/udl/eps/softarch/demo/domain/ShelterCertificate.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java index 647aa626..51d6a760 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java @@ -1,8 +1,6 @@ package cat.udl.eps.softarch.demo.domain; import java.time.ZonedDateTime; -import java.util.Date; - import com.fasterxml.jackson.annotation.JsonIdentityReference; import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.Entity; From fd928dafc3c603892b5d301a1415614839359156 Mon Sep 17 00:00:00 2001 From: Faysal Badaoui Date: Thu, 22 Feb 2024 17:22:02 +0100 Subject: [PATCH 33/54] refactor --- .../java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index df5d812e..8e71d636 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -13,6 +13,7 @@ public class ShelterVolunteer extends User { @Id private long Id; + @JsonIdentityReference(alwaysAsId = true) @ManyToOne private Shelter userShelter; From 019c3aeb1acd4c5bd11c748e3f34a39489397aeb Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 16:57:45 +0100 Subject: [PATCH 34/54] commented findByShelter since it's not passing the checks --- .../cat/udl/eps/softarch/demo/repository/PetRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index 0318a37b..abbbe9be 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -11,6 +11,6 @@ public interface PetRepository extends CrudRepository, PagingAndSortingRepository { List findBySize(@Param("size") String size); - List findByShelter(@Param("Shelter") Shelter shelter); + //List findByShelter(@Param("Shelter") Shelter shelter); } From 3b006f60f0f3bf4e532fcf4fde038f24a6db7cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Escol=C3=A0=20Curc=C3=B3?= Date: Tue, 27 Feb 2024 15:43:05 +0100 Subject: [PATCH 35/54] New SocialNetwork structure, (fields changed) --- EntitiesModel.puml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EntitiesModel.puml b/EntitiesModel.puml index 4ea591b9..08d033d7 100644 --- a/EntitiesModel.puml +++ b/EntitiesModel.puml @@ -62,8 +62,9 @@ class ShelterCertificate { class SocialNetworks { id: Integer - instagram: String - twitter: String + username: String + typeOfSocialNetwork: String + url: String } class Schedule { From c362f87aeffc1c7e2aee541264562b494314d5d5 Mon Sep 17 00:00:00 2001 From: peremunoz Date: Wed, 28 Feb 2024 13:47:36 +0100 Subject: [PATCH 36/54] Fix repository --- .../eps/softarch/demo/repository/ShelterCertRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java index 4c174696..5fb82a19 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java @@ -1,9 +1,9 @@ package cat.udl.eps.softarch.demo.repository; -import cat.udl.eps.softarch.demo.domain.Shelter; +import cat.udl.eps.softarch.demo.domain.ShelterCertificate; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ShelterCertRepository extends CrudRepository, PagingAndSortingRepository { +public interface ShelterCertRepository extends CrudRepository, PagingAndSortingRepository { } From 092aaec95ae7f3cea1c8784cfa497a6d1a370ed0 Mon Sep 17 00:00:00 2001 From: peremunoz Date: Wed, 28 Feb 2024 13:49:44 +0100 Subject: [PATCH 37/54] Fix repository --- .../softarch/demo/repository/ShelterVolunteerRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java index 9d0594df..2258994c 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java @@ -1,8 +1,8 @@ package cat.udl.eps.softarch.demo.repository; -import cat.udl.eps.softarch.demo.domain.Shelter; +import cat.udl.eps.softarch.demo.domain.ShelterVolunteer; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ShelterVolunteerRepository extends CrudRepository, PagingAndSortingRepository { +public interface ShelterVolunteerRepository extends CrudRepository, PagingAndSortingRepository { } From 3c290509ac65b02d0ca1e2b71f5a01fb96062e26 Mon Sep 17 00:00:00 2001 From: peremunoz Date: Wed, 28 Feb 2024 13:49:56 +0100 Subject: [PATCH 38/54] Fix id type as extending from User --- .../java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index 8e71d636..0b658330 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -12,7 +12,7 @@ @Entity public class ShelterVolunteer extends User { @Id - private long Id; + private String Id; @JsonIdentityReference(alwaysAsId = true) @ManyToOne From 31c13da0aeb6a4eb5e04a3fedf24bd38513d6ef7 Mon Sep 17 00:00:00 2001 From: peremunoz Date: Wed, 28 Feb 2024 13:54:46 +0100 Subject: [PATCH 39/54] Remove redundant id --- .../cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index 0b658330..4656676b 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityReference; import jakarta.persistence.Entity; -import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import lombok.Data; import lombok.EqualsAndHashCode; @@ -11,9 +10,6 @@ @Data @Entity public class ShelterVolunteer extends User { - @Id - private String Id; - @JsonIdentityReference(alwaysAsId = true) @ManyToOne private Shelter userShelter; From 2789d410213dcfea8da36bab44d0b0c444697b6b Mon Sep 17 00:00:00 2001 From: peremunoz Date: Wed, 28 Feb 2024 13:54:46 +0100 Subject: [PATCH 40/54] Remove redundant id --- .../cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java | 4 ---- .../softarch/demo/repository/ShelterVolunteerRepository.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java index 0b658330..4656676b 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityReference; import jakarta.persistence.Entity; -import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import lombok.Data; import lombok.EqualsAndHashCode; @@ -11,9 +10,6 @@ @Data @Entity public class ShelterVolunteer extends User { - @Id - private String Id; - @JsonIdentityReference(alwaysAsId = true) @ManyToOne private Shelter userShelter; diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java index 2258994c..e1eea87a 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java @@ -4,5 +4,5 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ShelterVolunteerRepository extends CrudRepository, PagingAndSortingRepository { +public interface ShelterVolunteerRepository extends CrudRepository, PagingAndSortingRepository { } From 6aad974b79a633119e0f30b8abb110d4485d9ad9 Mon Sep 17 00:00:00 2001 From: globox97 Date: Wed, 28 Feb 2024 17:13:27 +0100 Subject: [PATCH 41/54] crud-Client --- .../java/cat/udl/eps/softarch/demo/domain/Location.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java index c4773b14..3ecb60b7 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java @@ -1,7 +1,6 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -27,4 +26,8 @@ public class Location extends UriEntity{ private String postalCode; + @OneToOne + @JoinColumn(name = "shelter_id") + private Shelter shelter; + } From 8b865983d82db3a9a5b5101d8846f87e7bdd0222 Mon Sep 17 00:00:00 2001 From: Sebastian Jitaru Date: Wed, 28 Feb 2024 17:18:19 +0100 Subject: [PATCH 42/54] Time variable type changed to LocalDateTime --- src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java index 4794123e..19fd6f9d 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDateTime; import java.util.Date; @Entity @@ -18,10 +19,10 @@ public class Schedule extends UriEntity { private Long id; @NotNull - private Date start; + private LocalDateTime start; @NotNull - private Date finish; + private LocalDateTime finish; @ManyToOne public Shelter available; From 08f72817c2fbd1c4dcb72607897711381a594f58 Mon Sep 17 00:00:00 2001 From: globox97 Date: Wed, 28 Feb 2024 17:26:30 +0100 Subject: [PATCH 43/54] Location Repository --- .../demo/repository/LocationRepository.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java new file mode 100644 index 00000000..23090db9 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -0,0 +1,15 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.*; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +import java.util.List; + +@RepositoryRestResource +public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { + + List findByIdContaining(@Param("text") String text); +} From 5f2b92e1e0247a5f31378491448fbe2f3b8b48a2 Mon Sep 17 00:00:00 2001 From: globox97 Date: Wed, 28 Feb 2024 17:46:11 +0100 Subject: [PATCH 44/54] crud-Location --- .../eps/softarch/demo/domain/Location.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/domain/Location.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java new file mode 100644 index 00000000..9176cfb5 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java @@ -0,0 +1,32 @@ +package cat.udl.eps.softarch.demo.domain; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@EqualsAndHashCode(callSuper = false) +@Data +@NoArgsConstructor +@AllArgsConstructor + +public class Location extends UriEntity { + @Id + private Long id; + + private String address; + + private float longitude; + + private float latitude; + + private String municipality; + + private String postalCode; + + @OneToOne + @JoinColumn(name = "shelter_id") + private Shelter shelter; +} From 532d52b40cbe1b5c21fa74344b8b4693c14e5a58 Mon Sep 17 00:00:00 2001 From: faysalbadaoui Date: Thu, 29 Feb 2024 14:29:27 +0100 Subject: [PATCH 45/54] rename to complete name --- ...terCertRepository.java => ShelterCertificateRepository.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/cat/udl/eps/softarch/demo/repository/{ShelterCertRepository.java => ShelterCertificateRepository.java} (64%) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java similarity index 64% rename from src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java rename to src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java index 4c174696..9e267e68 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java @@ -4,6 +4,6 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ShelterCertRepository extends CrudRepository, PagingAndSortingRepository { +public interface ShelterCertificateRepository extends CrudRepository, PagingAndSortingRepository { } From ad5bae97dbd009255377737e2fe35b6894bf6e32 Mon Sep 17 00:00:00 2001 From: faysalbadaoui Date: Thu, 29 Feb 2024 14:30:08 +0100 Subject: [PATCH 46/54] rename to complete name --- .../softarch/demo/repository/ShelterCertificateRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java index 5fb82a19..114d4322 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java @@ -4,6 +4,6 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ShelterCertRepository extends CrudRepository, PagingAndSortingRepository { +public interface ShelterCertificateRepository extends CrudRepository, PagingAndSortingRepository { } From 07a4799a7a2465d6f32d43c6b260aefac3b6ea82 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 15:24:18 +0100 Subject: [PATCH 47/54] crud-Location --- src/main/java/cat/udl/eps/softarch/demo/domain/Location.java | 2 +- .../udl/eps/softarch/demo/repository/LocationRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java index 9176cfb5..8c8602ef 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; @Entity -@EqualsAndHashCode(callSuper = false) +@EqualsAndHashCode(callSuper = true) @Data @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java index 23090db9..9e932e63 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -11,5 +11,5 @@ @RepositoryRestResource public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { - List findByIdContaining(@Param("text") String text); + Location findByIdContaining(@Param("text") String text); } From d874076187858634aa19bc36487e03b0a9e0fda3 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 29 Feb 2024 15:33:24 +0100 Subject: [PATCH 48/54] reduced imports with Ctrl+Alt+O --- src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java | 5 ++++- .../cat/udl/eps/softarch/demo/repository/PetRepository.java | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java index cd82c311..12b5b11c 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java @@ -1,6 +1,9 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java index abbbe9be..12af9121 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -1,7 +1,6 @@ package cat.udl.eps.softarch.demo.repository; import cat.udl.eps.softarch.demo.domain.Pet; -import cat.udl.eps.softarch.demo.domain.Shelter; import cat.udl.eps.softarch.demo.domain.User; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; From 26c371c84410ab7889114ff0ea0a5d5cff2cae62 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 29 Feb 2024 15:35:00 +0100 Subject: [PATCH 49/54] added favourites relation --- src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java index 12b5b11c..0bd9ddea 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java @@ -1,9 +1,6 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; @@ -27,4 +24,6 @@ public class Pet extends UriEntity { @ManyToOne public Shelter isIn; + @ManyToMany + public User favouritedBy; } From 0b3c6ea9812d81b1c2a2547ed0da54b118e241dd Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 29 Feb 2024 15:37:34 +0100 Subject: [PATCH 50/54] added favourites relation --- src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java index 0bd9ddea..4f2d28be 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java @@ -25,5 +25,5 @@ public class Pet extends UriEntity { @ManyToOne public Shelter isIn; @ManyToMany - public User favouritedBy; + public User[] favouritedBy; } From b773e2b27ba60246d1d5ed70ee3437e024568d66 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 15:38:05 +0100 Subject: [PATCH 51/54] crud-Location --- .../eps/softarch/demo/repository/LocationRepository.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java index 9e932e63..ec317eb4 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -1,15 +1,13 @@ package cat.udl.eps.softarch.demo.repository; -import cat.udl.eps.softarch.demo.domain.*; +import cat.udl.eps.softarch.demo.domain.Location; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import java.util.List; - @RepositoryRestResource public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { - Location findByIdContaining(@Param("text") String text); + /*Location findByIdContaining(@Param("text") String text);*/ } From e352ceb8e6df6661b7c316ff186a755babdadf66 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 15:41:01 +0100 Subject: [PATCH 52/54] crud-Location --- .../udl/eps/softarch/demo/repository/LocationRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java index ec317eb4..4bf6a879 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -9,5 +9,5 @@ @RepositoryRestResource public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { - /*Location findByIdContaining(@Param("text") String text);*/ + Location findByIdContaining(@Param("shelter") String shelter); } From 7f457845c844e762a17dadded0675f925a6bfbcb Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 15:42:45 +0100 Subject: [PATCH 53/54] crud-Location --- .../udl/eps/softarch/demo/repository/LocationRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java index 4bf6a879..b859c69a 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -5,9 +5,10 @@ import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import java.util.List; @RepositoryRestResource public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { - Location findByIdContaining(@Param("shelter") String shelter); + List findByIdContaining(@Param("shelter") String shelter); } From 0ce079d6c6899627584fbcc63bada2bad732b71f Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 16:00:58 +0100 Subject: [PATCH 54/54] crud-Location --- .../eps/softarch/demo/repository/LocationRepository.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java index b859c69a..10cc8bdc 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -1,14 +1,14 @@ package cat.udl.eps.softarch.demo.repository; import cat.udl.eps.softarch.demo.domain.Location; +import cat.udl.eps.softarch.demo.domain.Shelter; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import java.util.List; @RepositoryRestResource -public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { +public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { - List findByIdContaining(@Param("shelter") String shelter); + Location findByShelterId(@Param("shelter_id") Long shelterId); }