Commit 7b1d2fa9 by Tuukka Kivilahti

Merge remote-tracking branch 'origin/master' into incomingMuutoksia

2 parents d89b0eec 7df098f7
...@@ -241,6 +241,12 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -241,6 +241,12 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE maps ADD COLUMN mime_type TEXT default 'image/png'", "ALTER TABLE maps ADD COLUMN mime_type TEXT default 'image/png'",
}); });
dbUpdates.add(new String[] {
"ALTER TABLE group_memberships ADD COLUMN entered_event_admin_id INTEGER",
"ALTER TABLE group_memberships ADD CONSTRAINT FK_group_memberships_entered_event_admin_id FOREIGN KEY (entered_event_admin_id) REFERENCES event_users (id)",
});
} }
public BootstrapBean() { public BootstrapBean() {
......
...@@ -43,138 +43,150 @@ import javax.persistence.TemporalType; ...@@ -43,138 +43,150 @@ import javax.persistence.TemporalType;
// GroupMembership.EVENTUSER_ID, GroupMembership.GROUP_ID }) }) // GroupMembership.EVENTUSER_ID, GroupMembership.GROUP_ID }) })
public class GroupMembership extends GenericEntity { public class GroupMembership extends GenericEntity {
/** /**
* *
*/ */
private static final long serialVersionUID = 2195875306960651526L; private static final long serialVersionUID = 2195875306960651526L;
protected static final String EVENTUSER_ID = "eventuser_id"; protected static final String EVENTUSER_ID = "eventuser_id";
protected static final String GROUP_ID = "group_id"; protected static final String GROUP_ID = "group_id";
@Column(name = "invite_token", unique = true, nullable = false) @Column(name = "invite_token", unique = true, nullable = false)
private String inviteToken; private String inviteToken;
@Column(name = "invite_accepted") @Column(name = "invite_accepted")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar inviteAccepted; private Calendar inviteAccepted;
@Column(name = "invite_email") @Column(name = "invite_email")
private String inviteEmail; private String inviteEmail;
@Column(name = "invite_name") @Column(name = "invite_name")
private String inviteName; private String inviteName;
@ManyToOne(optional = false, cascade = CascadeType.PERSIST) @ManyToOne(optional = false, cascade = CascadeType.PERSIST)
@JoinColumn(name = GROUP_ID, referencedColumnName = "id", nullable = false) @JoinColumn(name = GROUP_ID, referencedColumnName = "id", nullable = false)
private PlaceGroup placeGroup; private PlaceGroup placeGroup;
@OneToOne(optional = false) @OneToOne(optional = false)
@JoinColumn(name = "place_reservation_id", referencedColumnName = "id", nullable = true, unique = true) @JoinColumn(name = "place_reservation_id", referencedColumnName = "id", nullable = true, unique = true)
private Place placeReservation; private Place placeReservation;
@ManyToOne @ManyToOne
@JoinColumn(name = "place_product") @JoinColumn(name = "place_product")
private Product placeProduct; private Product placeProduct;
@JoinColumn(name = EVENTUSER_ID, referencedColumnName = EventUser.ID_COLUMN) @JoinColumn(name = EVENTUSER_ID, referencedColumnName = EventUser.ID_COLUMN)
@ManyToOne @ManyToOne
private EventUser user; private EventUser user;
@Column(name = "entered_event") /**
@Temporal(TemporalType.TIMESTAMP) * When user has redeemed ticket at the door
private Calendar enteredEvent; */
@Column(name = "entered_event")
public GroupMembership() { @Temporal(TemporalType.TIMESTAMP)
} private Calendar enteredEvent;
public GroupMembership(PlaceGroup pg, Place p, String token) { /**
super(); * User who has given the entrance to the event (ie who has set the
this.setPlaceGroup(pg); * enteredEvent field to not null)
this.setPlaceReservation(p); *
this.inviteToken = token; */
} @ManyToOne()
@JoinColumn(name = "entered_event_admin_id")
public Calendar getInviteAccepted() { private EventUser enteredEventAdmin;
return inviteAccepted;
} public GroupMembership() {
}
public void setInviteAccepted(Calendar inviteAccepted) {
this.inviteAccepted = inviteAccepted;
}
public String getInviteEmail() {
return inviteEmail;
}
public void setInviteEmail(String inviteEmail) {
this.inviteEmail = inviteEmail;
}
public String getInviteName() {
return inviteName;
}
public void setInviteName(String inviteName) {
this.inviteName = inviteName;
}
public PlaceGroup getPlaceGroup() {
return placeGroup;
}
public void setPlaceGroup(PlaceGroup groupsId) {
this.placeGroup = groupsId;
}
/**
* When user has selected place from map, it will be put on this.
* @return
*/
public Place getPlaceReservation() {
return placeReservation;
}
public void setPlaceReservation(Place placeReservation) { public GroupMembership(PlaceGroup pg, Place p, String token) {
this.placeReservation = placeReservation; super();
} this.setPlaceGroup(pg);
this.setPlaceReservation(p);
this.inviteToken = token;
}
public EventUser getUser() { public Calendar getInviteAccepted() {
return user; return inviteAccepted;
} }
public void setUser(EventUser usersId) { public void setInviteAccepted(Calendar inviteAccepted) {
this.user = usersId; this.inviteAccepted = inviteAccepted;
} }
/** public String getInviteEmail() {
* @return the enteredEvent return inviteEmail;
*/ }
public Calendar getEnteredEvent() {
return enteredEvent;
}
/** public void setInviteEmail(String inviteEmail) {
* @param enteredEvent this.inviteEmail = inviteEmail;
* the enteredEvent to set }
*/
public void setEnteredEvent(Calendar enteredEvent) { public String getInviteName() {
this.enteredEvent = enteredEvent; return inviteName;
} }
public void setInviteToken(String inviteToken) { public void setInviteName(String inviteName) {
this.inviteToken = inviteToken; this.inviteName = inviteName;
} }
public String getInviteToken() { public PlaceGroup getPlaceGroup() {
return inviteToken; return placeGroup;
} }
public void setPlaceGroup(PlaceGroup groupsId) {
/** this.placeGroup = groupsId;
* }
* PlaceProduct is part of membership BEFORE user has selected place.
* @return /**
*/ * When user has selected place from map, it will be put on this.
*
* @return
*/
public Place getPlaceReservation() {
return placeReservation;
}
public void setPlaceReservation(Place placeReservation) {
this.placeReservation = placeReservation;
}
public EventUser getUser() {
return user;
}
public void setUser(EventUser usersId) {
this.user = usersId;
}
/**
* @return the enteredEvent
*/
public Calendar getEnteredEvent() {
return enteredEvent;
}
/**
* @param enteredEvent
* the enteredEvent to set
*/
public void setEnteredEvent(Calendar enteredEvent) {
this.enteredEvent = enteredEvent;
}
public void setInviteToken(String inviteToken) {
this.inviteToken = inviteToken;
}
public String getInviteToken() {
return inviteToken;
}
/**
*
* PlaceProduct is part of membership BEFORE user has selected place.
*
* @return
*/
public Product getPlaceProduct() { public Product getPlaceProduct() {
return placeProduct; return placeProduct;
} }
......
...@@ -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>
......
...@@ -31,6 +31,7 @@ public class PrintedCardRestPojo { ...@@ -31,6 +31,7 @@ public class PrintedCardRestPojo {
private String template; private String template;
private String username; private String username;
private String wholeName; private String wholeName;
private String state; private String state;
private Date printTime; private Date printTime;
...@@ -65,6 +66,19 @@ public class PrintedCardRestPojo { ...@@ -65,6 +66,19 @@ public class PrintedCardRestPojo {
return wholeName; return wholeName;
} }
/**
* Possible values: ( from CardState )
*
* <ul>
* <li>DATA_MISSING,
* <li>PENDING_VALIDATION,
* <li>REJECTED,
* <li>VALIDATED,
* <li>PRINTING_IN_PROGRESS,
* <li>PRINTED,
* <li>DELIVERED;
* </ul>
*/
@XmlElement(name = "state") @XmlElement(name = "state")
public String getState() { public String getState() {
return state; return state;
......
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;
}
}
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
<ui:fragment rendered="#{sessionHandler.isInDevelopmentMode()}"> <ui:fragment rendered="#{sessionHandler.isInDevelopmentMode()}">
<br/> <br/>
<center> <center>
<img src="#{request.contextPath}/resources/media/error.jpg" /> <img src="http://thecatapi.com/api/images/get?format=src&type=gif" />
<!-- <img src="#{request.contextPath}/resources/media/error.jpg" /> -->
<h1>LOL, ERROR!</h1> <h1>LOL, ERROR!</h1>
<br/> <br/>
</center> </center>
......
...@@ -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!