PMT-4: Create Allocation Model and repository
Some checks failed
Quality Check / Validate OAS (push) Successful in 32s
Quality Check / Static Analysis (push) Failing after 1m4s
Quality Check / Linting (push) Successful in 1m7s
Quality Check / Testing (push) Successful in 1m9s

Co-authored-by: Rajbir Singh <rajbir.singh@hmmh.de>
Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-10-10 11:43:47 +02:00 committed by Snoweuph
parent d38c5a1084
commit c434a84b90
Signed by: Snoweuph
GPG key ID: BEFC41DA223CEC55
4 changed files with 57 additions and 0 deletions

View file

@ -1,6 +1,8 @@
package de.hmmh.pmt; package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper; 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.Project;
import de.hmmh.pmt.db.ProjectRepository; import de.hmmh.pmt.db.ProjectRepository;
import de.hmmh.pmt.dtos.CreateProjectDTO; import de.hmmh.pmt.dtos.CreateProjectDTO;
@ -30,6 +32,8 @@ public class ApiController implements DefaultApi {
private ApiClientFactory apiClientFactory; private ApiClientFactory apiClientFactory;
@Autowired @Autowired
private ProjectRepository projectRepository; private ProjectRepository projectRepository;
@Autowired
AllocationRepository allocationRepository;
@Override @Override
public Optional<ObjectMapper> getObjectMapper() { public Optional<ObjectMapper> getObjectMapper() {

View file

@ -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
}

View file

@ -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;
}

View file

@ -0,0 +1,7 @@
package de.hmmh.pmt.db;
import org.springframework.data.repository.CrudRepository;
public interface AllocationRepository extends CrudRepository<Allocation, AllocationId> {
}