Commit 6414acfa by Tuukka Kivilahti

picture magic, wtf?

1 parent 48a14a49
......@@ -21,6 +21,7 @@ import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User;
import java.util.ArrayList;
/**
* Session Bean implementation class PlaceMapBean
......@@ -44,27 +45,29 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
private UserFacade userFacade;
@Override
public void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, Integer placeId) throws IOException {
public void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, List<Integer> placeIds) throws IOException {
Integer eventId = event.getId();
Place place = null;
List<Place> selectedPlaceList = new ArrayList<Place>();
EventMap map = null;
if (placeId != null) {
place = placeFacade.find(eventId, placeId);
for (Integer id : placeIds) {
selectedPlaceList.add(placeFacade.find(eventId, id));
}
logger.info("Got event {}, mapid {}", event, mapId);
if (place != null) {
map = place.getMap();
if (selectedPlaceList.size() > 0) {
map = selectedPlaceList.get(0).getMap();
} else {
map = eventMapFacade.find(eventId, mapId);
}
List<Place> places = map.getPlaces();
logger.info("Places: from map {}", places.size());
BufferedImage image = map.getMapWithPlaces();
if (userId != null) {
......@@ -81,30 +84,29 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
}
if (place != null) {
for (Place place : selectedPlaceList) {
place.drawSelectedPlace(image);
}
ImageIO.write(image, filetype, outputStream);
}
public String getSelectPlaceMapUrl(EventMap activeMap, Place selectedPlace, User user) {
String parameters = "?";
if(selectedPlace != null) {
parameters += "placeid="+selectedPlace.getId().getId();
if (selectedPlace != null) {
parameters += "placeid=" + selectedPlace.getId().getId();
} else {
parameters += "mapid="+activeMap.getId().getId();
parameters += "mapid=" + activeMap.getId().getId();
}
if(user != null) {
parameters += "&userid="+user.getId();
if (user != null) {
parameters += "&userid=" + user.getId();
}
return "/LanBortalWeb/PlaceMap"+parameters;
return "/PlaceMap" + parameters;
// TODO: do something.
}
}
......@@ -15,5 +15,6 @@ public interface BillBeanLocal {
ByteArrayOutputStream getPdfBillStream(Bill bill);
}
package fi.insomnia.bortal.beans;
import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.User;
@Local
public interface JaasBeanLocal {
}
......@@ -10,5 +10,6 @@ public interface JaasBeanRemote {
boolean authenticate(String username, String password);
Enumeration<String> getGroupNames(String user);
}
......@@ -9,12 +9,14 @@ import java.io.OutputStream;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Event;
import java.util.List;
@Local
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, List<Integer> placeIds) throws IOException;
public String getSelectPlaceMapUrl(EventMap activeMap, Place selectedPlace, User user);
// public EventMap findMap(int i);
}
......@@ -386,6 +386,13 @@ is divided into following sections:
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.LanBortalUtilities}" name="call.subproject"/>
<param location="${project.LanBortalUtilities}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
</target>
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
<target depends="init" name="-check-automatic-build">
......@@ -779,6 +786,13 @@ is divided into following sections:
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.LanBortalUtilities}" name="call.subproject"/>
<param location="${project.LanBortalUtilities}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
</target>
<target depends="init" name="-do-clean">
<delete dir="${build.dir}"/>
......
build.xml.data.CRC32=c4f39d2a
build.xml.data.CRC32=9906f25b
build.xml.script.CRC32=9e7e8017
build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=c4f39d2a
nbproject/build-impl.xml.script.CRC32=044841d4
nbproject/build-impl.xml.data.CRC32=9906f25b
nbproject/build-impl.xml.script.CRC32=64a01634
nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
......@@ -31,7 +31,8 @@ javac.classpath=\
${libs.javaee-api-6.0.classpath}:\
${reference.LanBortalDatabase.jar}:\
${file.reference.slf4j-api-1.5.8.jar}:\
${file.reference.slf4j-jdk14-1.5.8.jar}
${file.reference.slf4j-jdk14-1.5.8.jar}:\
${reference.LanBortalUtilities.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
......@@ -59,7 +60,9 @@ manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
project.LanBortalDatabase=../LanBortalDatabase
project.LanBortalUtilities=../LanBortalUtilities
reference.LanBortalDatabase.jar=${project.LanBortalDatabase}/dist/LanBortalDatabase.jar
reference.LanBortalUtilities.jar=${project.LanBortalUtilities}/dist/LanBortalUtilities.jar
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
......
......@@ -18,6 +18,14 @@
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
<reference>
<foreign-project>LanBortalUtilities</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
<target>jar</target>
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
</references>
</configuration>
</project>
......@@ -29,9 +29,9 @@ includes=**
jar.compress=false
javac.classpath=\
${libs.javaee-api-6.0.classpath}:\
${reference.LanBortalUtilities.jar}:\
${file.reference.slf4j-api-1.5.8.jar}:\
${file.reference.slf4j-jdk14-1.5.8.jar}
${file.reference.slf4j-jdk14-1.5.8.jar}:\
${reference.LanBortalUtilities.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
......
......@@ -24,8 +24,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import org.eclipse.persistence.annotations.Cache;
import org.eclipse.persistence.annotations.CacheType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,7 +36,7 @@ import org.slf4j.LoggerFactory;
@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") })
@Cache(type = CacheType.NONE)
public class EventMap implements EventChildInterface {
private static final Logger logger = LoggerFactory.getLogger(EventMap.class);
......
......@@ -22,8 +22,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.eclipse.persistence.annotations.Cache;
import org.eclipse.persistence.annotations.CacheType;
/**
*
......@@ -38,7 +36,7 @@ import org.eclipse.persistence.annotations.CacheType;
@NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"),
@NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"),
@NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") })
@Cache(type =CacheType.NONE)
public class Place implements EventChildInterface {
private static final long serialVersionUID = 1L;
......
......@@ -391,6 +391,9 @@ exists or setup the property manually. For example like this:
<ant antfile="${project.LanBortalDatabase}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
<ant antfile="${project.LanBortalUtilities}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
</target>
<target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps">
<ant antfile="${project.LanBortalBeans}/build.xml" inheritall="false" target="dist-ear">
......@@ -402,6 +405,9 @@ exists or setup the property manually. For example like this:
<ant antfile="${project.LanBortalDatabase}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
<ant antfile="${project.LanBortalUtilities}/build.xml" inheritall="false" target="jar">
<property name="deploy.on.save" value="false"/>
</ant>
</target>
<target depends="init, deps-module-jar, deps-ear-jar" name="deps-jar" unless="no.deps"/>
<target depends="init,deps-jar" name="-pre-pre-compile">
......@@ -541,6 +547,7 @@ exists or setup the property manually. For example like this:
<copyfiles files="${file.reference.slf4j-api-1.5.8.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.slf4j-jdk14-1.5.8.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.LanBortalBeans.dist}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}"/>
<copyfiles files="${reference.LanBortalUtilities.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.LanBortalBeansClient.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.LanBortalDatabase.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<mkdir dir="${build.web.dir}/META-INF"/>
......@@ -550,6 +557,7 @@ exists or setup the property manually. For example like this:
<copyfiles files="${file.reference.slf4j-api-1.5.8.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.slf4j-jdk14-1.5.8.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${reference.LanBortalBeans.dist}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${reference.LanBortalUtilities.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${reference.LanBortalBeansClient.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${reference.LanBortalDatabase.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
</target>
......@@ -848,6 +856,7 @@ exists or setup the property manually. For example like this:
<ant antfile="${project.LanBortalBeans}/build.xml" inheritall="false" target="clean"/>
<ant antfile="${project.LanBortalBeansClient}/build.xml" inheritall="false" target="clean"/>
<ant antfile="${project.LanBortalDatabase}/build.xml" inheritall="false" target="clean"/>
<ant antfile="${project.LanBortalUtilities}/build.xml" inheritall="false" target="clean"/>
</target>
<target depends="init" name="do-clean">
<condition property="build.dir.to.clean" value="${build.web.dir}">
......
build.xml.data.CRC32=40f1e2b4
build.xml.data.CRC32=a85e9fc5
build.xml.script.CRC32=99b46f90
build.xml.stylesheet.CRC32=c0ebde35@1.21.1.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=40f1e2b4
nbproject/build-impl.xml.script.CRC32=7f685a03
nbproject/build-impl.xml.data.CRC32=a85e9fc5
nbproject/build-impl.xml.script.CRC32=27e0b6a5
nbproject/build-impl.xml.stylesheet.CRC32=b139b33b@1.21.1.1
......@@ -35,6 +35,7 @@ javac.classpath=\
${file.reference.slf4j-api-1.5.8.jar}:\
${file.reference.slf4j-jdk14-1.5.8.jar}:\
${reference.LanBortalBeans.dist}:\
${reference.LanBortalUtilities.jar}:\
${reference.LanBortalBeansClient.jar}:\
${reference.LanBortalDatabase.jar}
# Space-separated list of extra javac options
......@@ -67,9 +68,11 @@ platform.active=default_platform
project.LanBortalBeans=../LanBortalBeans
project.LanBortalBeansClient=../LanBortalBeansClient
project.LanBortalDatabase=../LanBortalDatabase
project.LanBortalUtilities=../LanBortalUtilities
reference.LanBortalBeans.dist=${project.LanBortalBeans}/dist/LanBortalBeans.jar
reference.LanBortalBeansClient.jar=${project.LanBortalBeansClient}/dist/LanBortalBeansClient.jar
reference.LanBortalDatabase.jar=${project.LanBortalDatabase}/dist/LanBortalDatabase.jar
reference.LanBortalUtilities.jar=${project.LanBortalUtilities}/dist/LanBortalUtilities.jar
resource.dir=setup
run.test.classpath=\
${javac.test.classpath}:\
......
......@@ -19,6 +19,10 @@
<path-in-war>WEB-INF/lib</path-in-war>
</library>
<library dirs="200">
<file>${reference.LanBortalUtilities.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
<library dirs="200">
<file>${reference.LanBortalBeansClient.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
......@@ -58,6 +62,14 @@
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
<reference>
<foreign-project>LanBortalUtilities</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
<target>jar</target>
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
</references>
</configuration>
</project>
userManagement
roleManagement
login
\ No newline at end of file
......@@ -20,6 +20,8 @@ import fi.insomnia.bortal.HostnameFilter;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PlaceMapBeanLocal;
import fi.insomnia.bortal.model.Event;
import java.util.ArrayList;
import java.util.List;
/**
*
......@@ -32,13 +34,10 @@ public class PlaceMap extends HttpServlet {
*
*/
private static final long serialVersionUID = 8769688627918936258L;
@EJB
private PlaceMapBeanLocal placemapBean;
@EJB
private EventBeanLocal eventBean;
public static final String PARAMETER_EVENT_MAP_ID = "mapid";
public static final String PARAMETER_SELECTED_PLACE_ID = "placeid";
public static final String PARAMETER_CURRENT_USER_ID = "userid";
......@@ -63,13 +62,15 @@ public class PlaceMap extends HttpServlet {
// PrintWriter out = response.getWriter();
ServletOutputStream ostream = response.getOutputStream();
try {
Integer placeId = getIntegerParameter(request, PARAMETER_SELECTED_PLACE_ID);
//Integer placeId = getIntegerParameter(request, PARAMETER_SELECTED_PLACE_ID);
List<Integer> placeIds = getIntegerParameters(request, PARAMETER_SELECTED_PLACE_ID);
Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID);
Integer userId = getIntegerParameter(request, PARAMETER_CURRENT_USER_ID);
response.setContentType("image/png");
placemapBean.printPlaceMapToStream(ostream, "png", getEvent(request), mapId, userId, placeId);
placemapBean.printPlaceMapToStream(ostream, "png", getEvent(request), mapId, userId, placeIds);
/*
* TODO output your page here out.println("<html>");
......@@ -109,6 +110,39 @@ public class PlaceMap extends HttpServlet {
return null;
}
/***
* Convert request parameter into integer
*
* @param request
* @param parameter
* @return
*/
private static List<Integer> getIntegerParameters(HttpServletRequest request, String parameter) {
try {
List<Integer> returnList = new ArrayList<Integer>();
String valueString = request.getParameter(parameter);
if (valueString == null) {
return returnList;
}
String splitted[] = valueString.split(",");
for (String value : splitted) {
try {
returnList.add(Integer.parseInt(value));
} catch (NumberFormatException x) {
}
}
return returnList;
} catch (NumberFormatException nfe) {
}
return null;
}
// <editor-fold defaultstate="collapsed"
// desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
......@@ -156,5 +190,4 @@ public class PlaceMap extends HttpServlet {
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
......@@ -68,6 +68,7 @@ public class MapView {
public EventMap getActiveMap() {
if (activeMap == null) {
if (sessionHandler.getCurrentEvent().getEventMaps().size() >= 1) {
activeMap = sessionHandler.getCurrentEvent().getEventMaps().get(0);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!