Commit 3b7d50df by Tuomas Riihimäki

Add rest api for usercard fetching from eventuserid

'Active' field for map rest
eventuserId for printedCard
1 parent 009690c8
......@@ -5,11 +5,14 @@ import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.rest.pojo.PrintedCardRestPojo;
import fi.codecrew.moya.rest.pojo.SimpleEventuserRoot;
import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
......@@ -24,6 +27,9 @@ public class UserRestView {
@EJB
private UserBeanLocal userbean;
@EJB
private CardTemplateBeanLocal cardbean;
@GET
@Path("/eventusers")
public SimpleEventuserRoot getEventUsers() {
......@@ -31,4 +37,12 @@ public class UserRestView {
SearchResult<EventUser> users = userbean.getThisEventsUsers(q);
return SimpleEventuserRoot.parse(users.getResults());
}
@GET
@Path("/card/{eventuserId}")
public PrintedCardRestPojo getUsersCard(@PathParam("eventuserId") Integer eventuserid) {
EventUser user = userbean.findByEventUserId(eventuserid);
return new PrintedCardRestPojo(cardbean.checkPrintedCard(user));
}
}
......@@ -51,6 +51,11 @@ public class MapRoot {
return map.getId();
}
@XmlElement(name = "active")
public boolean isActive() {
return map.isActive();
}
}
public static MapRoot parseMaps(List<EventMap> eventMaps) {
......
......@@ -20,6 +20,11 @@ public class PrintedCardRestPojo {
this.card = card;
}
@XmlElement(name = "eventuserId")
public Integer getEventuserId() {
return card.getUser().getId();
}
@XmlTransient
private final PrintedCard card;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!