fix: bugfix
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -29,7 +30,7 @@ public class AdminApiService {
|
||||
this.administratorService = administratorService;
|
||||
}
|
||||
|
||||
// TODO: check if test are sufficient
|
||||
// TODO: check if tests are sufficients - peer verification required
|
||||
public Iterable<Project> getProjectsOfAdmin(String email) {
|
||||
return projectService.getProjectsByAdminId(
|
||||
administratorService.getAdministratorById(
|
||||
@ -41,29 +42,35 @@ public class AdminApiService {
|
||||
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) {
|
||||
if (decision.isAccepted == 1) {
|
||||
projectService.updateProject(
|
||||
decision.projectId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
ACTIVE,
|
||||
this.administratorService.getAdministratorById(decision.projectId));
|
||||
}
|
||||
projectService.updateProject(
|
||||
decision.projectId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
(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 ? => it does not, thus needing to
|
||||
// have null in the project id field
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
Reference in New Issue
Block a user