Commit e908f55b by Tuomas Riihimäki

Add rest functions for giving out places

1 parent b5eedaea
......@@ -50,12 +50,14 @@ import com.wordnik.swagger.annotations.ApiParam;
import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.beans.TicketBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo;
......@@ -95,6 +97,50 @@ public class UserRestView {
@EJB
private TicketBeanLocal ticketbean;
@EJB
private PlaceBeanLocal placebean;
@POST
@Path("/giveplace/{placeId}")
public Response setPlacesGivenStatus(
@PathParam("placeId") Integer id,
@FormParam("action") String status) {
Place place = placebean.find(id);
if (place == null) {
ResponseBuilder resp = Response.status(Status.BAD_REQUEST);
resp.entity("Place not found with id: " + id);
return resp.build();
}
GroupMembership gm = place.getPlaceReserver();
if (gm == null) {
ResponseBuilder resp = Response.status(Status.BAD_REQUEST);
resp.entity("No group membership for place: " + id);
return resp.build();
}
ResponseBuilder resp = Response.ok();
switch (status) {
case "give":
gm = placegroupbean.markGroupMembershipEntered(gm);
break;
case "ungive":
gm = placegroupbean.markGroupMembershipNotEntered(gm);
break;
default:
resp = Response.status(Status.BAD_REQUEST);
resp.status(Status.BAD_REQUEST);
resp.entity("Unknown status" + status + " possible values: 'give' and 'ungive'");
return resp.build();
}
resp.entity(PojoUtils.initUserReservationPlace(gm));
return resp.build();
}
@GET
@Path("/reservationswithcode/{code}")
public Response getPlacesWithCode(@PathParam("code") String code) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!