Commit 87b56a89 by Tuomas Riihimäki

I can has testdata! \o/

1 parent 46e9694e
...@@ -128,12 +128,12 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -128,12 +128,12 @@ public class TestDataBean implements TestDataBeanLocal {
return user; return user;
} }
public void generateTestPlaces(EventMap map, Event e) { public void generateTestPlaces(EventMap map) {
logger.info("Adding places to map {}, event {}", map);
for (int x = 5; x < 400; x += 50) { for (int x = 5; x < 400; x += 50) {
for (int y = 5; y < 150; y += 50) { for (int y = 5; y < 150; y += 50) {
Place place = new Place(e); Place place = new Place(map);
place.setMap(map);
place.setMapX(x); place.setMapX(x);
place.setMapY(y); place.setMapY(y);
placeFacade.create(place); placeFacade.create(place);
...@@ -141,4 +141,6 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -141,4 +141,6 @@ public class TestDataBean implements TestDataBeanLocal {
} }
} }
} }
...@@ -15,6 +15,7 @@ public interface EventChildInterface extends ModelInterface<EventPk> { ...@@ -15,6 +15,7 @@ public interface EventChildInterface extends ModelInterface<EventPk> {
public void setId(EventPk id); public void setId(EventPk id);
public int getJpaVersionField(); public int getJpaVersionField();
public void setJpaVersionField(int jpaVersionField); public void setJpaVersionField(int jpaVersionField);
......
...@@ -17,10 +17,6 @@ public class EventPk implements Serializable { ...@@ -17,10 +17,6 @@ public class EventPk implements Serializable {
@Column(name = "event_id", nullable = false, updatable = false) @Column(name = "event_id", nullable = false, updatable = false)
private Integer eventId; private Integer eventId;
// @JoinColumn(name = "event_id", referencedColumnName = "event_id")
// @ManyToOne
// private Event event;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public EventPk() { public EventPk() {
...@@ -28,12 +24,12 @@ public class EventPk implements Serializable { ...@@ -28,12 +24,12 @@ public class EventPk implements Serializable {
public EventPk(Event event) { public EventPk(Event event) {
super(); super();
this.eventId = event.getId(); this.setEventId(event.getId());
} }
public EventPk(Integer eventId) { public EventPk(Integer eventId) {
super(); super();
this.eventId = eventId; this.setEventId(eventId);
} }
public void setId(Integer id) { public void setId(Integer id) {
...@@ -45,7 +41,7 @@ public class EventPk implements Serializable { ...@@ -45,7 +41,7 @@ public class EventPk implements Serializable {
} }
public int hashCode() { public int hashCode() {
return id.hashCode() + eventId.hashCode(); return id.hashCode() + getEventId().hashCode();
} }
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -56,18 +52,19 @@ public class EventPk implements Serializable { ...@@ -56,18 +52,19 @@ public class EventPk implements Serializable {
if (!(obj instanceof EventPk)) if (!(obj instanceof EventPk))
return false; return false;
EventPk pk = (EventPk) obj; EventPk pk = (EventPk) obj;
return pk.id == this.id && pk.eventId == this.eventId; return pk.id == this.id && pk.getEventId() == this.getEventId();
} }
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.EventPk[id=" + id + ", eventId=" + eventId + "]"; return "fi.insomnia.bortal.model.EventPk[id=" + id + ", eventId=" + getEventId() + "]";
}
public void setEventId(Integer eventId) {
this.eventId = eventId;
}
public Integer getEventId() {
return eventId;
} }
// public void setEvent(Event event) {
// this.event = event;
// }
//
// public Event getEvent() {
// return event;
// }
} }
...@@ -27,7 +27,7 @@ import javax.persistence.Version; ...@@ -27,7 +27,7 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "places") @Table(name = "places")
@NamedQueries( { @NamedQueries({
@NamedQuery(name = "Place.findAll", query = "SELECT p FROM Place p"), @NamedQuery(name = "Place.findAll", query = "SELECT p FROM Place p"),
@NamedQuery(name = "Place.findByDescription", query = "SELECT p FROM Place p WHERE p.description = :description"), @NamedQuery(name = "Place.findByDescription", query = "SELECT p FROM Place p WHERE p.description = :description"),
@NamedQuery(name = "Place.findByName", query = "SELECT p FROM Place p WHERE p.name = :name"), @NamedQuery(name = "Place.findByName", query = "SELECT p FROM Place p WHERE p.name = :name"),
...@@ -60,16 +60,25 @@ public class Place implements EventChildInterface { ...@@ -60,16 +60,25 @@ public class Place implements EventChildInterface {
private String code; private String code;
@OneToOne(mappedBy = "placeReservation") @OneToOne(mappedBy = "placeReservation")
private GroupMembership placeReserver; private GroupMembership placeReserver;
@SuppressWarnings("unused")
@Column(name = "group_id")
private Integer groupId;
/** /**
* Which group has bought the place * Which group has bought the place
*/ */
@JoinColumns( { @JoinColumns({
@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false), @JoinColumn(name = "group_id", referencedColumnName = "id", updatable = false, insertable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private PlaceGroup group; private PlaceGroup group;
@JoinColumns( { @SuppressWarnings("unused")
@Column(name = "map_id", nullable = false)
private Integer mapId;
@JoinColumns({
@JoinColumn(name = "map_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "map_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false) @ManyToOne(optional = false)
...@@ -77,7 +86,7 @@ public class Place implements EventChildInterface { ...@@ -77,7 +86,7 @@ public class Place implements EventChildInterface {
/** /**
* Which ticket type is this place sold as * Which ticket type is this place sold as
*/ */
@JoinColumns( { @JoinColumns({
@JoinColumn(name = "products_id", referencedColumnName = "id"), @JoinColumn(name = "products_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne() @ManyToOne()
...@@ -96,8 +105,10 @@ public class Place implements EventChildInterface { ...@@ -96,8 +105,10 @@ public class Place implements EventChildInterface {
public Place() { public Place() {
} }
public Place(Event event) { public Place(EventMap eventMap) {
this.id = new EventPk(event); this.id = new EventPk();
this.id.setEventId(eventMap.getId().getEventId());
this.setMap(eventMap);
} }
public String getDescription() { public String getDescription() {
...@@ -152,16 +163,24 @@ public class Place implements EventChildInterface { ...@@ -152,16 +163,24 @@ public class Place implements EventChildInterface {
return group; return group;
} }
public void setGroup(PlaceGroup groupsId) { public void setGroup(PlaceGroup group) {
this.group = groupsId; if (group.getId().getEventId() != getId().getEventId()) {
throw new RuntimeException("Can not set Group from different Event to Place!");
}
this.group = group;
this.groupId = group.getId().getId();
} }
public EventMap getMap() { public EventMap getMap() {
return map; return map;
} }
public void setMap(EventMap mapsId) { public void setMap(EventMap map) {
this.map = mapsId; if (map.getId().getEventId() != getId().getEventId()) {
throw new RuntimeException("Can not set Map from different Event to Place!");
}
this.map = map;
this.mapId = map.getId().getId();
} }
public Product getProduct() { public Product getProduct() {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<!-- Stream: ST (SAO TOME AND PRINCIPE ) --> <!-- Stream: ST (SAO TOME AND PRINCIPE ) -->
<!-- Vector VE (VENEZUELA, BOLIVARIAN REPUBLIC OF) --> <!-- Vector VE (VENEZUELA, BOLIVARIAN REPUBLIC OF) -->
<locale-config> <locale-config>
<default-locale>fi</default-locale> <default-locale>fi_FI</default-locale>
<supported-locale>fi_IN_XII</supported-locale> <supported-locale>fi_IN_XII</supported-locale>
<supported-locale>en_ST_v7</supported-locale> <supported-locale>en_ST_v7</supported-locale>
......
...@@ -9,6 +9,7 @@ import java.io.PrintWriter; ...@@ -9,6 +9,7 @@ import java.io.PrintWriter;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -54,8 +55,8 @@ public class PlaceMap extends HttpServlet { ...@@ -54,8 +55,8 @@ public class PlaceMap extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8"); response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter(); // PrintWriter out = response.getWriter();
ServletOutputStream ostream = response.getOutputStream();
try { try {
Integer placeId = getIntegerParameter(request, PARAMETER_SELECTED_PLACE_ID); Integer placeId = getIntegerParameter(request, PARAMETER_SELECTED_PLACE_ID);
Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID); Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID);
...@@ -63,7 +64,7 @@ public class PlaceMap extends HttpServlet { ...@@ -63,7 +64,7 @@ public class PlaceMap extends HttpServlet {
response.setContentType("image/png"); response.setContentType("image/png");
placemapBean.printPlaceMapToStream(response.getOutputStream(), "png", getEvent(request), mapId, userId, placeId); placemapBean.printPlaceMapToStream(ostream, "png", getEvent(request), mapId, userId, placeId);
/* /*
* TODO output your page here out.println("<html>"); * TODO output your page here out.println("<html>");
...@@ -74,7 +75,7 @@ public class PlaceMap extends HttpServlet { ...@@ -74,7 +75,7 @@ public class PlaceMap extends HttpServlet {
* () + "</h1>"); out.println("</body>"); out.println("</html>"); * () + "</h1>"); out.println("</body>"); out.println("</html>");
*/ */
} finally { } finally {
out.close(); ostream.close();
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!