merge
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
package enseirb.myinpulse.service;
|
||||
|
||||
import static enseirb.myinpulse.model.ProjectDecisionValue.ACTIVE;
|
||||
import static enseirb.myinpulse.model.ProjectDecisionValue.REJECTED;
|
||||
|
||||
import enseirb.myinpulse.model.*;
|
||||
import enseirb.myinpulse.service.database.AdministratorService;
|
||||
import enseirb.myinpulse.service.database.ProjectService;
|
||||
@ -44,7 +47,7 @@ public class AdminApiService {
|
||||
this.reportService = reportService;
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
// TODO: check if tests are sufficients - peer verification required
|
||||
public Iterable<Project> getProjectsOfAdmin(String mail) {
|
||||
return projectService.getProjectsByAdminId(
|
||||
administratorService.getAdministratorById(
|
||||
@ -54,27 +57,38 @@ public class AdminApiService {
|
||||
// TODO
|
||||
public Iterable<Appointment> getUpcomingAppointments(String mail) {
|
||||
logger.info("User {} check their upcoming appointments", mail);
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
// TODO: check if tests are sufficient - peer verification required
|
||||
public Iterable<Project> getPendingProjects() {
|
||||
return this.projectService.getPendingProjects();
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
// TODO: check if tests are sufficient - peer verification required
|
||||
public void validateProject(ProjectDecision decision) {
|
||||
projectService.updateProject(
|
||||
decision.projectId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"ACTIVE",
|
||||
this.administratorService.getAdministratorById(decision.projectId));
|
||||
(decision.isAccepted == 1) ? ACTIVE : REJECTED,
|
||||
this.administratorService.getAdministratorById(decision.adminId));
|
||||
}
|
||||
|
||||
// TODO: solve todo + test
|
||||
// TODO: check if tests are sufficient - peer verification required
|
||||
public void addNewProject(Project project) {
|
||||
projectService.addNewProject(project); // TODO: how can the front know the ID ?
|
||||
project.setIdProject(null);
|
||||
// We remove it from the request to be sure that it will be auto generated
|
||||
try {
|
||||
this.projectService.getProjectByName(project.getProjectName(), true);
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "Project already exists");
|
||||
} catch (ResponseStatusException e) {
|
||||
if (e.getStatusCode() == HttpStatus.CONFLICT) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "Project already exists");
|
||||
}
|
||||
projectService.addNewProject(project);
|
||||
}
|
||||
}
|
||||
|
||||
public void createAppointmentReport(long appointmentId, Report report, String mail) {
|
||||
|
Reference in New Issue
Block a user