From 6209292822fde1d711e2b42375a73744c41e9f60 Mon Sep 17 00:00:00 2001 From: Julian Dehne <julian.dehne@uni-potsdam.de> Date: Tue, 10 Jul 2018 12:33:41 +0200 Subject: [PATCH] added rest service for phases --- .../gf/core/states/PhasesService.java | 47 +++++++++++++++++++ .../gf/core/states/ProjectPhase.java | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java new file mode 100644 index 00000000..e3ad4220 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java @@ -0,0 +1,47 @@ +package unipotsdam.gf.core.states; + +import unipotsdam.gf.core.management.Management; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.interfaces.IPhases; + +import javax.inject.Inject; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + +/** + * REST API for switching phases + * In order to look up the possible phases @see unipotsdam.gf.core.states.ProjectPhase + */ +@Path("/phases") +public class PhasesService { + + @Inject + private IPhases phases; + + @Inject + private Management management; + + /** + * end phase + * @param projectPhase + * @param projectId + */ + @Path("/{projectPhase}/projects/{projectId}") + @POST + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public void endPhase(@PathParam("projectPhase") String projectPhase, @PathParam("projectId") String projectId) { + phases.endPhase(ProjectPhase.valueOf(projectPhase), management.getProjectById(projectId)); + } + + /** + * get current phase + * @param projectId + * @return + */ + @Path("/{projectPhase}/projects/{projectId}") + @GET + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public String getCurrentPhase(@PathParam("projectId") String projectId) { + return management.getProjectById(projectId).getPhase(); + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java index ba8bffad..328b415f 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java @@ -2,5 +2,5 @@ package unipotsdam.gf.core.states; public enum ProjectPhase { CourseCreation, GroupFormation, DossierFeedback, Execution, Assessment, - Projectfinished + Projectfinished; } -- GitLab