Commit f1b25329 by Tuomas Riihimäki

committing changes

2 parents 118a735f ed4fd0ed
......@@ -36,7 +36,6 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
public PlaceMapBean() {
// TODO Auto-generated constructor stub
}
@EJB
private PlaceFacade placeFacade;
@EJB
......@@ -70,8 +69,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
if (user != null) {
for (PlaceGroup uplacegroup : user.getPlaceGroups()) {
for (Place uplace : uplacegroup.getPlaces())
for (Place uplace : uplacegroup.getPlaces()) {
uplace.drawOwnedPlace(image);
}
}
}
}
......@@ -83,4 +83,6 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
ImageIO.write(image, filetype, outputStream);
}
}
package fi.insomnia.bortal.beans;
import java.io.IOException;
import java.io.OutputStream;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.Place;
@Local
public interface PlaceMapBeanLocal {
void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, Integer placeId) throws IOException;
}
......@@ -10,7 +10,6 @@ public interface TestDataBeanLocal {
EventMap generateTestMap(Event event);
void generateTestPlaces(EventMap map);
}
......@@ -33,10 +33,9 @@ import org.slf4j.LoggerFactory;
*/
@Entity
@Table(name = "maps")
@NamedQueries( {
@NamedQuery(name = "EventMap.findAll", query = "SELECT e FROM EventMap e"),
@NamedQuery(name = "EventMap.findByName", query = "SELECT e FROM EventMap e WHERE e.name = :name") })
@NamedQueries({
@NamedQuery(name = "EventMap.findAll", query = "SELECT e FROM EventMap e"),
@NamedQuery(name = "EventMap.findByName", query = "SELECT e FROM EventMap e WHERE e.name = :name")})
public class EventMap implements EventChildInterface {
private static final Logger logger = LoggerFactory.getLogger(EventMap.class);
......@@ -44,21 +43,16 @@ public class EventMap implements EventChildInterface {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Lob
@Column(name = "map_data")
private byte[] mapData;
@Column(name = "map_name")
private String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "map",fetch=FetchType.EAGER)
private List<Place> places = new ArrayList<Place>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "map")
private List<Place> places;
@ManyToOne(optional = false)
@JoinColumn(name = "event_id", referencedColumnName = "event_id", insertable = false, updatable = false, nullable = false)
private Event event;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
......@@ -189,4 +183,19 @@ public class EventMap implements EventChildInterface {
return event;
}
public Place findPlace(int x, int y) {
for (Place place : getPlaces()) {
if (place.getMapX() < x
&& (place.getMapX() + place.getWidth()) > x
&& place.getMapY() < y
&& (place.getMapY() + place.getHeight()) > y) {
return place;
}
}
return null;
}
}
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/tools/role">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:commandButton image="#{mapView.selectPlaceMapUrl}" actionListener="#{mapView.placeSelectActionListener}" />
</h:form>
</composite:implementation>
</html>
......@@ -4,6 +4,7 @@
*/
package fi.insomnia.bortal.servlet;
import fi.insomnia.bortal.model.Place;
import java.io.IOException;
import java.io.PrintWriter;
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.view;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
/**
*
* @author tuukka
*/
@ManagedBean(name = "mapView")
@SessionScoped
public class MapView {
private EventMap activeMap;
/** Creates a new instance of MapView */
public MapView() {
}
public void placeSelectActionListener(ActionEvent e) {
FacesContext context = FacesContext.getCurrentInstance();
String clientId = e.getComponent().getClientId(context);
Map requestParams = context.getExternalContext().getRequestParameterMap();
int x = new Integer((String) requestParams.get(clientId + ".x")).intValue();
int y = new Integer((String) requestParams.get(clientId + ".y")).intValue();
Place place = getActiveMap().findPlace(x, y);
throw new UnsupportedOperationException("We got place, but are doing nothing with it");
}
public String getSelectPlaceMapUrl() {
throw new UnsupportedOperationException("Return map url");
}
/**
* @return the activeMap
*/
public EventMap getActiveMap() {
return activeMap;
}
/**
* @param activeMap the activeMap to set
*/
public void setActiveMap(EventMap activeMap) {
this.activeMap = activeMap;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!