From 6aad974b79a633119e0f30b8abb110d4485d9ad9 Mon Sep 17 00:00:00 2001 From: globox97 Date: Wed, 28 Feb 2024 17:13:27 +0100 Subject: [PATCH 1/8] 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 08f72817c2fbd1c4dcb72607897711381a594f58 Mon Sep 17 00:00:00 2001 From: globox97 Date: Wed, 28 Feb 2024 17:26:30 +0100 Subject: [PATCH 2/8] 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 3/8] 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 07a4799a7a2465d6f32d43c6b260aefac3b6ea82 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 15:24:18 +0100 Subject: [PATCH 4/8] 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 b773e2b27ba60246d1d5ed70ee3437e024568d66 Mon Sep 17 00:00:00 2001 From: globox97 Date: Thu, 29 Feb 2024 15:38:05 +0100 Subject: [PATCH 5/8] 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 6/8] 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 7/8] 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 8/8] 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); }