Commit 860a76c0 by Tuomas Riihimäki

Merge branch 'eticket' into 'master'

Eticket

Etiket-systeemi demokunnossa, ei vielä mobiilisivua.

See merge request !153
2 parents 0eda61d3 eadce3f4
...@@ -39,7 +39,8 @@ public interface BarcodeBeanLocal { ...@@ -39,7 +39,8 @@ public interface BarcodeBeanLocal {
public String getPlaceTextCode(Place place); public String getPlaceTextCode(Place place);
public Place getPlaceFromTextCode(String hexcode); public Place getPlaceFromTextCode(String hexcode);
public String checkVrAuthCode(String code); public String checkVrAuthCode(String code);
public String getUserTextCode(EventUser user);
public Product getProduct(String barcode); public Product getProduct(String barcode);
public Place getPlaceFromBarcode(String barcode); public Place getPlaceFromBarcode(String barcode);
......
...@@ -46,6 +46,8 @@ public interface EventBeanLocal { ...@@ -46,6 +46,8 @@ public interface EventBeanLocal {
String getPropertyString(LanEventPropertyKey property); String getPropertyString(LanEventPropertyKey property);
boolean getPropertyBoolean(LanEventPropertyKey property);
LanEventProperty saveOrCreateProperty(LanEventProperty property); LanEventProperty saveOrCreateProperty(LanEventProperty property);
EventOrganiser mergeChanges(EventOrganiser eventorg); EventOrganiser mergeChanges(EventOrganiser eventorg);
......
...@@ -120,4 +120,6 @@ public interface PlaceBeanLocal { ...@@ -120,4 +120,6 @@ public interface PlaceBeanLocal {
List<PlaceSlot> getFreePlaceslots(EventUser user, Product product); List<PlaceSlot> getFreePlaceslots(EventUser user, Product product);
List<Place> findPlacePrintlistForUser(EventUser user);
} }
...@@ -54,4 +54,5 @@ public interface PlaceGroupBeanLocal { ...@@ -54,4 +54,5 @@ public interface PlaceGroupBeanLocal {
void markGrouMembershipNotEntered(GroupMembership row); void markGrouMembershipNotEntered(GroupMembership row);
List<GroupMembership> findMembershipPrintlistForUser(EventUser user);
} }
...@@ -49,11 +49,11 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -49,11 +49,11 @@ public class BarcodeBean implements BarcodeBeanLocal {
private static final String PLACE_BARCODEPREFIX = "289"; //2Y private static final String PLACE_BARCODEPREFIX = "289"; //2Y
private static final String PRINTED_CARD_TEXTCODEPREFIX = "10"; private static final String PRINTED_CARD_TEXTCODEPREFIX = "10";
private static final String PLACE_TEXTCODEPREFIX = "11"; private static final String PLACE_TEXTCODEPREFIX = "11";
private static final String EVENTUSER_TEXTCODEPREFIX = "12"; private static final String EVENTUSER_TEXTCODEPREFIX = "12";
private static final String TEXTCODE_CHARACTER_MAP = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ"; private static final String TEXTCODE_CHARACTER_MAP = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
private static final int TEXTCODE_ROTATE_COUNT = 64; // 8*8 private static final int TEXTCODE_ROTATE_COUNT = 128;
//private static final String NEXT_PREFIX = "265"; //2A //private static final String NEXT_PREFIX = "265"; //2A
...@@ -97,6 +97,34 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -97,6 +97,34 @@ public class BarcodeBean implements BarcodeBeanLocal {
return BarcodeUtils.getBarcodeEAN(barcode); return BarcodeUtils.getBarcodeEAN(barcode);
} }
public String getUserTextCode(EventUser user) {
String barcode = generateBarcodeNumbers(EVENTUSER_TEXTCODEPREFIX, user.getId(), 12);
BigInteger intCode;
try {
intCode = new BigInteger(barcode);
} catch(NumberFormatException x)
{
return "GenFail";
}
String textCode = generateTextcode(intCode, 5);
BigInteger checkCode = textcodeToNumber(textCode, 5);
logger.debug("CheckCode {} : Original {}", checkCode, intCode);
if(checkCode.compareTo(intCode) != 0) {
logger.error("CheckCode {} : Original {}", checkCode, intCode);
return "GenError"; // different error messages, so we can tell where the error was
}
// logger.debug("Geneating hexcode for place {} : {}", place.getId(), textCode);
return textCode;
}
public String getPlaceTextCode(Place place) { public String getPlaceTextCode(Place place) {
String barcode = generateBarcodeNumbers(PLACE_TEXTCODEPREFIX, place.getId(), 8); String barcode = generateBarcodeNumbers(PLACE_TEXTCODEPREFIX, place.getId(), 8);
......
...@@ -206,6 +206,8 @@ public class EventBean implements EventBeanLocal { ...@@ -206,6 +206,8 @@ public class EventBean implements EventBeanLocal {
return eventPropertyFacade.find(getCurrentEvent(), property); return eventPropertyFacade.find(getCurrentEvent(), property);
} }
@Override @Override
public long getPropertyLong(LanEventPropertyKey property) public long getPropertyLong(LanEventPropertyKey property)
{ {
...@@ -233,6 +235,24 @@ public class EventBean implements EventBeanLocal { ...@@ -233,6 +235,24 @@ public class EventBean implements EventBeanLocal {
} }
@Override @Override
public boolean getPropertyBoolean(LanEventPropertyKey property) {
LanEventProperty retProp = eventPropertyFacade.find(getCurrentEvent(), property);
boolean ret = false;
if (retProp == null) {
String def = property.getDefaultvalue();
if(def != null && !def.trim().isEmpty() && !def.trim().equals("0"))
ret = true;
} else {
ret = retProp.isBooleanValue();
}
return ret;
}
@Override
@RolesAllowed({ SpecialPermission.S_SUPERADMIN, EventPermission.S_MANAGE_EVENT }) @RolesAllowed({ SpecialPermission.S_SUPERADMIN, EventPermission.S_MANAGE_EVENT })
public LanEventProperty saveOrCreateProperty(LanEventProperty property) { public LanEventProperty saveOrCreateProperty(LanEventProperty property) {
LanEventProperty ret = null; LanEventProperty ret = null;
......
...@@ -149,6 +149,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -149,6 +149,7 @@ public class MenuBean implements MenuBeanLocal {
userPlaces.setKey("topnavi.userplaces"); userPlaces.setKey("topnavi.userplaces");
userPlaces.addPage(menuitemfacade.findOrCreate("/neomap/view"), MapPermission.VIEW); userPlaces.addPage(menuitemfacade.findOrCreate("/neomap/view"), MapPermission.VIEW);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES); userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/myEtickets"), MapPermission.BUY_PLACES).setVisible(false);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/edit"), MapPermission.MANAGE_OTHERS).setVisible(false); userPlaces.addPage(menuitemfacade.findOrCreate("/place/edit"), MapPermission.MANAGE_OTHERS).setVisible(false);
MenuNavigation usercompetitions = usermenu.addPage(null, null); MenuNavigation usercompetitions = usermenu.addPage(null, null);
......
...@@ -49,6 +49,7 @@ import javax.ejb.Timeout; ...@@ -49,6 +49,7 @@ import javax.ejb.Timeout;
import javax.ejb.Timer; import javax.ejb.Timer;
import javax.ejb.TimerService; import javax.ejb.TimerService;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -67,15 +68,6 @@ import fi.codecrew.moya.facade.PlaceFacade; ...@@ -67,15 +68,6 @@ import fi.codecrew.moya.facade.PlaceFacade;
import fi.codecrew.moya.facade.PlaceGroupFacade; import fi.codecrew.moya.facade.PlaceGroupFacade;
import fi.codecrew.moya.facade.PlaceSlotFacade; import fi.codecrew.moya.facade.PlaceSlotFacade;
import fi.codecrew.moya.facade.UserFacade; import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.PlaceSlot;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType; import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/** /**
...@@ -134,6 +126,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -134,6 +126,7 @@ public class PlaceBean implements PlaceBeanLocal {
@EJB @EJB
private PlaceSlotFacade placeSlotFacade; private PlaceSlotFacade placeSlotFacade;
@Override @Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS) @RolesAllowed(MapPermission.S_MANAGE_MAPS)
public Place mergeChanges(Place place) { public Place mergeChanges(Place place) {
...@@ -757,6 +750,35 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -757,6 +750,35 @@ public class PlaceBean implements PlaceBeanLocal {
} }
@Override @Override
public List<Place> findPlacePrintlistForUser(EventUser user) {
// TODO: get from placefacade. Sometimes it's easier to think loops then facadequeries
boolean printOnlyOwn = eventBean.getPropertyBoolean(LanEventPropertyKey.PLACECODE_PRINT_ONLY_OWN);
List<GroupMembership> gmems = gmemfacade.findMemberOrCreator(user);
List<Place> places = new ArrayList<>();
for(GroupMembership gm : gmems) {
if(gm.getPlaceReservation() != null) {
// places with no user belongs to creator
if(gm.getUser() == null || !printOnlyOwn) {
places.add(gm.getPlaceReservation());
} else if(user.equals(gm.getUser())) {
places.add(gm.getPlaceReservation());
}
}
}
return places;
}
@Override
public List<Product> getMapProducts(EventMap map) { public List<Product> getMapProducts(EventMap map) {
return placeFacade.getMapProducts(map); return placeFacade.getMapProducts(map);
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
...@@ -28,6 +29,7 @@ import javax.ejb.EJB; ...@@ -28,6 +29,7 @@ import javax.ejb.EJB;
import javax.ejb.EJBAccessException; import javax.ejb.EJBAccessException;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -45,12 +47,6 @@ import fi.codecrew.moya.enums.apps.SpecialPermission; ...@@ -45,12 +47,6 @@ import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.facade.EventUserFacade; import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade; import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PlaceGroupFacade; import fi.codecrew.moya.facade.PlaceGroupFacade;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.BarcodeUtils; import fi.codecrew.moya.utilities.BarcodeUtils;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType; import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
...@@ -161,20 +157,11 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -161,20 +157,11 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
public void getGroupMembershipPdf(EventUser usr, OutputStream ostream) { public void getGroupMembershipPdf(EventUser usr, OutputStream ostream) {
List<GroupMembership> memberships = getMembershipsAndCreations(usr); List<GroupMembership> memberships = getMembershipsAndCreations(usr);
LanEventProperty tmpProperty = eventbean.getProperty(LanEventPropertyKey.PLACECODE_FROM_USER);
boolean placecodeFromUser = false;
if (tmpProperty != null && tmpProperty.isBooleanValue()) boolean placecodeFromUser = eventbean.getPropertyBoolean(LanEventPropertyKey.PLACECODE_FROM_USER);
{
placecodeFromUser = true; boolean printOnlyOwn = eventbean.getPropertyBoolean(LanEventPropertyKey.PLACECODE_PRINT_ONLY_OWN);
}
tmpProperty = eventbean.getProperty(LanEventPropertyKey.PLACECODE_PRINT_ONLY_OWN);
boolean printOnlyOwn = false;
if (tmpProperty != null && tmpProperty.isBooleanValue())
{
printOnlyOwn = true;
}
try { try {
PDF pdf = new PDF(ostream); PDF pdf = new PDF(ostream);
...@@ -328,4 +315,33 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -328,4 +315,33 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
membership = gmemfacade.merge(membership); membership = gmemfacade.merge(membership);
} }
@Override
public List<GroupMembership> findMembershipPrintlistForUser(EventUser user) {
// TODO: get from placefacade. Sometimes it's easier to think loops then facadequeries
boolean printOnlyOwn = eventbean.getPropertyBoolean(LanEventPropertyKey.PLACECODE_PRINT_ONLY_OWN);
List<GroupMembership> gmems = gmemfacade.findMemberOrCreator(user);
List<GroupMembership> ret = new ArrayList<>();
for(GroupMembership gm : gmems) {
if(gm.getPlaceReservation() != null) {
// places with no user belongs to creator
if(gm.getUser() == null || !printOnlyOwn) {
ret.add(gm);
} else if(user.equals(gm.getUser())) {
ret.add(gm);
}
}
}
return ret;
}
} }
...@@ -174,6 +174,9 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -174,6 +174,9 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
} }
public Long findCountForProduct(Product product) { public Long findCountForProduct(Product product) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class); CriteriaQuery<Long> cq = cb.createQuery(Long.class);
......
...@@ -36,13 +36,14 @@ public enum LanEventPropertyKey { ...@@ -36,13 +36,14 @@ public enum LanEventPropertyKey {
GATHER_OTHER_BILL_INFO(Type.BOOL, null), GATHER_OTHER_BILL_INFO(Type.BOOL, null),
GATHER_SHIRT_SIZE(Type.BOOL, null), GATHER_SHIRT_SIZE(Type.BOOL, null),
ALLOW_BILLING(Type.BOOL, null), ALLOW_BILLING(Type.BOOL, null),
BILL_EXPIRE_HOURS(Type.LONG, "168"), BILL_EXPIRE_HOURS(Type.LONG, "1"),
TEMPLATE_PROPERTY1(Type.TEXT, null), TEMPLATE_PROPERTY1(Type.TEXT, null),
TEMPLATE_PROPERTY2(Type.TEXT, null), TEMPLATE_PROPERTY2(Type.TEXT, null),
TEMPLATE_PROPERTY3(Type.TEXT, null), TEMPLATE_PROPERTY3(Type.TEXT, null),
TEMPLATE_PROPERTY4(Type.TEXT, null), TEMPLATE_PROPERTY4(Type.TEXT, null),
TEMPLATE_PROPERTY5(Type.TEXT, null), TEMPLATE_PROPERTY5(Type.TEXT, null),
INVITE_ONLY_EVENT(Type.BOOL, null), INVITE_ONLY_EVENT(Type.BOOL, null),
USE_ETICKET(Type.BOOL, null),
; ;
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
</f:metadata>
<ui:define rendered="#{lectureUserView.lectureGroupsVisible}" name="title">
<h1>#{i18n['etickets.title']}</h1>
</ui:define>
<ui:define name="content">
<h:form id="etickets">
<br /><br />
<p:commandButton value="Print" type="button" icon="ui-icon-print" style="display:block;margin-bottom: 20px">
<p:printer target="eticketpanel"/>
</p:commandButton>&lt;--Tarvitaanko?<br/>
<p:commandButton icon="ui-icon-mail-closed" value="Send as email (TODO)"/><br/><br/><br/>
<p:outputPanel id="eticketpanel">
<p:fieldset legend="#{i18n['etickets.eticketcode']}" style="width: 250px; ">
<p:outputPanel style="text-align: center;">
<p:barcode id="userqrcode" value="#{eticketView.userTextCode}" type="qr" width="200" height="200"/><br />
<p:outputLabel for="userqrcode" value="#{eticketView.userTextCode}"/>
</p:outputPanel>
</p:fieldset>
<br /><br />
<p:fieldset legend="#{i18n['etickets.placeinfo']}">
<p:dataTable value="#{eticketView.groupMemberships}" var="member" id="placestable">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['etickets.place']}"/>
</f:facet>
<h:outputText value="#{member.placeReservation.name}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['etickets.product']}"/>
</f:facet>
<h:outputText value="#{member.placeReservation.product.name}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['etickets.user']}"/>
</f:facet>
<h:outputText value="#{member.user.wholeName} (#{member.user.nick})"/>
</p:column>
</p:dataTable>
</p:fieldset>
<br /><br />
<p:fieldset legend="#{i18n['etickets.placemap']}" style="#{eticketView.mapFieldsetStyle}">
<p:graphicImage url="/PlaceMap?mapid=#{mapView.activeMap.id}&amp;userid=#{userView.selectedUser.user.id}"/>
</p:fieldset>
</p:outputPanel>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -63,14 +63,19 @@ ...@@ -63,14 +63,19 @@
</p:dataTable> </p:dataTable>
<p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
<h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>
</h:form> </h:form>
<!-- TODO: button -->
<p:outputPanel rendered="#{!placeGroupView.useEticket}" >
<p> <p>
<input type="button" onclick="location.replace('#{request.contextPath}/PlaceGroupPdf');" value="#{i18n['placegroup.printPdf']}" /> <input type="button" onclick="location.replace('#{request.contextPath}/PlaceGroupPdf');" value="#{i18n['placegroup.printPdf']}" />
</p> </p>
</p:outputPanel>
<p:outputPanel rendered="#{placeGroupView.useEticket}" >
<p>
<p:button outcome="/place/myEtickets" value="#{i18n['placegroup.showEticket']}" />
</p>
</p:outputPanel>
<h2>#{i18n['placetoken.pageHeader']}</h2> <h2>#{i18n['placetoken.pageHeader']}</h2>
<p>#{i18n['placetoken.topText']}</p> <p>#{i18n['placetoken.topText']}</p>
<h:form id="placeTokenForm"> <h:form id="placeTokenForm">
......
...@@ -35,12 +35,22 @@ ...@@ -35,12 +35,22 @@
<version>5.1</version> <version>5.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId> <groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId> <artifactId>all-themes</artifactId>
<version>1.0.8</version> <version>1.0.8</version>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>net.matlux</groupId> <groupId>net.matlux</groupId>
<artifactId>jvm-breakglass</artifactId> <artifactId>jvm-breakglass</artifactId>
<version>0.0.7</version> <version>0.0.7</version>
......
...@@ -29,6 +29,7 @@ import java.awt.image.BufferedImage; ...@@ -29,6 +29,7 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -43,13 +44,11 @@ import javax.servlet.http.HttpServlet; ...@@ -43,13 +44,11 @@ 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;
import fi.codecrew.moya.beans.*;
import fi.codecrew.moya.model.User;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.LoggingBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.SecurityLogType;
import fi.codecrew.moya.enums.apps.MapPermission; import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
...@@ -75,7 +74,11 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -75,7 +74,11 @@ public class PlaceMapServlet extends HttpServlet {
@EJB @EJB
private transient LoggingBeanLocal loggerbean; private transient LoggingBeanLocal loggerbean;
@EJB
private UserBeanLocal userBean;
private static final String PARAMETER_EVENT_MAP_ID = "mapid"; private static final String PARAMETER_EVENT_MAP_ID = "mapid";
private static final String PARAMETER_USER_ID = "userid";
/** /**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
...@@ -102,6 +105,8 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -102,6 +105,8 @@ public class PlaceMapServlet extends HttpServlet {
// PARAMETER_SELECTED_PLACE_ID); // PARAMETER_SELECTED_PLACE_ID);
Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID); Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID);
Integer userId = getIntegerParameter(request, PARAMETER_USER_ID);
// Integer userId = getIntegerParameter(request, // Integer userId = getIntegerParameter(request,
// PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta. // PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta.
...@@ -115,19 +120,12 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -115,19 +120,12 @@ public class PlaceMapServlet extends HttpServlet {
ostream.print("Map error!"); ostream.print("Map error!");
} else { } else {
response.setContentType("image/jpeg"); response.setContentType("image/png");
printPlaceMapToStream(ostream, "jpg", map); printPlaceMapToStream(ostream, "png", map,userId);
logger.debug("Flushing ostream"); logger.debug("Flushing ostream");
ostream.flush(); ostream.flush();
} }
/*
* TODO output your page here out.println("<html>");
* out.println("<head>");
* out.println("<title>Servlet PlaceMap</title>");
* out.println("</head>"); out.println("<body>");
* out.println("<h1>Servlet PlaceMap at " + request.getContextPath
* () + "</h1>"); out.println("</body>"); out.println("</html>");
*/
} catch (EJBException e) { } catch (EJBException e) {
logger.debug("Permission denied. Returning SC_FORBIDDEN!"); logger.debug("Permission denied. Returning SC_FORBIDDEN!");
response.setContentType("text/html;charset=UTF-8"); response.setContentType("text/html;charset=UTF-8");
...@@ -141,7 +139,7 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -141,7 +139,7 @@ public class PlaceMapServlet extends HttpServlet {
} }
} }
private void printPlaceMapToStream(OutputStream outputStream, String filetype, EventMap map) throws IOException private void printPlaceMapToStream(OutputStream outputStream, String filetype, EventMap map, Integer userid) throws IOException
{ {
if (!permbean.hasPermission(MapPermission.VIEW)) if (!permbean.hasPermission(MapPermission.VIEW))
...@@ -167,6 +165,16 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -167,6 +165,16 @@ public class PlaceMapServlet extends HttpServlet {
// logger.debug("Got map object {}", map); // logger.debug("Got map object {}", map);
List<Place> places = map.getPlaces(); List<Place> places = map.getPlaces();
List<Place> userplaces = new ArrayList<>();
if(userid != null && userid != 0) {
EventUser user = userBean.findByUserId(userid, false);
if(user != null) {
userplaces = placeBean.findPlacePrintlistForUser(user);
}
}
EventUser user = permbean.getCurrentUser(); EventUser user = permbean.getCurrentUser();
// List<Place> selectedPlaces = placemapBean.findSelectedPlaces(map); // List<Place> selectedPlaces = placemapBean.findSelectedPlaces(map);
...@@ -175,7 +183,18 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -175,7 +183,18 @@ public class PlaceMapServlet extends HttpServlet {
Graphics2D g2d = image.createGraphics(); Graphics2D g2d = image.createGraphics();
for (Place place : places) { for (Place place : places) {
drawPlace(place, g2d, user);
if(userplaces.size() > 0) {
if(userplaces.contains(place)) {
drawPlace(place, g2d, user, true, true);
} else {
drawPlace(place, g2d, user, true, false);
}
} else {
drawPlace(place, g2d, user, false, false);
}
} }
// BufferedImage image = map.getMapWithPlaces(, selectedPlaces); // BufferedImage image = map.getMapWithPlaces(, selectedPlaces);
...@@ -259,41 +278,48 @@ public class PlaceMapServlet extends HttpServlet { ...@@ -259,41 +278,48 @@ public class PlaceMapServlet extends HttpServlet {
private static final Color LOCKED_COLOR = Color.DARK_GRAY; private static final Color LOCKED_COLOR = Color.DARK_GRAY;
private static final int BORDER_WIDTH = 2; private static final int BORDER_WIDTH = 2;
private static void drawPlace(Place p, Graphics2D g, EventUser user) { private static void drawPlace(Place p, Graphics2D g, EventUser user, boolean onlyFrame, boolean hilight) {
if (p.isDisabled()) { if (p.isDisabled()) {
return; return;
} }
Color color = null; Color color = null;
if (!p.isBuyable()) {
logger.debug("Setting color as locked place.");
color = LOCKED_COLOR;
}
if (p.isReservedFor(user)) {
// logger.debug("Setting place selected {}", p);
color = SELECTED_COLOR;
} else if (user.equals(p.getCurrentUser())
|| (p.getGroup() != null && user.equals(p.getGroup().getCreator()))
|| (p.getPlaceReserver() != null && user.equals(p
.getPlaceReserver().getUser()))) {
color = OWNED_COLOR;
// logger.debug("Setting place owned {}", p);
} else if (p.isTaken()) { if(!onlyFrame) {
color = RESERVED_COLOR; if (!p.isBuyable()) {
// logger.debug("Setting place Reserved {}", p); logger.debug("Setting color as locked place.");
color = LOCKED_COLOR;
}
} else if (p.getProduct() != null && p.getProduct() != null && p.getProduct().getColor() != null && !p.getProduct().getColor().isEmpty()) { if (p.isReservedFor(user)) {
// logger.debug("Setting place selected {}", p);
color = SELECTED_COLOR;
} else if (user.equals(p.getCurrentUser())
|| (p.getGroup() != null && user.equals(p.getGroup().getCreator()))
|| (p.getPlaceReserver() != null && user.equals(p
.getPlaceReserver().getUser()))) {
color = OWNED_COLOR;
// logger.debug("Setting place owned {}", p);
} else if (p.isTaken()) {
color = RESERVED_COLOR;
// logger.debug("Setting place Reserved {}", p);
} else if (p.getProduct() != null && p.getProduct() != null && p.getProduct().getColor() != null && !p.getProduct().getColor().isEmpty()) {
try {
color = Color.decode(p.getProduct().getColor());
} catch (NumberFormatException x) {
logger.error("Cannot convert string {} to color.", p.getProduct().getColor());
}
} else {
// too much debugging -TKjne
// logger.debug("Nothing special for this place. Color should be default.");
try {
color = Color.decode(p.getProduct().getColor());
} catch (NumberFormatException x) {
logger.error("Cannot convert string {} to color.", p.getProduct().getColor());
} }
} else { }
// too much debugging -TKjne
// logger.debug("Nothing special for this place. Color should be default.");
if(hilight) {
color = OWNED_COLOR;
} }
g.setColor(BORDER_COLOR); g.setColor(BORDER_COLOR);
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.web.cdiview.eticket;
import fi.codecrew.moya.beans.BarcodeBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.shop.InviteView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Named
@ConversationScoped
public class EticketView extends GenericCDIView {
private static final long serialVersionUID = -3934253910818396155L;
private static final Logger logger = LoggerFactory.getLogger(EticketView.class);
// @Inject
// private UserView userview;
@Inject
@SelectedUser
private EventUser user;
@EJB
private BarcodeBeanLocal barcodeBean;
@EJB
private PlaceGroupBeanLocal placegroupBean;
@EJB
UserBeanLocal userBean;
@EJB
PlaceBeanLocal placeBean;
@Inject
private InviteView inviteView;
private Place place;
private PlaceGroup group;
private transient ListDataModel<PlaceGroup> placegroups;
private transient ListDataModel<Place> placelist;
private transient ListDataModel<GroupMembership> memberlist;
private Map<Integer, String> inviteMails = new HashMap<>();
public String getUserTextCode() {
return barcodeBean.getUserTextCode(user);
}
public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>(placegroupBean.findMembershipPrintlistForUser(user));
return memberlist;
}
public String getMapFieldsetStyle() {
Integer width = placeBean.getActiveMap().getWidth();
if(width == null || width < 100)
return "";
return "width: " + (width+100) + "px;";
}
}
...@@ -29,13 +29,11 @@ import javax.faces.model.ListDataModel; ...@@ -29,13 +29,11 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal; import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.MapPermission; import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.*;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.shop.InviteView; import fi.codecrew.moya.web.cdiview.shop.InviteView;
...@@ -62,6 +60,9 @@ public class PlacegroupView extends GenericCDIView { ...@@ -62,6 +60,9 @@ public class PlacegroupView extends GenericCDIView {
@EJB @EJB
UserBeanLocal userBean; UserBeanLocal userBean;
@EJB
EventBeanLocal eventBean;
@Inject @Inject
private InviteView inviteView; private InviteView inviteView;
...@@ -83,6 +84,9 @@ public class PlacegroupView extends GenericCDIView { ...@@ -83,6 +84,9 @@ public class PlacegroupView extends GenericCDIView {
} }
public boolean isUseEticket() {
return eventBean.getPropertyBoolean(LanEventPropertyKey.USE_ETICKET);
}
public boolean isCanModifyCurrent() { public boolean isCanModifyCurrent() {
GroupMembership row = memberlist.getRowData(); GroupMembership row = memberlist.getRowData();
......
...@@ -446,3 +446,13 @@ invite.permissionDenied=Sinulla ei ole oikeutta luovuttaa paikkaa eteenp\u00E4in ...@@ -446,3 +446,13 @@ invite.permissionDenied=Sinulla ei ole oikeutta luovuttaa paikkaa eteenp\u00E4in
invite.userLoginSuccessfull=Kutsu vastaanotettu onnistuneesti invite.userLoginSuccessfull=Kutsu vastaanotettu onnistuneesti
invite.userLoginUnSuccessfull=Kirjautuminen ep\u00E4onnistui invite.userLoginUnSuccessfull=Kirjautuminen ep\u00E4onnistui
placegroupview.placetransferred=Paikka annettu eteenp\u00E4in placegroupview.placetransferred=Paikka annettu eteenp\u00E4in
product.expired=Vanhentuneet
product.edit=
etickets.title=Lippusi
etickets.place=Paikka
etickets.user=Paikan omistaja
etickets.product=Lippu
etickets.placeinfo=Paikkatiedot
etickets.eticketcode=Lippu
etickets.placemap=Paikat kartalla
placegroup.showEticket=N\u00E4yt\u00E4 lippu
...@@ -1644,3 +1644,12 @@ invite.permissionDenied=You don't have permission to regive this place. ...@@ -1644,3 +1644,12 @@ invite.permissionDenied=You don't have permission to regive this place.
invite.userLoginSuccessfull=Invite accepted successfully invite.userLoginSuccessfull=Invite accepted successfully
invite.userLoginUnSuccessfull=Login unsuccessfull invite.userLoginUnSuccessfull=Login unsuccessfull
placegroupview.placetransferred=Place is transferred placegroupview.placetransferred=Place is transferred
product.expired=Expired
etickets.title=Your ticket
etickets.place=Place
etickets.user=Place owner
etickets.product=Ticket
etickets.placeinfo=Placeinfo
etickets.eticketcode=Ticket
etickets.placemap=Places on map
placegroup.showEticket=Show eticket
...@@ -1625,3 +1625,12 @@ invite.permissionDenied=Sinulla ei ole oikeutta luovuttaa paikkaa eteenp\u00E4in ...@@ -1625,3 +1625,12 @@ invite.permissionDenied=Sinulla ei ole oikeutta luovuttaa paikkaa eteenp\u00E4in
invite.userLoginSuccessfull=Kutsu vastaanotettu onnistuneesti invite.userLoginSuccessfull=Kutsu vastaanotettu onnistuneesti
invite.userLoginUnSuccessfull=Kirjautuminen ep\u00E4onnistui invite.userLoginUnSuccessfull=Kirjautuminen ep\u00E4onnistui
placegroupview.placetransferred=Paikka on annettu eteenp\u00E4in. placegroupview.placetransferred=Paikka on annettu eteenp\u00E4in.
product.expired=Vanhentuneet
etickets.title=Lippusi
etickets.place=Paikka
etickets.user=Paikan omistaja
etickets.product=Lippu
etickets.placeinfo=Paikkatiedot
etickets.eticketcode=Lippu
etickets.placemap=Paikat kartalla
placegroup.showEticket=N\u00E4yt\u00E4 lippu
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!