PMT-4: Fix Relation and Functions of Allocations
All checks were successful
Quality Check / Validate OAS (push) Successful in 51s
Quality Check / Validate OAS (pull_request) Successful in 1m4s
Quality Check / Linting (push) Successful in 2m3s
Quality Check / Linting (pull_request) Successful in 2m11s
Quality Check / Testing (push) Successful in 2m18s
Quality Check / Testing (pull_request) Successful in 2m15s
Quality Check / Static Analysis (push) Successful in 2m26s
Quality Check / Static Analysis (pull_request) Successful in 2m21s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-10-21 12:37:25 +02:00
parent f5717076a8
commit 3a4c3fc21c
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
2 changed files with 15 additions and 10 deletions

View file

@ -137,7 +137,7 @@ public class ApiController implements DefaultApi {
Allocation allocation = new Allocation(); Allocation allocation = new Allocation();
allocation.setEmployeeId(employee.getId()); allocation.setEmployeeId(employee.getId());
allocation.setRole(body.getQualificationId()); allocation.setRole(body.getQualificationId());
allocation.setProjectId(project.getId()); allocation.setProject(project);
allocationRepository.save(allocation); allocationRepository.save(allocation);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);

View file

@ -2,10 +2,7 @@ package de.hmmh.pmt.db;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ -15,10 +12,13 @@ import lombok.Setter;
@IdClass(AllocationId.class) @IdClass(AllocationId.class)
@Table(name = "allocation") @Table(name = "allocation")
public class Allocation { public class Allocation {
@Id @Id
@Setter(AccessLevel.NONE)
private Long projectId; private Long projectId;
@ManyToOne @ManyToOne
@JoinColumn(name = "projectId", insertable = false, updatable = false) @JoinColumn(name = "allocation_project", referencedColumnName = "id", insertable = false, updatable = false)
private Project project; private Project project;
@Id @Id
@ -26,4 +26,9 @@ public class Allocation {
@NotNull @NotNull
private Long role; // This is a QualificationId private Long role; // This is a QualificationId
public void setProject(Project project) {
this.project = project;
this.projectId = project.getId();
}
} }