Skip to content

Commit

Permalink
Merge pull request #26 from UdL-EPS-SoftArch/shelter-all
Browse files Browse the repository at this point in the history
Implemented shelter relations and repository
  • Loading branch information
rogargon authored Mar 7, 2024
2 parents 8aebd15 + 070613b commit 5e90f43
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 36 deletions.
7 changes: 2 additions & 5 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Adoptions.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package cat.udl.eps.softarch.demo.domain;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
Expand All @@ -22,7 +19,7 @@
public class Adoptions {

@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@OneToOne
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -13,6 +15,7 @@
public class Permission {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotNull
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package cat.udl.eps.softarch.demo.domain;

import com.fasterxml.jackson.annotation.JsonIdentityReference;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
Expand All @@ -22,6 +19,7 @@
public abstract class Pet extends UriEntity<Long> {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotBlank
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Role.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cat.udl.eps.softarch.demo.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -11,10 +9,11 @@
@Table(name = "Role") // Nombre de la tabla en la base de datos
@Data
@EqualsAndHashCode(callSuper = true)
public class Role extends UriEntity<String> {
public class Role extends UriEntity<Long> {

@Id
private String id;
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotBlank
private String name;
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Schedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@


import com.fasterxml.jackson.annotation.JsonIdentityReference;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -18,7 +15,7 @@
public class Schedule {

@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.AUTO)
private int Id;

@NotNull
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package cat.udl.eps.softarch.demo.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import jakarta.persistence.Id;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jdk.jfr.BooleanFlag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.time.LocalDateTime;

Expand All @@ -19,7 +17,23 @@
@EqualsAndHashCode(callSuper = false)
public class Shelter extends UriEntity<Long> {

@ManyToOne
@NotNull
@JsonIdentityReference(alwaysAsId = true)
private User user;

@ManyToOne
@NotNull
@JsonIdentityReference(alwaysAsId = true)
private Pet pet;

@OneToOne
@NotNull
@JsonIdentityReference(alwaysAsId = true)
private ShelterCertificate shelterCertificate;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package cat.udl.eps.softarch.demo.domain;

import com.fasterxml.jackson.annotation.JsonIdentityReference;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -20,6 +18,7 @@ public class ShelterCertificate {
private Shelter shelter;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import cat.udl.eps.softarch.demo.domain.Adoptions;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface AdoptionsRepository extends CrudRepository<Adoptions, String>, PagingAndSortingRepository<Adoptions, String> {
@RepositoryRestResource
public interface AdoptionsRepository extends CrudRepository<Adoptions, Long>, PagingAndSortingRepository<Adoptions, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import cat.udl.eps.softarch.demo.domain.Cat;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface CatRepository extends CrudRepository<Cat, String>, PagingAndSortingRepository<Cat, String> {
@RepositoryRestResource
public interface CatRepository extends CrudRepository<Cat, Long>, PagingAndSortingRepository<Cat, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import cat.udl.eps.softarch.demo.domain.Dog;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface DogRepository extends CrudRepository<Dog, String>, PagingAndSortingRepository<Dog, String> {
@RepositoryRestResource
public interface DogRepository extends CrudRepository<Dog, Long>, PagingAndSortingRepository<Dog, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import cat.udl.eps.softarch.demo.domain.User;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface LocationRepository extends CrudRepository<Location, String>, PagingAndSortingRepository<Location, String> {
@RepositoryRestResource
public interface LocationRepository extends CrudRepository<Location, Long>, PagingAndSortingRepository<Location, Long> {


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import cat.udl.eps.softarch.demo.domain.Pet;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface PetRepository extends CrudRepository<Pet, String>, PagingAndSortingRepository<Pet, String> {
@RepositoryRestResource
public interface PetRepository extends CrudRepository<Pet, Long>, PagingAndSortingRepository<Pet, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import cat.udl.eps.softarch.demo.domain.Schedule;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface ScheduleRepository extends CrudRepository<Schedule, String>, PagingAndSortingRepository<Schedule, String> {
@RepositoryRestResource
public interface ScheduleRepository extends CrudRepository<Schedule, Long>, PagingAndSortingRepository<Schedule, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import cat.udl.eps.softarch.demo.domain.ShelterCertificate;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

public interface ShelterCertificateRepository extends CrudRepository<ShelterCertificate, String>, PagingAndSortingRepository<ShelterCertificate, String> {
@RepositoryRestResource
public interface ShelterCertificateRepository extends CrudRepository<ShelterCertificate, Long>, PagingAndSortingRepository<ShelterCertificate, Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

@RepositoryRestResource
public interface ShelterRepository extends CrudRepository<Shelter, Long>, PagingAndSortingRepository<Shelter, Long> {

}

0 comments on commit 5e90f43

Please sign in to comment.