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 0000000000000000000000000000000000000000..e3ad42205b6ae45070ae70f643a9f6e662757a18 --- /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 ba8bffad7c29716ddfd9bbb5f049e3f19b0241c4..328b415f28a8379e81258b79eb671e16614e0417 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; }