Commit d45b2ca7 by Tuomas Riihimäki

Add place info to place in user reservation

1 parent 3e8ab32c
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>moya-restpojo</artifactId>
<groupId>fi.codecrew.moya</groupId>
<version>1.0.4</version>
<version>1.0.5</version>
<build>
<plugins>
<plugin>
......
......@@ -4,12 +4,16 @@ import javax.xml.bind.annotation.XmlElement;
public class UserReservationPlacePojo {
@XmlElement
@XmlElement(name = "placeid")
private Integer placeid;
@XmlElement
@XmlElement(name = "placename")
private String placename;
@XmlElement
@XmlElement(name = "placegiven")
private boolean placegiven;
@XmlElement(name = "productid")
private Integer productId;
@XmlElement(name = "productname")
private String productName;
public String getPlacename() {
return placename;
......@@ -35,4 +39,20 @@ public class UserReservationPlacePojo {
this.placeid = placeid;
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
}
......@@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product;
......@@ -27,6 +28,7 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.CardRoot;
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.SimpleEventuserRoot;
import fi.codecrew.moya.rest.pojo.userinfo.v1.UserReservationPlacePojo;
public class PojoUtils {
public static EventUserRestPojo initEventUserRestPojo(EventUser user)
......@@ -275,4 +277,18 @@ public class PojoUtils {
ret.setHeight(map.getHeight());
return ret;
}
public static UserReservationPlacePojo initUserReservationPlace(GroupMembership g) {
UserReservationPlacePojo ur = new UserReservationPlacePojo();
ur.setPlacegiven(g.getEnteredEvent() != null);
Place place = g.getPlaceReservation();
if (place != null) {
ur.setPlaceid(place.getId());
ur.setPlacename(place.getName());
ur.setProductId(place.getProduct().getId());
ur.setProductName(place.getProduct().getName());
}
return ur;
}
}
......@@ -110,11 +110,8 @@ public class UserRestView {
ret.setUser(PojoUtils.initEventUserRestPojo(eu));
for (GroupMembership g : gms) {
UserReservationPlacePojo ur = new UserReservationPlacePojo();
ur.setPlaceid(g.getPlaceReservation().getId());
ur.setPlacegiven(g.getEnteredEvent() != null);
ur.setPlacename(g.getPlaceReservation().getName());
ret.getReservations().add(ur);
ret.getReservations().add(PojoUtils.initUserReservationPlace(g));
}
return Response.ok(ret).build();
}
......@@ -133,13 +130,7 @@ public class UserRestView {
UserReservationRoot ret = new UserReservationRoot();
ret.setUser(PojoUtils.initEventUserRestPojo(eu));
for (GroupMembership g : gms) {
UserReservationPlacePojo ur = new UserReservationPlacePojo();
ur.setPlaceid(g.getPlaceReservation().getId());
ur.setPlacename(g.getPlaceReservation().getName());
ur.setPlacegiven(g.getEnteredEvent() != null);
ret.getReservations().add(ur);
ret.getReservations().add(PojoUtils.initUserReservationPlace(g));
}
return Response.ok(ret).build();
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!