Commit e1d9738e by Tuomas Riihimäki

Merge branch 'insomnia_2014' into 'master'

Insomnia 2014

Insomnian muutokset tuotantoon

See merge request !124
2 parents ca930820 85063dd5
Showing with 1659 additions and 468 deletions
......@@ -27,6 +27,7 @@ import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
......@@ -47,7 +48,7 @@ public interface BillBeanLocal {
Collection<BillSummary> getBillLineSummary();
Bill markPaid(Bill bill, Calendar when);
Bill markPaid(Bill bill, Calendar when, boolean useCredits) throws BillException;
void getPdfBillStream(Bill bill, OutputStream ostream);
......
......@@ -23,5 +23,6 @@ import javax.ejb.Local;
@Local
public interface BootstrapBeanLocal {
void saneDefaults();
// no empty databases
// void saneDefaults();
}
......@@ -24,5 +24,6 @@ public enum SecurityLogType {
genericMessage,
accountEvent,
verkkomaksu,
bill,
}
/*
* 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 java.util.Map;
import javax.ejb.Local;
@Local
public interface StatisticsBeanLocal {
public Long getGroupMembershipsEnteredEvent();
public Long getCardDeliveredCount();
public Long getGroupMembershipsTotalCount();
public Map<Long, Long> getHourlyIncomingStatistics(long startingFromMillis, int hourCount);
}
/*
* 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.exceptions;
public class BillException extends Exception {
public BillException(String x) {
super(x);
}
/**
*
*/
private static final long serialVersionUID = 4744284457862674051L;
}
/*
* 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.exceptions;
public class BillExceptionAlreadyPaid extends BillException {
public BillExceptionAlreadyPaid(String ex) {
super(ex);
}
/**
*
*/
private static final long serialVersionUID = 4744284457862674051L;
}
/*
* 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.exceptions;
public class BillExceptionNotEnoughtCredits extends BillException {
public BillExceptionNotEnoughtCredits(String x) {
super(x);
}
/**
*
*/
private static final long serialVersionUID = 4744284457862674051L;
}
......@@ -74,7 +74,7 @@ public class CheckoutBank {
logger.info("Added param for {} name {} value {}", new Object[] { key, paramName, paramValue });
}
}
System.out.println();
// System.out.println();
}
......
......@@ -20,7 +20,6 @@ package fi.codecrew.moya.beans;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
......@@ -33,6 +32,8 @@ import javax.ejb.EJBAccessException;
import javax.ejb.EJBException;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -40,7 +41,11 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beanutil.PdfPrinter;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.exceptions.BillExceptionAlreadyPaid;
import fi.codecrew.moya.exceptions.BillExceptionNotEnoughtCredits;
import fi.codecrew.moya.facade.BillFacade;
import fi.codecrew.moya.facade.BillLineFacade;
import fi.codecrew.moya.facade.EventUserFacade;
......@@ -51,10 +56,8 @@ import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag;
import fi.codecrew.moya.util.MailMessage;
/**
* Session Bean implementation class BillBean
......@@ -93,12 +96,15 @@ public class BillBean implements BillBeanLocal {
@EJB
private DiscountBean discountBean;
@EJB
private LoggingBeanLocal logbean;
/**
* Default constructor.
*/
public BillBean() {
// TODO Auto-generated constructor stub
}
@Override
......@@ -223,36 +229,75 @@ public class BillBean implements BillBeanLocal {
return ret;
}
@Override
@RolesAllowed({ BillPermission.S_WRITE_ALL,
SpecialPermission.S_VERKKOMAKSU_CHECK })
public Bill markPaid(Bill bill, Calendar when) {
/**
* We will mark bill paid in different transaction. That's because we don't wont it to fail if something other fails.
*
* @param bill
* @param when
* @param useCredits
* @return
* @throws BillException
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private Bill markPaidSafeTransaction(Bill bill, Calendar when, boolean useCredits) throws BillException {
bill = billFacade.reload(bill);
if (bill.getAccountEvent() != null || bill.getPaidDate() != null) {
throw new EJBException("Bill already marked paid!");
}
if (bill.isFoowavePaymentOver())
{
throw new EJBException("Trying to mark paid a closed or left foodwave");
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to doublemark bill paid", bill.getId());
throw new BillExceptionAlreadyPaid("Trying to mark bill paid, already paid, BillID: "+bill.getId());
}
bill = billFacade.reload(bill);
Product creditproduct = productBean.findCreditProduct();
EventUser user = bill.getUser();
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
// Used in foodwave. Should be null!
// ac.setDelivered(when);
ac.setEventTime(when);
ac.setBill(bill);
ac.setSeller(permbean.getCurrentUser());
bill.setAccountEvent(ac);
if(useCredits) {
// check if there is enought credits
if(bill.getUser().getAccountBalance().compareTo(bill.getTotalPrice()) < 1) {
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Trying to pay bill with accountevents, and there is no saldo, billid: ", bill.getId());
throw new BillExceptionNotEnoughtCredits("There is not enought credits to pay. , BillID: "+bill.getId());
}
} else {
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
ac.setEventTime(when);
ac.setBill(bill);
ac.setSeller(permbean.getCurrentUser());
bill.setAccountEvent(ac);
}
bill.setPaidDate(when.getTime());
return bill;
}
@Override
@RolesAllowed({ BillPermission.S_WRITE_ALL,
SpecialPermission.S_VERKKOMAKSU_CHECK })
public Bill markPaid(Bill bill, Calendar when, boolean useCredits) throws BillException {
bill = markPaidSafeTransaction(bill, when,useCredits);
EventUser user = bill.getUser();
if (bill.isFoowavePaymentOver() && !permbean.hasPermission(ShopPermission.MANAGE_FOODWAVES))
{
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "FoodwaveClosed and marking bill for it paid");
throw new EJBException("Trying to mark paid a closed or left foodwave");
}
// bill = billFacade.merge(bill);
......@@ -269,8 +314,11 @@ public class BillBean implements BillBeanLocal {
ac2.setSeller(permbean.getCurrentUser());
}
}
billFacade.flush();
/*
MailMessage msg = new MailMessage();
String subject = MessageFormat.format(eventbean.getPropertyString(LanEventPropertyKey.BILL_PAID_MAIL_SUBJECT), user.getEvent().getName());
......@@ -280,9 +328,12 @@ public class BillBean implements BillBeanLocal {
msg.setMessage(content);
msg.setTo(bill.getUser().getUser());
utilbean.sendMail(msg);
*/
eventUserFacade.flush();
logbean.logMessage(SecurityLogType.bill, permbean.getCurrentUser(), "Marking bill paid, for user: ", bill.getUser().getId(),"BillId: ",bill.getId());
eventUserFacade.evict(bill.getUser());
return bill;
}
......
......@@ -238,8 +238,13 @@ public class BootstrapBean implements BootstrapBeanLocal {
// tai saadaan poikkeuksia nyrkillä kurkusta .
dbUpdates.add(new String[] {
"DELETE FROM product_productflags where productflags = 'PREPAID_INSTANT_CREATE'"
});
dbUpdates.add(new String[] {
"ALTER TABLE food_wave_templates ADD COLUMN wait_payments_minutes integer DEFAULT null;",
});
} // start_time timestamp without time zone,
......@@ -293,16 +298,16 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbModelFacade.create(dBm);
}
}
public void saneDefaults() {
User adminUser = userFacade.findByLogin("admin");
if (adminUser == null) {
adminUser = new User();
adminUser.setLogin("admin");
// adminUser.setSuperadmin(true);
adminUser.resetPassword("admin");
userFacade.create(adminUser);
}
}
// We will never run this again with empty database
// public void saneDefaults() {
// User adminUser = userFacade.findByLogin("admin");
// if (adminUser == null) {
// adminUser = new User();
// adminUser.setLogin("admin");
// // adminUser.setSuperadmin(true);
// adminUser.resetPassword("admin");
// userFacade.create(adminUser);
// }
// }
}
......@@ -399,7 +399,7 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
card.setCardState(CardState.DELIVERED);
} else {
logger.info("Not marking card to delivered: " + card.getCardState() + " : " + card.getId());
}
}
if (markUserPlacesDelivered) {
for (GroupMembership membership : gmFacade.findMemberships(user)) {
......
......@@ -84,19 +84,23 @@ public class JaasBean implements MoyaRealmBeanRemote {
private EventBean eventorgbean;
public EventUser tryLogin(String username, String password) {
// username = username.trim().toLowerCase();
EventUser eventUser = eventUserFacade.findByLogin(username.trim().toLowerCase());
EventUser eventUser = eventUserFacade.findByLogin(username);
logger.info("Found eventuser '{}' with username '{}'", eventUser, username);
User user = null;
// Might not have EventUser
if (eventUser == null) {
user = userfacade.findByLogin(username.trim());
user = userfacade.findByLogin(username);
} else {
user = eventUser.getUser();
}
logger.info("User '{}' with '{}' ", user, username);
// If there is no eventuser found, try to create one.
if (user != null) {
logger.info("TryLogin user not null: {}", user);
if (user.isAnonymous()) {
logger.info("logging in as anonymous!!!");
} else if (!user.checkPassword(password)) {
......@@ -255,7 +259,7 @@ public class JaasBean implements MoyaRealmBeanRemote {
public String authenticateApp(String pathInfo, String appId, String userId, String appStamp, String mac) {
logger.info("Authenticat app with pathinfo {}, appid {}, userid {}, appstamp {}, mac {}",
new Object[]{pathInfo, appId, userId, appStamp, mac}
new Object[] { pathInfo, appId, userId, appStamp, mac }
);
if (mac == null) {
logger.warn("Rest auth failed: Mac is null");
......
......@@ -302,6 +302,10 @@ public class MenuBean implements MenuBeanLocal {
adminevent.addPage(menuitemfacade.findOrCreate("/eventorg/editEvent"), EventPermission.MANAGE_PROPERTIES);
adminevent.addPage(menuitemfacade.findOrCreate("/eventorg/edit"), EventPermission.MANAGE_PROPERTIES).setVisible(false);
adminevent.addPage(menuitemfacade.findOrCreate("/reports/basicStatistics"), EventPermission.VIEW_STATISTICS);
MenuNavigation tournamentsadm = adminmenu.addPage(null, null);
tournamentsadm.setKey("tournaments.menutitle");
......@@ -332,6 +336,8 @@ public class MenuBean implements MenuBeanLocal {
infonavi.addPage(menuitemfacade.findOrCreate("/info/index"), TerminalPermission.INFO);
infonavi.addPage(menuitemfacade.findOrCreate("/info/incoming"), TerminalPermission.INFO);
infonavi.addPage(menuitemfacade.findOrCreate("/info/shop"), TerminalPermission.INFO);
infonavi.addPage(menuitemfacade.findOrCreate("/info/foodwave/foodwaveshop"), TerminalPermission.INFO);
infonavi.addPage(menuitemfacade.findOrCreate("/info/foodwave/foodwaveProducts"), TerminalPermission.INFO).setVisible(false);
navifacade.create(adminmenu);
......
/*
* 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 java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.model.GroupMembership;
/**
* Session Bean implementation class FoodWaveBean
*/
@Stateless
@DeclareRoles({ EventPermission.S_VIEW_STATISTICS })
public class StatisticsBean implements StatisticsBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(StatisticsBean.class);
@EJB
GroupMembershipFacade groupMembershipFacade;
@EJB
PrintedCardFacade printedCardFacade;
@Override
@RolesAllowed(EventPermission.S_VIEW_STATISTICS)
public Long getGroupMembershipsEnteredEvent() {
return groupMembershipFacade.findGroupMembershipsEnteredCount();
}
@Override
@RolesAllowed(EventPermission.S_VIEW_STATISTICS)
public Long getCardDeliveredCount() {
return printedCardFacade.findDeliveredCardCount();
}
@Override
@RolesAllowed(EventPermission.S_VIEW_STATISTICS)
public Long getGroupMembershipsTotalCount() {
return groupMembershipFacade.findGroupMembershipsCount();
}
@Override
public Map<Long, Long> getHourlyIncomingStatistics(long startingFromMillis, int hourCount) {
List<GroupMembership> groupMemberships = groupMembershipFacade.findAllEnteredBetween(startingFromMillis, (startingFromMillis + ((long) hourCount)*60l*60l*1000l));
HashMap<Long, Long> retMap = new HashMap<Long, Long>();
long currentTimestamp = startingFromMillis;
long hour = (60l*60l*1000l);
long hourEntered = 0;
for(GroupMembership gm : groupMemberships) {
// find the hour this one belongs to (sometime we need to skip empty hours)
while(gm.getEnteredEvent().getTimeInMillis() > currentTimestamp+hour) {
retMap.put(currentTimestamp, hourEntered);
hourEntered = 0;
currentTimestamp += hour;
}
hourEntered++;
}
return retMap;
}
}
......@@ -27,6 +27,7 @@ import javax.ejb.Stateless;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
@Stateless
......@@ -38,7 +39,12 @@ public class VerkkomaksuRunner {
private BillBeanLocal billbean;
public void markPaid(Bill bill, Calendar when) {
billbean.markPaid(bill, when);
try {
billbean.markPaid(bill, when, false);
} catch (BillException x) {
throw new RuntimeException(x);
}
}
}
......@@ -18,6 +18,8 @@
*/
package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
......@@ -167,5 +169,72 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi
return super.getSingleNullableResult(getEm().createQuery(cq));
}
public Long findGroupMembershipsCount() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<GroupMembership> root = cq.from(GroupMembership.class);
Path<PlaceGroup> pg = root.get(GroupMembership_.placeGroup);
cq.select(cb.count(root));
cq.where(cb.equal(pg.get(PlaceGroup_.event), eventbean.getCurrentEvent()));
return super.getSingleNullableResult(getEm().createQuery(cq));
}
public Long findGroupMembershipsEnteredCount() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<GroupMembership> root = cq.from(GroupMembership.class);
Path<PlaceGroup> pg = root.get(GroupMembership_.placeGroup);
cq.select(cb.count(root));
cq.where(cb.not(cb.isNull(root.get(GroupMembership_.enteredEvent))),
cb.equal(pg.get(PlaceGroup_.event), eventbean.getCurrentEvent())
);
return super.getSingleNullableResult(getEm().createQuery(cq));
}
public List<GroupMembership> findAllEnteredBetween(long startTimestamp, long endTimestamp) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class);
Root<GroupMembership> root = cq.from(GroupMembership.class);
Path<PlaceGroup> pg = root.get(GroupMembership_.placeGroup);
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTimeInMillis(startTimestamp);
c2.setTimeInMillis(endTimestamp);
cq.where(cb.between(root.get(GroupMembership_.enteredEvent), c1, c2),
cb.equal(pg.get(PlaceGroup_.event), eventbean.getCurrentEvent()));
return getEm().createQuery(cq).getResultList();
}
}
......@@ -38,6 +38,8 @@ import fi.codecrew.moya.model.CardCode;
import fi.codecrew.moya.model.CardCode_;
import fi.codecrew.moya.model.CardTemplate_;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.GroupMembership_;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.PrintedCard_;
......@@ -137,4 +139,26 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
return new ArrayList<PrintedCard>(pch.values());
}
public Long findDeliveredCardCount() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<PrintedCard> root = cq.from(PrintedCard.class);
cq.select(cb.count(root));
cq.where(cb.equal(root.get(PrintedCard_.cardState), CardState.DELIVERED),
cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
return super.getSingleNullableResult(getEm().createQuery(cq));
}
}
......@@ -89,11 +89,11 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
*
* @param login
*/
public User findByLogin(String login) {
public User findByLogin(final String login) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class);
cq.where(cb.equal(root.get(User_.login), login.toLowerCase().trim()));
cq.where(cb.equal(root.get(User_.login), login));
return getSingleNullableResult(getEm().createQuery(cq));
}
......
......@@ -36,6 +36,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
/**
*
......@@ -44,220 +45,245 @@ import javax.persistence.TemporalType;
@Table(name = "food_waves")
public class FoodWave extends GenericEntity {
private static final long serialVersionUID = 9221716203467295049L;
private static final long serialVersionUID = 9221716203467295049L;
@Column(name = "wave_name", nullable = false)
private String name;
@Lob
@Column(name = "wave_description")
private String description;
@Column(name = "wave_time")
@Temporal(TemporalType.TIMESTAMP)
private Date time;
@Column(name = "max_foods")
private Integer maximumFoods;
@Column(name = "wave_closed", nullable = false, columnDefinition = "boolean default false")
private boolean closed = false;
@OneToMany(mappedBy = "foodWave")
private List<AccountEvent> accountEvents;
@OneToMany(mappedBy = "foodwave")
private List<BillLine> billLines;
@ManyToOne
@JoinColumn(name = "template_id", referencedColumnName = "id", nullable = false)
private FoodWaveTemplate template;
public FoodWave() {
super();
}
public FoodWave(String waveName, boolean waveClosed) {
super();
this.name = waveName;
this.closed = waveClosed;
}
public String getName() {
return name;
}
public void setName(String waveName) {
this.name = waveName;
}
public String getDescription() {
return description;
}
public void setDescription(String waveDescription) {
this.description = waveDescription;
}
public Date getTime() {
return time;
}
public void setTime(Date waveTime) {
this.time = waveTime;
}
public boolean getClosed() {
return closed;
}
public boolean isClosed() {
return closed;
}
public void setClosed(boolean waveClosed) {
this.closed = waveClosed;
}
public void toggleClosed() {
this.closed = !isClosed();
}
public List<AccountEvent> getAccountEvents() {
return accountEvents;
}
public void setAccountEvents(List<AccountEvent> accountEventList) {
this.accountEvents = accountEventList;
}
public void setTemplate(FoodWaveTemplate template) {
this.template = template;
}
public FoodWaveTemplate getTemplate() {
return template;
}
public boolean isFull() {
if(getMaximumFoods() <= 0) {
return false;
}
if(getReservedCount() >= getMaximumFoods()) {
return true;
}
return false;
}
/**
* Check if foodwave is orderable
*
* That means that it's not closed, full and it's in future
*
* @return
*/
public boolean isOrderable() {
if (isClosed()) {
return false;
}
if (getTime().before(new Date())) {
return false;
}
if (isFull()) {
return false;
}
return true;
}
public List<Product> getOrderedProducts() {
List<Product> retlist = new ArrayList<Product>();
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
if (!retlist.contains(ae.getProduct())) {
retlist.add(ae.getProduct());
}
}
}
return retlist;
}
public List<BillLine> getBillLines() {
return billLines;
}
public Integer getMaximumFoods() {
if(maximumFoods == null) {
return 0;
}
return maximumFoods;
}
public void setBillLines(List<BillLine> billLines) {
this.billLines = billLines;
}
public Integer getReservedCount() {
Integer retval = 0;
retval += getOrderedCount();
retval += getUnpaidCount();
return retval;
}
public void setMaximumFoods(Integer maximumFoods) {
this.maximumFoods = maximumFoods;
}
public Integer getUnpaidCount() {
Integer ret = 0;
for (BillLine line : getBillLines()) {
if (!line.getBill().isPaid()) {
ret += line.getQuantity().intValue();
}
}
return ret;
}
public Integer getOrderedCount() {
Integer ret = 0;
if (getAccountEvents() != null) {
for(AccountEvent ae : getAccountEvents()) {
ret += ae.getQuantity().intValue();
}
}
return ret;
}
public boolean isDelivered() {
if (getAccountEvents() != null && getReservedCount() != 0) {
for(AccountEvent ae : getAccountEvents()) {
if (ae.isEventDelivered()) {
return true;
}
}
return false;
}
return true;
}
}
@Column(name = "wave_name", nullable = false)
private String name;
@Lob
@Column(name = "wave_description")
private String description;
@Column(name = "wave_time")
@Temporal(TemporalType.TIMESTAMP)
private Date time;
@Column(name = "max_foods")
private Integer maximumFoods;
@Column(name = "wave_closed", nullable = false, columnDefinition = "boolean default false")
private boolean closed = false;
@OneToMany(mappedBy = "foodWave")
private List<AccountEvent> accountEvents;
@OneToMany(mappedBy = "foodwave")
private List<BillLine> billLines;
@ManyToOne
@JoinColumn(name = "template_id", referencedColumnName = "id", nullable = false)
private FoodWaveTemplate template;
public FoodWave() {
super();
}
public FoodWave(String waveName, boolean waveClosed) {
super();
this.name = waveName;
this.closed = waveClosed;
}
public String getName() {
return name;
}
public void setName(String waveName) {
this.name = waveName;
}
public String getDescription() {
return description;
}
public void setDescription(String waveDescription) {
this.description = waveDescription;
}
public Date getTime() {
return time;
}
public void setTime(Date waveTime) {
this.time = waveTime;
}
public boolean getClosed() {
return closed;
}
public boolean isClosed() {
return closed;
}
public void setClosed(boolean waveClosed) {
this.closed = waveClosed;
}
public void toggleClosed() {
this.closed = !isClosed();
}
public List<AccountEvent> getAccountEvents() {
return accountEvents;
}
public void setAccountEvents(List<AccountEvent> accountEventList) {
this.accountEvents = accountEventList;
}
public void setTemplate(FoodWaveTemplate template) {
this.template = template;
}
public FoodWaveTemplate getTemplate() {
return template;
}
public boolean isFull() {
if (getMaximumFoods() <= 0) {
return false;
}
if (getReservedCount() >= getMaximumFoods()) {
return true;
}
return false;
}
/**
* Check if foodwave is orderable
*
* That means that it's not closed, full and it's in future
*
* @return
*/
public boolean isOrderable() {
if (isClosed()) {
return false;
}
if (getTime().before(new Date())) {
return false;
}
if (isFull()) {
return false;
}
return true;
}
public List<Product> getOrderedProducts() {
List<Product> retlist = new ArrayList<Product>();
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
if (!retlist.contains(ae.getProduct())) {
retlist.add(ae.getProduct());
}
}
}
return retlist;
}
public List<BillLine> getBillLines() {
return billLines;
}
public Integer getMaximumFoods() {
if (maximumFoods == null) {
return 0;
}
return maximumFoods;
}
public void setBillLines(List<BillLine> billLines) {
this.billLines = billLines;
}
public Integer getReservedCount() {
Integer retval = 0;
retval += getOrderedCount();
retval += getUnpaidCount();
return retval;
}
public void setMaximumFoods(Integer maximumFoods) {
this.maximumFoods = maximumFoods;
}
public Integer getUnpaidCount() {
Integer ret = 0;
for (BillLine line : getBillLines()) {
if (!line.getBill().isPaid() && !line.getBill().isExpired()) {
ret += line.getQuantity().intValue();
}
}
return ret;
}
public Integer getOrderedCount() {
Integer ret = 0;
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
ret += ae.getQuantity().intValue();
}
}
return ret;
}
public Integer getDeliveredCount() {
Integer delCount = new Integer(0);
if (getAccountEvents() != null && getReservedCount() != 0) {
for (AccountEvent ae : getAccountEvents()) {
if (ae.isEventDelivered()) {
delCount++;
}
}
}
return delCount;
}
public boolean isDelivered() {
if (getAccountEvents() != null && getReservedCount() != 0) {
for (AccountEvent ae : getAccountEvents()) {
if (!ae.isEventDelivered()) {
return false;
}
}
}
return true;
}
@Transient
public Date getLastPaymentTime() {
return new Date(getTime().getTime() + (getTemplate().getWaitPaymentsMinutes().longValue() * 60l * 1000l));
}
public boolean isPaymentOver() {
// add this magical "wait payments this amount of minutes" to foodwave
Date endDate = new Date(getTime().getTime() + (getTemplate().getWaitPaymentsMinutes().longValue() * 60l * 1000l));
if (isClosed() || endDate.before(new Date())) {
return true;
}
return false;
}
}
......@@ -66,6 +66,9 @@ public class FoodWaveTemplate extends GenericEntity {
@Column(name = "max_foods")
private Integer maximumFoods;
@Column(name = "wait_payments_minutes")
private Integer waitPaymentsMinutes = 0;
public FoodWaveTemplate() {
}
......@@ -135,4 +138,16 @@ public class FoodWaveTemplate extends GenericEntity {
return returnList;
}
public Integer getWaitPaymentsMinutes() {
if(waitPaymentsMinutes == null)
waitPaymentsMinutes = 0;
return waitPaymentsMinutes;
}
public void setWaitPaymentsMinutes(Integer waitPaymentsMinutes) {
this.waitPaymentsMinutes = waitPaymentsMinutes;
}
}
......@@ -70,5 +70,9 @@
<id>apache.snapshots</id>
<url>http://repository.apache.org/snapshots/</url>
</repository>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
</project>
......@@ -101,6 +101,21 @@
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>net.matlux</groupId>
<artifactId>jvm-breakglass</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>
<parent>
......
......@@ -24,13 +24,15 @@ public enum EventPermission implements IAppPermission {
MANAGE_PROPERTIES,
MANAGE_PRIVATE_PROPERTIES,
MANAGE_EVENT
MANAGE_EVENT,
VIEW_STATISTICS
;
public static final String S_MANAGE_PROPERTIES = "EVENT/MANAGE_PROPERTIES";
public static final String S_MANAGE_PRIVATE_PROPERTIES = "EVENT/MANAGE_PRIVATE_PROPERTIES";
public static final String S_MANAGE_EVENT = "EVENT/MANAGE_EVENT";
public static final String S_VIEW_STATISTICS = "EVENT/VIEW_STATISTICS";
private final String fullName;
private final String key;
......
......@@ -7,24 +7,34 @@
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>#{sessionHandler.theme}</param-value>
</context-param>
<param-name>primefaces.THEME</param-name>
<param-value>#{sessionHandler.theme}</param-value>
</context-param>
<!-- Asetetaan PROJECT_STAGE JNDI:llä, ja fallbackataan arvoon Development -->
<resource-ref>
<res-ref-name>jsf/ProjectStage</res-ref-name>
<res-type>java.lang.String</res-type>
</resource-ref>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Add req.remoteHost, req.xForwardedFor, req.requestURI, req.requestURL,
req.queryString and req.userAgent to logger MDC -->
<filter>
<filter-name>MDCInsertingServletFilter</filter-name>
<filter-class>ch.qos.logback.classic.helpers.MDCInsertingServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MDCInsertingServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<display-name>PrimefacesFileupload</display-name>
<filter-name>PrimefacesFileupload</filter-name>
......@@ -44,19 +54,27 @@
<filter-name>HostnameFilter</filter-name>
<servlet-name>*</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- <servlet> <servlet-name>ViewStatusMessages</servlet-name> <servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet
</servlet-class> </servlet> <servlet-mapping> <servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logback</url-pattern> </servlet-mapping> -->
<servlet>
<servlet-name>repl-servlet</servlet-name>
<servlet-class>fi.codecrew.moya.management.ReplServlet</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
......@@ -97,4 +115,5 @@
<persistence-unit-ref>
<persistence-unit-ref-name>BortalEMF</persistence-unit-ref-name>
</persistence-unit-ref>
</web-app>
\ No newline at end of file
......@@ -62,6 +62,10 @@
</ui:fragment>
<p:outputPanel rendered="#{billEditView.bill.foodwaveBill}">
<span class="notify"><h:outputText value="#{i18n['foodshop.canBuyToCounter']}" /></span>
</p:outputPanel>
<br />
<p:outputPanel rendered="#{!billEditView.bill.paid and !billEditView.bill.expired}">
<h:form>
<p:commandButton id="cancelbtn" actionListener="#{billEditView.expireBill()}" onerror="location.reload(true);" value="#{i18n['bill.cancel']}" update=":billPanel">
......@@ -70,6 +74,13 @@
</h:form>
</p:outputPanel>
<p:outputPanel rendered="#{billEditView.bill.user.accountBalance ge billEditView.bill.totalPrice}">
<h:form>
<p:commandButton id="buyCreditsButton" 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>
</h:form>
</p:outputPanel>
</p:outputPanel>
</ui:define>
......
......@@ -8,6 +8,7 @@
<h:body>
<!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq false}"> -->
<h1>#{i18n['error.error']}</h1>
<h2>#{errorPageView.message}</h2>
<p>${i18n['error.contact']}
<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.time}" /><br/><br/>
<!-- Trail:<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.trail}" /> -->
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition
template="#{sessionHandler.template}">
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:viewParam name="id" value="#{foodWaveView.templateId}" />
<f:event type="preRenderView"
listener="#{foodWaveView.initEditTemplate()}" />
<f:event type="preRenderView" listener="#{foodWaveView.initEditTemplate()}" />
</f:metadata>
<ui:define name="title">
......@@ -27,58 +18,46 @@
<p:panel header="#{i18n['foodwavetemplate.edit']}">
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="name"
value="#{i18n['foodwave.template.name']}" />
<h:outputLabel for="name" value="#{i18n['foodwave.template.name']}" />
<h:inputText id="name" value="#{foodWaveView.template.name}" />
<h:message for="name" />
<h:outputLabel for="desc"
value="#{i18n['foodwave.template.description']}" />
<h:inputText id="desc"
value="#{foodWaveView.template.description}" />
<h:outputLabel for="desc" value="#{i18n['foodwave.template.description']}" />
<h:inputText id="desc" value="#{foodWaveView.template.description}" />
<h:message for="desc" />
<h:outputLabel for="overtime" value="#{i18n['foodwave.template.waitPaymentsMinutes']}" />
<p:spinner id="overtime" value="#{foodWaveView.template.waitPaymentsMinutes}" suffix=" #{i18n['suffix.minutes']}" min="0" />
<h:message for="overtime" />
<h:outputText value=" " />
<h:commandButton action="#{foodWaveView.saveTemplate()}"
value="#{i18n['foodwavetemplate.save']}" />
<h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foodwavetemplate.save']}" />
</h:panelGrid>
</h:form>
<h:form>
<h:selectOneMenu value="#{foodWaveView.currentProduct}"
converter="#{productConverter}">
<f:selectItems value="#{foodWaveView.products}" var="product"
itemLabel="#{product.name}"></f:selectItems>
<h:selectOneMenu value="#{foodWaveView.currentProduct}" converter="#{productConverter}">
<f:selectItems value="#{foodWaveView.products}" var="product" itemLabel="#{product.name}"></f:selectItems>
</h:selectOneMenu>
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}"
actionListener="#{foodWaveView.addProductToTemplate}"
ajax="false" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" actionListener="#{foodWaveView.addProductToTemplate}" ajax="false" />
</h:form>
<h:form>
<h:panelGrid columns="4">
<h:outputText value="#{i18n['foodwavetemplate.productname']}" />
<h:outputText
value="#{i18n['foodwavetemplate.productdescription']}" />
<h:outputText value="#{i18n['foodwavetemplate.productdescription']}" />
<h:outputText value="#{i18n['foodwavetemplate.price']}" />
<h:outputText value="&nbsp;" />
<h:inputText id="productname"
value="#{foodWaveView.currentProduct.name}" />
<h:inputText id="productdescription"
value="#{foodWaveView.currentProduct.description}" />
<h:inputText id="price"
value="#{foodWaveView.currentProduct.price}" />
<h:inputText id="productname" value="#{foodWaveView.currentProduct.name}" />
<h:inputText id="productdescription" value="#{foodWaveView.currentProduct.description}" />
<h:inputText id="price" value="#{foodWaveView.currentProduct.price}" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}"
actionListener="#{foodWaveView.addProductToTemplate}"
ajax="false" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" actionListener="#{foodWaveView.addProductToTemplate}" ajax="false" />
</h:panelGrid>
</h:form>
<h:form>
<p:dataTable name="productTable" id="productTable"
value="#{foodWaveView.template.products}" var="product"
editable="true">
<p:dataTable name="productTable" id="productTable" value="#{foodWaveView.template.products}" var="product" editable="true">
<p:ajax event="rowEdit" listener="#{foodWaveView.onEdit}" />
......@@ -89,20 +68,17 @@
<h:outputText value="#{product.name}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{product.name}" style="width:100%"
required="true" requiredMessage="Name required" />
<p:inputText value="#{product.name}" style="width:100%" required="true" requiredMessage="Name required" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText="#{i18n['foodwavetemplate.productdescription']}">
<p:column headerText="#{i18n['foodwavetemplate.productdescription']}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{product.description}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{product.description}" style="width:100%"
required="true" requiredMessage="Description required" />
<p:inputText value="#{product.description}" style="width:100%" required="true" requiredMessage="Description required" />
</f:facet>
</p:cellEditor>
</p:column>
......@@ -112,52 +88,38 @@
<h:outputText value="#{product.price}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{product.price}" style="width:100%"
required="true" requiredMessage="Price required" />
<p:inputText value="#{product.price}" style="width:100%" required="true" requiredMessage="Price required" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{i18n['foodwavetemplate.editRow']}"
style="width:20px">
<p:column style="width:20px">
<p:rowEditor />
</p:column>
<p:column headerText="#{i18n['foodwavetemplate.actions']}"
style="width:20px;">
<p:commandButton
value="#{i18n['foodwavetemplate.removeFromList']}"
action="#{foodWaveView.removeProductFromList(product)}"
update="productTable" />
<p:column style="width:70px">
<p:commandButton value="#{i18n['foodwavetemplate.removeFromList']}" action="#{foodWaveView.removeProductFromList(product)}" update="productTable" />
</p:column>
</p:dataTable>
<h:commandButton action="#{foodWaveView.saveTemplate()}"
value="#{i18n['foodwavetemplate.savetemplate']}" />
<h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foodwavetemplate.savetemplate']}" />
<!-- -->
</h:form>
</h:form>
</p:panel>
<h:form>
<p:panel header="#{i18n['foodwavetemplate.createwave']}">
<h:panelGrid columns="3">
<h:outputLabel for="waveName"
value="#{i18n['foodwavetemplate.waveName']}" />
<h:inputText id="waveName"
value="#{foodWaveView.selectedFoodWave.name}" />
<h:outputLabel for="waveName" value="#{i18n['foodwavetemplate.waveName']}" />
<h:inputText id="waveName" value="#{foodWaveView.selectedFoodWave.name}" />
<h:message for="waveName" />
<h:outputLabel for="waveMaxFoods"
value="#{i18n['foodwavetemplate.maxfoods']}" />
<h:inputText id="waveMaxFoods"
value="#{foodWaveView.selectedFoodWave.maximumFoods}" />
<h:outputLabel for="waveMaxFoods" value="#{i18n['foodwavetemplate.maxfoods']}" />
<h:inputText id="waveMaxFoods" value="#{foodWaveView.selectedFoodWave.maximumFoods}" />
<h:message for="waveMaxFoods" />
<h:outputLabel for="startTime"
value="#{i18n['foodwavetemplate.startTime']}" />
<p:calendar id="startTime" value="#{foodWaveView.startDate}"
pattern="dd.MM.yyyy HH:mm" />
<h:outputLabel for="startTime" value="#{i18n['foodwavetemplate.startTime']}" />
<p:calendar id="startTime" value="#{foodWaveView.startDate}" pattern="dd.MM.yyyy HH:mm" />
<h:message for="startTime" />
</h:panelGrid>
<h:commandButton action="#{foodWaveView.createFoodwave()}"
value="#{i18n['foodwavetemplate.createFoodwave']}" />
<h:commandButton action="#{foodWaveView.createFoodwave()}" value="#{i18n['foodwavetemplate.createFoodwave']}" />
</p:panel>
</h:form>
</ui:define>
......
......@@ -64,6 +64,13 @@
</f:facet>
<h:outputText value="#{foodwave.unpaidCount}" />
</p:column>
<p:column styleClass="text-center">
<f:facet name="header">
<h:outputText value="${i18n['foodWave.deliveredCount']}" />
</f:facet>
<h:outputText value="#{foodwave.deliveredCount}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['foodWave.totalReserved']}" />
......
......@@ -23,8 +23,7 @@
<ui:define name="content">
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromCounter()}"
items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyFromCounter"/>
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyFromInternet()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyProceedToPay"/>
</ui:define>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:foodwave="http://java.sun.com/jsf/composite/cditools/foodwave" xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
>
<h:body>
<ui:composition template="/resources/templates/#{sessionHandler.infoscreen}/template.xhtml">
<f:metadata>
<f:viewParam name="foodwaveid" value="#{foodWaveFoodView.foodwaveid}" />
<f:viewParam name="userid" value="#{flowFoodwaveView.userId}" />
<f:event type="preRenderView" listener="#{flowFoodwaveView.initFoodsView}" />
</f:metadata>
<ui:define name="content">
<reader:backendReader selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{flowFoodwaveView.polledRead}" />
<h:form>
<p:autoComplete id="acsb" value="#{infoView.multiSearchUser}" completeMethod="#{infoView.matchMulti}" converter="#{eventUserConverter}" var="usrx" itemLabel="#{usrx.shortUserDescriptor}" itemValue="#{usrx}">
<p:ajax event="itemSelect" listener="#{flowFoodwaveView.changeUser}" />
</p:autoComplete>
</h:form>
<br /><br />
<h1>Shop to user: #{userView.selectedUser.user.nick}</h1>
<br /><br />
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}" selectCreditsAction="#{foodWaveFoodView.buyAndPayWithCredits}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay" commitCreditsValue="foodshop.buyAndPayWithCredits"/>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:foodwave="http://java.sun.com/jsf/composite/cditools/foodwave"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition
template="/resources/templates/#{sessionHandler.infoscreen}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{flowFoodwaveView.userId}" />
<f:viewParam name="templateid" value="#{foodWaveView.templateId}" />
<f:event type="preRenderView" listener="#{flowFoodwaveView.initView}" />
</f:metadata>
<ui:define name="content">
<reader:backendReader selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{flowFoodwaveView.polledRead}" />
<h:form>
<p:autoComplete id="acsb" value="#{infoView.multiSearchUser}" completeMethod="#{infoView.matchMulti}" converter="#{eventUserConverter}" var="usrx" itemLabel="#{usrx.shortUserDescriptor}" itemValue="#{usrx}">
<p:ajax event="itemSelect" listener="#{flowFoodwaveView.changeUser}" />
</p:autoComplete>
</h:form>
<br /><br />
<h1>Shop to user: #{userView.selectedUser.user.nick}</h1>
<br /><br />
<foodwave:list outcome="/info/foodwave/foodwaveProducts"/>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:products="http://java.sun.com/jsf/composite/tools/products"
xmlns:foodwave="http://java.sun.com/jsf/composite/tools"
xmlns:p="http://primefaces.org/ui"
>
<h:body>
<ui:composition template="#{sessionHandler.template}">
<ui:define name="content">
Sisällä: <p:outputLabel value="#{basicStatisticsView.groupMembershipsEnteredCount} / #{basicStatisticsView.groupMembershipsTotalCount}" /><br />
Korttei: <p:outputLabel value="#{basicStatisticsView.cardDeliveredCount}" />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -34,7 +34,7 @@
<h:outputText value="${i18n['bill.sentDate']}" />
</f:facet>
<h:outputText value="#{bill.sentDateTime}">
<f:convertDateTime pattern="#{sessionHandler.dateFormat}" timeZone="#{sessionHandler.timezone}" />
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column>
......
......@@ -23,7 +23,7 @@
<h:link rendered="#{not foodwave.isFull()}" outcome="#{cc.attrs.outcome}" value="#{foodwave.name}">
<f:param name="foodwaveid" value="#{foodwave.id}" />
<f:param name="userid" value="#{userView.getCurrentUser().user.id}" />
<f:param name="userid" value="#{userView.selectedUser.user.id}" />
</h:link>
<h:outputText rendered="#{foodwave.isFull()}" value="#{foodwave.name}" />
......
......@@ -15,13 +15,14 @@
<composite:attribute name="items" required="true" />
<!-- <composite:attribute name="selectValue" required="true" /> -->
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="true" />
<composite:attribute name="selectCreditsAction" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<h:outputScript library="primefaces" name="jquery/jquery.js" />
<h:form>
<h:form styleClass="foodformselector">
<p:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign"
styleClass="bordertable" value="#{cc.attrs.items}" var="cart">
<!-- p:column>
......@@ -54,6 +55,17 @@
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['product.description']}" />
</f:facet>
<h:outputText id="description" value="#{cart.product.description}" />
<p:tooltip rendered="#{cart.product.name != null}" for="description" value="#{cart.product.name}" showEffect="fade" hideEffect="fade" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:outputText id="price" value="#{cart.product.price.abs()}">
......@@ -73,28 +85,30 @@
<h:outputText id="count" value="${i18n['product.cart.count']}" />
</f:facet>
<h:commandButton action="#{foodWaveFoodView.addMinusOne}"
value="#{i18n['productshop.minusOne']}">
<f:ajax render="@form" />
</h:commandButton>
<p:commandButton actionListener="#{foodWaveFoodView.addMinusOne}" update="@(.foodformselector)"
value="#{i18n['productshop.minusOne']}" />
<h:inputText size="4" id="cartcount" value="#{cart.count}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="0" />
</h:inputText>
<h:commandButton action="#{foodWaveFoodView.addOne}"
value="#{i18n['productshop.plusOne']}">
<f:ajax render="@form" />
</h:commandButton>
<p:commandButton actionListener="#{foodWaveFoodView.addOne}" update="@(.foodformselector)"
value="#{i18n['productshop.plusOne']}" />
</p:column>
</p:dataTable>
<div>
<h:outputLabel for="total" value="#{i18n['foodshop.total']}: "/>
<h:outputText id="total" value="#{foodWaveFoodView.totalPrice}" >
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
<div>
<h:outputLabel for="total" value="#{i18n['foodshop.total']}: "/>
<h:outputText id="total" value="#{foodWaveFoodView.totalPrice}" style="font-weight: bold;" >
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</div>
<h:commandButton action="#{cc.attrs.selectaction}" value="#{i18n[cc.attrs.commitValue]}" />
<h:commandButton action="#{foodWaveFoodView.buyFromInternet}" value="#{i18n['foodshop.buyFromInternet']}" />
<br />
<p:commandButton action="#{cc.attrs.selectaction}" value="#{i18n[cc.attrs.commitValue]}" ajax="false" />
<br />
<p:commandButton rendered="#{foodWaveFoodView.totalPrice le userView.selectedUser.accountBalance and not empty cc.attrs.selectCreditsAction}" action="#{cc.attrs.selectCreditsAction}" value="#{i18n[cc.attrs.commitCreditsValue]}" ajax="false" />
<!-- <h:commandButton action="#{foodWaveFoodView.buyFromInternet}" value="#{i18n['foodshop.buyFromInternet']}" /> -->
</h:form>
......
......@@ -27,8 +27,8 @@ xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
<h:panelGroup id="reader_autopoll">
<p:poll rendered="#{readerView.pollingMode}" interval="2" listener="#{cc.attrs.selectaction}" onerror="location.reload();" />
</h:panelGroup>
readerid:
#{readerNameContainer.readerId}
<p:dataTable rendered="#{empty readerNameContainer.readerId}" border="1" id="reader" value="#{readerListDataView.readers}" var="rr">
<p:column>
......
......@@ -21,7 +21,7 @@
<p:panelGrid columns="1" cellpadding="1">
<ui:fragment rendered="#{not empty userView.selectedUser.id}">
<p:dialog id="chartPanel" for="webcamButton" modal="true" dynamic="true" widgetVar="webcamDialog">
<p:dialog id="chartPanel" for="webcamButton" dynamic="true" widgetVar="webcamDialog">
<p:photoCam widgetVar="pc" listener="#{userView.oncapture}" update="@all" />
<p:commandButton type="button" value="Capture" onclick="PF('pc').capture()" onerror="location.reload(true);" />
</p:dialog>
......
......@@ -64,6 +64,8 @@ body {
list-style: none;
}
#top-menu li a {
display: block;
line-height: 1.7em;
......@@ -270,18 +272,14 @@ label {
.bgColor1 {
background-color: #68A3C2;
}
/*
#header {
clear: both;
float: left;
width: 100%;
border-bottom: 4px solid #333;
}
}*/
#header a {
color: white;
text-decoration: none;
}
#header_left {
float: left;
......
......@@ -174,7 +174,7 @@ a.shopItem:active {
color: #666600;
}
.expired {
.expired, .closed {
color: #c0c0c0;
}
......@@ -186,6 +186,10 @@ a.shopItem:active {
color: red;
}
.notify {
color: red;
}
.success {
color: #006600;
}
......@@ -223,4 +227,7 @@ a.shopItem:active {
padding-left: 40px !important;
}
.hidden {
display: none !important;
visibility: hidden;
}
......@@ -278,10 +278,7 @@ label {
border-bottom: 4px solid #333;
}
#header a {
color: white;
text-decoration: none;
}
#header_left {
float: left;
......
......@@ -26,8 +26,8 @@
<ui:define name="content">
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}"
items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay"/>
<foodwave:listFoods selectaction="#{foodWaveFoodView.buyAndPay}" selectCreditsAction="#{foodWaveFoodView.buyAndPayWithCredits}" items="#{foodWaveFoodView.shoppingcart}" commitValue="foodshop.buyAndPay" commitCreditsValue="foodshop.buyAndPayWithCredits"/>
</ui:define>
......
......@@ -12,7 +12,7 @@
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingIncludes>WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*</packagingIncludes>
<packagingIncludes>WEB-INF/lib/javamelody-core*,WEB-INF/lib/primefaces*,WEB-INF/lib/*-1.0.8.jar,**/*.xml,**/*.xhtml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,resources/*</packagingIncludes>
</configuration>
</plugin>
</plugins>
......@@ -29,12 +29,22 @@
<artifactId>javamelody-core</artifactId>
<version>1.52.0</version>
</dependency>
<dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>net.matlux</groupId>
<artifactId>jvm-breakglass</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>
<parent>
<groupId>fi.codecrew.moya</groupId>
......@@ -42,4 +52,4 @@
<version>1.0</version>
<relativePath>../moya-parent/pom.xml</relativePath>
</parent>
</project>
\ No newline at end of file
</project>
package fi.codecrew.moya;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class LoggingContextFilter implements Filter {
public LoggingContextFilter() {
// TODO Auto-generated constructor stub
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
}
@Override
public void destroy() {
// TODO Auto-generated method stub
}
}
package fi.codecrew.moya;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Allows defining a filter in web.xml so, that deployment doesn't blow up if
* the class is not found. E.g. Logback specific filters when logback is a
* provided dependency.
*
* @author jkj
*
*/
public class RobustFilterProxy implements Filter {
Logger log = LoggerFactory.getLogger(RobustFilterProxy.class);
private Filter wrapped = null;
public RobustFilterProxy() {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
try {
String filterClassName = filterConfig.getInitParameter("wrapped-class");
if (filterClassName == null) {
throw new ServletException("wrapped-class init-param required");
}
log.info("Wrapped class: " + filterClassName);
Class<?> wrappedFilterClass = this.getClass().getClassLoader().loadClass(filterClassName);
// Class<?> wrapperFilterClass = Class.forName(filterClassName);
log.debug("Wrapped filter class: " + wrappedFilterClass);
wrapped = (Filter) wrappedFilterClass.newInstance();
log.debug("Wrapped filter instance: " + wrapped);
wrapped.init(filterConfig);
} catch (ClassNotFoundException e) {
log.warn("Wrapped filter class not found", e);
} catch (InstantiationException e) {
log.warn("Could not instantiate wrapper filter class", e);
} catch (IllegalAccessException e) {
log.warn("Could not wrap filter", e);
}
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (wrapped != null) {
// Use the wrapped filter if available.
wrapped.doFilter(request, response, chain);
} else {
// Otherwise just work as a no-op filter calling the next filter in
// chain.
chain.doFilter(request, response);
}
}
@Override
public void destroy() {
if (wrapped != null) {
wrapped.destroy();
}
wrapped = null;
}
}
package fi.codecrew.moya.management;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;
import javax.servlet.annotation.WebServlet;
import net.matlux.NreplServer;
// XXX: The annotation did not cause the servlet to start. Thus the servlet is also defined in web.xml.
@WebServlet(loadOnStartup = 5, name = "repl-servlet")
public class ReplServlet implements Servlet {
private static final int NREPL_DEFAULT_PORT = 1112;
private NreplServer nreplServer;
private ServletConfig servletConfig;
@Override
public void init(ServletConfig config) throws ServletException {
servletConfig = config;
int port = NREPL_DEFAULT_PORT;
String portStr = config.getInitParameter("port");
if (portStr != null) {
port = Integer.parseInt(portStr);
}
nreplServer = new NreplServer(port);
}
@Override
public ServletConfig getServletConfig() {
return servletConfig;
}
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
throw new UnavailableException("This servlet doesn't really serve.");
}
@Override
public String getServletInfo() {
return "REPL Servlet for introspecting the JVM";
}
public NreplServer getNreplServer() {
return nreplServer;
}
@Override
public void destroy() {
if (nreplServer != null) {
nreplServer.stop();
}
}
}
......@@ -31,8 +31,12 @@ bill.billNumber = Number
bill.cancel = Cancel bill
bill.expires = Expires
bill.isExpired = Bill is expired
bill.markPaid.cash = Maksa k\u00E4teisell\u00E4
bill.markPaid.cashOrCredit = K\u00E4teisell\u00E4 vai krediiteill\u00E4?
bill.markPaid.credits = Maksa krediiteill\u00E4
bill.markPaid.show = Show Mark paid -buttons
bill.notes.title = Lis\u00E4tietoja
bill.products = Tuotteet
bill.save = Save
bill.showPayButtons = Show pay buttons
......@@ -118,6 +122,8 @@ cardTemplate.emptyCardTemplate = ----
code.inputfield = Sy\u00F6t\u00E4 viivakoodi
confirmation.message = Oletko varma?
create = Luo
delete = Poista
......@@ -159,8 +165,19 @@ eventorg.create = Create
eventorg.title = Tapahtuman tiedot
foodWave.closeNow = Close now
foodWave.deliveredCount = Luovutetut
foodWave.openNow = Open now
foodshop.buyAndPayWithCredits = Varaa ja maksa krediiteill\u00E4
foodshop.buyProceedToPay = Varaa ja siirry maksamaan
foodshop.canBuyToCounter = Voit maksaa t\u00E4m\u00E4n ruokatilauksen my\u00F6s infotiskille. Mik\u00E4li haluat tehd\u00E4 n\u00E4in, voit sulkea t\u00E4m\u00E4n ikkunan ja tulla infotiskille maksamaan tilauksen.
foodwave.cancelOrder = Peruuta
foodwave.closed = Ruokatilaus on suljettu
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.ordersBefore = Tilaukset ennen
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
game.active = Aktiivinen
game.codecount = Avattuja
game.codes.available = Lisenssikoodit
......@@ -313,9 +330,10 @@ poll.edit = edit
print = Print
product.description = Kuvaus
product.providedRole = Product defines role
product.returnProductEdit = Return to product:
product.saved = Product saved
product.saved = Product saved
productshop.minusOne = -1
productshop.minusTen = -10
......@@ -347,18 +365,22 @@ submenu.NotImplementedYet = Not implemented
submenu.admin.adduser = K\u00E4ytt\u00E4j\u00E4nlis\u00E4ys
submenu.admin.adduser.index = K\u00E4ytt\u00E4j\u00E4nlis\u00E4ys
submenu.frontpage = Frontpage
submenu.info.foodwave.foodwaveshop = Ruokakauppa
submenu.info.incoming = Sis\u00E4\u00E4ntulo
submenu.info.index = Infon\u00E4kym\u00E4
submenu.info.shop = Kauppa
submenu.lectureadmin.lectureParticipants = Tarkastele osallistujia
submenu.lectureadmin.manageLectureGroups = Hallinnoi
submenu.lectures.viewLectures = Ilmoittaudu
submenu.reports.basicStatistics = Tilastoja
subnavi.cards = \u0009\u0009
subnavi.info = Info
success = Onnistui
suffix.minutes = min
topnavi.adminlectures = Kurssit ja luennot
topnavi.license = Lisenssikoodit
topnavi.userlectures = Kurssit ja luennot
......
......@@ -77,6 +77,9 @@ bill.expires = Expires
bill.isExpired = Bill is expired
bill.isPaid = Paid
bill.markPaid = Mark paid
bill.markPaid.cash = Buy with cash
bill.markPaid.cashOrCredit = Cash or credit?
bill.markPaid.credits = Buy with credits
bill.markPaid.show = Show Mark paid -buttons
bill.markedPaid = Bill marked paid
bill.notes = Notes
......@@ -88,6 +91,7 @@ bill.payer = Payer
bill.paymentTime = Payment time
bill.paymentTime.now = Now
bill.printBill = Print bill
bill.products = Products
bill.receiverAddress = Receiver address
bill.referenceNumberBase = Reference number base
bill.referencenumber = Reference nr.
......@@ -304,6 +308,8 @@ compofile.shaChecksum = SHA checksum
compofile.upload = Upload file
compofile.uploadTime = Upload time
confirmation.message = Are you sure?
content.showContentEditLinks = Show content edit links
create = Create
......@@ -405,8 +411,9 @@ food = Food
foodWave.accountevents = Accountevents
foodWave.activeFoodWaves = Active Foodwaves
foodWave.billLines = Pending Online Payments
foodWave.billLines = Pending Payments
foodWave.closeNow = Close now
foodWave.deliveredCount = Delivered
foodWave.deliveredFoodWaves = Delivered Foodwaves
foodWave.description = Foodwave description
foodWave.list = Active Foodwaves
......@@ -425,14 +432,21 @@ foodWave.unconfirmedOrders = Unconfirmed
foodadmin.editTemplate = Edit
foodshop.buyAndPay = Buy and Pay
foodshop.buyAndPayWithCredits = Reserve and buy with credits
foodshop.buyFromCounter = Pay at info
foodshop.buyFromInternet = Pay at Internet
foodshop.buyProceedToPay = Reserve and continue to buy
foodshop.canBuyToCounter = You can buy this bill on infodesk. If you want to buy this order at the infodesk, you can close this window and come to infodesk to buy this order.
foodshop.total = Total
foodwave.buyInPrice = Buy In Price
foodwave.cancelOrder = Cancel
foodwave.closed = Foodwave is closed
foodwave.foodwaveBuyInPrice = Total buy in price
foodwave.foodwaveLastBillPayTime = Last payments time
foodwave.markPaid = Foodwave marked paid
foodwave.orders = Foodwave Orders
foodwave.ordersBefore = Orders before
foodwave.price = Foodwave price
foodwave.summaryView = Foodwave Summary
foodwave.template.basicinfo = Template Information
......@@ -441,6 +455,7 @@ foodwave.template.edit.title = Foodwave Template Editor
foodwave.template.list.title = Foodwave Templates
foodwave.template.name = Name
foodwave.template.selectproducts = Products
foodwave.template.waitPaymentsMinutes = Webpayments waittime
foodwave.totalCount = Amount
foodwave.totalPrice = Customer Price
......@@ -936,6 +951,7 @@ product.color = Color in UI
product.create = Create product
product.createDiscount = Add volumediscount
product.createLimit = Create product limitation
product.description = Description
product.edit = edit
product.inventoryQuantity = Inventory count
product.name = Name of product
......@@ -1170,6 +1186,7 @@ submenu.foodmanager.listFoodwaves = List active foodwaves
submenu.foodwave.list = Foodwaves
submenu.foodwave.listTemplates = Food provides
submenu.index = Frontpage
submenu.info.foodwave.foodwaveshop = Foodshop
submenu.info.incoming = Incomingview
submenu.info.index = Infoview
submenu.info.shop = Shop
......@@ -1194,6 +1211,7 @@ submenu.place.placemap = Placemap
submenu.poll.index = Polls
submenu.product.create = Create product
submenu.product.list = List products
submenu.reports.basicStatistics = Statistics
submenu.role.create = Create role
submenu.role.list = Show Roles
submenu.shop.createBill = Purchase
......@@ -1242,6 +1260,8 @@ subnavi.roles = Roles
success = Success
suffix.minutes = min
supernavi.admin = Adminview
supernavi.user = Userview
......
......@@ -77,6 +77,9 @@ bill.expires = Vanhentuu
bill.isExpired = Lasku on vanhentunut
bill.isPaid = Maksettu
bill.markPaid = Maksettu
bill.markPaid.cash = Maksa k\u00E4teisell\u00E4
bill.markPaid.cashOrCredit = K\u00E4teisell\u00E4 vai krediiteill\u00E4?
bill.markPaid.credits = Maksa krediiteill\u00E4
bill.markPaid.show = N\u00E4yt\u00E4 Maksettu -napit
bill.markedPaid = Lasku merkitty maksetuksi.
bill.notes = Huomioita
......@@ -88,6 +91,7 @@ bill.payer = Maksaja
bill.paymentTime = Maksuehdot
bill.paymentTime.now = Heti
bill.printBill = Tulosta lasku
bill.products = Tuotteet
bill.receiverAddress = Kauppiaan osoite
bill.referenceNumberBase = Viitenumeropohja
bill.referencenumber = Viitenumero
......@@ -305,6 +309,8 @@ compofile.shaChecksum = SHA tarkistesumma
compofile.upload = L\u00E4het\u00E4 tiedosto
compofile.uploadTime = Tallennusaika
confirmation.message = Oletko varma?
content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit
create = Luo
......@@ -406,8 +412,9 @@ food = Ruoka
foodWave.accountevents = Maksetut tilaukset
foodWave.activeFoodWaves = Aktiiviset Ruokatilaukset
foodWave.billLines = Maksamattomat Verkkomaksut
foodWave.billLines = Maksamattomat maksut
foodWave.closeNow = Sulje nyt
foodWave.deliveredCount = Toimitetut
foodWave.deliveredFoodWaves = Toimitetut Ruokatilaukset
foodWave.description = Ruokatilauksen kuvaus
foodWave.list = Ruokatilaukset
......@@ -426,14 +433,21 @@ foodWave.unconfirmedOrders = Vahvistamattomia
foodadmin.editTemplate = Muokkaa
foodshop.buyAndPay = Varaa ja maksa
foodshop.buyAndPayWithCredits = Varaa ja maksa krediiteill\u00E4
foodshop.buyFromCounter = Maksa infossa
foodshop.buyFromInternet = Maksa Internetiss\u00E4
foodshop.buyProceedToPay = Varaa ja siirry maksamaan
foodshop.canBuyToCounter = Voit maksaa t\u00E4m\u00E4n ruokatilauksen my\u00F6s infotiskille. Mik\u00E4li haluat tehd\u00E4 n\u00E4in, voit sulkea t\u00E4m\u00E4n ikkunan ja tulla infotiskille maksamaan tilauksen.
foodshop.total = Yhteens\u00E4
foodwave.buyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.cancelOrder = Peruuta
foodwave.closed = Ruokatilaus on suljettu
foodwave.foodwaveBuyInPrice = Sis\u00E4\u00E4nostohinta
foodwave.foodwaveLastBillPayTime = Maksut viimeist\u00E4\u00E4n
foodwave.markPaid = Merkitty maksetuksi
foodwave.orders = Maksetut Tilaukset
foodwave.ordersBefore = Tilaukset ennen
foodwave.price = Tilausten kokonaishinta
foodwave.summaryView = Ruokatilauksen Yhteenveto
foodwave.template.basicinfo = Template Infot
......@@ -442,6 +456,7 @@ foodwave.template.edit.title = Foodwave Template Editori
foodwave.template.list.title = Ruokatilaus Templatet
foodwave.template.name = Nimi
foodwave.template.selectproducts = Tuotteet
foodwave.template.waitPaymentsMinutes = Verkkomaksujen odotusaika
foodwave.totalCount = M\u00E4\u00E4r\u00E4
foodwave.totalPrice = Asiakkaan Hinta
......@@ -919,6 +934,7 @@ product.color = V\u00E4ri k\u00E4ytt\u00F6liittym\u00E4ss\u00E4
product.create = Luo tuote
product.createDiscount = Lis\u00E4\u00E4 m\u00E4\u00E4r\u00E4alennus
product.createLimit = Luo tuoterajoite
product.description = Kuvaus
product.edit = Muokkaa
product.inventoryQuantity = Varastotilanne
product.name = Tuotteen nimi
......@@ -1150,6 +1166,7 @@ submenu.foodmanager.listFoodwaves = Aktiiviset ruokatilaukset
submenu.foodwave.list = Ruokatilaukset
submenu.frontpage = Etusivu
submenu.index = Etusivu
submenu.info.foodwave.foodwaveshop = Ruokakauppa
submenu.info.incoming = Sis\u00E4\u00E4ntulo
submenu.info.index = Infon\u00E4kym\u00E4
submenu.info.shop = Kauppa
......@@ -1174,6 +1191,7 @@ submenu.place.placemap = Paikkakartta
submenu.poll.index = Kyselyt
submenu.product.create = Uusi tuote
submenu.product.list = Listaa tuotteet
submenu.reports.basicStatistics = Tilastoja
submenu.role.create = Luo rooli
submenu.role.list = N\u00E4yt\u00E4 roolit
submenu.shop.createBill = Osta tuotteita
......@@ -1225,6 +1243,8 @@ subnavi.roles = Roolit
success = Onnistui
suffix.minutes = min
supernavi.admin = Yll\u00E4piton\u00E4kym\u00E4
supernavi.user = K\u00E4ytt\u00E4j\u00E4n\u00E4kym\u00E4
......
......@@ -46,8 +46,8 @@ public class ErrorPageView implements Serializable {
// private static final long serialVersionUID = -2179309061036632342L;
String trace;
// @Inject
// private transient FacesContext context;
// @Inject
// private transient FacesContext context;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(ErrorPageView.class);
......@@ -68,6 +68,13 @@ public class ErrorPageView implements Serializable {
}
public String getMessage() {
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getRequestMap();
Throwable ex = (Throwable) requestMap.get("javax.servlet.error.exception");
return ex.getMessage();
}
public String getStackTraceHash() {
FacesContext context = FacesContext.getCurrentInstance();
......
......@@ -44,12 +44,12 @@ public class ReaderListDataView extends GenericCDIView {
private static final long serialVersionUID = -601822388844764143L;
@EJB
private transient ReaderBeanLocal readerbean;
private ReaderBeanLocal readerbean;
@Inject
private transient ReaderNameContainer readerNameContainer;
private ReaderNameContainer readerNameContainer;
private transient ListDataModel<Reader> readers;
private ListDataModel<Reader> readers;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(ReaderListDataView.class);
......
......@@ -25,6 +25,9 @@ import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Named
@SessionScoped
public class ReaderNameContainer implements Serializable {
......@@ -32,50 +35,53 @@ public class ReaderNameContainer implements Serializable {
private static final long serialVersionUID = 571747919767505523L;
//private Integer readerId;
// handling first user when using via getReaderId and setReaderId;
private List<Integer> readers;
private final List<Integer> readers = new ArrayList<Integer>();;
private boolean autopoll = false;
private static final Logger logger = LoggerFactory.getLogger(ReaderNameContainer.class);
/**
* use this function when using readers in "only one reader" -mode
* use this function when using readers in "only one reader" -mode
*
* @return first selected reader, or null if no reader selected
*/
public Integer getReaderId() {
if(getReaders().size() == 0)
if (getReaders().size() == 0)
return null;
return readers.get(0);
}
/**
* Use this function when using readers in "only one reader" -mode
* @param readerId to set, or null to clear all readers
*
* @param readerId
* to set, or null to clear all readers
*/
public void setReaderId(Integer readerId) {
if(readerId == null)
if (readerId == null) {
clearReaders();
if(getReaders().size() == 0) {
return;
}
if (getReaders().isEmpty()) {
getReaders().add(readerId);
} else {
getReaders().set(0, readerId);
}
}
public void addReader(Integer readerId) {
if(!getReaders().contains(readerId)) {
if (readerId != null && !getReaders().contains(readerId)) {
getReaders().add(readerId);
}
}
public List<Integer> getReaders() {
if(readers == null)
readers = new ArrayList<Integer>();
return readers;
}
......@@ -86,9 +92,9 @@ public class ReaderNameContainer implements Serializable {
public void setAutopoll(boolean autopoll) {
this.autopoll = autopoll;
}
public void clearReaders() {
readers = null;
readers.clear();
}
}
......@@ -59,7 +59,7 @@ public class ReaderView extends GenericCDIView {
private ReaderEvent lastReadEvent = null;
private transient ListDataModel<UserCardWrapper> userlist;
private ListDataModel<UserCardWrapper> userlist;
private ListDataModel<ReaderEvent> readerEventList;
private Reader editReader = null;
......
......@@ -18,6 +18,7 @@
*/
package fi.codecrew.moya.web.cdiview.shop;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
......@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.beans.CheckoutFiBeanLocal;
import fi.codecrew.moya.beans.VerkkomaksutFiBeanLocal;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.util.CheckoutBank;
import fi.codecrew.moya.util.VerkkomaksutReturnEntry;
......@@ -138,5 +140,15 @@ public class BillEditView extends GenericCDIView {
public void expireBill() {
bill = billbean.expireBill(bill);
}
public void buyWithCredits() {
try {
bill = billbean.markPaid(bill, Calendar.getInstance(), true);
} catch (BillException e) {
throw new RuntimeException(e);
// TODO: error handling
}
}
}
......@@ -26,10 +26,12 @@ import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import javax.management.RuntimeErrorException;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.web.annotations.SelectedUser;
......@@ -95,7 +97,11 @@ public class BillListView extends GenericCDIView {
public String markPaid() {
if (permbean.hasPermission(BillPermission.WRITE_ALL)) {
billbean.markPaid(bills.getRowData(), Calendar.getInstance());
try {
billbean.markPaid(bills.getRowData(), Calendar.getInstance(), false);
} catch (BillException x) {
throw new RuntimeException(x);
}
this.addFaceMessage("bill.markedPaid");
} else {
......
......@@ -36,6 +36,7 @@ import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.FoodWaveBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEventPropertyKey;
......@@ -169,11 +170,31 @@ public class FoodWaveFoodView extends GenericCDIView {
return bill;
}
public String buyAndPayWithCredits() {
Bill b = createBillFromShoppingcart();
try {
billBean.markPaid(b, Calendar.getInstance(), true);
} catch (BillException e) {
throw new RuntimeException(e);
}
super.addFaceMessage("foodwave.markPaid");
return "/useradmin/edit";
}
public String buyAndPay()
{
Bill b = createBillFromShoppingcart();
billBean.markPaid(b, Calendar.getInstance());
try {
billBean.markPaid(b, Calendar.getInstance(), false);
} catch (BillException e) {
throw new RuntimeException(e);
}
super.addFaceMessage("foodwave.markPaid");
return "/useradmin/edit";
}
......
......@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;
......@@ -41,6 +42,7 @@ import fi.codecrew.moya.beans.FoodWaveBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.exceptions.BillException;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine;
......@@ -76,12 +78,13 @@ public class FoodWaveView extends GenericCDIView {
private Date startDate;
private Product currentProduct;
private ListDataModel<BillLine> billLines;
//private ListDataModel<BillLine> billLines;
// private List<BillLine> unpaidBills;
private Integer foodWaveId;
private ListDataModel<AccountEvent> accountEventLines;
private ListDataModel<FoodWave> foodWaves;
private ListDataModel<Bill> bills;
private static final Logger logger = LoggerFactory.getLogger(FoodWaveView.class);
public List<Product> getProducts() {
......@@ -107,12 +110,11 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES))
{
if (foodWaves == null) {
super.beginConversation();
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
}
}
foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
}
public String createFoodwave() {
......@@ -175,7 +177,7 @@ public class FoodWaveView extends GenericCDIView {
public List<FoodwaveProductSummary> getProductSummaries() {
System.out.println("..asdfasdf");
HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<Product, FoodwaveProductSummary>();
for (AccountEvent ae : getSelectedFoodWave().getAccountEvents()) {
......@@ -221,6 +223,10 @@ public class FoodWaveView extends GenericCDIView {
}
return ret.negate();
}
public BigDecimal getFoodwaveBuyInPrice()
{
......@@ -245,13 +251,56 @@ public class FoodWaveView extends GenericCDIView {
// ListDataModel<FoodWave>(foodWaveBean.getEventFoodWaves());
// }
public String markBillExpired() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = bills.getRowData();
b = billbean.expireBill(b);
foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null;
bills = null;
initFoodWaveOrderList();
}
return null;
}
public String markBillPaid() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && getBillLines().isRowAvailable()) {
Bill b = getBillLines().getRowData().getBill();
b = billbean.markPaid(b, Calendar.getInstance());
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = bills.getRowData();
try {
b = billbean.markPaid(b, Calendar.getInstance(), false);
} catch (BillException e) {
throw new RuntimeException(e);
}
foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null;
bills = null;
initFoodWaveOrderList();
}
return null;
}
public String markBillPaidWithCredits() {
if (permbean.hasPermission(BillPermission.WRITE_ALL) && bills != null && bills.isRowAvailable()) {
Bill b = bills.getRowData();
try {
b = billbean.markPaid(b, Calendar.getInstance(), true);
} catch (BillException e) {
throw new RuntimeException(e);
}
foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null;
bills = null;
initFoodWaveOrderList();
}
......@@ -259,8 +308,8 @@ public class FoodWaveView extends GenericCDIView {
}
public String deliverAccountEvent() {
if (getAccountEventLines().isRowAvailable()) {
AccountEvent e = getAccountEventLines().getRowData();
if (accountEventLines != null && accountEventLines.isRowAvailable()) {
AccountEvent e = accountEventLines.getRowData();
e = productbeanlocal.markDelivered(e, Calendar.getInstance());
foodWaveId = selectedFoodWave.getId();
selectedFoodWave = null;
......@@ -271,27 +320,28 @@ public class FoodWaveView extends GenericCDIView {
}
public void initFoodWaveOrderList() {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES) && selectedFoodWave == null) {
selectedFoodWave = foodWaveBean.findFoodwave(foodWaveId);
logger.debug("Got foodwave {} with id {}", selectedFoodWave, foodWaveId);
this.setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents()));
List<BillLine> tmpLines = new ArrayList<BillLine>();
super.beginConversation();
}
HashSet<Bill> billList = new HashSet<Bill>();
for (BillLine line : selectedFoodWave.getBillLines()) {
if (!line.getBill().isPaid()) {
tmpLines.add(line);
}
for (BillLine line : getSelectedFoodWave().getBillLines()) {
if (!line.getBill().isPaid()) {
billList.add(line.getBill());
}
setBillLines(new ListDataModel<BillLine>(tmpLines));
setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents()));
super.beginConversation();
}
bills = new ListDataModel<Bill>(new ArrayList<Bill>(billList));
accountEventLines = new ListDataModel<AccountEvent>(getSelectedFoodWave().getAccountEvents());
}
public String saveTemplate()
......@@ -315,7 +365,6 @@ public class FoodWaveView extends GenericCDIView {
}
public FoodWave getSelectedFoodWave() {
// System.out.println("APOFKASFASFASFASFASFASFASFASFASFKJIOJIO");
return selectedFoodWave;
}
......@@ -351,13 +400,10 @@ public class FoodWaveView extends GenericCDIView {
this.foodWaveId = foodWaveId;
}
public ListDataModel<BillLine> getBillLines() {
return billLines;
public ListDataModel<Bill> getBills() {
return bills;
}
public void setBillLines(ListDataModel<BillLine> billLines) {
this.billLines = billLines;
}
public void setFoodWaves(ListDataModel<FoodWave> foodWaves) {
this.foodWaves = foodWaves;
......@@ -366,15 +412,12 @@ public class FoodWaveView extends GenericCDIView {
public ListDataModel<FoodWave> getFoodWaves() {
return foodWaves;
}
public ListDataModel<AccountEvent> getAccountEventLines() {
return accountEventLines;
}
public void setAccountEventLines(ListDataModel<AccountEvent> accountEventLines) {
this.accountEventLines = accountEventLines;
}
/*
* public List<BillLine> getUnpaidBills() { return unpaidBills; }
*
......
......@@ -115,7 +115,7 @@ public class InviteAcceptView extends GenericCDIView {
if (existingUsername == null) {
try {
req.login(usr, pwd);
req.login(usr.trim().toLowerCase(), pwd);
} catch (ServletException e) {
logger.warn("Login failed for invite user " + usr, e);
}
......
......@@ -131,7 +131,7 @@ public class AuthView extends GenericCDIView {
private void doLogin(String onError) {
bootStrapBean.saneDefaults();
// bootStrapBean.saneDefaults();
if (login == null || password == null || login.isEmpty() || password.isEmpty()) {
return;
......@@ -150,7 +150,7 @@ public class AuthView extends GenericCDIView {
}
try {
request.login(login.toLowerCase(), password);
request.login(login.trim().toLowerCase(), password);
} catch (Throwable e) {
logger.info("Error while trying to login {}", e.getMessage());
......@@ -163,7 +163,9 @@ public class AuthView extends GenericCDIView {
} else {
navihandler.forward(onError);
try {
request.login(User.ANONYMOUS_LOGINNAME, null);
request.logout();
request.getSession().invalidate();
navihandler.forward("/frontpage?faces-redirect=true");
} catch (ServletException e) {
logger.warn("Error while trying to relogin as anonymous", e);
}
......
......@@ -198,6 +198,9 @@ public class UserView extends GenericCDIView {
return user;
}
public String saveRoles()
{
rolebean.saveRoles(user, usersRoles);
......@@ -418,8 +421,9 @@ public class UserView extends GenericCDIView {
// still there, we can get real card and update it's barcodes
card = cardBean.checkPrintedCard(user);
readerbean.assocCodeToCard(event, card);
event = readerbean.assocCodeToCard(event, card);
user = event.getUser();
return null;
}
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.web.flow;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.primefaces.event.SelectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView;
import fi.codecrew.moya.web.cdiview.shop.FoodWaveFoodView;
import fi.codecrew.moya.web.cdiview.shop.FoodWaveView;
import fi.codecrew.moya.web.cdiview.shop.ProductShopView;
import fi.codecrew.moya.web.cdiview.user.UserView;
@Named
@ConversationScoped
public class FlowFoodwaveView extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L;
private static final Logger logger = LoggerFactory.getLogger(IncomingView.class);
// shop userid, we need this so we can tell when to show anonymous and when real user.
private Integer userId;
@EJB
PermissionBeanLocal permBean;
@Inject
private FoodWaveView foodwaveView;
@Inject
private FoodWaveFoodView foodWaveFoodView;
@Inject
private UserView userView;
@Inject
private InfoView infoView;
@Inject
private ReaderView readerView;
@Inject
private FlowUserContainer flowUserContainer;
public void initView() {
if(userId == null || userId == 0) {
userView.setUserid(null);
} else {
userView.setUserid(userId);
}
foodwaveView.initListFoodwaves();
}
public void initFoodsView() {
if(userId == null || userId == 0) {
userView.setUserid(null);
} else {
userView.setUserid(userId);
}
foodWaveFoodView.initFoodWaveFoods();
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public void changeUser(SelectEvent event) {
if (infoView.getMultiSearchUser() != null) {
flowUserContainer.setUserId(infoView.getMultiSearchUser().getUser().getId());
// TODO: kauneista nää
super.navihandler.redirectNavigation("/MoyaWeb/info/foodwave/foodwaveshop.jsf?userid=" + infoView.getMultiSearchUser().getUser().getId());
}
}
public void polledRead() {
ReaderEvent event = readerView.getReaderEvent();
if(event == null) {
return;
}
EventUser user = event.getUser();
if (user != null) {
if (!user.equals(userView.getUser())) {
logger.info("found user {}, redirecting", user.getNick());
userView.setUser(user);
flowUserContainer.setUserId(user.getUser().getId());
super.navihandler.redirectNavigation("/MoyaWeb/info/foodwave/foodwaveshop.jsf?userid=" + user.getUser().getId());
}
}
}
}
......@@ -272,15 +272,18 @@ public class IncomingView extends GenericCDIView {
* @return Card filing info String or empty string.
*/
public String getCardFiling() {
String ret = "";
try {
PrintedCard card = cardBean.checkPrintedCard(userview.getSelectedUser());
JsonObject cardMeta = card.getMeta();
JsonObject cardFilingObject = cardMeta.getJsonObject("card-filing");
return cardFilingObject.getString("cardplace");
if (card != null) {
JsonObject cardMeta = card.getMeta();
JsonObject cardFilingObject = cardMeta.getJsonObject("card-filing");
ret = cardFilingObject.getString("cardplace");
}
} catch (Exception e) {
logger.warn("Could not get card filing info", e);
}
return "";
return ret;
}
public String printCard() {
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.web.reports;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LectureBeanLocal;
import fi.codecrew.moya.beans.StatisticsBeanLocal;
import fi.codecrew.moya.enums.apps.LecturePermission;
import fi.codecrew.moya.model.Lecture;
import fi.codecrew.moya.model.LectureGroup;
import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class BasicStatisticsView extends GenericCDIView {
private static final long serialVersionUID = 1L;
@EJB
private StatisticsBeanLocal statisticsBean;
public Long getGroupMembershipsEnteredCount() {
return statisticsBean.getGroupMembershipsEnteredEvent();
}
public Long getCardDeliveredCount() {
return statisticsBean.getCardDeliveredCount();
}
public Long getGroupMembershipsTotalCount() {
return statisticsBean.getGroupMembershipsTotalCount();
}
}
domain.xml settings:
<jvm-options>-Dlog4j.configuration=file:///${com.sun.aas.instanceRoot}/config/bridged_logging.properties</jvm-options>
<jvm-options>-Dlogback.configurationFile=file:///${com.sun.aas.instanceRoot}/config/logback.xml</jvm-options>
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true" scan="true" scanPeriod="10 seconds">
<jmxConfigurator />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${com.sun.aas.instanceRoot}/logs/server.log</file>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} %X{req.remoteHost} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>server.%i{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>32MB</MaxFileSize>
</triggeringPolicy>
</appender>
<logger name="fi.codecrew" level="DEBUG" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
handlers = org.slf4j.bridge.SLF4JBridgeHandler
com.sun.enterprise.server.logging.GFFileHandler.flushFrequency=1
com.sun.enterprise.server.logging.GFFileHandler.file=${com.sun.aas.instanceRoot}/logs/jul.log
com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=0
com.sun.enterprise.server.logging.GFFileHandler.logtoConsole=false
com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=2000000
com.sun.enterprise.server.logging.GFFileHandler.alarms=false
com.sun.enterprise.server.logging.GFFileHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
com.sun.enterprise.server.logging.GFFileHandler.retainErrorsStasticsForHours=0
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!