Commit c0ce1592 by Tuomas Riihimäki

Mergetty juttuja

2 parents e851e7b0 95269df6
......@@ -17,6 +17,7 @@ import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User;
......@@ -35,7 +36,6 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
public PlaceMapBean() {
// TODO Auto-generated constructor stub
}
@EJB
private PlaceFacade placeFacade;
@EJB
......@@ -55,11 +55,14 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
logger.info("Got event {}, mapid {}", event, mapId);
if (place != null) {
map = place.getMap();
} else {
map = eventMapFacade.find(eventId, mapId);
}
List<Place> places = map.getPlaces();
logger.info("Places: from map {}", places.size());
BufferedImage image = map.getMapWithPlaces();
......@@ -70,7 +73,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
if (user != null) {
for (PlaceGroup uplacegroup : user.getPlaceGroups()) {
for (Place uplace : uplacegroup.getPlaces()) {
uplace.drawOwnedPlace(image);
if (uplace.getMap().equals(map)) {
uplace.drawOwnedPlace(image);
}
}
}
}
......@@ -84,4 +89,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.
}
}
......@@ -28,6 +28,7 @@ import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import java.util.List;
/**
* Session Bean implementation class TestDataBean
......@@ -36,8 +37,8 @@ import fi.insomnia.bortal.model.User;
@DeclareRoles(JaasBean.JAAS_SUPERADMINGROUP)
@RolesAllowed(JaasBean.JAAS_SUPERADMINGROUP)
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);
@EJB
private EventMapFacade eventMapFacade;
......@@ -45,7 +46,6 @@ public class TestDataBean implements TestDataBeanLocal {
private EventStatusBeanLocal eventStatusBean;
@EJB
private EventOrganiserFacade eventOrganiserFacade;
@EJB
private EventBeanLocal eventBean;
@EJB
......@@ -181,7 +181,6 @@ public class TestDataBean implements TestDataBeanLocal {
/**
* Generate all metashit, ex. events.
*/
private User generateUser() {
User user = new User();
......@@ -204,10 +203,18 @@ public class TestDataBean implements TestDataBeanLocal {
place.setMapY(y);
place.setWidth(50);
place.setHeight(50);
// map.getPlaces().add(place);
// map.getPlaces().add(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;
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.OutputStream;
......@@ -11,4 +14,7 @@ import fi.insomnia.bortal.model.Event;
public interface PlaceMapBeanLocal {
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);
}
......@@ -20,4 +20,7 @@ public interface TestDataBeanLocal {
User createUser();
public void printPlacesInfo();
}
......@@ -11,10 +11,11 @@ package fi.insomnia.bortal.enums;
*/
public enum EventStatusEnum {
INACTIVE, // Not yet public
NOT_STARTED, // Upcoming event
TICKET_SALES, // Site is public with ticket sales
PRE_EVENT, // Upcoming event...
RUNNING, // Ongoing event
SPLITTED, // Detached: The event has a copy of it's database. SPLITTED event
// cannot be modified.
// cannot be modified.
ARCHIVED; // Past events are archived
public static EventStatusEnum getEventStatusEnum(String name) {
......@@ -22,6 +23,6 @@ public enum EventStatusEnum {
}
public static EventStatusEnum getDefaultEventStatusEnum() {
return NOT_STARTED;
return INACTIVE;
}
}
......@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
public class EventMap implements EventChildInterface {
private static final Logger logger = LoggerFactory.getLogger(EventMap.class);
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
......@@ -169,8 +168,8 @@ public class EventMap implements EventChildInterface {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(getMapData()));
List<Place> myplaces = getPlaces();
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);
}
......
......@@ -9,6 +9,11 @@
<h:form>
<!-- todo: remember to remove this :) -->
<h:commandButton value="generate the data" action="#{TestDataView.generateData}" />
<br />
<br />
<h:commandButton value="print places debug info" action="#{TestDataView.printPlacesInfo}" />
</h:form>
</h:body>
</html>
......
......@@ -19,6 +19,7 @@
<h:form>
<h:commandButton image="#{mapView.selectPlaceMapUrl}" actionListener="#{mapView.placeSelectActionListener}" />
</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
......@@ -35,6 +35,7 @@ public class PlaceMap extends HttpServlet {
@EJB
private PlaceMapBeanLocal placemapBean;
@EJB
private EventBeanLocal eventBean;
......
......@@ -4,13 +4,20 @@
*/
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.Place;
import fi.insomnia.bortal.model.User;
import java.util.Map;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
......@@ -20,7 +27,13 @@ import javax.faces.event.ActionEvent;
@SessionScoped
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 */
public MapView() {
......@@ -34,18 +47,32 @@ public class MapView {
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");
selectedPlace = place;
//throw new UnsupportedOperationException("We got place, but are doing nothing with it");
}
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() {
if (activeMap == null) {
if (sessionHandler.getCurrentEvent().getEventMaps().size() >= 1) {
activeMap = sessionHandler.getCurrentEvent().getEventMaps().get(0);
}
}
return activeMap;
}
......@@ -56,4 +83,31 @@ public class MapView {
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;
}
}
......@@ -56,4 +56,11 @@ public class TestDataView {
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!