PMT-26 refactor naming pmt.yml, ApiController, Mapper
All checks were successful
Quality Check / Validate OAS (push) Successful in 53s
Quality Check / Validate OAS (pull_request) Successful in 1m6s
Quality Check / Linting (push) Successful in 2m3s
Quality Check / Linting (pull_request) Successful in 2m9s
Quality Check / Testing (push) Successful in 2m23s
Quality Check / Static Analysis (push) Successful in 2m29s
Quality Check / Testing (pull_request) Successful in 2m19s
Quality Check / Static Analysis (pull_request) Successful in 2m22s

This commit is contained in:
Rajbir Singh 2024-10-23 08:46:53 +02:00
parent b3327ad351
commit 8fa066b374
3 changed files with 16 additions and 19 deletions

View file

@ -77,7 +77,7 @@ components:
qualificationId:
type: integer
format: int64
EmployeeDTO:
Employee:
type: object
properties:
id:
@ -100,8 +100,8 @@ components:
skillSet:
type: array
items:
$ref: '#/components/schemas/QualificationDTO'
QualificationDTO:
$ref: '#/components/schemas/Qualification'
Qualification:
type: object
properties:
skill:
@ -109,13 +109,13 @@ components:
id:
type: integer
format: int64
GetEmployeesByProjectDTO:
ProjectEmployeesDTO:
type: object
properties:
employees:
type: array
items:
$ref: "#/components/schemas/EmployeeDTO"
$ref: "#/components/schemas/Employee"
responses:
Ok:
description: "OK"
@ -268,7 +268,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/GetEmployeesByProjectDTO"
$ref: "#/components/schemas/ProjectEmployeesDTO"
description: 'Get a List of all Employees from a specific Project '
404:
$ref: '#/components/responses/NotFound'

View file

@ -145,12 +145,12 @@ public class ApiController implements DefaultApi {
}
@Override
public ResponseEntity<GetEmployeesByProjectDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
public ResponseEntity<ProjectEmployeesDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
if (!projectRepository.existsById(id)) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
GetEmployeesByProjectDTO dto = new GetEmployeesByProjectDTO();
ProjectEmployeesDTO dto = new ProjectEmployeesDTO();
List<Allocation> allocationsByProject = allocationRepository.findAllByProjectId(id);
if (allocationsByProject.isEmpty()) {
return new ResponseEntity<>(dto, HttpStatus.OK);
@ -161,7 +161,7 @@ public class ApiController implements DefaultApi {
.collect(Collectors.toSet());
try {
List<EmployeeDTO> employees = apiClientFactory.getEmployeeApi().findAll1().stream()
List<Employee> employees = apiClientFactory.getEmployeeApi().findAll1().stream()
.filter(employeeResponseDTO -> employeeIds.contains(employeeResponseDTO.getId()))
.map(mapper::map)
.toList();
@ -170,8 +170,5 @@ public class ApiController implements DefaultApi {
} catch (RestClientException exception) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
// Was wenn, die Liste der Allocation und die Liste der EmployeeResponseDTO nicht die gleiche Anzahl haben.
// Das EmployeeResponseDTO wird vom EmployeeService gestellt, sollte man die Daten auf eigenes DTO mappen.
}
}

View file

@ -3,8 +3,8 @@ package de.hmmh.pmt.util;
import de.hmmh.pmt.db.Project;
import de.hmmh.pmt.dtos.CreateProjectDTO;
import de.hmmh.pmt.dtos.CreatedProjectDTO;
import de.hmmh.pmt.dtos.EmployeeDTO;
import de.hmmh.pmt.dtos.QualificationDTO;
import de.hmmh.pmt.dtos.Employee;
import de.hmmh.pmt.dtos.Qualification ;
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
import de.hmmh.pmt.employee.dtos.QualificationGetDTO;
import org.springframework.stereotype.Component;
@ -36,8 +36,8 @@ public class Mapper {
return dto;
}
public EmployeeDTO map(EmployeeResponseDTO employeeResponseDTO) {
EmployeeDTO dto = new EmployeeDTO();
public Employee map(EmployeeResponseDTO employeeResponseDTO) {
Employee dto = new Employee();
dto.setId(employeeResponseDTO.getId());
dto.setLastName(employeeResponseDTO.getLastName());
dto.setFirstName(employeeResponseDTO.getFirstName());
@ -46,7 +46,7 @@ public class Mapper {
dto.setCity(employeeResponseDTO.getCity());
dto.setPhone(employeeResponseDTO.getPhone());
List<QualificationDTO> skillSet = employeeResponseDTO.getSkillSet().stream()
List<Qualification > skillSet = employeeResponseDTO.getSkillSet().stream()
.map(this::map)
.toList();
@ -54,8 +54,8 @@ public class Mapper {
return dto;
}
private QualificationDTO map(QualificationGetDTO qualificationGetDTO) {
QualificationDTO dto = new QualificationDTO();
private Qualification map(QualificationGetDTO qualificationGetDTO) {
Qualification dto = new Qualification ();
dto.setId(qualificationGetDTO.getId());
dto.setSkill(qualificationGetDTO.getSkill());
return dto;