Commit ceabdea2 by Tuukka Kivilahti

Merge branch 'userreservation' into 'master'

Userreservation

User reservation rest for fetching user reservations (DRD)

See merge request !202
2 parents 7bad8abc 19e1d46e
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>moya-restpojo</artifactId> <artifactId>moya-restpojo</artifactId>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<version>1.0</version> <version>1.0.2</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
package fi.codecrew.moya.rest.pojo.userinfo.v1;
import javax.xml.bind.annotation.XmlElement;
public class UserReservationPlacePojo {
@XmlElement
private Integer placeid;
@XmlElement
private String placename;
@XmlElement
private boolean placegiven;
public String getPlacename() {
return placename;
}
public void setPlacename(String placename) {
this.placename = placename;
}
public boolean isPlacegiven() {
return placegiven;
}
public void setPlacegiven(boolean placegiven) {
this.placegiven = placegiven;
}
public Integer getPlaceid() {
return placeid;
}
public void setPlaceid(Integer placeid) {
this.placeid = placeid;
}
}
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.rest.pojo.userinfo.v1;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement()
public class UserReservationRoot {
private List<UserReservationRoot> eventusers;
public UserReservationRoot() {
super();
}
public List<UserReservationRoot> getEventusers() {
return eventusers;
}
public void setEventusers(List<UserReservationRoot> eventusers) {
this.eventusers = eventusers;
}
}
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<artifactId>moya-restpojo</artifactId> <artifactId>moya-restpojo</artifactId>
<version>${moya.version}</version> <version>1.0.2</version>
</dependency> </dependency>
</dependencies> </dependencies>
<parent> <parent>
......
...@@ -19,10 +19,9 @@ ...@@ -19,10 +19,9 @@
package fi.codecrew.moya.rest; package fi.codecrew.moya.rest;
import java.security.Principal; import java.security.Principal;
import java.util.List;
import javax.annotation.Resource;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.SessionContext;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -41,17 +40,20 @@ import javax.ws.rs.core.Response; ...@@ -41,17 +40,20 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.Status;
import org.apache.http.HttpRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.CardTemplateBeanLocal; import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.SimpleEventuserRoot; import fi.codecrew.moya.rest.pojo.userinfo.v1.SimpleEventuserRoot;
import fi.codecrew.moya.rest.pojo.userinfo.v1.UserReservationPlacePojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.UserReservationRoot;
import fi.codecrew.moya.util.UserSearchQuery; import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder; import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
import fi.codecrew.moya.utilities.SearchResult; import fi.codecrew.moya.utilities.SearchResult;
...@@ -76,6 +78,27 @@ public class UserRestView { ...@@ -76,6 +78,27 @@ public class UserRestView {
private static final Logger logger = LoggerFactory.getLogger(UserRestView.class); private static final Logger logger = LoggerFactory.getLogger(UserRestView.class);
@EJB
private PlaceGroupBeanLocal placegroupbean;
@GET
@Path("/{userid}/reservations")
public Response usersPlaces(@QueryParam("userid") Integer userid) {
EventUser eu = userbean.findByUserId(userid, false);
if (eu != null) {
List<GroupMembership> gms = placegroupbean.getMemberships(eu);
UserReservationRoot ret = new UserReservationRoot();
for (GroupMembership g : gms) {
UserReservationPlacePojo ur = new UserReservationPlacePojo();
ur.setPlaceid(g.getPlaceReservation().getId());
ur.setPlacegiven(g.getEnteredEvent() != null);
ur.setPlacename(g.getPlaceReservation().getName());
}
return Response.ok(ret).build();
}
return Response.status(Status.NOT_FOUND).build();
}
@POST @POST
@Path("/auth") @Path("/auth")
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!