From 36e604d2b050ba3c54cd11932898f3df54c423e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Thu, 10 Oct 2024 11:43:47 +0200 Subject: [PATCH] PMT-4: Create Allocation Model and repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rajbir Singh Signed-off-by: Dominik Säume --- src/main/java/de/hmmh/pmt/ApiController.java | 4 +++ src/main/java/de/hmmh/pmt/db/Allocation.java | 29 +++++++++++++++++++ .../java/de/hmmh/pmt/db/AllocationId.java | 17 +++++++++++ .../de/hmmh/pmt/db/AllocationRepository.java | 7 +++++ 4 files changed, 57 insertions(+) create mode 100644 src/main/java/de/hmmh/pmt/db/Allocation.java create mode 100644 src/main/java/de/hmmh/pmt/db/AllocationId.java create mode 100644 src/main/java/de/hmmh/pmt/db/AllocationRepository.java diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index 51799b5..c20b9f4 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -1,6 +1,8 @@ package de.hmmh.pmt; import com.fasterxml.jackson.databind.ObjectMapper; +import de.hmmh.pmt.db.AllocationRepository; +import de.hmmh.pmt.employee.ApiClientFactory; import de.hmmh.pmt.db.Project; import de.hmmh.pmt.db.ProjectRepository; import de.hmmh.pmt.dtos.CreateProjectDTO; @@ -30,6 +32,8 @@ public class ApiController implements DefaultApi { private ApiClientFactory apiClientFactory; @Autowired private ProjectRepository projectRepository; + @Autowired + AllocationRepository allocationRepository; @Override public Optional getObjectMapper() { diff --git a/src/main/java/de/hmmh/pmt/db/Allocation.java b/src/main/java/de/hmmh/pmt/db/Allocation.java new file mode 100644 index 0000000..5ed7008 --- /dev/null +++ b/src/main/java/de/hmmh/pmt/db/Allocation.java @@ -0,0 +1,29 @@ +package de.hmmh.pmt.db; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +@Entity +@IdClass(AllocationId.class) +@Table(name = "allocation") +public class Allocation { + @Id + private Long projectId; + @ManyToOne + @JoinColumn(name = "projectId", insertable = false, updatable = false) + private Project project; + + @Id + private Long employeeId; + + @NotNull + private Long role; // This is a QualificationId +} diff --git a/src/main/java/de/hmmh/pmt/db/AllocationId.java b/src/main/java/de/hmmh/pmt/db/AllocationId.java new file mode 100644 index 0000000..2274d71 --- /dev/null +++ b/src/main/java/de/hmmh/pmt/db/AllocationId.java @@ -0,0 +1,17 @@ +package de.hmmh.pmt.db; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.io.Serializable; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class AllocationId implements Serializable { + private Long projectId; + private Long employeeId; +} diff --git a/src/main/java/de/hmmh/pmt/db/AllocationRepository.java b/src/main/java/de/hmmh/pmt/db/AllocationRepository.java new file mode 100644 index 0000000..387b20f --- /dev/null +++ b/src/main/java/de/hmmh/pmt/db/AllocationRepository.java @@ -0,0 +1,7 @@ +package de.hmmh.pmt.db; + +import org.springframework.data.repository.CrudRepository; + +public interface AllocationRepository extends CrudRepository { + +}