Commit d45b2ca7 by Tuomas Riihimäki

Add place info to place in user reservation

1 parent 3e8ab32c
...@@ -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.4</version> <version>1.0.5</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
......
...@@ -4,12 +4,16 @@ import javax.xml.bind.annotation.XmlElement; ...@@ -4,12 +4,16 @@ import javax.xml.bind.annotation.XmlElement;
public class UserReservationPlacePojo { public class UserReservationPlacePojo {
@XmlElement @XmlElement(name = "placeid")
private Integer placeid; private Integer placeid;
@XmlElement @XmlElement(name = "placename")
private String placename; private String placename;
@XmlElement @XmlElement(name = "placegiven")
private boolean placegiven; private boolean placegiven;
@XmlElement(name = "productid")
private Integer productId;
@XmlElement(name = "productname")
private String productName;
public String getPlacename() { public String getPlacename() {
return placename; return placename;
...@@ -35,4 +39,20 @@ public class UserReservationPlacePojo { ...@@ -35,4 +39,20 @@ public class UserReservationPlacePojo {
this.placeid = placeid; 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; ...@@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
...@@ -27,6 +28,7 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.CardRoot; ...@@ -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.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;
public class PojoUtils { public class PojoUtils {
public static EventUserRestPojo initEventUserRestPojo(EventUser user) public static EventUserRestPojo initEventUserRestPojo(EventUser user)
...@@ -275,4 +277,18 @@ public class PojoUtils { ...@@ -275,4 +277,18 @@ public class PojoUtils {
ret.setHeight(map.getHeight()); ret.setHeight(map.getHeight());
return ret; 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 { ...@@ -110,11 +110,8 @@ public class UserRestView {
ret.setUser(PojoUtils.initEventUserRestPojo(eu)); ret.setUser(PojoUtils.initEventUserRestPojo(eu));
for (GroupMembership g : gms) { for (GroupMembership g : gms) {
UserReservationPlacePojo ur = new UserReservationPlacePojo();
ur.setPlaceid(g.getPlaceReservation().getId()); ret.getReservations().add(PojoUtils.initUserReservationPlace(g));
ur.setPlacegiven(g.getEnteredEvent() != null);
ur.setPlacename(g.getPlaceReservation().getName());
ret.getReservations().add(ur);
} }
return Response.ok(ret).build(); return Response.ok(ret).build();
} }
...@@ -133,13 +130,7 @@ public class UserRestView { ...@@ -133,13 +130,7 @@ public class UserRestView {
UserReservationRoot ret = new UserReservationRoot(); UserReservationRoot ret = new UserReservationRoot();
ret.setUser(PojoUtils.initEventUserRestPojo(eu)); ret.setUser(PojoUtils.initEventUserRestPojo(eu));
for (GroupMembership g : gms) { for (GroupMembership g : gms) {
UserReservationPlacePojo ur = new UserReservationPlacePojo(); ret.getReservations().add(PojoUtils.initUserReservationPlace(g));
ur.setPlaceid(g.getPlaceReservation().getId());
ur.setPlacename(g.getPlaceReservation().getName());
ur.setPlacegiven(g.getEnteredEvent() != null);
ret.getReservations().add(ur);
} }
return Response.ok(ret).build(); 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!