Commit 611a31e5 by Tuukka Kivilahti

Just some testing stuff, nothing to see here..

...really.
1 parent f1b25329
...@@ -17,7 +17,6 @@ import fi.insomnia.bortal.facade.PlaceFacade; ...@@ -17,7 +17,6 @@ import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade; import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.Event; import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.Place; import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup; import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
...@@ -55,13 +54,16 @@ public class PlaceMapBean implements PlaceMapBeanLocal { ...@@ -55,13 +54,16 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
} }
logger.info("Got event {}, mapid {}", event, mapId); logger.info("Got event {}, mapid {}", event, mapId);
if (place != null) { if (place != null) {
map = place.getMap(); map = place.getMap();
} else { } else {
map = eventMapFacade.find(eventId, mapId); map = eventMapFacade.find(eventId, mapId);
} }
List<Place> places = map.getPlaces(); List<Place> places = map.getPlaces();
logger.info("Places: from map {}", places.size());
BufferedImage image = map.getMapWithPlaces(); BufferedImage image = map.getMapWithPlaces();
if (userId != null) { if (userId != null) {
...@@ -70,7 +72,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal { ...@@ -70,7 +72,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
if (user != null) { if (user != null) {
for (PlaceGroup uplacegroup : user.getPlaceGroups()) { for (PlaceGroup uplacegroup : user.getPlaceGroups()) {
for (Place uplace : uplacegroup.getPlaces()) { for (Place uplace : uplacegroup.getPlaces()) {
uplace.drawOwnedPlace(image); if (uplace.getMap().equals(map)) {
uplace.drawOwnedPlace(image);
}
} }
} }
} }
...@@ -84,5 +88,22 @@ public class PlaceMapBean implements PlaceMapBeanLocal { ...@@ -84,5 +88,22 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
} }
public String getSelectPlaceMapUrl(EventMap activeMap, Place selectedPlace, User user) {
String parameters = "?";
if(selectedPlace != null) {
parameters += "placeid="+selectedPlace.getId().getId();
} else {
parameters += "mapid="+activeMap.getId().getId();
}
if(user != null) {
parameters += "&userid="+user.getId();
}
return "/LanBortalWeb/PlaceMap"+parameters;
// TODO: do something.
}
} }
...@@ -12,25 +12,23 @@ import javax.ejb.Stateless; ...@@ -12,25 +12,23 @@ import javax.ejb.Stateless;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.facade.EventMapFacade; import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.facade.EventOrganiserFacade; import fi.insomnia.bortal.facade.EventOrganiserFacade;
import fi.insomnia.bortal.facade.PlaceFacade; import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade; import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.Event; import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventOrganiser;
import fi.insomnia.bortal.model.EventStatus;
import fi.insomnia.bortal.model.Place; import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import java.util.List;
/** /**
* Session Bean implementation class TestDataBean * Session Bean implementation class TestDataBean
*/ */
@Stateless @Stateless
public class TestDataBean implements TestDataBeanLocal { public class TestDataBean implements TestDataBeanLocal {
public static final String TEST_MAP_IMAGE_NAME = "testmap.png";
public static final String TEST_MAP_IMAGE_NAME = "testmap.png";
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDataBean.class); private static final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDataBean.class);
@EJB @EJB
private EventMapFacade eventMapFacade; private EventMapFacade eventMapFacade;
...@@ -38,7 +36,6 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -38,7 +36,6 @@ public class TestDataBean implements TestDataBeanLocal {
private EventStatusBeanLocal eventStatusBean; private EventStatusBeanLocal eventStatusBean;
@EJB @EJB
private EventOrganiserFacade eventOrganiserFacade; private EventOrganiserFacade eventOrganiserFacade;
@EJB @EJB
private EventBeanLocal eventBean; private EventBeanLocal eventBean;
@EJB @EJB
...@@ -98,7 +95,6 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -98,7 +95,6 @@ public class TestDataBean implements TestDataBeanLocal {
/** /**
* Generate all metashit, ex. events. * Generate all metashit, ex. events.
*/ */
private User generateUser() { private User generateUser() {
User user = new User(); User user = new User();
...@@ -122,9 +118,17 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -122,9 +118,17 @@ public class TestDataBean implements TestDataBeanLocal {
place.setWidth(50); place.setWidth(50);
place.setHeight(50); place.setHeight(50);
// map.getPlaces().add(place); // map.getPlaces().add(place);
placeFacade.create(place); placeFacade.create(place);
} }
} }
} }
public void printPlacesInfo() {
List<Place> places = placeFacade.findAll();
logger.info("Printing info from places");
for (Place place : places) {
logger.info("Place id: {}. Event Map id: {}.",place.getId().getId(), place.getMap().getId().getId());
}
}
} }
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import javax.ejb.Local; import javax.ejb.Local;
import fi.insomnia.bortal.model.Event; import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.Place;
@Local @Local
public interface PlaceMapBeanLocal { public interface PlaceMapBeanLocal {
void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, Integer placeId) throws IOException; void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, Integer placeId) throws IOException;
public String getSelectPlaceMapUrl(EventMap activeMap, Place selectedPlace, User user);
} }
...@@ -12,4 +12,7 @@ public interface TestDataBeanLocal { ...@@ -12,4 +12,7 @@ public interface TestDataBeanLocal {
void generateTestPlaces(EventMap map); void generateTestPlaces(EventMap map);
public void printPlacesInfo();
} }
...@@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory; ...@@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
public class EventMap implements EventChildInterface { public class EventMap implements EventChildInterface {
private static final Logger logger = LoggerFactory.getLogger(EventMap.class); private static final Logger logger = LoggerFactory.getLogger(EventMap.class);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -171,8 +170,8 @@ public class EventMap implements EventChildInterface { ...@@ -171,8 +170,8 @@ public class EventMap implements EventChildInterface {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(getMapData())); BufferedImage image = ImageIO.read(new ByteArrayInputStream(getMapData()));
List<Place> myplaces = getPlaces(); List<Place> myplaces = getPlaces();
logger.info("Getting places in Event map {}, found {}", this, myplaces.size()); logger.info("Getting places in Event map {}, found {}", this, myplaces.size());
for (Place place : myplaces ) {
logger.info("Drawing place {}", place); for (Place place : myplaces) {
place.drawPlace(image); place.drawPlace(image);
} }
......
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
<h:form> <h:form>
<!-- todo: remember to remove this :) --> <!-- todo: remember to remove this :) -->
<h:commandButton value="generate the data" action="#{TestDataView.generateData}" /> <h:commandButton value="generate the data" action="#{TestDataView.generateData}" />
<br />
<br />
<h:commandButton value="print places debug info" action="#{TestDataView.printPlacesInfo}" />
</h:form> </h:form>
</h:body> </h:body>
</html> </html>
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<h:form> <h:form>
<h:commandButton image="#{mapView.selectPlaceMapUrl}" actionListener="#{mapView.placeSelectActionListener}" /> <h:commandButton image="#{mapView.selectPlaceMapUrl}" actionListener="#{mapView.placeSelectActionListener}" />
</h:form> </h:form>
......
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:map="http://java.sun.com/jsf/composite/tools/map"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/default-template.xhtml">
<ui:define name="title">Omnia</ui:define>
<ui:define name="header">Paikkakartta</ui:define>
<ui:define name="content">
<map:placeSelect />
</ui:define>
<ui:define name="footer">Valitse kartta</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -78,7 +78,6 @@ public class SessionHandler { ...@@ -78,7 +78,6 @@ public class SessionHandler {
throw new RuntimeException("Empty target"); throw new RuntimeException("Empty target");
} }
return handlerbean.hasPermission(Permission.getPermission(target), getUser(), permission); return handlerbean.hasPermission(Permission.getPermission(target), getUser(), permission);
} }
......
...@@ -37,6 +37,7 @@ public class PlaceMap extends HttpServlet { ...@@ -37,6 +37,7 @@ public class PlaceMap extends HttpServlet {
@EJB @EJB
private PlaceMapBeanLocal placemapBean; private PlaceMapBeanLocal placemapBean;
@EJB @EJB
private EventBeanLocal eventBean; private EventBeanLocal eventBean;
......
...@@ -4,13 +4,20 @@ ...@@ -4,13 +4,20 @@
*/ */
package fi.insomnia.bortal.view; package fi.insomnia.bortal.view;
import fi.insomnia.bortal.beans.PlaceMapBeanLocal;
import fi.insomnia.bortal.handler.SessionHandler;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place; import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import java.util.Map; import java.util.Map;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
...@@ -20,7 +27,13 @@ import javax.faces.event.ActionEvent; ...@@ -20,7 +27,13 @@ import javax.faces.event.ActionEvent;
@SessionScoped @SessionScoped
public class MapView { public class MapView {
private EventMap activeMap; private Logger logger = LoggerFactory.getLogger(MapView.class);
@EJB
private PlaceMapBeanLocal placeMapBean;
@ManagedProperty("#{sessionHandler}")
private SessionHandler sessionHandler;
private EventMap activeMap = null;
private Place selectedPlace = null;
/** Creates a new instance of MapView */ /** Creates a new instance of MapView */
public MapView() { public MapView() {
...@@ -34,18 +47,32 @@ public class MapView { ...@@ -34,18 +47,32 @@ public class MapView {
int y = new Integer((String) requestParams.get(clientId + ".y")).intValue(); int y = new Integer((String) requestParams.get(clientId + ".y")).intValue();
Place place = getActiveMap().findPlace(x, y); Place place = getActiveMap().findPlace(x, y);
throw new UnsupportedOperationException("We got place, but are doing nothing with it"); selectedPlace = place;
//throw new UnsupportedOperationException("We got place, but are doing nothing with it");
} }
public String getSelectPlaceMapUrl() { public String getSelectPlaceMapUrl() {
throw new UnsupportedOperationException("Return map url"); User user = sessionHandler.getUser();
EventMap map = getActiveMap();
if (map == null) {
return "";
}
return placeMapBean.getSelectPlaceMapUrl(getActiveMap(), selectedPlace, user);
} }
/** /**
* @return the activeMap * @return the activeMap, if it's not setted, return events first map. If this event does not have map, return null.
*/ */
public EventMap getActiveMap() { public EventMap getActiveMap() {
if (activeMap == null) {
if (sessionHandler.getCurrentEvent().getEventMaps().size() >= 1) {
activeMap = sessionHandler.getCurrentEvent().getEventMaps().get(0);
}
}
return activeMap; return activeMap;
} }
...@@ -56,4 +83,31 @@ public class MapView { ...@@ -56,4 +83,31 @@ public class MapView {
this.activeMap = activeMap; this.activeMap = activeMap;
} }
/**
* @return the selectedPlace
*/
public Place getSelectedPlace() {
return selectedPlace;
}
/**
* @param selectedPlace the selectedPlace to set
*/
public void setSelectedPlace(Place selectedPlace) {
this.selectedPlace = selectedPlace;
}
/**
* @return the sessionHandler
*/
public SessionHandler getSessionHandler() {
return sessionHandler;
}
/**
* @param sessionHandler the sessionHandler to set
*/
public void setSessionHandler(SessionHandler sessionHandler) {
this.sessionHandler = sessionHandler;
}
} }
...@@ -53,4 +53,11 @@ public class TestDataView { ...@@ -53,4 +53,11 @@ public class TestDataView {
return sessionhandler; return sessionhandler;
} }
public String printPlacesInfo() {
testdatabean.printPlacesInfo();
return null;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!