Commit 2b9d7703 by Ossi Pesonen

Merge branch 'master' of gitlab.codecrew.fi:codecrew/moya

2 parents 5225b308 3521c558
Showing with 2491 additions and 703 deletions
...@@ -39,7 +39,12 @@ public interface BarcodeBeanLocal { ...@@ -39,7 +39,12 @@ 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 EventUser getUserFromTextCode(String textcode);
public String getUserLongTextCode(EventUser user);
public EventUser getUserFromLongTextCode(String textcode);
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,14 @@ public interface PlaceBeanLocal { ...@@ -120,4 +120,14 @@ public interface PlaceBeanLocal {
List<PlaceSlot> getFreePlaceslots(EventUser user, Product product); List<PlaceSlot> getFreePlaceslots(EventUser user, Product product);
List<Place> findPlacePrintlistForUser(EventUser user);
List<PlaceSlot> getFreePlaceslots(EventUser u, EventMap map);
List<PlaceSlot> getPlaceslots(EventUser user);
boolean lockSlot(PlaceSlot row);
boolean releaseSlot(PlaceSlot row);
} }
package fi.codecrew.moya.beans;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import javax.ejb.Local;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.map.MapReservationQueueEntry;
@Local
public interface QueueBeanLocal {
MapReservationQueueEntry enterQueue(EventMap map, EventUser user);
boolean isReserving(EventMap map, EventUser user);
Integer getQueuePosition(EventMap map, EventUser user);
boolean isQueueEnabled();
MapReservationQueueEntry remove(EventMap map, EventUser user);
int getMinimumSlotsInQueue();
void setMinimumSlotsInQueue(int minimumSlotsInQueue);
Date getReservationTimeout(EventMap map);
void setReservingSize(int reservingSize);
int getReservingSize();
void setDefaultTimeoutMin(int defaultTimeoutMin);
int getDefaultTimeoutMin();
MapQueueI getMapQueue(EventMap map);
public interface MapQueueI {
LinkedBlockingQueue<EventUser> getQueue();
Set<EventUser> getReserving();
MapReservationQueueEntry getEntry(EventUser u);
}
void forceAddToReserving(EventMap map, EventUser u, Date time);
void forceRemove(EventMap e, EventUser u);
}
...@@ -18,18 +18,64 @@ ...@@ -18,18 +18,64 @@
*/ */
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.io.Serializable;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.beans.StatisticsBeanLocal.ProductSlotcountMover;
import fi.codecrew.moya.model.Product;
@Local @Local
public interface StatisticsBeanLocal { public interface StatisticsBeanLocal {
public Long getGroupMembershipsEnteredEvent(); public Long getGroupMembershipsEnteredEvent();
public Long getCardDeliveredCount(); public Long getCardDeliveredCount();
public Long getGroupMembershipsTotalCount(); public Long getGroupMembershipsTotalCount();
public Map<Long, Long> getHourlyIncomingStatistics(long startingFromMillis, int hourCount); public Map<Long, Long> getHourlyIncomingStatistics(long startingFromMillis, int hourCount);
public static class ProductSlotcountMover implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7759706761198824766L;
private final Product product;
private Long totalSlots;
private Long unusedSlots;
public ProductSlotcountMover(Product p) {
this.product = p;
}
public Long getTotalSlots() {
return totalSlots;
}
public void setTotalSlots(Long totalSlots) {
this.totalSlots = totalSlots;
}
public Long getUnusedSlots() {
return unusedSlots;
}
public void setUnusedSlots(Long unusedSlots) {
this.unusedSlots = unusedSlots;
}
public Product getProduct() {
return product;
}
}
List<ProductSlotcountMover> getUnusedSlots(boolean onlyPaid);
} }
/*
* 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.beans;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.PlaceGroup;
import javax.ejb.Local;
import java.io.OutputStream;
import java.util.List;
@Local
public interface TicketBeanLocal {
List<GroupMembership> findMembershipPrintlistForUser(EventUser user);
void sendTicketEmail(EventUser user, String url);
}
...@@ -89,7 +89,21 @@ public interface UserBeanLocal { ...@@ -89,7 +89,21 @@ public interface UserBeanLocal {
boolean userExists(String login); boolean userExists(String login);
boolean invite(String invitemail, String url); boolean userExistsByEmail(String email);
/**
*
* @param invitemail
* Target mail
* @param url
* Url to send
* @param membership
* target group membership, if null we generate new one
* @return
*/
boolean invite(String invitemail, String url, GroupMembership membership);
void cancelInvite(GroupMembership ship);
EventUser mergeEventUserChanges(EventUser shoppingUser); EventUser mergeEventUserChanges(EventUser shoppingUser);
...@@ -119,7 +133,7 @@ public interface UserBeanLocal { ...@@ -119,7 +133,7 @@ public interface UserBeanLocal {
boolean initPasswordResetForEmail(String email, String url); boolean initPasswordResetForEmail(String email, String url);
PrintedCard rejectPrintedCard(PrintedCard card, MailMessage mail); PrintedCard rejectPrintedCard(PrintedCard card, MailMessage mail);
boolean initPasswordResetForUsername(String username, String url); boolean initPasswordResetForUsername(String username, String url);
void addGameID(TournamentGame game, String gameid); void addGameID(TournamentGame game, String gameid);
...@@ -149,7 +163,17 @@ public interface UserBeanLocal { ...@@ -149,7 +163,17 @@ public interface UserBeanLocal {
*/ */
BigDecimal transferAccountSaldoFromPreviousEvent(List<User> dstEventuser, LanEvent source); BigDecimal transferAccountSaldoFromPreviousEvent(List<User> dstEventuser, LanEvent source);
EventUser getUser(String authcode); EventUser getUserByAuthcode(String authcode);
String getAuthCode(EventUser user); String getAuthCode(EventUser user);
/**
* Find username by email or username, this is kind of login-helper.
*
* @param filter
* @return
*/
String findUsernameByEmailUsername(String filter);
EventUser findEventuserByLogin(String username);
} }
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
*/ */
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.util.List;
import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.util.SvmReturnType; import fi.codecrew.moya.util.SvmReturnType;
...@@ -33,4 +36,9 @@ public interface VerkkomaksutFiBeanLocal { ...@@ -33,4 +36,9 @@ public interface VerkkomaksutFiBeanLocal {
boolean validateReturn(SvmReturnType type, String orderNumber, String timestamp, String paid, String method, String authcode); boolean validateReturn(SvmReturnType type, String orderNumber, String timestamp, String paid, String method, String authcode);
String getMerchantId();
Map<Integer, String> getAuthcodeForBills(List<Bill> bills);
} }
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<artifactId>moya-beans-client</artifactId> <artifactId>moya-beans-client</artifactId>
<build> <build>
<sourceDirectory>ejbModule</sourceDirectory> <sourceDirectory>ejbModule</sourceDirectory>
</build> </build>
<dependencies> <dependencies>
<dependency> <dependency>
......
...@@ -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 = 500;
//private static final String NEXT_PREFIX = "265"; //2A //private static final String NEXT_PREFIX = "265"; //2A
...@@ -97,6 +97,102 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -97,6 +97,102 @@ public class BarcodeBean implements BarcodeBeanLocal {
return BarcodeUtils.getBarcodeEAN(barcode); return BarcodeUtils.getBarcodeEAN(barcode);
} }
@Override
public String getUserLongTextCode(EventUser user) {
return getUserTextCode(user,38,16);
}
@Override
public EventUser getUserFromLongTextCode(String textcode) {
return getUserFromTextCode(textcode,38,16);
}
@Override
public String getUserTextCode(EventUser user) {
return getUserTextCode(user, 12, 5);
}
@Override
public EventUser getUserFromTextCode(String textcode) {
return getUserFromTextCode(textcode,12,5);
}
private String getUserTextCode(EventUser user, int lenght, int bytecount) {
int barcodeLenght = 12;
if(lenght < barcodeLenght)
barcodeLenght = lenght;
// barcode is still only 12 marks long
String barcode = generateBarcodeNumbers(EVENTUSER_TEXTCODEPREFIX, user.getId(), barcodeLenght);
// add some random -stuff to start of string
for (int i = lenght - barcode.length(); i > 0; --i) {
barcode = ((int) (Math.random() * 10.0)) + barcode;
}
logger.debug(barcode);
BigInteger intCode;
try {
intCode = new BigInteger(barcode);
} catch(NumberFormatException x)
{
return "GenFail";
}
String textCode = generateTextcode(intCode, bytecount);
BigInteger checkCode = textcodeToNumber(textCode, bytecount);
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;
}
private EventUser getUserFromTextCode(String textcode, int lenght, int bytecount) {
BigInteger numbercode = textcodeToNumber(textcode, bytecount);
String barcode = numbercode.toString();
// remove random prefix
int barcodeLenght = 12;
if(lenght < barcodeLenght)
barcodeLenght = lenght;
// remove some random -stuff to start of string
for (int i = lenght - barcodeLenght; i > 0; --i) {
barcode = barcode.substring(1);
}
try {
if (barcode.startsWith(EVENTUSER_TEXTCODEPREFIX)) {
int id = Integer.parseInt(barcode.substring(PLACE_TEXTCODEPREFIX.length(), barcode.length()));
EventUser user = userBean.findByEventUserId(id);
return user;
}
} catch (NumberFormatException x) {
}
return null;
}
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);
...@@ -112,8 +208,7 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -112,8 +208,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
String textCode = generateTextcode(intCode, 3); String textCode = generateTextcode(intCode, 3);
BigInteger checkCode = textcodeToNumber(textCode, 3); BigInteger checkCode = textcodeToNumber(textCode, 3);
logger.debug("CheckCode {} : Original {}", checkCode, intCode);
if(checkCode.compareTo(intCode) != 0) { if(checkCode.compareTo(intCode) != 0) {
logger.error("CheckCode {} : Original {}", checkCode, intCode); logger.error("CheckCode {} : Original {}", checkCode, intCode);
......
...@@ -23,6 +23,7 @@ import java.math.BigDecimal; ...@@ -23,6 +23,7 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
...@@ -49,6 +50,7 @@ import fi.codecrew.moya.exceptions.BillExceptionNotEnoughtCredits; ...@@ -49,6 +50,7 @@ import fi.codecrew.moya.exceptions.BillExceptionNotEnoughtCredits;
import fi.codecrew.moya.facade.BillFacade; import fi.codecrew.moya.facade.BillFacade;
import fi.codecrew.moya.facade.BillLineFacade; import fi.codecrew.moya.facade.BillLineFacade;
import fi.codecrew.moya.facade.EventUserFacade; import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.PlaceSlotFacade;
import fi.codecrew.moya.model.AccountEvent; import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine; import fi.codecrew.moya.model.BillLine;
...@@ -56,8 +58,10 @@ import fi.codecrew.moya.model.Discount; ...@@ -56,8 +58,10 @@ import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave; import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.PlaceSlot;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag; import fi.codecrew.moya.model.ProductFlag;
import fi.codecrew.moya.utilities.jpa.GenericFacade;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType; import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/** /**
...@@ -102,6 +106,8 @@ public class BillBean implements BillBeanLocal { ...@@ -102,6 +106,8 @@ public class BillBean implements BillBeanLocal {
private LoggingBeanLocal logbean; private LoggingBeanLocal logbean;
@EJB @EJB
private BillPBean billpbean; private BillPBean billpbean;
@EJB
private PlaceSlotFacade psFacade;
/** /**
* Default constructor. * Default constructor.
...@@ -257,11 +263,58 @@ public class BillBean implements BillBeanLocal { ...@@ -257,11 +263,58 @@ public class BillBean implements BillBeanLocal {
loggingBean.sendMessage(MoyaEventType.BILL_ERROR, permbean.getCurrentUser(), "Not enought rights to create bill for user: ", bill.getUser()); loggingBean.sendMessage(MoyaEventType.BILL_ERROR, permbean.getCurrentUser(), "Not enought rights to create bill for user: ", bill.getUser());
throw new EJBAccessException("Could not create bill for another user"); throw new EJBAccessException("Could not create bill for another user");
} }
// if there is autoproducts, check that they exists in bill
for (Product product : productBean.listUserShoppableProducts()) {
if (product.isUsershopAutoproduct()) {
boolean containsAutoproduct = false;
for (BillLine line : bill.getBillLines()) {
if (line.getLineProduct() != null && line.getLineProduct().equals(product) && line.getQuantity().compareTo(BigDecimal.ONE) >= 0) {
containsAutoproduct = true;
}
}
if (!containsAutoproduct) {
BillLine line = new BillLine(bill, product, BigDecimal.ONE);
bill.getBillLines().add(line);
}
}
}
billFacade.create(bill); billFacade.create(bill);
generateBillNumber(bill); generateBillNumber(bill);
createPlaceslots(bill);
return bill; return bill;
} }
/**
* Create place slots for the bill
*
* @param bill
*/
private void createPlaceslots(Bill bill) {
for (BillLine bl : bill.getBillLines()) {
if (bl == null) {
return;
}
Product prod = bl.getLineProduct();
if (prod == null || prod.getPlaces() == null || prod.getPlaces().isEmpty()) {
// Not a place product.
return;
}
int count = bl.getQuantity().intValue();
Date now = new Date();
for (int i = 0; i < count; ++i) {
PlaceSlot ps = new PlaceSlot();
ps.setBill(bill);
ps.setCreated(now);
ps.setProduct(prod);
psFacade.create(ps);
}
}
}
@RolesAllowed({ BillPermission.S_WRITE_ALL }) @RolesAllowed({ BillPermission.S_WRITE_ALL })
public Bill save(Bill bill) { public Bill save(Bill bill) {
return billFacade.merge(bill); return billFacade.merge(bill);
......
...@@ -38,27 +38,8 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -38,27 +38,8 @@ public class BootstrapBean implements BootstrapBeanLocal {
@EJB @EJB
UserFacade userFacade; UserFacade userFacade;
public BootstrapBean() { @EJB
} private DBModelFacade dbModelFacade;
/**
* Runs a "ALTER TABLE
* <table>
* <statement>" for each of tables.
*
* @param alterStatement
* e.g. "ADD meta json"
* @param tables
* table name strings
* @return1
*/
private static final String[] alterTables(String alterStatement, String... tables) {
String[] strings = new String[tables.length];
for (int i = 0; i < tables.length; i++) {
strings[i] = "ALTER TABLE \"" + tables[i] + "\" " + alterStatement;
}
return strings;
}
private static final List<String[]> dbUpdates = new ArrayList<String[]>(); private static final List<String[]> dbUpdates = new ArrayList<String[]>();
static { static {
...@@ -256,10 +237,33 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -256,10 +237,33 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE place_slots ADD CONSTRAINT FK_place_slots_PRODUCT_id FOREIGN KEY (PRODUCT_id) REFERENCES products (id)" "ALTER TABLE place_slots ADD CONSTRAINT FK_place_slots_PRODUCT_id FOREIGN KEY (PRODUCT_id) REFERENCES products (id)"
}); });
} // start_time timestamp without time zone, dbUpdates.add(new String[] {
"ALTER TABLE maps ADD COLUMN mime_type TEXT default 'image/png'",
});
}
@EJB public BootstrapBean() {
private DBModelFacade dbModelFacade; }
/**
* Runs a "ALTER TABLE
* <table>
* <statement>" for each of tables.
*
* @param alterStatement
* e.g. "ADD meta json"
* @param tables
* table name strings
* @return1
*/
private static final String[] alterTables(String alterStatement, String... tables) {
String[] strings = new String[tables.length];
for (int i = 0; i < tables.length; i++) {
strings[i] = "ALTER TABLE \"" + tables[i] + "\" " + alterStatement;
}
return strings;
}
@PostConstruct @PostConstruct
public void bootstrap() { public void bootstrap() {
...@@ -268,7 +272,7 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -268,7 +272,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
private void doDBUpdates() { private void doDBUpdates() {
DBModel dBm = dbModelFacade.findLastRevision(); DBModel dBm = dbModelFacade.findLastRevision();
Integer upIdx = (dbUpdates.size() - 1); Integer upIdx = dbUpdates.size() - 1;
if (dBm != null) { if (dBm != null) {
Integer revId = dBm.getRevision(); Integer revId = dBm.getRevision();
......
...@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans; ...@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Singleton; import javax.ejb.Singleton;
import javax.ejb.Stateless;
import fi.iudex.utils.irc.IrcBot; import fi.iudex.utils.irc.IrcBot;
...@@ -19,7 +18,6 @@ public class BotBean implements BotBeanLocal { ...@@ -19,7 +18,6 @@ public class BotBean implements BotBeanLocal {
* Default constructor. * Default constructor.
*/ */
public BotBean() { public BotBean() {
// TODO Auto-generated constructor stub
} }
@Override @Override
......
...@@ -86,8 +86,6 @@ public class CardPrintBean implements CardPrintBeanLocal { ...@@ -86,8 +86,6 @@ public class CardPrintBean implements CardPrintBeanLocal {
@EJB @EJB
private CardTemplateFacade cardTemplateFacade; private CardTemplateFacade cardTemplateFacade;
@EJB @EJB
private UserFacade userfacade;
@EJB
private BarcodeBean barcodeBean; private BarcodeBean barcodeBean;
@EJB @EJB
private PrintedCardFacade printedCardFacade; private PrintedCardFacade printedCardFacade;
...@@ -99,7 +97,6 @@ public class CardPrintBean implements CardPrintBeanLocal { ...@@ -99,7 +97,6 @@ public class CardPrintBean implements CardPrintBeanLocal {
* Default constructor. * Default constructor.
*/ */
public CardPrintBean() { public CardPrintBean() {
// TODO Auto-generated constructor stub
} }
// TODO: Roles? // TODO: Roles?
......
...@@ -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;
......
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
*/ */
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.util.Enumeration; import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.Vector;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -97,6 +94,22 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -97,6 +94,22 @@ public class JaasBean implements MoyaRealmBeanRemote {
} else { } else {
user = eventUser.getUser(); user = eventUser.getUser();
} }
// no user found, let's see if user is stupid and using email-address instead of username
// this is how it work's in theory, on practice, the fucking UserPrincipal get it's principal
// from used loginname, so, let's do this shit on loginview
/*if(user == null) {
List<User> users = userfacade.findByEmail(username);
// this must be 1, if there is more, it would just be quessing
logger.info("found by email some users {} ",users.size());
if(users.size() == 1) {
user = users.get(0);
eventUser = userbean.getEventUser(user,false);
}
}*/
logger.info("User '{}' with '{}' ", user, username); logger.info("User '{}' with '{}' ", user, username);
// If there is no eventuser found, try to create one. // If there is no eventuser found, try to create one.
...@@ -106,7 +119,7 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -106,7 +119,7 @@ public class JaasBean implements MoyaRealmBeanRemote {
logger.info("logging in as anonymous!!!"); logger.info("logging in as anonymous!!!");
} else if (!user.checkPassword(password)) { } else if (!user.checkPassword(password)) {
secubean.sendMessage(MoyaEventType.LOGIN_FAILED, eventUser, "Login failed: wrong password for username ", username); secubean.sendMessage(MoyaEventType.LOGIN_FAILED, eventUser, "Login failed: wrong password for username: ", username);
eventUser = null; eventUser = null;
user = null; user = null;
} }
...@@ -125,6 +138,10 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -125,6 +138,10 @@ public class JaasBean implements MoyaRealmBeanRemote {
eventUserFacade.flush(); eventUserFacade.flush();
eventUser.setCreator(eventUser); eventUser.setCreator(eventUser);
} }
// jos logitetaan anomuumi, niin uuden tapahtuman luominen hajoaa jännästi.
if (!user.isAnonymous())
secubean.sendMessage(MoyaEventType.LOGIN_SUCCESSFULL, eventUser, "User logged in with username: '", username, "' eventuser: ", eventUser);
} else { } else {
secubean.sendMessage(MoyaEventType.LOGIN_FAILED, eventUserFacade.findByLogin(User.ANONYMOUS_LOGINNAME), "Login failed: Username not found: ", username); secubean.sendMessage(MoyaEventType.LOGIN_FAILED, eventUserFacade.findByLogin(User.ANONYMOUS_LOGINNAME), "Login failed: Username not found: ", username);
} }
...@@ -190,7 +207,7 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -190,7 +207,7 @@ public class JaasBean implements MoyaRealmBeanRemote {
roleset.add(UserPermission.ANYUSER.getFullName()); roleset.add(UserPermission.ANYUSER.getFullName());
if (usr == null) { if (usr == null) {
usr = permbean.getAnonEventUser(); usr = permbean.getAnonEventUser();
roleset.add(SpecialPermission.ANONYMOUS.name()); roleset.add(SpecialPermission.ANONYMOUS.name());
} }
...@@ -207,8 +224,8 @@ public class JaasBean implements MoyaRealmBeanRemote { ...@@ -207,8 +224,8 @@ public class JaasBean implements MoyaRealmBeanRemote {
default: default:
throw new RuntimeException("Unknown user type: " + usertype); throw new RuntimeException("Unknown user type: " + usertype);
} }
} catch (Throwable t) { } catch (Exception t) {
logger.warn("UserType authentication " + usertype); logger.warn("UserType authentication " + usertype, t);
} }
} }
......
...@@ -109,7 +109,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -109,7 +109,7 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation usermenu = new MenuNavigation(ev, "topmenu.user", 5); MenuNavigation usermenu = new MenuNavigation(ev, "topmenu.user", 5);
usermenu.addPage(menuitemfacade.findOrCreate("/frontpage"), UserPermission.ANYUSER); usermenu.addPage(menuitemfacade.findOrCreate("/frontpage"), UserPermission.ANYUSER);
usermenu.addPage(menuitemfacade.findOrCreate("/checkout/return"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/checkout/return"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/checkout/delayed"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/checkout/delayed"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/checkout/reject"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/checkout/reject"), null).setVisible(false);
...@@ -124,6 +124,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -124,6 +124,7 @@ public class MenuBean implements MenuBeanLocal {
usermenu.addPage(menuitemfacade.findOrCreate("/auth/resetmailSent"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/auth/resetmailSent"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/passwordChanged"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/auth/passwordChanged"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/notauthorized"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/auth/notauthorized"), null).setVisible(false);
MenuNavigation userEvent = usermenu.addPage(null, null); MenuNavigation userEvent = usermenu.addPage(null, null);
userEvent.setKey("topnavi.userevent"); userEvent.setKey("topnavi.userevent");
...@@ -132,14 +133,23 @@ public class MenuBean implements MenuBeanLocal { ...@@ -132,14 +133,23 @@ public class MenuBean implements MenuBeanLocal {
userEvent.addPage(menuitemfacade.findOrCreate("/user/invite"), UserPermission.INVITE_USERS); userEvent.addPage(menuitemfacade.findOrCreate("/user/invite"), UserPermission.INVITE_USERS);
userEvent.addPage(menuitemfacade.findOrCreate("/feedback/index"), UserPermission.VITUTTAAKO); userEvent.addPage(menuitemfacade.findOrCreate("/feedback/index"), UserPermission.VITUTTAAKO);
MenuNavigation helpmenu = usermenu.addPage(null, null);
helpmenu.setKey("topnavi.help");
helpmenu.addPage(menuitemfacade.findOrCreate("/help"), UserPermission.HELPPAGE);
MenuNavigation userkauppa = usermenu.addPage(null, null); MenuNavigation userkauppa = usermenu.addPage(null, null);
userkauppa.setKey("topnavi.usershop"); userkauppa.setKey("topnavi.usershop");
userkauppa.addPage(menuitemfacade.findOrCreate("/shop/createBill"), BillPermission.CREATE_BILL); userkauppa.addPage(menuitemfacade.findOrCreate("/shop/createBill"), BillPermission.CREATE_BILL);
userkauppa.addPage(menuitemfacade.findOrCreate("/neomap/reserve"), MapPermission.BUY_PLACES);
userkauppa.addPage(menuitemfacade.findOrCreate("/neomap/notenoughslots"), UserPermission.ANYUSER).setVisible(false);;
userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/list"), ShopPermission.SHOP_FOODWAVE); userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/list"), ShopPermission.SHOP_FOODWAVE);
userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/listProducts"), ShopPermission.SHOP_FOODWAVE).setVisible(false); userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/listProducts"), ShopPermission.SHOP_FOODWAVE).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/ThanksForOrderingFromCounter"), ShopPermission.SHOP_FOODWAVE).setVisible(false); userkauppa.addPage(menuitemfacade.findOrCreate("/foodwave/ThanksForOrderingFromCounter"), ShopPermission.SHOP_FOODWAVE).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/svm/success"), UserPermission.ANYUSER).setVisible(false); // landingpages are always "anyuser"
userkauppa.addPage(menuitemfacade.findOrCreate("/svm/notification"), UserPermission.ANYUSER).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/svm/pending"), UserPermission.ANYUSER).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/list"), BillPermission.VIEW_OWN); userkauppa.addPage(menuitemfacade.findOrCreate("/bill/list"), BillPermission.VIEW_OWN);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/edit"), BillPermission.VIEW_OWN).setVisible(false); userkauppa.addPage(menuitemfacade.findOrCreate("/bill/edit"), BillPermission.VIEW_OWN).setVisible(false);
userkauppa.addPage(menuitemfacade.findOrCreate("/bill/showBill"), BillPermission.VIEW_OWN).setVisible(false); userkauppa.addPage(menuitemfacade.findOrCreate("/bill/showBill"), BillPermission.VIEW_OWN).setVisible(false);
...@@ -147,9 +157,12 @@ public class MenuBean implements MenuBeanLocal { ...@@ -147,9 +157,12 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation userPlaces = usermenu.addPage(null, null); MenuNavigation userPlaces = usermenu.addPage(null, null);
userPlaces.setKey("topnavi.userplaces"); userPlaces.setKey("topnavi.userplaces");
userPlaces.addPage(menuitemfacade.findOrCreate("/place/placemap"), MapPermission.VIEW);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES); userPlaces.addPage(menuitemfacade.findOrCreate("/place/myGroups"), MapPermission.BUY_PLACES);
userPlaces.addPage(menuitemfacade.findOrCreate("/neomap/view"), MapPermission.VIEW);
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);
userPlaces.addPage(menuitemfacade.findOrCreate("/place/eticketStandalone"), UserPermission.ANYUSER).setVisible(false);
MenuNavigation usercompetitions = usermenu.addPage(null, null); MenuNavigation usercompetitions = usermenu.addPage(null, null);
usercompetitions.setKey("topnavi.competitions"); usercompetitions.setKey("topnavi.competitions");
...@@ -166,6 +179,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -166,6 +179,7 @@ public class MenuBean implements MenuBeanLocal {
userprofile.addPage(menuitemfacade.findOrCreate("/user/changePassword"), UserPermission.VIEW_SELF); userprofile.addPage(menuitemfacade.findOrCreate("/user/changePassword"), UserPermission.VIEW_SELF);
userprofile.addPage(menuitemfacade.findOrCreate("/user/gameids"), UserPermission.MODIFY_OWN_GAMEIDS); userprofile.addPage(menuitemfacade.findOrCreate("/user/gameids"), UserPermission.MODIFY_OWN_GAMEIDS);
userprofile.addPage(menuitemfacade.findOrCreate("/auth/logout"), UserPermission.LOGOUT); userprofile.addPage(menuitemfacade.findOrCreate("/auth/logout"), UserPermission.LOGOUT);
userprofile.addPage(menuitemfacade.findOrCreate("/user/created"), UserPermission.ANYUSER).setVisible(false); // landingpages are always "anyuser"
MenuNavigation tournaments = usermenu.addPage(null, null); MenuNavigation tournaments = usermenu.addPage(null, null);
tournaments.setKey("tournaments.menutitle"); tournaments.setKey("tournaments.menutitle");
...@@ -274,6 +288,7 @@ public class MenuBean implements MenuBeanLocal { ...@@ -274,6 +288,7 @@ public class MenuBean implements MenuBeanLocal {
mapnavi.addPage(menuitemfacade.findOrCreate("/map/list"), MapPermission.MANAGE_MAPS); mapnavi.addPage(menuitemfacade.findOrCreate("/map/list"), MapPermission.MANAGE_MAPS);
mapnavi.addPage(menuitemfacade.findOrCreate("/map/create"), MapPermission.MANAGE_MAPS); mapnavi.addPage(menuitemfacade.findOrCreate("/map/create"), MapPermission.MANAGE_MAPS);
mapnavi.addPage(menuitemfacade.findOrCreate("/map/edit"), null).setVisible(false); mapnavi.addPage(menuitemfacade.findOrCreate("/map/edit"), null).setVisible(false);
mapnavi.addPage(menuitemfacade.findOrCreate("/neomap/quemgmt"), null).setVisible(false);
// event // event
MenuNavigation adminevent = adminmenu.addPage(null, null); MenuNavigation adminevent = adminmenu.addPage(null, null);
......
...@@ -112,7 +112,7 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal { ...@@ -112,7 +112,7 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
@Override @Override
@RolesAllowed(NetworkAssociationPermission.S_CAN_ADMINISTER_ASSOCIATIONS) @RolesAllowed(NetworkAssociationPermission.S_CAN_ADMINISTER_ASSOCIATIONS)
public NetworkAssociation tryAssociate(String usercode, String ip, String mac, String code, Boolean codeRequired) throws Exception { public NetworkAssociation tryAssociate(String usercode, String ip, String mac, String code, Boolean codeRequired) throws Exception {
EventUser authUser = userBean.getUser(usercode); EventUser authUser = userBean.getUserByAuthcode(usercode);
if(authUser == null) if(authUser == null)
throw new Exception("INVALID_USERCODE"); throw new Exception("INVALID_USERCODE");
......
/* /*
* Copyright Codecrew Ry * Copyright Codecrew Ry
* *
* All rights reserved. * All rights reserved.
* *
* This license applies to any software containing a notice placed by the * This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software. * copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software. * This license covers modification, distribution and use of the Software.
* *
* Any distribution and use in source and binary forms, with or without * Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the * modification is not permitted without explicit written permission from the
* copyright owner. * copyright owner.
* *
* A non-exclusive royalty-free right is granted to the copyright owner of the * 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 * Software to use, modify and distribute all modifications to the Software in
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.security.Principal; import java.security.Principal;
...@@ -67,6 +67,7 @@ import fi.codecrew.moya.model.User; ...@@ -67,6 +67,7 @@ import fi.codecrew.moya.model.User;
UserPermission.S_READ_ORGROLES, UserPermission.S_READ_ORGROLES,
UserPermission.S_WRITE_ORGROLES, UserPermission.S_WRITE_ORGROLES,
UserPermission.S_VITUTTAAKO, UserPermission.S_VITUTTAAKO,
UserPermission.S_HELPPAGE,
MapPermission.S_VIEW, MapPermission.S_VIEW,
MapPermission.S_MANAGE_MAPS, MapPermission.S_MANAGE_MAPS,
...@@ -211,10 +212,10 @@ public class PermissionBean implements PermissionBeanLocal { ...@@ -211,10 +212,10 @@ public class PermissionBean implements PermissionBeanLocal {
public String getPrincipal() { public String getPrincipal() {
Principal principal = context.getCallerPrincipal(); Principal principal = context.getCallerPrincipal();
logger.debug("Principal: {}", principal); //logger.debug("Principal: {}", principal);
String principalName = principal.getName(); String principalName = principal.getName();
logger.debug("Principal is {}", principalName); // logger.debug("Principal is {}", principalName);
return principalName; return principalName;
} }
......
...@@ -25,6 +25,7 @@ package fi.codecrew.moya.beans; ...@@ -25,6 +25,7 @@ package fi.codecrew.moya.beans;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
...@@ -47,6 +48,9 @@ import javax.ejb.Stateless; ...@@ -47,6 +48,9 @@ import javax.ejb.Stateless;
import javax.ejb.Timeout; import javax.ejb.Timeout;
import javax.ejb.Timer; import javax.ejb.Timer;
import javax.ejb.TimerService; import javax.ejb.TimerService;
import javax.xml.registry.infomodel.Slot;
import fi.codecrew.moya.model.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -66,15 +70,6 @@ import fi.codecrew.moya.facade.PlaceFacade; ...@@ -66,15 +70,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;
/** /**
...@@ -230,8 +225,8 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -230,8 +225,8 @@ public class PlaceBean implements PlaceBeanLocal {
@Override @Override
@RolesAllowed(MapPermission.S_BUY_PLACES) @RolesAllowed(MapPermission.S_BUY_PLACES)
public boolean reservePlace(Place place, EventUser user) { public boolean reservePlace(Place place, EventUser user) {
place = placeFacade.find(place.getId()); place = placeFacade.reload(place);
user = eventUserFacade.find(user.getId()); user = eventUserFacade.reload(user);
boolean ret = false; boolean ret = false;
// when admin click's place, he reserves it -> just ignore it // when admin click's place, he reserves it -> just ignore it
...@@ -239,13 +234,30 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -239,13 +234,30 @@ public class PlaceBean implements PlaceBeanLocal {
if (place.isBuyable() || permbean.hasPermission(MapPermission.MANAGE_OTHERS)) { if (place.isBuyable() || permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
if (place.getProduct().getProductFlags().contains(ProductFlag.PREPAID_CREDIT)) { if (place.getProduct().getProductFlags().contains(ProductFlag.PREPAID_CREDIT)) {
// TODO: We should check there is enough credits... logger.warn("Reserving place {} with Prepaid credit!", place);
BigDecimal balance = user.getAccountBalance();
BigDecimal price = getTotalReservationPrice(user, place);
boolean canReserve = (price.compareTo(balance) <= 0);
logger.debug("Balance {}, price {}", balance, price);
if (!canReserve && !permbean.hasPermission(MapPermission.MANAGE_OTHERS))
{
logger.debug("Did not have enought credits to reserve place! required {} , got {}", price, balance);
return false;
}
} else { } else {
List<PlaceSlot> slots = placeSlotFacade.findFreePlaceSlots(user, place.getProduct()); List<PlaceSlot> slots = placeSlotFacade.findFreePlaceSlotsForProduct(user, place.getProduct());
logger.info("Found free slots {} for user {}", Arrays.asList(slots.toArray()), user);
if (slots != null && !slots.isEmpty()) { if (slots != null && !slots.isEmpty()) {
PlaceSlot slot = slots.get(0); PlaceSlot slot = slots.get(0);
logger.warn("Reserving place {} with placeslot {}", place, slot);
slot.setPlace(place); slot.setPlace(place);
slot.setUsed(new Date()); slot.setUsed(new Date());
} else if (!permbean.hasPermission(MapPermission.MANAGE_OTHERS)) { // we still can reserve places to other people
logger.warn("Not enough slots to reserve place {}", place);
// Not enough slots to reserve place
return false;
} }
} }
...@@ -327,8 +339,10 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -327,8 +339,10 @@ public class PlaceBean implements PlaceBeanLocal {
return null; return null;
} }
// Check wether we should reserve places via credit or plcaeslot
boolean placePrepaidcredit = places.get(0).getProduct().getProductFlags().contains(ProductFlag.PREPAID_CREDIT);
// PlaceGroup pg = pgbean.createPlaceGroup(user); // PlaceGroup pg = pgbean.createPlaceGroup(user);
if (createAccountevents) if (placePrepaidcredit && createAccountevents)
{ {
BigDecimal totalprice = addAndCalcPrice(user, null); BigDecimal totalprice = addAndCalcPrice(user, null);
BigDecimal balance = user.getAccountBalance(); BigDecimal balance = user.getAccountBalance();
...@@ -597,7 +611,15 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -597,7 +611,15 @@ public class PlaceBean implements PlaceBeanLocal {
place.setPlaceReserver(null); place.setPlaceReserver(null);
gmemfacade.remove(res); gmemfacade.remove(res);
}
PlaceSlot slot = placeSlotFacade.findSlotForPlace(place);
// remove also slot from place
if (slot != null) {
slot.setPlace(null);
slot.setUsed(null);
place.setReserverSlot(null);
} }
return place; return place;
} }
...@@ -726,7 +748,34 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -726,7 +748,34 @@ public class PlaceBean implements PlaceBeanLocal {
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) if (!permbean.isCurrentUser(user) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS))
throw new EJBAccessException("User " + permbean.getCurrentUser() + "tried to fetch free places for user " + user); throw new EJBAccessException("User " + permbean.getCurrentUser() + "tried to fetch free places for user " + user);
return placeSlotFacade.findFreePlaceSlots(user, product); return placeSlotFacade.findFreePlaceSlotsForProduct(user, product);
}
@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 @Override
...@@ -734,4 +783,44 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -734,4 +783,44 @@ public class PlaceBean implements PlaceBeanLocal {
return placeFacade.getMapProducts(map); return placeFacade.getMapProducts(map);
} }
@Override
public List<PlaceSlot> getFreePlaceslots(EventUser user, EventMap map) {
user = eventUserFacade.reload(user);
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS))
throw new EJBAccessException("User " + permbean.getCurrentUser() + "tried to fetch free places for user " + user);
return placeSlotFacade.findFreePlaceSlots(user, map);
}
@Override
public List<PlaceSlot> getPlaceslots(EventUser user) {
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
throw new EJBAccessException("User " + permbean.getCurrentUser() + "tried to get slots for user " + user);
}
return placeSlotFacade.finForUser(user);
}
@Override
public boolean lockSlot(PlaceSlot row) {
row = placeSlotFacade.reload(row);
if (row.getPlace() == null && row.getUsed() == null) {
row.setUsed(new Date());
}else {
return false;
}
return true;
}
@Override
public boolean releaseSlot(PlaceSlot row) {
row = placeSlotFacade.reload(row);
if (row.getPlace() == null && row.getUsed() != null) {
row.setUsed(null);
}else {
return false;
}
return true;
}
} }
...@@ -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;
...@@ -141,6 +137,12 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -141,6 +137,12 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
boolean ret = false; boolean ret = false;
if (mem != null && mem.getUser() == null) { if (mem != null && mem.getUser() == null) {
loggerbean.sendMessage(MoyaEventType.INVITE_ACCEPTED, user, "Moya place accepted by user. ", mem);
// change token, just in case
mem.setInviteToken(gmemfacade.createInviteToken());
mem.setUser(user); mem.setUser(user);
// gmemfacade.merge(mem); // gmemfacade.merge(mem);
ret = true; ret = true;
...@@ -155,20 +157,11 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -155,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);
...@@ -298,6 +291,8 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -298,6 +291,8 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
throw new EJBAccessException("Not enough rights to release token"); throw new EJBAccessException("Not enough rights to release token");
} }
gmem.setUser(null); gmem.setUser(null);
gmem.setInviteEmail(null);
gmem.setInviteName(null);
gmem.setInviteToken(gmemfacade.createInviteToken()); gmem.setInviteToken(gmemfacade.createInviteToken());
logger.info("Place released. {} new token {}", gmem.getInviteToken()); logger.info("Place released. {} new token {}", gmem.getInviteToken());
} }
...@@ -320,4 +315,6 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -320,4 +315,6 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
membership = gmemfacade.merge(membership); membership = gmemfacade.merge(membership);
} }
} }
...@@ -212,13 +212,15 @@ public class ProductBean implements ProductBeanLocal { ...@@ -212,13 +212,15 @@ public class ProductBean implements ProductBeanLocal {
ret.put(prod.getId(), lim); ret.put(prod.getId(), lim);
// logger.info("Added product limit {} to {}", lim, prod); // logger.info("Added product limit {} to {}", lim, prod);
if (!prod.getProductFlags().contains(ProductFlag.PREPAID_CREDIT)) if (!prod.getProductFlags().contains(ProductFlag.PREPAID_CREDIT) && !prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT))
{ {
if (prod.getPlaces() != null && !prod.getPlaces().isEmpty()) { if (prod.getPlaces() != null && !prod.getPlaces().isEmpty()) {
int totalcount = prod.getPlaces().size();
Long boughtSlots = slotfacade.totalSlotcount(prod); Long selectableCount = placeFacade.countSelectable(prod);
int freeCount = totalcount - boughtSlots.intValue(); Long unusedSlots = slotfacade.findUnusedSlotsCount(prod, false);
logger.info("Prodlimit totcnt {}, bought {}, free {}, prod {}", totalcount, boughtSlots, freeCount, prod); int freeCount = selectableCount.intValue() - unusedSlots.intValue();
logger.info("Prodlimit selectable {}, unused {}, free {}, prod {}", selectableCount, unusedSlots, freeCount, prod);
ret.put(prod.getId(), BigDecimal.valueOf(freeCount)); ret.put(prod.getId(), BigDecimal.valueOf(freeCount));
} }
} }
......
...@@ -108,9 +108,9 @@ public class ProductPBean { ...@@ -108,9 +108,9 @@ public class ProductPBean {
List<Discount> discounts = new ArrayList<>(); List<Discount> discounts = new ArrayList<>();
if (overriddenUnitPrice != null && BigDecimal.ZERO.compareTo(overriddenUnitPrice) < 0) { if (overriddenUnitPrice != null && BigDecimal.ZERO.compareTo(overriddenUnitPrice) <= 0) {
unitPrice = overriddenUnitPrice; unitPrice = overriddenUnitPrice.negate();
lbean.sendMessage(MoyaEventType.ACCOUNTEVENT_INFO, permbean.getCurrentUser(), "User creating accountevent with discount"); lbean.sendMessage(MoyaEventType.ACCOUNTEVENT_INFO, permbean.getCurrentUser(), "User creating accountevent with discount");
// lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User creating accountevent with discount"); // lbean.logMessage(SecurityLogType.accountEvent, permbean.getCurrentUser(), "User creating accountevent with discount");
} else { } else {
...@@ -158,7 +158,7 @@ public class ProductPBean { ...@@ -158,7 +158,7 @@ public class ProductPBean {
// flush changes to db. // flush changes to db.
// userFacade.flush(); // userFacade.flush();
lbean.sendMessage(MoyaEventType.ACCOUNTEVENT_INFO, permbean.getCurrentUser(), "User created accountevent: ", ret.getId()); lbean.sendMessage(MoyaEventType.ACCOUNTEVENT_INFO, user, "User created accountevent: for product ", ret.getProduct().getName(), " count: ", ret.getQuantity());
return ret; return ret;
} }
} }
...@@ -23,6 +23,8 @@ import java.util.HashMap; ...@@ -23,6 +23,8 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
...@@ -51,18 +53,16 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal { ...@@ -51,18 +53,16 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
private final Map<String, String> sessionUsers = Collections.synchronizedMap(new HashMap<String, String>()); private final ConcurrentSkipListMap<String, String> sessionUsers = new ConcurrentSkipListMap<String, String>();
private final Set<HttpSession> sessions = Collections.synchronizedSet(new HashSet<HttpSession>()); private final ConcurrentSkipListSet<HttpSession> sessions = new ConcurrentSkipListSet<HttpSession>();
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(SessionMgmtBean.class); private static final Logger logger = LoggerFactory.getLogger(SessionMgmtBean.class);
@Override @Override
public void updateSessionUser(String sessionId, String user) public void updateSessionUser(String sessionId, String user) {
{
if (!sessionUsers.containsKey(sessionId)) if (!sessionUsers.containsKey(sessionId)) {
{
sessionUsers.put(sessionId, user); sessionUsers.put(sessionId, user);
} }
} }
...@@ -80,8 +80,7 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal { ...@@ -80,8 +80,7 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
@Override @Override
@RolesAllowed(UserPermission.S_MANAGE_HTTP_SESSION) @RolesAllowed(UserPermission.S_MANAGE_HTTP_SESSION)
public Set<HttpSession> getSessions() public Set<HttpSession> getSessions() {
{
return Collections.unmodifiableSet(sessions); return Collections.unmodifiableSet(sessions);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -32,8 +33,10 @@ import org.slf4j.LoggerFactory; ...@@ -32,8 +33,10 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.EventPermission; import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.facade.GroupMembershipFacade; import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PlaceSlotFacade;
import fi.codecrew.moya.facade.PrintedCardFacade; import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.model.GroupMembership; import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Product;
/** /**
* Session Bean implementation class FoodWaveBean * Session Bean implementation class FoodWaveBean
...@@ -43,14 +46,18 @@ import fi.codecrew.moya.model.GroupMembership; ...@@ -43,14 +46,18 @@ import fi.codecrew.moya.model.GroupMembership;
public class StatisticsBean implements StatisticsBeanLocal { public class StatisticsBean implements StatisticsBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(StatisticsBean.class); private static final Logger logger = LoggerFactory.getLogger(StatisticsBean.class);
@EJB @EJB
GroupMembershipFacade groupMembershipFacade; GroupMembershipFacade groupMembershipFacade;
@EJB @EJB
PrintedCardFacade printedCardFacade; PrintedCardFacade printedCardFacade;
@EJB
private PlaceSlotFacade psfacade;
@EJB
private ProductBeanLocal prodbean;
@Override @Override
@RolesAllowed(EventPermission.S_VIEW_STATISTICS) @RolesAllowed(EventPermission.S_VIEW_STATISTICS)
...@@ -72,38 +79,44 @@ public class StatisticsBean implements StatisticsBeanLocal { ...@@ -72,38 +79,44 @@ public class StatisticsBean implements StatisticsBeanLocal {
@Override @Override
public Map<Long, Long> getHourlyIncomingStatistics(long startingFromMillis, int hourCount) { public Map<Long, Long> getHourlyIncomingStatistics(long startingFromMillis, int hourCount) {
List<GroupMembership> groupMemberships = groupMembershipFacade.findAllEnteredBetween(startingFromMillis, (startingFromMillis + ((long) hourCount)*60l*60l*1000l)); List<GroupMembership> groupMemberships = groupMembershipFacade.findAllEnteredBetween(startingFromMillis, (startingFromMillis + ((long) hourCount) * 60l * 60l * 1000l));
HashMap<Long, Long> retMap = new HashMap<Long, Long>(); HashMap<Long, Long> retMap = new HashMap<>();
long currentTimestamp = startingFromMillis; long currentTimestamp = startingFromMillis;
long hour = (60l*60l*1000l); long hour = (60l * 60l * 1000l);
long hourEntered = 0; long hourEntered = 0;
for(GroupMembership gm : groupMemberships) { for (GroupMembership gm : groupMemberships) {
// find the hour this one belongs to (sometime we need to skip empty hours) // find the hour this one belongs to (sometime we need to skip empty hours)
while(gm.getEnteredEvent().getTimeInMillis() > currentTimestamp+hour) { while (gm.getEnteredEvent().getTimeInMillis() > currentTimestamp + hour) {
retMap.put(currentTimestamp, hourEntered); retMap.put(currentTimestamp, hourEntered);
hourEntered = 0; hourEntered = 0;
currentTimestamp += hour; currentTimestamp += hour;
} }
hourEntered++; hourEntered++;
} }
return retMap; return retMap;
} }
}
@Override
public List<ProductSlotcountMover> getUnusedSlots(boolean onlyPaid) {
List<ProductSlotcountMover> ret = new ArrayList<>();
for (Product p : prodbean.getProducts()) {
logger.info("Products for stats {}", p);
ProductSlotcountMover m = new ProductSlotcountMover(p);
m.setUnusedSlots(psfacade.findUnusedSlotsCount(p, onlyPaid));
m.setTotalSlots(psfacade.totalSlotcount(p, onlyPaid));
if (m.getTotalSlots() > 0 && m.getUnusedSlots() > 0) {
ret.add(m);
}
}
return ret;
}
}
/*
* 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.beans;
import com.pdfjet.*;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PlaceGroupFacade;
import fi.codecrew.moya.model.*;
import fi.codecrew.moya.util.MailMessage;
import fi.codecrew.moya.utilities.BarcodeUtils;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.EJBAccessException;
import javax.ejb.Stateless;
import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/**
* Session Bean implementation class PlaceGroupBean
*/
@Stateless
@DeclareRoles({ SpecialPermission.S_USER, MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_MAPS })
public class TicketBean implements TicketBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(TicketBean.class);
private static final int YSTART = 30;
@EJB
private EventBeanLocal eventbean;
@EJB
private BarcodeBeanLocal barcodeBean;
@EJB
private GroupMembershipFacade gmemfacade;
@EJB
private LoggingBeanLocal loggingbean;
@EJB
private PermissionBeanLocal permbean;
@EJB
private PlaceGroupFacade pgfacade;
@EJB
private EventUserFacade eventuserfacade;
@EJB
private UtilBean utilBean;
/**
* Default constructor.
*/
public TicketBean() {
// TODO Auto-generated constructor stub
}
@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;
}
@Override
public void sendTicketEmail(EventUser user , String url) {
String token = barcodeBean.getUserLongTextCode(user);
MailMessage msg = new MailMessage();
msg.setSubject(eventbean.getPropertyString(LanEventPropertyKey.ETICKETMAIL_SUBJECT));
String formatUrl = MessageFormat.format(url, token);
logger.info("Sending eticket url {}", formatUrl);
msg.setMessage(MessageFormat.format(eventbean.getPropertyString(LanEventPropertyKey.ETICKETMAIL_CONTENT), formatUrl, user.getUser().getWholeName()));
msg.setToAddress(user.getEmail());
utilBean.sendMail(msg);
}
}
...@@ -48,6 +48,8 @@ import javax.imageio.ImageIO; ...@@ -48,6 +48,8 @@ import javax.imageio.ImageIO;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import fi.codecrew.moya.enums.apps.MapPermission;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -425,6 +427,11 @@ public class UserBean implements UserBeanLocal { ...@@ -425,6 +427,11 @@ public class UserBean implements UserBeanLocal {
user.getUser().resetPassword(password); user.getUser().resetPassword(password);
user.setEvent(eventBean.getCurrentEvent()); user.setEvent(eventBean.getCurrentEvent());
if (user.getLogin() == null || user.getLogin().trim().isEmpty()) {
user.setLogin(user.getEmail());
}
// Tallennetaan olio kantaan... // Tallennetaan olio kantaan...
eventUserFacade.create(user); eventUserFacade.create(user);
...@@ -540,22 +547,49 @@ public class UserBean implements UserBeanLocal { ...@@ -540,22 +547,49 @@ public class UserBean implements UserBeanLocal {
// } // }
@Override @Override
@RolesAllowed(UserPermission.S_INVITE_USERS) public boolean invite(String invitemail, String url, GroupMembership inviteGm) {
public boolean invite(String invitemail, String url) {
invitemail = invitemail.trim(); invitemail = invitemail.trim();
List<User> usercheck = userFacade.findByEmail(invitemail); List<User> usercheck = userFacade.findByEmail(invitemail);
if (usercheck.size() > 0) { if (usercheck.size() > 0 && inviteGm == null) {
logger.info("Email already exists {}", invitemail);
return false; return false;
} }
EventUser creator = permbean.getCurrentUser(); EventUser creator = permbean.getCurrentUser();
LanEvent ev = eventBean.getCurrentEvent(); LanEvent ev = eventBean.getCurrentEvent();
PlaceGroup pg = new PlaceGroup(ev, Calendar.getInstance(), Calendar.getInstance(), false);
pg.setCreator(creator); String token = gmfacade.createInviteToken();
pg.setName("Invite to " + invitemail);
String token = PasswordFunctions.generateRandomString(30, PasswordFunctions.ALL_CHARS); PlaceGroup pg;
pg.getMembers().add(new GroupMembership(pg, null, token)); if (inviteGm != null) {
pgfacade.create(pg); if (!permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
if (inviteGm.getUser() != null && !permbean.isCurrentUser(inviteGm.getUser())) {
throw new EJBAccessException("No permission to reinvite to that place");
}
if (inviteGm.getUser() == null && !permbean.isCurrentUser(inviteGm.getPlaceGroup().getCreator())) {
throw new EJBAccessException("No permission to invite to that place");
}
}
inviteGm.setInviteToken(token);
inviteGm.setInviteEmail(invitemail);
gmfacade.merge(inviteGm);
pg = inviteGm.getPlaceGroup();
} else {
if (!permbean.hasPermission(UserPermission.INVITE_USERS)) {
throw new EJBAccessException("No permission to invite other people");
}
pg = new PlaceGroup(ev, Calendar.getInstance(), Calendar.getInstance(), false);
pg.setCreator(creator);
pg.setName("Invite to " + invitemail);
GroupMembership gm = new GroupMembership(pg, null, token);
gm.setInviteEmail(invitemail);
pg.getMembers().add(gm);
pgfacade.create(pg);
}
MailMessage msg = new MailMessage(); MailMessage msg = new MailMessage();
msg.setSubject(eventBean.getPropertyString(LanEventPropertyKey.INVITEMAIL_SUBJECT)); msg.setSubject(eventBean.getPropertyString(LanEventPropertyKey.INVITEMAIL_SUBJECT));
...@@ -568,6 +602,14 @@ public class UserBean implements UserBeanLocal { ...@@ -568,6 +602,14 @@ public class UserBean implements UserBeanLocal {
} }
@Override @Override
public void cancelInvite(GroupMembership ship) {
ship = gmfacade.merge(ship);
ship.setInviteToken(gmfacade.createInviteToken());
ship.setInviteEmail(null);
ship.setInviteName(null);
}
@Override
@PermitAll @PermitAll
public GroupMembership findToken(String token) { public GroupMembership findToken(String token) {
return gmfacade.findByToken(token); return gmfacade.findByToken(token);
...@@ -577,15 +619,26 @@ public class UserBean implements UserBeanLocal { ...@@ -577,15 +619,26 @@ public class UserBean implements UserBeanLocal {
@PermitAll @PermitAll
public EventUser acceptInviteForExistingUser(String username, String password, String token) { public EventUser acceptInviteForExistingUser(String username, String password, String token) {
GroupMembership gm = findToken(token); GroupMembership gm = findToken(token);
if (gm == null || gm.getUser() != null || gm.getInviteAccepted() != null) { if (gm == null || ((gm.getUser() != null || gm.getInviteAccepted() != null) && gm.getPlaceReservation() == null)) {
return null; return null;
} }
User u = userFacade.findByLogin(username);
EventUser eu = this.getEventUser(u, true); // it's nice to check password also
EventUser eu = validateUser(username, password, true);
if (eu == null)
return null;
loggerbean.sendMessage(MoyaEventType.INVITE_ACCEPTED, eu, "Ivite accepted by current user", gm, gm.getUser());
gm.setUser(eu); gm.setUser(eu);
gm.setInviteAccepted(Calendar.getInstance()); gm.setInviteAccepted(Calendar.getInstance());
gm.setInviteEmail(null);
// change token, just in case
gm.setInviteToken(gmfacade.createInviteToken());
return eu; return eu;
} }
...@@ -594,16 +647,25 @@ public class UserBean implements UserBeanLocal { ...@@ -594,16 +647,25 @@ public class UserBean implements UserBeanLocal {
public boolean createFromInviteToken(EventUser user, String token) { public boolean createFromInviteToken(EventUser user, String token) {
if (user == null || user.getLogin() == null) if (user == null || user.getLogin() == null)
return false; return false;
GroupMembership gm = findToken(token); GroupMembership gm = findToken(token);
// Check that invite has not already been accepted! // Check that invite has not already been accepted!
if (gm == null || gm.getUser() != null || gm.getInviteAccepted() != null) { if (gm == null || ((gm.getUser() != null || gm.getInviteAccepted() != null) && gm.getPlaceReservation() == null)) {
return false; return false;
} }
user.setEvent(eventBean.getCurrentEvent()); user.setEvent(eventBean.getCurrentEvent());
if (user.getLogin() == null || user.getLogin().trim().isEmpty()) {
user.setLogin(user.getEmail());
}
gm.setUser(user); gm.setUser(user);
gm.setInviteAccepted(Calendar.getInstance()); gm.setInviteAccepted(Calendar.getInstance());
// change token, just in case
gm.setInviteToken(gmfacade.createInviteToken());
eventUserFacade.create(user); eventUserFacade.create(user);
return true; return true;
} }
...@@ -719,6 +781,13 @@ public class UserBean implements UserBeanLocal { ...@@ -719,6 +781,13 @@ public class UserBean implements UserBeanLocal {
} }
@Override @Override
public boolean userExistsByEmail(String email) {
List<User> usr = userFacade.findByEmail(email);
return (usr != null && usr.size() > 0);
}
@Override
public EventUser findByEventUserId(Integer integer) { public EventUser findByEventUserId(Integer integer) {
return eventUserFacade.find(integer); return eventUserFacade.find(integer);
} }
...@@ -765,17 +834,20 @@ public class UserBean implements UserBeanLocal { ...@@ -765,17 +834,20 @@ public class UserBean implements UserBeanLocal {
return ret; return ret;
} }
@Override private EventUser validateUser(String username, String password, boolean createEventUser) {
public EventUser validateUser(String username, String password)
{
User user = userFacade.findByLogin(username); User user = userFacade.findByLogin(username);
EventUser ret = null; EventUser ret = null;
if (user != null && user.checkPassword(password)) if (user != null && user.checkPassword(password))
{ {
ret = this.getEventUser(user, false); ret = this.getEventUser(user, createEventUser);
} }
return ret; return ret;
}
@Override
public EventUser validateUser(String username, String password)
{
return validateUser(username, password, false);
} }
@Override @Override
...@@ -1010,8 +1082,37 @@ public class UserBean implements UserBeanLocal { ...@@ -1010,8 +1082,37 @@ public class UserBean implements UserBeanLocal {
} }
@Override @Override
public String findUsernameByEmailUsername(String filter) {
User user = userFacade.findByLogin(filter);
List<User> users = userFacade.findByEmail(filter);
if (users.size() == 1 && user != null) {
if (user.equals(users.get(0)))
return user.getLogin();
return null;
}
if (user != null)
return user.getLogin();
if (users.size() == 1) {
return users.get(0).getLogin();
}
return null;
}
@RolesAllowed(UserPermission.S_VIEW_ALL)
public EventUser findEventuserByLogin(String username) {
return eventUserFacade.findByLogin(username);
}
@Override
@RolesAllowed(EventPermission.S_MANAGE_EVENT) @RolesAllowed(EventPermission.S_MANAGE_EVENT)
public EventUser getUser(String authcode) { public EventUser getUserByAuthcode(String authcode) {
logger.info("getUser({})", authcode); logger.info("getUser({})", authcode);
EventUser user = null; EventUser user = null;
...@@ -1054,4 +1155,5 @@ public class UserBean implements UserBeanLocal { ...@@ -1054,4 +1155,5 @@ public class UserBean implements UserBeanLocal {
return user; return user;
} }
} }
\ No newline at end of file
...@@ -80,6 +80,7 @@ public class UtilBean implements UtilBeanLocal { ...@@ -80,6 +80,7 @@ public class UtilBean implements UtilBeanLocal {
@Override @Override
public boolean sendMail(MailMessage message) { public boolean sendMail(MailMessage message) {
logger.info("Sending mail message {} ", message); logger.info("Sending mail message {} ", message);
if (message.getFromAddress() == null || message.getFromAddress().isEmpty()) { if (message.getFromAddress() == null || message.getFromAddress().isEmpty()) {
message.setFromAddress(eventbean.getPropertyString(LanEventPropertyKey.PORTAL_EMAIL_ADDRESS)); message.setFromAddress(eventbean.getPropertyString(LanEventPropertyKey.PORTAL_EMAIL_ADDRESS));
......
...@@ -27,6 +27,9 @@ import java.math.BigDecimal; ...@@ -27,6 +27,9 @@ import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
...@@ -63,6 +66,7 @@ import fi.codecrew.moya.beanutil.DecimalXMLAdapter; ...@@ -63,6 +66,7 @@ import fi.codecrew.moya.beanutil.DecimalXMLAdapter;
import fi.codecrew.moya.clientutils.BortalLocalContextHolder; import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
import fi.codecrew.moya.enums.apps.BillPermission; import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.facade.BillFacade; import fi.codecrew.moya.facade.BillFacade;
import fi.codecrew.moya.facade.LanEventPrivatePropertyFacade;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.LanEventPrivateProperty; import fi.codecrew.moya.model.LanEventPrivateProperty;
import fi.codecrew.moya.model.LanEventPrivatePropertyKey; import fi.codecrew.moya.model.LanEventPrivatePropertyKey;
...@@ -77,7 +81,7 @@ import fi.codecrew.moya.verkkomaksutfi.PaymentEntry; ...@@ -77,7 +81,7 @@ import fi.codecrew.moya.verkkomaksutfi.PaymentEntry;
*/ */
@Stateless @Stateless
@LocalBean @LocalBean
@DeclareRoles({ BillPermission.S_CREATE_VERKKOMAKSU }) @DeclareRoles({ BillPermission.S_CREATE_VERKKOMAKSU, BillPermission.S_WRITE_ALL })
public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal { public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(VerkkomaksutFiBean.class); private static final Logger logger = LoggerFactory.getLogger(VerkkomaksutFiBean.class);
...@@ -97,6 +101,10 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal { ...@@ -97,6 +101,10 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
@Override @Override
public boolean isSvmEnabled() public boolean isSvmEnabled()
{ {
if (!permbean.hasPermission(BillPermission.CREATE_VERKKOMAKSU))
{
return false;
}
LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.VERKKOMAKSU_KEY_EXPIRE); LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.VERKKOMAKSU_KEY_EXPIRE);
String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_ID); String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_ID);
String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_PASSWORD); String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_PASSWORD);
...@@ -339,4 +347,31 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal { ...@@ -339,4 +347,31 @@ public class VerkkomaksutFiBean implements VerkkomaksutFiBeanLocal {
logger.warn(msg, params); logger.warn(msg, params);
} }
@EJB
private LanEventPrivatePropertyFacade eventPrivatePropertyFacade;
@Override
public String getMerchantId() {
String ret = null;
if (isSvmEnabled() && permbean.hasPermission(BillPermission.WRITE_ALL)) {
LanEventPrivateProperty e = eventPrivatePropertyFacade.getPropertyForEvent(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_ID);
if (e != null && e.getTextvalue() != null && !e.getTextvalue().isEmpty())
ret = e.getTextvalue();
}
return ret;
}
@Override
public Map<Integer, String> getAuthcodeForBills(List<Bill> bills) {
Map<Integer, String> ret = new HashMap<>();
if (isSvmEnabled() && permbean.hasPermission(BillPermission.WRITE_ALL)) {
String merchantId = eventPrivatePropertyFacade.getPropertyForEvent(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_ID).getTextvalue();
String merchantPassword = eventPrivatePropertyFacade.getPropertyForEvent(LanEventPrivatePropertyKey.VERKKOMAKSU_MERCHANT_PASSWORD).getTextvalue();
for (Bill b : bills) {
ret.put(b.getId(),PasswordFunctions.calculateMd5("&", merchantPassword, merchantId, b.getId().toString()).toUpperCase());
}
}
return ret;
}
} }
package fi.codecrew.moya.beans.moyamessage; package fi.codecrew.moya.beans.moyamessage;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.MessageDriven; import javax.ejb.MessageDriven;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.MessageListener; import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BotBean; import fi.codecrew.moya.beans.BotBean;
import fi.codecrew.moya.facade.EventFacade;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage; import fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage;
/** /**
...@@ -26,25 +29,49 @@ public class IrcBotMoyaEventTopicListener implements MessageListener { ...@@ -26,25 +29,49 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
@EJB @EJB
private BotBean botbean; private BotBean botbean;
@EJB
private EventFacade eventfacade;
@EJB
private UserFacade userfacade;
@EJB
private EventUserFacade eventuserfacade;
/** /**
* @see MessageListener#onMessage(Message) * @see MessageListener#onMessage(Message)
*/ */
public void onMessage(Message message) { public void onMessage(Message message) {
try { try {
MoyaEventMessage msg = message.getBody(MoyaEventMessage.class); MoyaEventMessage msg = message.getBody(MoyaEventMessage.class);
botbean.getBot().say(toString("Got Message ", msg.getEventtype(), " msg: ", msg.getDescription())); String event = "unknown event";
if (msg.getEventId() != null) {
LanEvent e = eventfacade.find(msg.getEventId());
if (e != null)
event = e.getName();
}
StringBuilder sb = new StringBuilder();
sb.append(event).append(" ");
sb.append(msg.getEventtype()).append(" ");
if (msg.getCurrentUserId() != null) {
User user = userfacade.find(msg.getCurrentUserId());
if (user != null) {
sb.append("user: ").append(user.getLogin()).append(" ");
}
}
if (msg.getEventUserId() != null) {
EventUser eu = eventuserfacade.find(msg.getEventUserId());
if (eu != null && !eu.getUser().getId().equals(msg.getCurrentUserId())) {
sb.append("for user: ").append(eu.getUser().getLogin()).append(": ");
}
}
sb.append(msg.getDescription());
//botbean.getBot().say(toString(event, " ", msg.getEventtype(), " User ", msg.getDescription()));
botbean.getBot().say(sb.toString());
logger.warn("Received moya event message for irc bot {}", message); logger.warn("Received moya event message for irc bot {}", message);
} catch (JMSException e) { } catch (JMSException e) {
logger.warn("Exception while getting jms message for IRCbot"); logger.warn("Exception while getting jms message for IRCbot", e);
botbean.getBot().say("Caught exception while logging message" + e.getCause());
} }
} }
private static String toString(Object... string) {
StringBuilder sb = new StringBuilder();
for (Object s : string) {
sb.append(s);
}
return sb.toString();
}
} }
...@@ -63,7 +63,7 @@ public class MoyaEventSender implements LoggingBeanLocal { ...@@ -63,7 +63,7 @@ public class MoyaEventSender implements LoggingBeanLocal {
MoyaEventMessage msg = new MoyaEventMessage(); MoyaEventMessage msg = new MoyaEventMessage();
msg.setEventtype(type); msg.setEventtype(type);
msg.setTime(Calendar.getInstance()); msg.setTime(Calendar.getInstance());
msg.setUserId(user.getId()); msg.setEventUserId(user.getId());
msg.setCurrentUserId(permbean.getCurrentUser().getUser().getId()); msg.setCurrentUserId(permbean.getCurrentUser().getUser().getId());
msg.setEventId(eventbean.getCurrentEvent().getId()); msg.setEventId(eventbean.getCurrentEvent().getId());
msg.setDescription(message); msg.setDescription(message);
......
...@@ -20,31 +20,26 @@ package fi.codecrew.moya.beans.moyamessage; ...@@ -20,31 +20,26 @@ package fi.codecrew.moya.beans.moyamessage;
import java.util.Calendar; import java.util.Calendar;
import javax.annotation.Resource;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.MessageDriven; import javax.ejb.MessageDriven;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.MessageListener; import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.transaction.UserTransaction;
import org.slf4j.Logger; import org.slf4j.Logger;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.LanEventFacade;
import fi.codecrew.moya.facade.LogEntryFacade; import fi.codecrew.moya.facade.LogEntryFacade;
import fi.codecrew.moya.facade.LogEntryTypeFacade; import fi.codecrew.moya.facade.LogEntryTypeFacade;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LoggingBeanLocal;
import fi.codecrew.moya.beans.SecurityLogType;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LogEntry; import fi.codecrew.moya.model.LogEntry;
import fi.codecrew.moya.model.LogEntryType; import fi.codecrew.moya.model.LogEntryType;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage; import fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
/** /**
* Session Bean implementation class SercurityBean * Session Bean implementation class SercurityBean
...@@ -55,13 +50,26 @@ public class MoyaEventTopicLoggingBean implements MessageListener { ...@@ -55,13 +50,26 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
private static final boolean DEBUG = true; private static final boolean DEBUG = true;
private final Logger logger = org.slf4j.LoggerFactory.getLogger(MoyaEventTopicLoggingBean.class); private final Logger logger = org.slf4j.LoggerFactory.getLogger(MoyaEventTopicLoggingBean.class);
@EJB
private LanEventFacade eventfacade;
@Override
public void onMessage(Message message) { public void onMessage(Message message) {
if (message != null) { if (message != null) {
try { try {
MoyaEventMessage msg = message.getBody(MoyaEventMessage.class); MoyaEventMessage msg = message.getBody(MoyaEventMessage.class);
logger.warn("Got message at TopicLogging {}, {}", msg.getEventtype(), msg.getDescription()); logger.warn("Got message at TopicLogging {}, {}", msg.getEventtype(), msg.getDescription());
LanEvent event = null;
if (msg.getEventId() != null)
event = eventfacade.find(msg.getEventId());
User user = null;
if (msg.getEventUserId() != null) {
EventUser euser = eventUserfacade.find(msg.getEventUserId());
if (euser != null)
user = euser.getUser();
}
logMessage(msg.getEventtype(), event, user, msg.getDescription());
} catch (JMSException e) { } catch (JMSException e) {
logger.warn("Exception whie receiving Moya EventTopic", e); logger.warn("Exception whie receiving Moya EventTopic", e);
} }
...@@ -69,27 +77,34 @@ public class MoyaEventTopicLoggingBean implements MessageListener { ...@@ -69,27 +77,34 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
} }
@EJB @EJB
private EventUserFacade eventUserfacade;
@EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
public LogEntry logMessage(SecurityLogType paramType, LanEvent event, User user, Object... description) { @EJB
private LogEntryFacade entryFacade;
@EJB
private LogEntryTypeFacade typeFacade;
private LogEntry logMessage(MoyaEventType moyaEventType, LanEvent event, User user, String desc) {
LogEntry entry = null; LogEntry entry = null;
if (event == null) { if (event == null) {
event = eventbean.getCurrentEvent(); event = eventbean.getCurrentEvent();
} }
try { try {
String desc = toString(description);
logger.warn("Sending logmsg {}", desc); logger.warn("Sending logmsg {}", desc);
//LogEntryType type = typeFacade.findOrCreate(paramType); LogEntryType type = typeFacade.findOrCreate(moyaEventType);
// entry = new LogEntry(Calendar.getInstance()); entry = new LogEntry(Calendar.getInstance());
// entry.setParentEvent(event); entry.setParentEvent(event);
// entry.setType(type); entry.setType(type);
// entry.setDescription(desc); entry.setDescription(desc);
// entry.setUser(user); entry.setUser(user);
// entryFacade.create(entry); entryFacade.create(entry);
String msg = "SECURITY DEBUG: Type: \"" + paramType.name() + // String msg = "SECURITY DEBUG: Type: \"" + moyaEventType.name() +
"\" user \"" + paramType.name() + // "\" user \"" + moyaEventType.name() +
"\", description \"" + ((user == null) ? "null" : user.getLogin()) + "\"" + desc; // "\", description \"" + ((user == null) ? "null" : user.getLogin()) + "\"" + desc;
// sender.sendMessage(msg); // sender.sendMessage(msg);
// utx.commit(); // utx.commit();
} catch (Exception e) { } catch (Exception e) {
...@@ -98,23 +113,12 @@ public class MoyaEventTopicLoggingBean implements MessageListener { ...@@ -98,23 +113,12 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
return entry; return entry;
} }
public LogEntry logMessage(SecurityLogType paramType, EventUser user, Object... description) { // private static final String toString(Object... desc) {
LanEvent event = null; // StringBuilder msg = new StringBuilder();
User usr = null; // for (Object msgpart : desc) {
if (user != null) // msg.append(msgpart);
{ // }
event = user.getEvent(); // return msg.toString();
usr = user.getUser(); // }
}
return logMessage(paramType, event, usr, description);
}
private static final String toString(Object... desc) {
StringBuilder msg = new StringBuilder();
for (Object msgpart : desc) {
msg.append(msgpart);
}
return msg.toString();
}
} }
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package fi.codecrew.moya.beanutil; package fi.codecrew.moya.beanutil;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Locale; import java.util.Locale;
...@@ -28,8 +29,9 @@ public class DecimalXMLAdapter extends XmlAdapter<String, BigDecimal> { ...@@ -28,8 +29,9 @@ public class DecimalXMLAdapter extends XmlAdapter<String, BigDecimal> {
@Override @Override
public String marshal(BigDecimal v) throws Exception { public String marshal(BigDecimal v) throws Exception {
NumberFormat format = NumberFormat.getNumberInstance(new Locale("en", "US"));
return format.format(v); v = v.setScale(2,RoundingMode.UP);
return v.toString();
} }
@Override @Override
......
...@@ -65,13 +65,16 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi ...@@ -65,13 +65,16 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi
logger.info("Generated token {} found from GoupMembership: {} Generating new!", token, gm); logger.info("Generated token {} found from GoupMembership: {} Generating new!", token, gm);
} }
token = eventbean.getCurrentEvent().getId().toString(); token = eventbean.getCurrentEvent().getId().toString();
token += PasswordFunctions.generateRandomString(15); token += PasswordFunctions.generateRandomString(30);
gm = findByToken(token); gm = findByToken(token);
} while (gm != null); } while (gm != null);
return token; return token;
} }
public GroupMembership findByToken(String token) { public GroupMembership findByToken(String token) {
if(token == null || token.trim().isEmpty())
return null;
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class); CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class);
Root<GroupMembership> root = cq.from(GroupMembership.class); Root<GroupMembership> root = cq.from(GroupMembership.class);
......
/*
* 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.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventDomain_;
import fi.codecrew.moya.model.LanEvent_;
import fi.codecrew.moya.model.LanEventDomain;
@Stateless
@LocalBean
public class LanEventFacade extends IntegerPkGenericFacade<LanEvent> {
public LanEventFacade() {
super(LanEvent.class);
}
}
...@@ -24,6 +24,7 @@ import javax.persistence.TypedQuery; ...@@ -24,6 +24,7 @@ import javax.persistence.TypedQuery;
import fi.codecrew.moya.beans.SecurityLogType; import fi.codecrew.moya.beans.SecurityLogType;
import fi.codecrew.moya.model.LogEntryType; import fi.codecrew.moya.model.LogEntryType;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -34,18 +35,18 @@ public class LogEntryTypeFacade extends IntegerPkGenericFacade<LogEntryType> { ...@@ -34,18 +35,18 @@ public class LogEntryTypeFacade extends IntegerPkGenericFacade<LogEntryType> {
super(LogEntryType.class); super(LogEntryType.class);
} }
public LogEntryType findOrCreate(SecurityLogType type) { public LogEntryType findOrCreate(MoyaEventType moyaEventType) {
// Fetch log entry type // Fetch log entry type
TypedQuery<LogEntryType> q = getEm().createNamedQuery("LogEntryType.findByName", LogEntryType.class); TypedQuery<LogEntryType> q = getEm().createNamedQuery("LogEntryType.findByName", LogEntryType.class);
q.setParameter("name", type.name()); q.setParameter("name", moyaEventType.name());
LogEntryType logEntryType = getSingleNullableResult(q); LogEntryType logEntryType = getSingleNullableResult(q);
// Might not exist yet // Might not exist yet
if (logEntryType == null) { if (logEntryType == null) {
logEntryType = new LogEntryType(); logEntryType = new LogEntryType();
logEntryType.setName(type.name()); logEntryType.setName(moyaEventType.name());
getEm().persist(logEntryType); getEm().persist(logEntryType);
} }
......
...@@ -34,8 +34,7 @@ import fi.codecrew.moya.model.Menuitem; ...@@ -34,8 +34,7 @@ import fi.codecrew.moya.model.Menuitem;
@LocalBean @LocalBean
public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> { public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> {
private static final Logger logger = LoggerFactory private static final Logger logger = LoggerFactory.getLogger(MenuitemFacade.class);
.getLogger(MenuitemFacade.class);
public MenuitemFacade() { public MenuitemFacade() {
...@@ -60,7 +59,7 @@ public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> { ...@@ -60,7 +59,7 @@ public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> {
create(ret); create(ret);
} }
return ret; return ret;
} catch (Throwable e) { } catch (Exception e) {
logger.warn("Exception menussa" + url, e); logger.warn("Exception menussa" + url, e);
} }
return null; return null;
......
...@@ -35,14 +35,17 @@ import org.slf4j.Logger; ...@@ -35,14 +35,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LoggingBeanLocal;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventMap_; import fi.codecrew.moya.model.EventMap_;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceSlot;
import fi.codecrew.moya.model.Place_; import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.Product_; import fi.codecrew.moya.model.Product_;
import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -51,7 +54,13 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -51,7 +54,13 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
private static final Logger logger = LoggerFactory.getLogger(PlaceFacade.class); private static final Logger logger = LoggerFactory.getLogger(PlaceFacade.class);
@EJB @EJB
EventBeanLocal eventBean; private EventBeanLocal eventBean;
@EJB
private PlaceSlotFacade placeslotfacade;
@EJB
private LoggingBeanLocal logbean;
public PlaceFacade() { public PlaceFacade() {
...@@ -73,7 +82,15 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -73,7 +82,15 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
int updated = 0; int updated = 0;
for (Place p : q.getResultList()) { for (Place p : q.getResultList()) {
logger.debug("Releasing place {} at automagic timed place check.", p); logger.debug("Releasing place {} at automagic timed place check.", p);
final EventUser cu = p.getCurrentUser();
if (p.checkReleased()) { if (p.checkReleased()) {
PlaceSlot slot = placeslotfacade.findSlotForPlace(p);
if (slot != null) {
slot.setPlace(null);
slot.setUsed(null);
}
logbean.sendMessage(MoyaEventType.PLACE_ERROR, cu, "Automatically release unlocked place ", p.getName());
++updated; ++updated;
} }
} }
...@@ -100,6 +117,27 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -100,6 +117,27 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
return q.getResultList(); return q.getResultList();
} }
public List<Place> findUsersUnlocketSelected(EventUser user) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Place> cq = cb.createQuery(Place.class);
Root<Place> root = cq.from(Place.class);
cq.select(root);
cq.where(
cb.and(
cb.equal(root.get(Place_.map).get(EventMap_.event), user.getEvent()),
cb.equal(root.get(Place_.currentUser), user),
cb.isNull(root.get(Place_.group))
));
TypedQuery<Place> q = getEm().createQuery(cq);
return q.getResultList();
}
public int setBuyable(EventMap map, String like, boolean b) { public int setBuyable(EventMap map, String like, boolean b) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Place> cq = cb.createQuery(Place.class); CriteriaQuery<Place> cq = cb.createQuery(Place.class);
...@@ -158,6 +196,22 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -158,6 +196,22 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
public Long countSelectable(Product product) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Place> root = cq.from(Place.class);
cq.select(cb.count(root));
cq.where(
cb.equal(root.get(Place_.product), product),
cb.isNull(root.get(Place_.releaseTime)),
cb.isNull(root.get(Place_.group)),
cb.isFalse(root.get(Place_.disabled)),
cb.isTrue(root.get(Place_.buyable))
);
return super.getSingleNullableResult(getEm().createQuery(cq));
}
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);
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -26,7 +28,9 @@ import javax.ejb.Stateless; ...@@ -26,7 +28,9 @@ import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -34,11 +38,15 @@ import org.slf4j.LoggerFactory; ...@@ -34,11 +38,15 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.Bill_; import fi.codecrew.moya.model.Bill_;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventMap_;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceSlot; import fi.codecrew.moya.model.PlaceSlot;
import fi.codecrew.moya.model.PlaceSlot_; import fi.codecrew.moya.model.PlaceSlot_;
import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.Product_;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -61,16 +69,20 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> { ...@@ -61,16 +69,20 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
* @param product * @param product
* @return * @return
*/ */
public List<PlaceSlot> findFreePlaceSlots(EventUser user, Product product) { public List<PlaceSlot> findFreePlaceSlotsForProduct(EventUser user, Product product) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PlaceSlot> q = cb.createQuery(PlaceSlot.class); CriteriaQuery<PlaceSlot> q = cb.createQuery(PlaceSlot.class);
Root<PlaceSlot> root = q.from(PlaceSlot.class); Root<PlaceSlot> root = q.from(PlaceSlot.class);
Path<Bill> bill = root.get(PlaceSlot_.bill); Path<Bill> bill = root.get(PlaceSlot_.bill);
q.where(cb.equal(bill.get(Bill_.user), user), final List<Predicate> preds = new ArrayList<>();
cb.isNotNull(bill.get(Bill_.paidDate)), preds.add(cb.equal(bill.get(Bill_.user), user));
cb.isNull(root.get(PlaceSlot_.used)), preds.add(cb.isNotNull(bill.get(Bill_.paidDate)));
cb.equal(root.get(PlaceSlot_.product), product) preds.add(cb.isNull(root.get(PlaceSlot_.used)));
); if (product != null) {
preds.add(cb.equal(root.get(PlaceSlot_.product), product));
}
q.where(preds.toArray(new Predicate[preds.size()]));
return getEm().createQuery(q).getResultList(); return getEm().createQuery(q).getResultList();
} }
...@@ -91,15 +103,95 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> { ...@@ -91,15 +103,95 @@ public class PlaceSlotFacade extends IntegerPkGenericFacade<PlaceSlot> {
return slot; return slot;
} }
public Long totalSlotcount(Product prod) { public List<PlaceSlot> finForUser(EventUser user) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PlaceSlot> q = cb.createQuery(PlaceSlot.class);
Root<PlaceSlot> root = q.from(PlaceSlot.class);
Path<Bill> bill = root.get(PlaceSlot_.bill);
q.where(cb.equal(bill.get(Bill_.user), user),
cb.isNotNull(bill.get(Bill_.paidDate)));
return getEm().createQuery(q).getResultList();
}
public Long findUnusedSlotsCount(Product prod, boolean paidOnly) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> q = cb.createQuery(Long.class); CriteriaQuery<Long> q = cb.createQuery(Long.class);
Root<PlaceSlot> root = q.from(PlaceSlot.class); Root<PlaceSlot> root = q.from(PlaceSlot.class);
q.select(cb.count(root)); q.select(cb.count(root));
Path<Bill> bill = root.get(PlaceSlot_.bill);
List<Predicate> preds = new ArrayList<>();
preds.add(cb.equal(root.get(PlaceSlot_.product), prod));
if (paidOnly) {
// Only if bill is paid
preds.add(cb.isNotNull(bill.get(Bill_.paidDate)));
} else {
// If expire is null or has not passed, count it
Path<Calendar> billexp = bill.get(Bill_.expires);
preds.add(cb.or(
cb.isNull(billexp),
cb.greaterThan(billexp, Calendar.getInstance())
));
}
// Check that slot is not used
preds.add(cb.isNull(root.get(PlaceSlot_.place)));
preds.add(cb.isNull(root.get(PlaceSlot_.used)));
q.where(preds.toArray(new Predicate[preds.size()]));
q.where(cb.equal(root.get(PlaceSlot_.product), prod));
Long count = super.getSingleNullableResult(getEm().createQuery(q)); Long count = super.getSingleNullableResult(getEm().createQuery(q));
return count; return count;
} }
public Long totalSlotcount(Product prod, boolean paidOnly) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> q = cb.createQuery(Long.class);
Root<PlaceSlot> root = q.from(PlaceSlot.class);
q.select(cb.count(root));
Path<Bill> bill = root.get(PlaceSlot_.bill);
List<Predicate> preds = new ArrayList<>();
preds.add(cb.equal(root.get(PlaceSlot_.product), prod));
if (paidOnly) {
preds.add(cb.isNotNull(bill.get(Bill_.paidDate)));
} else {
Path<Calendar> billexp = bill.get(Bill_.expires);
preds.add(cb.or(
cb.isNull(billexp),
cb.greaterThan(billexp, Calendar.getInstance())
));
}
q.where(preds.toArray(new Predicate[preds.size()]));
Long count = super.getSingleNullableResult(getEm().createQuery(q));
return count;
}
public List<PlaceSlot> findFreePlaceSlots(EventUser user, EventMap map) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PlaceSlot> q = cb.createQuery(PlaceSlot.class);
Root<PlaceSlot> root = q.from(PlaceSlot.class);
Path<Bill> bill = root.get(PlaceSlot_.bill);
final List<Predicate> preds = new ArrayList<>();
preds.add(cb.equal(bill.get(Bill_.user), user));
preds.add(cb.isNotNull(bill.get(Bill_.paidDate)));
preds.add(cb.isNull(root.get(PlaceSlot_.used)));
Subquery<Integer> mapProdq = q.subquery(Integer.class);
Root<EventMap> mapProdqRoot = mapProdq.from(EventMap.class);
mapProdq.select(mapProdqRoot.join(EventMap_.places).get(Place_.product).get(Product_.id));
mapProdq.where(cb.equal(mapProdqRoot, map));
mapProdq.distinct(true);
preds.add(root.get(PlaceSlot_.product).get(Product_.id).in(mapProdq));
q.where(preds.toArray(new Predicate[preds.size()]));
return getEm().createQuery(q).getResultList();
}
} }
...@@ -116,7 +116,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -116,7 +116,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class); CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class);
Root<PrintedCard> root = cq.from(PrintedCard.class); Root<PrintedCard> root = cq.from(PrintedCard.class);
List<Predicate> preds = new ArrayList<Predicate>(); List<Predicate> preds = new ArrayList<>();
preds.add(cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent())); preds.add(cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
......
...@@ -93,7 +93,7 @@ public class UserFacade extends IntegerPkGenericFacade<User> { ...@@ -93,7 +93,7 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class); CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class); Root<User> root = cq.from(User.class);
cq.where(cb.equal(root.get(User_.login), login)); cq.where(cb.equal(cb.lower(root.get(User_.login)), login.toLowerCase()));
return getSingleNullableResult(getEm().createQuery(cq)); return getSingleNullableResult(getEm().createQuery(cq));
} }
...@@ -139,7 +139,7 @@ public class UserFacade extends IntegerPkGenericFacade<User> { ...@@ -139,7 +139,7 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class); CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class); Root<User> root = cq.from(User.class);
cq.where(cb.equal(root.get(User_.email), email)); cq.where(cb.equal(cb.upper(root.get(User_.email)), email.toUpperCase()));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
......
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
<exclude>**/*.java</exclude> <exclude>**/*.java</exclude>
</excludes> </excludes>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-ejb-plugin</artifactId> <artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version> <version>2.4</version>
<configuration> <configuration>
<ejbVersion>3.2</ejbVersion> <ejbVersion>3.2</ejbVersion>
</configuration> </configuration>
......
...@@ -52,6 +52,9 @@ public class EventMap extends GenericEntity { ...@@ -52,6 +52,9 @@ public class EventMap extends GenericEntity {
this.event = event; this.event = event;
} }
@Column(name = "mime_type")
private String mimeType;
@Lob @Lob
@Column(name = "map_data") @Column(name = "map_data")
private byte[] mapData; private byte[] mapData;
...@@ -160,4 +163,11 @@ public class EventMap extends GenericEntity { ...@@ -160,4 +163,11 @@ public class EventMap extends GenericEntity {
this.height = height; this.height = height;
} }
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
} }
...@@ -476,6 +476,37 @@ public class EventUser extends GenericEntity { ...@@ -476,6 +476,37 @@ public class EventUser extends GenericEntity {
} }
/**
* Get first place from user registered places
*
* If you want to get where user is possibly sitting,
* use this function.
*
* @return first found place, of null if no places at all
*/
public Place getFirstPlace() {
// first, check if there is some currentUser -mapping in use (vectorama)
if(getCurrentPlaces() != null && getCurrentPlaces().size() >= 1) {
return getCurrentPlaces().get(0);
}
// no, there is not, so get places via old way
if (getGroupMemberships() == null) {
return null;
}
for(GroupMembership ship : getGroupMemberships()) {
if(this.equals(ship.getUser())) {
if(ship.getPlaceReservation() != null) {
return ship.getPlaceReservation();
}
}
}
return null;
}
public String getShortUserDescriptor() { public String getShortUserDescriptor() {
return user.getShortUserDescriptor(); return user.getShortUserDescriptor();
} }
......
...@@ -55,6 +55,8 @@ public class GenericEntity extends EntityEquals implements ModelInterface, Entit ...@@ -55,6 +55,8 @@ public class GenericEntity extends EntityEquals implements ModelInterface, Entit
@Override @Override
public JsonObject getMeta() { public JsonObject getMeta() {
// TODO: do not return null, it's not logical
// empty jsonobject would be moar logical (maybe?)
return meta; return meta;
} }
......
...@@ -325,6 +325,7 @@ public class LanEvent extends GenericEntity { ...@@ -325,6 +325,7 @@ public class LanEvent extends GenericEntity {
} }
public String getTheme() { public String getTheme() {
return theme; return theme;
} }
......
...@@ -36,13 +36,18 @@ public enum LanEventPropertyKey { ...@@ -36,13 +36,18 @@ 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),
ETICKETMAIL_SUBJECT(Type.TEXT, "Your etickets to Moya Online Youth Accumulator"),
ETICKETMAIL_CONTENT(Type.TEXT, "Hello {1},\n\nYou can find your etickets to an event from: {0}"),
MAP_QUEUE(Type.BOOL, null),
DISABLE_PHOTO_ON_KIOSK(Type.BOOL, null),
; ;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
*/ */
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.awt.Color;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
...@@ -310,6 +309,18 @@ public class Place extends GenericEntity implements Comparable<Place> { ...@@ -310,6 +309,18 @@ public class Place extends GenericEntity implements Comparable<Place> {
return buyable; return buyable;
} }
/**
* NOTE: you can newer be sure that this is up to date
* @return
*/
public PlaceSlot getReserverSlot() {
return reserverSlot;
}
public void setReserverSlot(PlaceSlot reserverSlot) {
this.reserverSlot = reserverSlot;
}
public void setReleaseTime(Calendar releaseTime) { public void setReleaseTime(Calendar releaseTime) {
this.releaseTime = releaseTime; this.releaseTime = releaseTime;
} }
......
...@@ -31,86 +31,83 @@ import javax.persistence.Table; ...@@ -31,86 +31,83 @@ import javax.persistence.Table;
@Table(name = "poll_answer") @Table(name = "poll_answer")
public class PollAnswer extends GenericEntity implements Serializable { public class PollAnswer extends GenericEntity implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -9170023819401407461L; private static final long serialVersionUID = -9170023819401407461L;
@Lob @Lob
@Column(name = "answer_text", nullable = true) @Column(name = "answer_text", nullable = true)
private String answerText = ""; private String answerText = "";
@Column(name = "answer_boolean", nullable = true) @Column(name = "answer_boolean", nullable = true)
private Boolean answerBoolean = false; private Boolean answerBoolean = false;
@ManyToOne @ManyToOne
@JoinColumn(name = "possible_answer_id", referencedColumnName = PossibleAnswer.ID_COLUMN, nullable = false) @JoinColumn(name = "possible_answer_id", referencedColumnName = PossibleAnswer.ID_COLUMN, nullable = false)
private PossibleAnswer choice; private PossibleAnswer choice;
@ManyToOne @ManyToOne
@JoinColumn(name = "eventuser_id", referencedColumnName = EventUser.ID_COLUMN, nullable = false) @JoinColumn(name = "eventuser_id", referencedColumnName = EventUser.ID_COLUMN, nullable = false)
private EventUser user; private EventUser user;
public PollAnswer() { public PollAnswer() {
super(); super();
} }
@Override
public boolean equals(Object o) @Override
{ public boolean equals(Object o)
boolean ret = false; {
if (o instanceof PollAnswer) boolean ret = false;
{ if (o instanceof PollAnswer) {
PollAnswer objO = (PollAnswer) o; PollAnswer objO = (PollAnswer) o;
if (super.getId() == null) if (super.getId() == null) {
{ ret = choice.equals(objO.getChoice());
ret = choice.equals(objO.getChoice());
} else {
} ret = super.equals(o);
else }
{ }
ret = super.equals(o); return ret;
}
} }
return ret;
public PollAnswer(PossibleAnswer possible) {
} super();
choice = possible;
public PollAnswer(PossibleAnswer possible) { }
super();
choice = possible; public void setAnswerText(String answerText) {
} this.answerText = answerText;
}
public void setAnswerText(String answerText) {
this.answerText = answerText; public String getAnswerText() {
} return answerText;
}
public String getAnswerText() {
return answerText; public void setChoice(PossibleAnswer choice) {
} this.choice = choice;
}
public void setChoice(PossibleAnswer choice) {
this.choice = choice; public PossibleAnswer getChoice() {
} return choice;
}
public PossibleAnswer getChoice() {
return choice; public void setUser(EventUser user) {
} this.user = user;
}
public void setUser(EventUser user) {
this.user = user; public EventUser getUser() {
} return user;
}
public EventUser getUser() {
return user; public void setAnswerBoolean(Boolean answerBoolean) {
} this.answerBoolean = answerBoolean;
}
public void setAnswerBoolean(Boolean answerBoolean) {
this.answerBoolean = answerBoolean; public Boolean getAnswerBoolean() {
} return answerBoolean;
}
public Boolean getAnswerBoolean() {
return answerBoolean;
}
} }
...@@ -360,4 +360,9 @@ public class Product extends GenericEntity { ...@@ -360,4 +360,9 @@ public class Product extends GenericEntity {
this.licenseTargets = licenseTargets; this.licenseTargets = licenseTargets;
} }
public boolean isUsershopAutoproduct() {
return getProductFlags().contains(ProductFlag.USERSHOP_AUTOPRODUCT);
}
} }
...@@ -54,7 +54,13 @@ public enum ProductFlag { ...@@ -54,7 +54,13 @@ public enum ProductFlag {
/** /**
* Käyttäjän itse kaupasta ostettavissa oleva tuote. * Käyttäjän itse kaupasta ostettavissa oleva tuote.
*/ */
USER_SHOPPABLE; USER_SHOPPABLE,
/**
* Tuote joka lisätään jokaisen käyttäjäkaupasta tehtyyn tilaukseen automaattisesti
*/
USERSHOP_AUTOPRODUCT
;
private static final String KEY_PREFIX = "productFlag."; private static final String KEY_PREFIX = "productFlag.";
private final String key; private final String key;
...@@ -65,7 +71,6 @@ public enum ProductFlag { ...@@ -65,7 +71,6 @@ public enum ProductFlag {
public String getI18nkey() public String getI18nkey()
{ {
return key; return key;
} }
......
package fi.codecrew.moya.model.map;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.GenericEntity;
/**
*
*
*/
//mapQueGroup
//- queEnableTime
//- queDisableTime
//- maxSiultaneousPlaces
//- maxSimultaneoutUsers
//- minPlaces
//- maxPlaces
//- placecountWeight ( 1 = more places go first, 0 = fully random
//- queueTimeWeight ( 1 = fifo, 0 = fully random )
//@Entity
// @Table(name = "map_reservation_queue")
public class MapReservationQueue extends GenericEntity {
@ManyToOne
@JoinColumn(nullable = false)
private EventMap map;
private String name;
private String description;
@Temporal(TemporalType.TIMESTAMP)
private Date queueEnableTime;
@Temporal(TemporalType.TIMESTAMP)
private Date queueDisableTime;
// how many placeslots or users can be reserving places at the same time
private Integer simultaneousPlaceslots;
private Integer simultaneousUsers;
private Integer queMinPlaces;
private Integer queMaxPlaces;
// Bigger gets selected first if multiple queues apply to user
private Integer selectionPriority = 100;
// // 100 = more places go always first, 0 = fully random
// @Column(nullable = false, precision = 6, scale = 7)
// private Integer placeslotWeight;
//
// // ( 100 = fifo, 0 = fully random )
// private Integer queueTimeWeight;
// If there are multiple queues enabled, queueus with the same weight
// are evaluated against eachother. Queues with bigger priorities are always selected
// before queues with lower prorities
private Integer queueQuePriority = 10;
/**
*
*/
private static final long serialVersionUID = -6631083485543375943L;
public MapReservationQueue() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getQueueEnableTime() {
return queueEnableTime;
}
public void setQueueEnableTime(Date queueEnableTime) {
this.queueEnableTime = queueEnableTime;
}
public Date getQueueDisableTime() {
return queueDisableTime;
}
public void setQueueDisableTime(Date queueDisableTime) {
this.queueDisableTime = queueDisableTime;
}
public Integer getSimultaneousPlaceslots() {
return simultaneousPlaceslots;
}
public void setSimultaneousPlaceslots(Integer simultaneousPlaceslots) {
this.simultaneousPlaceslots = simultaneousPlaceslots;
}
public Integer getSimultaneousUsers() {
return simultaneousUsers;
}
public void setSimultaneousUsers(Integer simultaneousUsers) {
this.simultaneousUsers = simultaneousUsers;
}
public Integer getQueMinPlaces() {
return queMinPlaces;
}
public void setQueMinPlaces(Integer queMinPlaces) {
this.queMinPlaces = queMinPlaces;
}
public Integer getQueMaxPlaces() {
return queMaxPlaces;
}
public void setQueMaxPlaces(Integer queMaxPlaces) {
this.queMaxPlaces = queMaxPlaces;
}
public EventMap getMap() {
return map;
}
public void setMap(EventMap map) {
this.map = map;
}
public Integer getSelectionPriority() {
return selectionPriority;
}
public void setSelectionPriority(Integer selectionPriority) {
this.selectionPriority = selectionPriority;
}
public Integer getQueueQuePriority() {
return queueQuePriority;
}
public void setQueueQuePriority(Integer queueQuePriority) {
this.queueQuePriority = queueQuePriority;
}
}
package fi.codecrew.moya.model.map;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GenericEntity;
//userque
//- user
//- enteredQueue
//- enteredSelection
// @Entity
// @Table(name = "map_reservation_queue_entry")
public class MapReservationQueueEntry extends GenericEntity {
/**
*
*/
private static final long serialVersionUID = -1529588850152306791L;
@Column()
@JoinColumn(nullable = false)
private MapReservationQueue queue;
@ManyToOne
private EventUser user;
@Temporal(TemporalType.TIMESTAMP)
private Date created;
@Temporal(TemporalType.TIMESTAMP)
private Date reservationTimeout;
@Transient
private Date seenTime;
// @OneToOne()
// @JoinColumn(nullable = true)
// private MapReservationQueueEntry previous;
//
// @OneToOne(mappedBy = "previous")
// private MapReservationQueueEntry next;
private static final Logger logger = LoggerFactory.getLogger(MapReservationQueueEntry.class);
// public void removeFromQueue() {
// if (previous != null) {
// if (!this.equals(previous.getNext())) {
// logger.warn("WTF!! Previous entrys next value does not match this! This '{}', Previous '{}', Next of previous '{}'", this, getPrevious(), getPrevious().getNext());
// }
// previous.setNext(next);
// previous = null;
// next = null;
// }
// }
//
// public void addToQueue(MapReservationQueueEntry previous) {
// if (previous != null) {
// next = previous.getNext();
// previous.setNext(this);
// if (next != null) {
// next.setPrevious(this);
// }
// }
// }
public MapReservationQueue getQueue() {
return queue;
}
public void setQueue(MapReservationQueue queue) {
this.queue = queue;
}
public EventUser getUser() {
return user;
}
public void setUser(EventUser user) {
this.user = user;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getReservationTimeout() {
return reservationTimeout;
}
public void setReservationTimeout(Date reservationTimeout) {
this.reservationTimeout = reservationTimeout;
}
public Date getSeenTime() {
return seenTime;
}
public void setSeenTime(Date seenTime) {
this.seenTime = seenTime;
}
}
...@@ -65,4 +65,22 @@ ...@@ -65,4 +65,22 @@
<relativePath>../moya-parent/pom.xml</relativePath> <relativePath>../moya-parent/pom.xml</relativePath>
<version>1.0</version> <version>1.0</version>
</parent> </parent>
<profiles>
<profile>
<id>exploded</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<unpackTypes>war,ejb</unpackTypes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<module>../moya-authmodule</module> <module>../moya-authmodule</module>
<module>../moya-authmodule-client</module> <module>../moya-authmodule-client</module>
<module>../moya-database</module> <module>../moya-database</module>
<module>../moya-restpojo</module>
<module>../moya-beans-client</module> <module>../moya-beans-client</module>
<module>../moya-beans</module> <module>../moya-beans</module>
<module>../moya-web</module> <module>../moya-web</module>
...@@ -47,14 +48,19 @@ ...@@ -47,14 +48,19 @@
<version>0.0.0-2013-08-19</version> <version>0.0.0-2013-08-19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.4-alpha1</version> <version>4.4-beta1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<version>6.8.8</version> <version>6.8.13</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -66,7 +72,7 @@ ...@@ -66,7 +72,7 @@
<dependency> <dependency>
<groupId>fi.iudex</groupId> <groupId>fi.iudex</groupId>
<artifactId>utils-standalone</artifactId> <artifactId>utils-standalone</artifactId>
<version>1.0.9</version> <version>1.0.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.barcode4j</groupId> <groupId>net.sf.barcode4j</groupId>
...@@ -118,7 +124,7 @@ ...@@ -118,7 +124,7 @@
<dependency> <dependency>
<groupId>fi.iudex</groupId> <groupId>fi.iudex</groupId>
<artifactId>jerklib</artifactId> <artifactId>jerklib</artifactId>
<version>1.0.1</version> <version>1.0.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.matlux</groupId> <groupId>net.matlux</groupId>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>moya-restpojo</artifactId>
<parent>
<groupId>fi.codecrew.moya</groupId>
<artifactId>moya-parent</artifactId>
<version>1.0</version>
<relativePath>../moya-parent/pom.xml</relativePath>
</parent>
<!--
<dependencies>
<dependency>
<groupId>fi.codecrew.moya</groupId>
<artifactId>moya-database</artifactId>
<version>${moya.version}</version>
</dependency>
</dependencies>
-->
</project>
\ No newline at end of file
package fi.codecrew.moya.rest.pojo.map.v1;
import javax.xml.bind.annotation.XmlElement;
public class MapPojo {
private String name;
private Integer id;
private Boolean active;
public MapPojo() {
super();
}
@XmlElement(name = "name")
public String getName() {
return name;
}
@XmlElement(name = "id")
public Integer getId() {
return id;
}
@XmlElement(name = "active")
public boolean isActive() {
return active;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
public void setName(String name) {
this.name = name;
}
public void setId(Integer id) {
this.id = id;
}
}
...@@ -16,16 +16,12 @@ ...@@ -16,16 +16,12 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.map.v1;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventMap;
@XmlRootElement @XmlRootElement
public class MapRoot { public class MapRoot {
...@@ -47,41 +43,4 @@ public class MapRoot { ...@@ -47,41 +43,4 @@ public class MapRoot {
this.maps = maps; this.maps = maps;
} }
public static class MapPojo {
private EventMap map;
public MapPojo() {
super();
}
public MapPojo(EventMap m) {
this();
this.map = m;
}
@XmlElement(name = "name")
public String getName() {
return map.getName();
}
@XmlElement(name = "id")
public Integer getId() {
return map.getId();
}
@XmlElement(name = "active")
public boolean isActive() {
return map.isActive();
}
}
public static MapRoot parseMaps(List<EventMap> eventMaps) {
List<MapPojo> ret = new ArrayList<>();
for (EventMap m : eventMaps) {
ret.add(new MapPojo(m));
}
return new MapRoot(ret);
}
} }
...@@ -16,9 +16,13 @@ ...@@ -16,9 +16,13 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.map.v1;
public class PlaceInputPojo { import java.util.Calendar;
import javax.xml.bind.annotation.XmlElement;
public class PlacePojo {
private Integer id; private Integer id;
private String name; private String name;
...@@ -31,6 +35,12 @@ public class PlaceInputPojo { ...@@ -31,6 +35,12 @@ public class PlaceInputPojo {
private Integer productId; private Integer productId;
private Integer mapId; private Integer mapId;
private Boolean taken; private Boolean taken;
private String details;
private String code;
private Calendar releaseTime;
private String description;
private Integer reserverId;
private Integer eventuserId;
public String getName() { public String getName() {
return name; return name;
...@@ -88,6 +98,7 @@ public class PlaceInputPojo { ...@@ -88,6 +98,7 @@ public class PlaceInputPojo {
this.disabled = disabled; this.disabled = disabled;
} }
@XmlElement
public Integer getProductId() { public Integer getProductId() {
return productId; return productId;
} }
...@@ -120,4 +131,52 @@ public class PlaceInputPojo { ...@@ -120,4 +131,52 @@ public class PlaceInputPojo {
this.taken = taken; this.taken = taken;
} }
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Calendar getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(Calendar releaseTime) {
this.releaseTime = releaseTime;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getReserverId() {
return reserverId;
}
public void setReserverId(Integer reserverId) {
this.reserverId = reserverId;
}
public Integer getEventuserId() {
return eventuserId;
}
public void setEventuserId(Integer eventuserId) {
this.eventuserId = eventuserId;
}
} }
...@@ -16,31 +16,22 @@ ...@@ -16,31 +16,22 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.map.v1;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.rest.pojo.MapRoot.MapPojo;
@XmlRootElement @XmlRootElement
public class PlaceRoot { public class PlaceRoot {
public PlaceRoot() public PlaceRoot() {
{ super();
}
public PlaceRoot(EventMap map2) {
this.map = new MapPojo(map2);
setPlaces(PlaceOutPojo.parse(map2.getPlaces()));
} }
private MapPojo map; private MapPojo map;
private List<PlaceOutPojo> places; private List<PlacePojo> places;
public MapPojo getMap() { public MapPojo getMap() {
return map; return map;
...@@ -50,11 +41,11 @@ public class PlaceRoot { ...@@ -50,11 +41,11 @@ public class PlaceRoot {
this.map = map; this.map = map;
} }
public List<PlaceOutPojo> getPlaces() { public List<PlacePojo> getPlaces() {
return places; return places;
} }
public void setPlaces(List<PlaceOutPojo> places) { public void setPlaces(List<PlacePojo> places) {
this.places = places; this.places = places;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.network.v1;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
......
...@@ -16,14 +16,10 @@ ...@@ -16,14 +16,10 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.network.v1;
import java.util.Calendar;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.NetworkAssociation;
public class NetworkAssociationInfoPojo { public class NetworkAssociationInfoPojo {
private String createTime; private String createTime;
private String modifyTime; private String modifyTime;
...@@ -32,18 +28,7 @@ public class NetworkAssociationInfoPojo { ...@@ -32,18 +28,7 @@ public class NetworkAssociationInfoPojo {
private Integer placeId; private Integer placeId;
private Integer eventuserId; private Integer eventuserId;
public NetworkAssociationInfoPojo(NetworkAssociation na) {
this.createTime = na.getCreateTime().getTime().toString();
this.modifyTime = na.getModifyTime().getTime().toString();
this.ipAddress = na.getIP();
this.macAddress = na.getMAC();
if(na.getPlace() != null)
this.placeId = na.getPlace().getId();
else
this.placeId = null;
this.eventuserId = na.getEventUser().getId();
}
public NetworkAssociationInfoPojo() { public NetworkAssociationInfoPojo() {
this.createTime = null; this.createTime = null;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.network.v1;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.network.v1;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.network.v1;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.network.v1;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
......
package fi.codecrew.moya.rest.pojo.placemap.v1;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class IntegerRoot {
private Integer value = -1;
@XmlElement(name = "value")
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
}
package fi.codecrew.moya.rest.pojo.placemap; package fi.codecrew.moya.rest.pojo.placemap.v1;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
...@@ -9,10 +8,6 @@ import javax.xml.bind.annotation.XmlRootElement; ...@@ -9,10 +8,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.rest.pojo.ProductRestPojo;
@XmlRootElement @XmlRootElement
public class PlacemapMapRootPojo { public class PlacemapMapRootPojo {
...@@ -25,56 +20,50 @@ public class PlacemapMapRootPojo { ...@@ -25,56 +20,50 @@ public class PlacemapMapRootPojo {
public static class MapPojo { public static class MapPojo {
private EventMap map; private Integer id;
private String name;
private Integer width;
private Integer height;
public MapPojo() { public MapPojo() {
} }
public MapPojo(EventMap map2) {
this.map = map2;
}
@XmlElement(name = "name") @XmlElement(name = "name")
public String getName() { public String getName() {
return map.getName(); return name;
} }
@XmlElement(name = "id") @XmlElement(name = "id")
public Integer getId() { public Integer getId() {
return map.getId(); return id;
} }
@XmlElement(name = "width") @XmlElement(name = "width")
public Integer getWidth() { public Integer getWidth() {
return map.getWidth(); return width;
} }
@XmlElement(name = "height") @XmlElement(name = "height")
public Integer getHeight() { public Integer getHeight() {
return map.getHeight(); return height;
} }
} public void setId(Integer id) {
this.id = id;
public List<ProductRestPojo> getProducts() { }
return products;
}
public void setProducts(List<ProductRestPojo> products) { public void setName(String name) {
this.products = products; this.name = name;
} }
public void setMap(EventMap map2) { public void setWidth(Integer width) {
logger.info("Adding map {} to placemapMap", map2); this.width = width;
map = new MapPojo(map2); }
}
public void setRawProducts(List<Product> mapProducts) { public void setHeight(Integer height) {
products = new ArrayList<>(); this.height = height;
for (Product p : mapProducts) {
logger.warn("Adding product {}", p);
products.add(new ProductRestPojo(p));
} }
} }
public MapPojo getMap() { public MapPojo getMap() {
...@@ -85,4 +74,12 @@ public class PlacemapMapRootPojo { ...@@ -85,4 +74,12 @@ public class PlacemapMapRootPojo {
this.map = map; this.map = map;
} }
public List<ProductRestPojo> getProducts() {
return products;
}
public void setProducts(List<ProductRestPojo> products) {
this.products = products;
}
} }
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.placemap.v1;
import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.Product;
public class ProductRestPojo { public class ProductRestPojo {
private Product prod; private Integer id;
private String name;
private String price;
private String description;
public ProductRestPojo() { public ProductRestPojo() {
super();
}
public ProductRestPojo(Product p) {
this.prod = p;
} }
@XmlElement(name = "id") @XmlElement(name = "id")
public Integer getId() { public Integer getId() {
return prod.getId(); return id;
} }
@XmlElement(name = "name") @XmlElement(name = "name")
public String getName() { public String getName() {
return prod.getName(); return name;
} }
@XmlElement(name = "price") @XmlElement(name = "price")
public String getPrice() { public String getPrice() {
return prod.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString(); return price;
} }
@XmlElement(name = "description") @XmlElement(name = "description")
public String getDescription() { public String getDescription() {
return prod.getDescription(); return description;
}
public void setId(Integer id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setPrice(String price) {
this.price = price;
}
public void setDescription(String description) {
this.description = description;
} }
} }
package fi.codecrew.moya.rest.pojo.placemap.v1;
import javax.xml.bind.annotation.XmlElement;
public class SimplePlacePojo {
private Integer id;
private String name;
private String state;
private Integer x;
private Integer y;
private Integer width;
private Integer height;
public SimplePlacePojo() {
super();
}
@XmlElement(name = "id")
public Integer getId() {
return id;
}
@XmlElement(name = "name")
public String getName() {
return name;
}
@XmlElement(name = "state")
public String getState() {
return state;
}
@XmlElement(name = "x")
public Integer getX() {
return x;
}
@XmlElement(name = "y")
public Integer getY() {
return y;
}
@XmlElement(name = "w")
public Integer getWidth() {
return width;
}
@XmlElement(name = "h")
public Integer getHeight() {
return height;
}
public void setId(Integer id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setState(String state) {
this.state = state;
}
public void setX(Integer x) {
this.x = x;
}
public void setY(Integer y) {
this.y = y;
}
public void setWidth(Integer width) {
this.width = width;
}
public void setHeight(Integer height) {
this.height = height;
}
}
package fi.codecrew.moya.rest.pojo.placemap; package fi.codecrew.moya.rest.pojo.placemap.v1;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
@XmlRootElement @XmlRootElement
public class SimplePlacelistRoot { public class SimplePlacelistRoot {
...@@ -21,16 +17,6 @@ public class SimplePlacelistRoot { ...@@ -21,16 +17,6 @@ public class SimplePlacelistRoot {
this.places = places; this.places = places;
} }
public static SimplePlacelistRoot wrap(List<Place> places, EventUser user)
{
SimplePlacelistRoot ret = new SimplePlacelistRoot();
ArrayList<SimplePlacePojo> placeList = new ArrayList<SimplePlacePojo>();
ret.setPlaces(placeList);
for (Place p : places) {
placeList.add(new SimplePlacePojo(p, user));
}
return ret;
}
} }
...@@ -16,36 +16,27 @@ ...@@ -16,36 +16,27 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.reader.v1;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.enums.CardState; import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo;
import fi.codecrew.moya.model.ReaderEvent; import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo;
public class ReaderEventRestPojo { public class ReaderEventRestPojo {
private ReaderEvent event;
private EventUserRestPojo eventUser; private EventUserRestPojo eventUser;
private PrintedCardRestPojo printedCard; private PrintedCardRestPojo printedCard;
private Integer readerEventId;
private Date readerEventTime;
private Integer readerId;
private Integer printedCardId;
private String printedCardState;
public ReaderEventRestPojo() { public ReaderEventRestPojo() {
} }
public ReaderEventRestPojo(ReaderEvent re) {
this.event = re;
if (re != null && re.getPrintedCard() != null) {
if (re.getPrintedCard().getUser() != null) {
eventUser = new EventUserRestPojo(re.getPrintedCard().getUser());
}
} else if(re != null && re.getUser() != null) {
eventUser = new EventUserRestPojo(re.getUser());
}
}
@XmlElement(name = "eventuser") @XmlElement(name = "eventuser")
public EventUserRestPojo getEventuser() { public EventUserRestPojo getEventuser() {
return eventUser; return eventUser;
...@@ -53,48 +44,27 @@ public class ReaderEventRestPojo { ...@@ -53,48 +44,27 @@ public class ReaderEventRestPojo {
@XmlElement(name = "readerEventId") @XmlElement(name = "readerEventId")
public Integer getEventId() { public Integer getEventId() {
return event.getId(); return readerEventId;
} }
@XmlElement(name = "readerEventTime") @XmlElement(name = "readerEventTime")
public Date getEventTime() { public Date getReaderEventTime() {
return event.getUpdatetime(); return readerEventTime;
} }
@XmlElement(name = "readerId") @XmlElement(name = "readerId")
public Integer getReaderId() { public Integer getReaderId() {
return event.getReader().getId(); return readerId;
} }
@XmlElement(name = "printedCardId") @XmlElement(name = "printedCardId")
public Integer getPrintedCardId() public Integer getPrintedCardId() {
{ return printedCardId;
Integer ret = null;
if (event != null && event.getPrintedCard() != null)
{
ret = event.getPrintedCard().getId();
}
return ret;
} }
@XmlElement(name = "printedCardState") @XmlElement(name = "printedCardState")
public CardState getPrintedCardState() public String getPrintedCardState() {
{ return printedCardState;
CardState ret = null;
if (event != null && event.getPrintedCard() != null) {
ret = event.getPrintedCard().getCardState();
}
return ret;
}
public static List<ReaderEventRestPojo> parse(List<ReaderEvent> readers) {
List<ReaderEventRestPojo> ret = new ArrayList<>();
for (ReaderEvent re : readers)
{
ret.add(new ReaderEventRestPojo(re));
}
return ret;
} }
public PrintedCardRestPojo getPrintedCard() { public PrintedCardRestPojo getPrintedCard() {
...@@ -104,4 +74,37 @@ public class ReaderEventRestPojo { ...@@ -104,4 +74,37 @@ public class ReaderEventRestPojo {
public void setPrintedCard(PrintedCardRestPojo printedCard) { public void setPrintedCard(PrintedCardRestPojo printedCard) {
this.printedCard = printedCard; this.printedCard = printedCard;
} }
public EventUserRestPojo getEventUser() {
return eventUser;
}
public void setEventUser(EventUserRestPojo eventUser) {
this.eventUser = eventUser;
}
public Integer getReaderEventId() {
return readerEventId;
}
public void setReaderEventId(Integer readerEventId) {
this.readerEventId = readerEventId;
}
public void setReaderEventTime(Date readerEventTime) {
this.readerEventTime = readerEventTime;
}
public void setReaderId(Integer readerId) {
this.readerId = readerId;
}
public void setPrintedCardId(Integer printedCardId) {
this.printedCardId = printedCardId;
}
public void setPrintedCardState(String printedCardState) {
this.printedCardState = printedCardState;
}
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.reader.v1;
import java.util.List; import java.util.List;
......
...@@ -16,53 +16,63 @@ ...@@ -16,53 +16,63 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.reader.v1;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.Reader;
import fi.codecrew.moya.model.ReaderType;
public class ReaderRestPojo { public class ReaderRestPojo {
private Reader reader; private Integer readerId;
private String identification;
private String description;
private String readerType;
public ReaderRestPojo() {
super();
}
@XmlElement(name = "readerId") @XmlElement(name = "readerId")
public Integer getId() { public Integer getId() {
return reader.getId(); return readerId;
} }
@XmlElement(name = "identification") @XmlElement(name = "identification")
public String getIdent() { public String getIdentification() {
return reader.getIdentification(); return identification;
} }
@XmlElement(name = "description") @XmlElement(name = "description")
public String getDescr() { public String getdescription() {
return reader.getDescription(); return description;
} }
@XmlElement(name = "readerType") @XmlElement(name = "readerType")
public ReaderType getType() { public String getReaderType() {
return reader.getType(); return readerType;
} }
public ReaderRestPojo() { public void setReaderType(String readerType) {
this.reader = null; this.readerType = readerType;
} }
public ReaderRestPojo(Reader r) { public Integer getReaderId() {
this.reader = r; return readerId;
} }
public static List<ReaderRestPojo> parse(List<Reader> readers) { public void setReaderId(Integer readerId) {
ArrayList<ReaderRestPojo> ret = new ArrayList<>(); this.readerId = readerId;
for (Reader r : readers) {
ret.add(new ReaderRestPojo(r));
}
return ret;
} }
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setIdentification(String identification) {
this.identification = identification;
}
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.reader.v1;
import java.util.List; import java.util.List;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import java.util.List; import java.util.List;
......
...@@ -16,75 +16,83 @@ ...@@ -16,75 +16,83 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.model.EventUser;
public class EventUserRestPojo { public class EventUserRestPojo {
private EventUser user; private String nick = "";
private String login = "";
private Integer eventuserId = 0;
private Integer userId = 0;
private String firstname = "";
private String lastname = "";
public EventUserRestPojo() { public EventUserRestPojo() {
} }
public EventUserRestPojo(EventUser user) {
this.user = user;
}
@XmlElement(name = "nick") @XmlElement(name = "nick")
public String getUsername() public String getNick() {
{ return nick;
if(user == null)
return "";
else
return user.getUser().getNick();
} }
@XmlElement(name = "login") @XmlElement(name = "login")
public String getLogin() public String getLogin()
{ {
if(user == null) return login;
return "";
else
return user.getUser().getLogin();
} }
@XmlElement(name = "eventuserId") @XmlElement(name = "eventuserId")
public Integer getEventuserId() public Integer getEventuserId()
{ {
if(user == null) return eventuserId;
return 0;
else
return user.getId();
} }
@XmlElement(name = "userId") @XmlElement(name = "userId")
public Integer getuserId() public Integer getuserId()
{ {
if(user == null) return getUserId();
return 0;
else
return user.getUser().getId();
} }
@XmlElement(name = "firstname") @XmlElement(name = "firstname")
public String getFirstname() public String getFirstname() {
{ return firstname;
if(user == null)
return "";
else
return user.getUser().getFirstnames();
} }
@XmlElement(name = "lastname") @XmlElement(name = "lastname")
public String getLastname() public String getLastname() {
{ return lastname;
if(user == null) }
return "";
else public void setNick(String nick) {
return user.getUser().getLastname(); this.nick = nick;
}
public void setLogin(String login) {
this.login = login;
}
public void setEventuserId(Integer eventuserId) {
this.eventuserId = eventuserId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
} }
} }
...@@ -16,86 +16,91 @@ ...@@ -16,86 +16,91 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import fi.codecrew.moya.model.PrintedCard;
public class PrintedCardRestPojo { public class PrintedCardRestPojo {
public PrintedCardRestPojo() { private Integer eventuserId;
card = null; private Integer id;
} private String template;
private String username;
private String wholeName;
private String state;
private Date printTime;
public PrintedCardRestPojo(PrintedCard card) public PrintedCardRestPojo() {
{ super();
this.card = card;
} }
@XmlElement(name = "eventuserId") @XmlElement(name = "eventuserId")
public Integer getEventuserId() { public Integer getEventuserId() {
return card.getUser().getId(); return eventuserId;
} }
@XmlTransient
private final PrintedCard card;
@XmlElement(name = "cardId") @XmlElement(name = "cardId")
public Integer getId() public Integer getId() {
{ return id;
return card.getId();
} }
@XmlElement(name = "cardTemplate") @XmlElement(name = "cardTemplate")
public String getTemplate() public String getTemplate() {
{ return template;
String ret = null;
if (card.getTemplate() != null)
ret = card.getTemplate().getName();
return ret;
} }
@XmlElement(name = "username") @XmlElement(name = "username")
public String getUsername() public String getUsername()
{ {
return card.getUser().getNick(); return username;
} }
@XmlElement(name = "wholeName") @XmlElement(name = "wholeName")
public String getWholeName() public String getWholeName() {
{ return wholeName;
return card.getUser().getWholeName();
} }
@XmlElement(name = "state") @XmlElement(name = "state")
public String getState() { public String getState() {
return card.getCardState().toString(); return state;
} }
@XmlElement(name = "printTime") @XmlElement(name = "printTime")
public Date getPrintTime() public Date getPrintTime() {
{ return printTime;
Date ret = null;
if (card.getPrintTime() != null)
ret = card.getPrintTime().getTime();
return ret;
} }
public static CardRoot parseCards(List<PrintedCard> cards) public void setEventuserId(Integer eventuserId) {
{ this.eventuserId = eventuserId;
ArrayList<PrintedCardRestPojo> ret = new ArrayList<PrintedCardRestPojo>();
for (PrintedCard c : cards) {
ret.add(new PrintedCardRestPojo(c));
}
CardRoot root = new CardRoot();
root.setCards(ret);
return root;
} }
public void setId(Integer id) {
this.id = id;
}
public void setTemplate(String template) {
this.template = template;
}
public void setUsername(String username) {
this.username = username;
}
public void setWholeName(String wholeName) {
this.wholeName = wholeName;
}
public void setState(String state) {
this.state = state;
}
public void setPrintTime(Date printTime) {
this.printTime = printTime;
}
} }
...@@ -16,21 +16,25 @@ ...@@ -16,21 +16,25 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.EventUser;
@XmlRootElement() @XmlRootElement()
public class SimpleEventuserRoot { public class SimpleEventuserRoot {
private List<EventUserRestPojo> eventusers; private List<EventUserRestPojo> eventusers;
public SimpleEventuserRoot() { public SimpleEventuserRoot() {
super();
}
public SimpleEventuserRoot(List<EventUserRestPojo> users)
{
this.eventusers = users;
} }
public SimpleEventuserRoot(ArrayList<EventUserRestPojo> list) { public SimpleEventuserRoot(ArrayList<EventUserRestPojo> list) {
...@@ -44,14 +48,4 @@ public class SimpleEventuserRoot { ...@@ -44,14 +48,4 @@ public class SimpleEventuserRoot {
public void setEventusers(List<EventUserRestPojo> eventusers) { public void setEventusers(List<EventUserRestPojo> eventusers) {
this.eventusers = eventusers; this.eventusers = eventusers;
} }
public static SimpleEventuserRoot parse(List<EventUser> users) {
ArrayList<EventUserRestPojo> list = new ArrayList<>();
for (EventUser u : users)
{
list.add(new EventUserRestPojo(u));
}
return new SimpleEventuserRoot(list);
}
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* future versions of the Software. * future versions of the Software.
* *
*/ */
package fi.codecrew.moya.rest.pojo; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
......
...@@ -40,7 +40,8 @@ public enum UserPermission implements IAppPermission { ...@@ -40,7 +40,8 @@ public enum UserPermission implements IAppPermission {
VITUTTAAKO, VITUTTAAKO,
LOGGED_IN_USER, LOGGED_IN_USER,
MODIFY_OWN_GAMEIDS, MODIFY_OWN_GAMEIDS,
VIEW_ALL_GAMEIDS; VIEW_ALL_GAMEIDS,
HELPPAGE;
public static final String S_VIEW_ALL = "USER/VIEW_ALL"; public static final String S_VIEW_ALL = "USER/VIEW_ALL";
public static final String S_MODIFY = "USER/MODIFY"; public static final String S_MODIFY = "USER/MODIFY";
...@@ -61,6 +62,7 @@ public enum UserPermission implements IAppPermission { ...@@ -61,6 +62,7 @@ public enum UserPermission implements IAppPermission {
public static final String S_VITUTTAAKO = "USER/VITUTTAAKO"; public static final String S_VITUTTAAKO = "USER/VITUTTAAKO";
public static final String S_MODIFY_OWN_GAMEIDS = "USER/MODIFY_OWN_GAMEIDS"; public static final String S_MODIFY_OWN_GAMEIDS = "USER/MODIFY_OWN_GAMEIDS";
public static final String S_VIEW_ALL_GAMEIDS = "USER/VIEW_ALL_GAMEIDS"; public static final String S_VIEW_ALL_GAMEIDS = "USER/VIEW_ALL_GAMEIDS";
public static final String S_HELPPAGE = "USER/HELPPAGE";
private final String fullName; private final String fullName;
private final String key; private final String key;
......
package fi.codecrew.moya.utilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Gather all system properties in here as enums, so we have some kind of
* understanding what kind of properties there are.
*
* @author tuomari
*
*/
public enum SystemProperty {
MOYA_IRC_SERVER,
MOYA_IRC_CHANNEL("#moya-debug"),
MOYA_IRC_SERVERPASS(),
;
private final String defaultValue;
private final Integer defaultIntegerValue;
private static final Logger logger = LoggerFactory.getLogger(SystemProperty.class);
private SystemProperty() {
defaultValue = null;
defaultIntegerValue = null;
}
private SystemProperty(String value) {
defaultValue = value;
defaultIntegerValue = null;
}
private SystemProperty(Integer value) {
defaultIntegerValue = value;
defaultValue = null;
}
public String getDefaultValue() {
return defaultValue;
}
public String getValueOrDefault() {
String val = System.getProperty(this.name());
if (val == null) {
val = defaultValue;
}
return val;
}
public Integer getIntvalueOrDefault() {
String val = System.getProperty(this.name());
Integer intval = null;
try {
intval = Integer.parseInt(val);
} catch (Exception t) {
intval = null;
logger.warn("Unable to parse system property '{}' value '{}' as integer. Defaulting to {}", name(), val, defaultIntegerValue);
}
if (val == null) {
intval = defaultIntegerValue;
}
return intval;
}
public String getValueOrNull() {
String val = System.getProperty(this.name());
return val;
}
}
...@@ -11,7 +11,7 @@ public class MoyaEventMessage implements Serializable { ...@@ -11,7 +11,7 @@ public class MoyaEventMessage implements Serializable {
private Calendar time; private Calendar time;
private MoyaEventType eventtype; private MoyaEventType eventtype;
private String description; private String description;
private Integer userId; private Integer eventUserId;
private Integer eventId; private Integer eventId;
private Integer currentUserId; private Integer currentUserId;
...@@ -27,8 +27,8 @@ public class MoyaEventMessage implements Serializable { ...@@ -27,8 +27,8 @@ public class MoyaEventMessage implements Serializable {
this.description = description; this.description = description;
} }
public void setUserId(Integer userId) { public void setEventUserId(Integer eventUserId) {
this.userId = userId; this.eventUserId = eventUserId;
} }
public void setEventId(Integer eventId) { public void setEventId(Integer eventId) {
...@@ -47,8 +47,8 @@ public class MoyaEventMessage implements Serializable { ...@@ -47,8 +47,8 @@ public class MoyaEventMessage implements Serializable {
return description; return description;
} }
public Integer getUserId() { public Integer getEventUserId() {
return userId; return eventUserId;
} }
public Integer getEventId() { public Integer getEventId() {
......
...@@ -11,7 +11,9 @@ public enum MoyaEventType { ...@@ -11,7 +11,9 @@ public enum MoyaEventType {
BANKING_MESSAGE(MoyaEventSource.SHOP), BANKING_MESSAGE(MoyaEventSource.SHOP),
PLACE_ERROR(MoyaEventSource.PLACEMAP), PLACE_ERROR(MoyaEventSource.PLACEMAP),
ACCOUNTEVENT_INFO(MoyaEventSource.USER), ACCOUNTEVENT_INFO(MoyaEventSource.USER),
USER_PERMISSION_VIOLATION(MoyaEventSource.USER), INVITE_ACCEPTED(MoyaEventSource.USER),
USER_PERMISSION_VIOLATION(MoyaEventSource.USER),
LOGIN_SUCCESSFULL(MoyaEventSource.USER),
; ;
......
...@@ -19,9 +19,12 @@ ...@@ -19,9 +19,12 @@
</h:link> </h:link>
<span style="width: 6em;"> &nbsb; <span style="width: 6em;"> &nbsb;
</span> </span>
<h:link styleClass="touchItem" outcome="/admin/adduser/login">
<div>#{i18n['adduser.update']}</div> <p:outputPanel rendered="#{!userView.kioskPhotoDisabled}">
</h:link> <h:link styleClass="touchItem" outcome="/admin/adduser/login">
<div>#{i18n['adduser.update']}</div>
</h:link>
</p:outputPanel>
</div> </div>
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
<h:form id="billform"> <h:form id="billform">
<p:panelGrid columns="2"> <p:panelGrid columns="2">
<h:outputLabel for="billid" value="#{i18n['bill.id']}:" />
<h:inputText id="billid" value="#{billEditView.bill.id}" />
<h:outputLabel for="paidDate" value="#{i18n['bill.paidDate']}:" /> <h:outputLabel for="paidDate" value="#{i18n['bill.paidDate']}:" />
<h:inputText id="paidDate" value="#{billEditView.bill.paidDate}"> <h:inputText id="paidDate" value="#{billEditView.bill.paidDate}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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" <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:bills="http://java.sun.com/jsf/composite/cditools/bills" xmlns:h="http://java.sun.com/jsf/html" xmlns:bills="http://java.sun.com/jsf/composite/cditools/bills"
xmlns:f="http://java.sun.com/jsf/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
> >
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
...@@ -13,6 +13,14 @@ ...@@ -13,6 +13,14 @@
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<bills:list /> <bills:list />
<br /><br />
<p:outputPanel rendered="#{placeGroupView.useEticket}" >
<p>
<p:button outcome="/place/myEtickets" value="#{i18n['placegroup.showEticket']}" />
</p>
</p:outputPanel>
<br /><br />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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:tools="http://java.sun.com/jsf/composite/tools" xmlns:bill="http://java.sun.com/jsf/composite/cditools/bills" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"> <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:tools="http://java.sun.com/jsf/composite/tools"
xmlns:bill="http://java.sun.com/jsf/composite/cditools/bills"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:body> <h:body>
...@@ -14,39 +20,50 @@ ...@@ -14,39 +20,50 @@
<h1>#{i18n['page.bill.show.header']}</h1> <h1>#{i18n['page.bill.show.header']}</h1>
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
<p:outputPanel id="billPanel"> <p:outputPanel id="billPanel">
<ui:fragment rendered="#{billEditView.bill.paid}"> <ui:fragment rendered="#{billEditView.bill.paid}">
<h:outputText value="#{i18n['bill.billIsPaid']}" /> <h:outputText value="#{i18n['bill.billIsPaid']}" />
<br /> <br /><br />
<h:outputText value="#{i18n['bill.billPaidDate']}" />: <h:outputText value="#{i18n['bill.billPaidDate']}" />:
<h:outputText value="#{billEditView.bill.paidDate}"> <h:outputText value="#{billEditView.bill.paidDate}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</ui:fragment> </ui:fragment>
<br /> <br />
<bill:showBill bill="#{billEditView.bill}" />
<bill:showBill bill="#{billEditView.bill}" /> <bill:verkkomaksubuttons
<bill:verkkomaksubuttons rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}"/> rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}" />
<p:outputPanel rendered="#{billEditView.bill.foodwaveBill}"> <p:outputPanel rendered="#{billEditView.bill.foodwaveBill}">
<span class="notify"><h:outputText value="#{i18n['foodshop.canBuyToCounter']}" /></span> <span class="notify"><h:outputText
</p:outputPanel> value="#{i18n['foodshop.canBuyToCounter']}" /></span>
<br /> </p:outputPanel>
<p:outputPanel rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}"> <br />
<p:outputPanel
rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}">
<h:form> <h:form>
<p:commandButton id="cancelbtn" actionListener="#{billEditView.expireBill()}" onerror="location.reload(true);" value="#{i18n['bill.cancel']}" update=":billPanel"> <p:commandButton id="cancelbtn"
<p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" /> actionListener="#{billEditView.expireBill()}"
onerror="location.reload(true);" value="#{i18n['bill.cancel']}"
update=":billPanel">
<p:confirm header="Confirmation" message="Are you sure?"
icon="ui-icon-alert" />
</p:commandButton> </p:commandButton>
</h:form> </h:form>
</p:outputPanel> </p:outputPanel>
<p:outputPanel rendered="#{billEditView.bill.user.accountBalance ge billEditView.bill.totalPrice}"> <p:outputPanel
rendered="#{billEditView.bill.user.accountBalance ge billEditView.bill.totalPrice}">
<h:form> <h:form>
<p:commandButton id="buyCreditsButton" actionListener="#{billEditView.buyWithCredits()}" onerror="location.reload(true);" value="#{i18n['bill.markPaid.credits']}" update=":billPanel"> <p:commandButton id="buyCreditsButton"
<p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" /> actionListener="#{billEditView.buyWithCredits()}"
onerror="location.reload(true);"
value="#{i18n['bill.markPaid.credits']}" update=":billPanel">
<p:confirm header="Confirmation" message="Are you sure?"
icon="ui-icon-alert" />
</p:commandButton> </p:commandButton>
</h:form> </h:form>
</p:outputPanel> </p:outputPanel>
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<p:outputLabel for="themeSwitcher" value="#{i18n['event.theme']}:" /> <p:outputLabel for="themeSwitcher" value="#{i18n['event.theme']}:" />
<p:themeSwitcher value="#{eventorgView.event.theme}" id="themeSwitcher" var="t" style="width: 200px;" > <p:themeSwitcher value="#{eventorgView.event.theme}" id="themeSwitcher" var="t" style="width: 200px;" >
<f:selectItem itemLabel="Choose Theme" itemValue="Aristo" /> <f:selectItem itemLabel="Choose Theme" itemValue="" />
<f:selectItems value="#{themeSwitcherView.themes}" /> <f:selectItems value="#{themeSwitcherView.themes}" />
</p:themeSwitcher> </p:themeSwitcher>
<p:message for="themeSwitcher" /> <p:message for="themeSwitcher" />
......
...@@ -42,18 +42,21 @@ ...@@ -42,18 +42,21 @@
</p:column> </p:column>
<p:column sortBy="#{acc_line.user.wholeName}"> <p:column sortBy="#{acc_line.user.wholeName}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.eventuser']}" /> <h:outputLabel value="#{i18n['acc_line.eventuser']} (#{i18n['acc_line.nick']})" />
</f:facet> </f:facet>
<h:outputText outcome="/useradmin/edit" value="#{acc_line.user.wholeName}" />
<h:link outcome="/useradmin/edit" value="#{acc_line.user.wholeName} (#{acc_line.user.nick})">
<f:param name="userid" value="#{acc_line.user.user.id}" />
</h:link>
</p:column> </p:column>
<p:column sortBy="#{acc_line.user.nick}"> <p:column style="width: 80px;">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['acc_line.nick']}" /> <h:outputLabel value="#{i18n['acc_line.place']}" />
</f:facet> </f:facet>
<h:link outcome="/useradmin/edit" value="#{acc_line.user.nick}"> <h:outputText value="#{acc_line.user.firstPlace.name}" />
<f:param name="userid" value="#{acc_line.user.user.id}" />
</h:link>
</p:column> </p:column>
<p:column sortBy="#{acc_line.eventDelivered}"> <p:column sortBy="#{acc_line.eventDelivered}">
<f:facet name="header"> <f:facet name="header">
<h:outputLabel value="#{i18n['accountEvent.delivered']}" /> <h:outputLabel value="#{i18n['accountEvent.delivered']}" />
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
<f:event type="preRenderView" listener="#{pageOutputView.initIndexView}" /> <f:event type="preRenderView" listener="#{pageOutputView.initIndexView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa.
Täällä voit huoletta rikkoa.
</h:outputLabel>
<ui:fragment rendered="#{layoutView.manageContent}"> <ui:fragment rendered="#{layoutView.manageContent}">
<h:link value="#{i18n['layout.editContent']}" outcome="/pages/manage"> <h:link value="#{i18n['layout.editContent']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}" /> <f:param name="pagename" value="#{layoutView.pagepath}" />
......
<!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">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{pageOutputView.initHelpView}" />
</f:metadata>
<ui:define name="content">
<ui:fragment rendered="#{layoutView.manageContent}">
<h:link value="#{i18n['layout.editContent']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}" />
</h:link>
<br />
</ui:fragment>
<ui:repeat var="cont1" value="#{pageOutputView.contents}">
<h:outputText value="#{cont1.content}" escape="false" />
</ui:repeat>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
<h:form id="attachform"> <h:form id="attachform">
<p:poll update="attachBarcode" interval="2" ignoreAutoUpdate="true" onerror="location.reload();" /> <p:poll update="attachBarcode" interval="2" ignoreAutoUpdate="true" onerror="location.reload();" />
<h:panelGroup id="attachBarcode"> <h:panelGroup id="attachBarcode">
...@@ -41,6 +40,7 @@ ...@@ -41,6 +40,7 @@
</script> </script>
<h1>#{i18n['incomingView.attachDialogTitle']}</h1> <h1>#{i18n['incomingView.attachDialogTitle']}</h1>
<!-- napin painaminen aiheuttaa aina NullPOinterExceptionin, mutta tekee siitä huolimatta tarvittavat asiat --> <!-- napin painaminen aiheuttaa aina NullPOinterExceptionin, mutta tekee siitä huolimatta tarvittavat asiat -->
<!-- tarjoan oluen sille ketä ratkasee ton exceptionin -TKjne -->
<p:commandButton styleClass="attachbuttonidclass" value="#{i18n['incomingView.attach']}" actionListener="#{incomingView.attachCodeToCard}" update=":cardcodeform :placelistform :imgCropperForm :cardsetform" onerror="location.reload(true);" /> <p:commandButton styleClass="attachbuttonidclass" value="#{i18n['incomingView.attach']}" actionListener="#{incomingView.attachCodeToCard}" update=":cardcodeform :placelistform :imgCropperForm :cardsetform" onerror="location.reload(true);" />
<p:commandButton value="#{i18n['incomingView.cancel']}" actionListener="#{incomingView.hideAttachDialog}" update=":attachform:attachBarcode" /> <p:commandButton value="#{i18n['incomingView.cancel']}" actionListener="#{incomingView.hideAttachDialog}" update=":attachform:attachBarcode" />
</div> </div>
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
</tr> </tr>
<tr> <tr>
<td colspan="2"><b><h:outputLabel value="#{i18n['user.email']}" for="email" /></b> <br /> <p:inplace emptyLabel="#{i18n['user.insert']}"> <td colspan="2"><b><h:outputLabel value="#{i18n['user.email']}" for="email" /></b> <br /> <p:inplace emptyLabel="#{i18n['user.insert']}">
<p:inputText validator="#{userValidator.validateEmail}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" /> <p:inputText validator="#{userValidator.validateEmailEdit}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" />
</p:inplace></td> </p:inplace></td>
</tr> </tr>
<tr> <tr>
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
<p:graphicImage url="/dydata/usercard/#{userView.selectedUser.user.id}.png" width="300" /> <p:graphicImage url="/dydata/usercard/#{userView.selectedUser.user.id}.png" width="300" />
<br /> <br />
<h:commandButton action="#{incomingView.printCard}" value="#{i18n['print']}" /> <p:commandButton actionListener="#{incomingView.printCard}" update="cardsetform" value="#{i18n['print']}" />
<b> <b>
(status: <p:outputLabel value="#{incomingView.printedStatus}" />) (status: <p:outputLabel value="#{incomingView.printedStatus}" />)
<p:outputLabel value="#{i18n['incomingflow.cardfiling.label']}" rendered="#{!empty incomingView.cardFiling}" /> <p:outputLabel value="#{i18n['incomingflow.cardfiling.label']}" rendered="#{!empty incomingView.cardFiling}" />
......
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/cditools/map"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<ui:define name="content">
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:map="http://java.sun.com/jsf/composite/cditools/map"
xmlns:tools="http://java.sun.com/jsf/composite/cditools" 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:viewParam name="mapId" value="#{queueManageView.mapId}" />
<f:event type="preRenderView" listener="#{queueManageView.initView}" />
</f:metadata>
<ui:define name="content">
<h2>Queue properties</h2>
<h:form>
<p:panelGrid columns="2">
<p:outputLabel for="minslots" value="#{i18n['queuemgmt.minimumSlotsInQueue']}" />
<p:inputText id="minslots" value="#{queueManageView.queuebean.minimumSlotsInQueue}" />
<p:outputLabel for="reservingsize" value="#{i18n['queuemgmt.reservingSize']}" />
<p:inputText id="reservingsize" value="#{queueManageView.queuebean.reservingSize}" />
<p:outputLabel for="defaultTimeout" value="#{i18n['queuemgmt.defaultTimeoutMin']}" />
<p:inputText id="defaultTimeout" value="#{queueManageView.queuebean.defaultTimeoutMin}" />
</p:panelGrid>
<p:commandButton ajax="false" value="#{i18n['queuemgmt.saveProperties']}"></p:commandButton>
</h:form>
<h2>Manage queue</h2>
<h:form>
<p:panelGrid columns="2">
<p:outputLabel for="username" value="#{i18n['queuemgmt.username']}" />
<p:inputText id="username" value="#{queueManageView.username}" />
<p:outputLabel for="expiretime" value="#{i18n['queuemgmt.time']}" />
<p:calendar id="expiretime" label="" value="#{queueManageView.time}" pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</p:panelGrid>
<p:commandButton action="#{queueManageView.addToReserving}" ajax="false" value="#{i18n['queuemgmt.adduser']}" />
<p:commandButton action="#{queueManageView.forceRemove}" ajax="false" value="#{i18n['queuemgmt.remove']}" />
</h:form>
<h:outputText value="#{queueManageView.now}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
<h2>Currently reserving</h2>
<p:dataTable var="u" value="#{queueManageView.userReserving}">
<p:column>
<p:link outcome="/user/edit" value="#{u.user.user.login}">
<f:param name="userid" value="#{u.user.user.id}" />
</p:link>
</p:column>
<p:column headerText="Created">
<h:outputText value="#{u.created}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column headerText="Reservation timeout">
<h:outputText value="#{u.reservationTimeout}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
</p:dataTable>
<h2>In queue</h2>
Queue size: #{queueManageView.userQueue.rowCount}<br />
<p:dataTable var="u" value="#{queueManageView.userQueue}">
<p:column>
<p:link outcome="/user/edit" value="#{u.user.user.login}">
<f:param name="userid" value="#{u.user.user.id}" />
</p:link>
</p:column>
<p:column headerText="Created">
<h:outputText value="#{u.created}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column headerText="Seen time">
<p:calendar value="#{u.seenTime}" pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" showOn="button" />
</p:column>
</p:dataTable>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!