-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into crud-Shelter
- Loading branch information
Showing
17 changed files
with
207 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/cat/udl/eps/softarch/demo/domain/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<GrantedAuthority> getAuthorities(){ | ||
return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_CLIENT"); | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
src/main/java/cat/udl/eps/softarch/demo/domain/Location.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
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.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
|
||
public class Location extends UriEntity<Long>{ | ||
public class Location extends UriEntity<Long> { | ||
@Id | ||
private Long id; | ||
|
||
private String address; | ||
|
||
private float latitude; | ||
|
||
private float longitude; | ||
|
||
private String province; | ||
private float latitude; | ||
|
||
private String municipality; | ||
|
||
private String postalCode; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "shelter_id") | ||
private Shelter shelter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 23 additions & 7 deletions
30
src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
package cat.udl.eps.softarch.demo.domain; | ||
|
||
import java.util.Date; | ||
import java.time.ZonedDateTime; | ||
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; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
@Entity | ||
public class ShelterCertificate extends UriEntity<Long> { | ||
|
||
|
||
@Id | ||
@GeneratedValue() | ||
private Long id; | ||
private Date expirationDate; | ||
|
||
@Override | ||
public Long getId() { | ||
return id; | ||
} | ||
@JsonProperty(access = JsonProperty.Access.READ_ONLY) | ||
@NotNull | ||
private ZonedDateTime expirationDate; | ||
|
||
@JsonIdentityReference(alwaysAsId = true) | ||
@ManyToOne | ||
private Shelter shelterServed; | ||
} |
13 changes: 12 additions & 1 deletion
13
src/main/java/cat/udl/eps/softarch/demo/domain/ShelterVolunteer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package cat.udl.eps.softarch.demo.domain; | ||
|
||
public class ShelterVolunteer extends User { | ||
import com.fasterxml.jackson.annotation.JsonIdentityReference; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
@Entity | ||
public class ShelterVolunteer extends User { | ||
@JsonIdentityReference(alwaysAsId = true) | ||
@ManyToOne | ||
private Shelter userShelter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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<Admin, String>, PagingAndSortingRepository<Admin, String> { | ||
List<User> findByIdContaining(@Param("text") String text); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/cat/udl/eps/softarch/demo/repository/ClientRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Client, String>, PagingAndSortingRepository<Client, String> { | ||
|
||
/* 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<User> findByIdContaining(@Param("text") String text); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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; | ||
|
||
@RepositoryRestResource | ||
public interface LocationRepository extends CrudRepository<Location, Long>, PagingAndSortingRepository<Location, Long> { | ||
|
||
Location findByShelterId(@Param("shelter_id") Long shelterId); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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<Pet, Long>, PagingAndSortingRepository<Pet, Long> { | ||
List<User> findBySize(@Param("size") String size); | ||
//List<Shelter> findByShelter(@Param("Shelter") Shelter shelter); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/cat/udl/eps/softarch/demo/repository/ScheduleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
|
||
import java.util.List; | ||
|
||
public interface ScheduleRepository extends CrudRepository<Schedule, Long>, PagingAndSortingRepository<Schedule, Long>{ | ||
|
||
//Get list of scheduled of a specific shelter | ||
List<Schedule> findByAvailable(@Param("shelter") Shelter shelter); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package cat.udl.eps.softarch.demo.repository; | ||
|
||
import cat.udl.eps.softarch.demo.domain.ShelterCertificate; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
public interface ShelterCertificateRepository extends CrudRepository<ShelterCertificate, Long>, PagingAndSortingRepository<ShelterCertificate, Long> { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/cat/udl/eps/softarch/demo/repository/ShelterVolunteerRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package cat.udl.eps.softarch.demo.repository; | ||
|
||
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<ShelterVolunteer, String>, PagingAndSortingRepository<ShelterVolunteer, String> { | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/cat/udl/eps/softarch/demo/repository/SocialNetworksRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SocialNetworks,Long> { | ||
|
||
} |