From 17e20ee8309d4d908b084178cfdd16dd46830904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Mon, 21 Oct 2024 13:04:25 +0200 Subject: [PATCH] PMT-4: Add Database Model for Allocations --- src/main/java/de/hmmh/pmt/db/Allocation.java | 34 +++++++++++++++++++ .../java/de/hmmh/pmt/db/AllocationId.java | 18 ++++++++++ src/main/resources/spotbugs-exclude.xml | 4 +++ 3 files changed, 56 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 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..3f2ae9b --- /dev/null +++ b/src/main/java/de/hmmh/pmt/db/Allocation.java @@ -0,0 +1,34 @@ +package de.hmmh.pmt.db; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +@Entity +@IdClass(AllocationId.class) +@Table(name = "allocation") +public class Allocation { + + @Id + @Setter(AccessLevel.NONE) + private Long projectId; + + @ManyToOne + @JoinColumn(name = "allocation_project", referencedColumnName = "id", insertable = false, updatable = false) + private Project project; + + @Id + private Long employeeId; + + @NotNull + private Long role; // This is a QualificationId + + public void setProject(Project project) { + this.project = project; + this.projectId = project.getId(); + } +} 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..355cfa9 --- /dev/null +++ b/src/main/java/de/hmmh/pmt/db/AllocationId.java @@ -0,0 +1,18 @@ +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 static final long serialVersionUID = 1L; + private Long projectId; + private Long employeeId; +} diff --git a/src/main/resources/spotbugs-exclude.xml b/src/main/resources/spotbugs-exclude.xml index af92a63..6fab22b 100644 --- a/src/main/resources/spotbugs-exclude.xml +++ b/src/main/resources/spotbugs-exclude.xml @@ -4,6 +4,10 @@ + + + +