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.setEmployeeId(employee.getId());
allocation.setRole(body.getQualificationId());
allocation.setProjectId(project.getId());
allocation.setProject(project);
allocationRepository.save(allocation);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);

View file

@ -2,10 +2,7 @@ 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;
import lombok.*;
@NoArgsConstructor
@AllArgsConstructor
@ -15,10 +12,13 @@ import lombok.Setter;
@IdClass(AllocationId.class)
@Table(name = "allocation")
public class Allocation {
@Id
@Setter(AccessLevel.NONE)
private Long projectId;
@ManyToOne
@JoinColumn(name = "projectId", insertable = false, updatable = false)
@JoinColumn(name = "allocation_project", referencedColumnName = "id", insertable = false, updatable = false)
private Project project;
@Id
@ -26,4 +26,9 @@ public class Allocation {
@NotNull
private Long role; // This is a QualificationId
public void setProject(Project project) {
this.project = project;
this.projectId = project.getId();
}
}