Compare commits

...

5 commits

Author SHA1 Message Date
Rajbir Singh
33157758c3 PMT-40 Mapper
All checks were successful
Quality Check / Validate OAS (push) Successful in 1m28s
Quality Check / Validate OAS (pull_request) Successful in 1m36s
Quality Check / Linting (push) Successful in 2m46s
Quality Check / Linting (pull_request) Successful in 2m48s
Quality Check / Testing (push) Successful in 3m0s
Quality Check / Static Analysis (push) Successful in 3m4s
Quality Check / Testing (pull_request) Successful in 2m57s
Quality Check / Static Analysis (pull_request) Successful in 3m0s
2024-10-23 14:52:58 +02:00
Rajbir Singh
54725d7fb1 PMT-40 remove Mapper
Some checks failed
Quality Check / Validate OAS (push) Has been cancelled
Quality Check / Testing (push) Has been cancelled
Quality Check / Static Analysis (push) Has been cancelled
Quality Check / Linting (push) Has been cancelled
Quality Check / Validate OAS (pull_request) Successful in 1m14s
Quality Check / Static Analysis (pull_request) Failing after 2m13s
Quality Check / Linting (pull_request) Failing after 2m17s
Quality Check / Testing (pull_request) Failing after 2m16s
2024-10-23 14:52:18 +02:00
Rajbir Singh
ada6f9c90f PMT-40 Mapper 2024-10-23 14:52:18 +02:00
Rajbir Singh
f0b7317d49 PMT-40 implements ApiController
Some checks failed
Quality Check / Validate OAS (push) Successful in 36s
Quality Check / Linting (push) Failing after 1m6s
Quality Check / Static Analysis (push) Failing after 1m5s
Quality Check / Testing (push) Failing after 1m5s
Quality Check / Validate OAS (pull_request) Successful in 47s
Quality Check / Static Analysis (pull_request) Failing after 1m1s
Quality Check / Linting (pull_request) Failing after 1m4s
Quality Check / Testing (pull_request) Failing after 1m1s
2024-10-23 14:45:59 +02:00
Rajbir Singh
32b81b5d41 PMT-40 define Endpoint
Some checks failed
Quality Check / Static Analysis (push) Has been cancelled
Quality Check / Testing (push) Has been cancelled
Quality Check / Linting (push) Has been cancelled
Quality Check / Validate OAS (push) Has been cancelled
2024-10-23 14:45:28 +02:00
3 changed files with 91 additions and 0 deletions

View file

@ -87,6 +87,31 @@ components:
plannedEnd:
type: string
format: date-time
Project:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
goal:
type: string
customerId:
type: integer
format: int64
administratorId:
type: integer
format: int64
start:
type: string
format: date-time
plannedEnd:
type: string
format: date-time
realEnd:
type: string
format: date-time
AddEmployeeDTO:
type: object
properties:
@ -135,6 +160,13 @@ components:
type: array
items:
$ref: "#/components/schemas/Employee"
EmployeeProjectsDTO:
type: object
properties:
projects:
type: array
items:
$ref: '#/components/schemas/Project'
responses:
Unauthorized:
description: "Unauthorized"
@ -366,3 +398,25 @@ paths:
$ref: '#/components/responses/NotFound'
500:
$ref: "#/components/responses/InternalError"
/employye/{id}/projects:
get:
description: "getAllProjects"
operationId: "Get a List of all Projects from a specific Employee"
parameters:
- in: path
name: id
schema:
type: integer
format: int64
required: true
responses:
200:
content:
application/json:
schema:
$ref: "#/components/schemas/EmployeeProjectsDTO"
description: 'Get a List of all Projects from a specific Employee'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalError'

View file

@ -3,6 +3,7 @@ package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hmmh.pmt.db.*;
import de.hmmh.pmt.db.Project;
import de.hmmh.pmt.dtos.*;
import de.hmmh.pmt.employee.ApiClientFactory;
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
@ -225,4 +226,28 @@ public class ApiController implements DefaultApi {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@Override
public ResponseEntity<EmployeeProjectsDTO> getAListOfAllProjectsFromASpecificEmployee(Long id) {
if (!projectRepository.existsById(id)) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
EmployeeProjectsDTO dto = new EmployeeProjectsDTO();
List<Allocation> allocationsByEmployee = allocationRepository.findAllByEmployeeId(id);
if (allocationsByEmployee.isEmpty()) {
return new ResponseEntity<>(dto, HttpStatus.OK);
}
Set<Project> projects = allocationsByEmployee.stream()
.map(Allocation::getProject)
.collect(Collectors.toSet());
EmployeeProjectsDTO response = new EmployeeProjectsDTO();
for (Project project : projects) {
response.addProjectsItem(mapper.mapProject(project));
}
return new ResponseEntity<>(HttpStatus.OK);
}
}

View file

@ -72,4 +72,16 @@ public class Mapper {
project.setPlannedEnd(dto.getPlannedEnd());
return project;
}
public de.hmmh.pmt.dtos.Project mapProject(Project project){
de.hmmh.pmt.dtos.Project dto = new de.hmmh.pmt.dtos.Project();
dto.setId(project.getId());
dto.setName(project.getName());
dto.setGoal(project.getGoal());
dto.setCustomerId(project.getCustomerId());
dto.setAdministratorId(project.getAdministratorId());
dto.setStart(project.getStart());
dto.setPlannedEnd(project.getPlannedEnd());
dto.setRealEnd(project.getRealEnd());
return dto;
}
}