Commit a362cd15 by Tuomas Riihimäki

Kaikenmoisia juttuiluja..

1 parent a3bca642
Showing with 1159 additions and 1177 deletions
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
<dependent-module archiveName="LanBortalUtilities.jar" deploy-path="/lib" handle="module:/resource/LanBortalUtilities/LanBortalUtilities"> <dependent-module archiveName="LanBortalUtilities.jar" deploy-path="/lib" handle="module:/resource/LanBortalUtilities/LanBortalUtilities">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="granite.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/granite.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="granite-eclipselink.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/granite-eclipselink.jar"> <dependent-module archiveName="granite-eclipselink.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/granite-eclipselink.jar">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
...@@ -46,5 +43,11 @@ ...@@ -46,5 +43,11 @@
<dependent-module archiveName="PDFjet.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/PDFjet.jar"> <dependent-module archiveName="PDFjet.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/PDFjet.jar">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="jbarcode-0.2.8.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/jbarcode-0.2.8.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="barcode4j.jar" deploy-path="/lib" handle="module:/classpath/lib/LanBortal/ExtraLibs/barcode4j.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
</wb-module> </wb-module>
</project-modules> </project-modules>
No preview for this file type
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -56,6 +58,9 @@ public class BillBean implements BillBeanLocal { ...@@ -56,6 +58,9 @@ public class BillBean implements BillBeanLocal {
@EJB @EJB
private ProductBeanLocal productBean; private ProductBeanLocal productBean;
@EJB
private PlaceBeanLocal placebean;
/** /**
* Default constructor. * Default constructor.
*/ */
...@@ -79,14 +84,14 @@ public class BillBean implements BillBeanLocal { ...@@ -79,14 +84,14 @@ public class BillBean implements BillBeanLocal {
} }
@Override @Override
public ByteArrayOutputStream getPdfBillStream(Bill bill) { public void getPdfBillStream(Bill bill, OutputStream ostream) {
if (bill == null) { if (bill == null) {
return null; return;
} }
if (bill.getBillNumber() == null || bill.getBillNumber() <= 0) { if (bill.getBillNumber() == null || bill.getBillNumber() <= 0) {
generateBillNumber(bill); generateBillNumber(bill);
} }
return new PdfPrinter(bill).output(); new PdfPrinter(bill).output(ostream);
} }
private void generateBillNumber(Bill bill) { private void generateBillNumber(Bill bill) {
...@@ -125,6 +130,8 @@ public class BillBean implements BillBeanLocal { ...@@ -125,6 +130,8 @@ public class BillBean implements BillBeanLocal {
@Override @Override
public BillLine addProductToBill(Bill bill, Product product, BigDecimal count) { public BillLine addProductToBill(Bill bill, Product product, BigDecimal count) {
userBean.fatalPermission(Permission.BILL, RolePermission.EXECUTE, "User tried to add a product to bill");
// If bill number > 0 bill has been sent and extra privileges are needed // If bill number > 0 bill has been sent and extra privileges are needed
// to modify. // to modify.
boolean iscurrent = userBean.isCurrentUser(bill.getUser()); boolean iscurrent = userBean.isCurrentUser(bill.getUser());
...@@ -133,6 +140,7 @@ public class BillBean implements BillBeanLocal { ...@@ -133,6 +140,7 @@ public class BillBean implements BillBeanLocal {
userBean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.EXECUTE, "User tried to modify bill ", bill, "without sufficient permissions"); userBean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.EXECUTE, "User tried to modify bill ", bill, "without sufficient permissions");
} }
BillLine line = new BillLine(bill, product.getName(), product.getUnitName(), count, product.getPrice(), product.getVat()); BillLine line = new BillLine(bill, product.getName(), product.getUnitName(), count, product.getPrice(), product.getVat());
line.setLineProduct(product);
billLineFacade.create(line); billLineFacade.create(line);
List<Discount> discounts = productBean.getActiveDiscounts(product, count); List<Discount> discounts = productBean.getActiveDiscounts(product, count);
...@@ -152,17 +160,17 @@ public class BillBean implements BillBeanLocal { ...@@ -152,17 +160,17 @@ public class BillBean implements BillBeanLocal {
@Override @Override
public List<Bill> findAll() { public List<Bill> findAll() {
if (!userBean.hasPermission(Permission.TICKET_SALES, RolePermission.WRITE)) { if (!userBean.hasPermission(Permission.BILL, RolePermission.WRITE)) {
throw new PermissionDeniedException(secubean, userBean.getCurrentUser(), "User tried to list all bills without sufficient permissions"); throw new PermissionDeniedException(secubean, userBean.getCurrentUser(), "User tried to list all bills without sufficient permissions");
} }
return billFacade.findAll(); return billFacade.findAll(eventbean.getCurrentEvent());
} }
@Override @Override
public List<BillSummary> getBillLineSummary() { public Collection<BillSummary> getBillLineSummary() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "User tried to view the bill summary"); userBean.fatalPermission(Permission.BILL, RolePermission.READ, "User tried to view the bill summary");
List<BillSummary> ret = billLineFacade.getLineSummary(); Collection<BillSummary> ret = billLineFacade.getLineSummary(eventbean.getCurrentEvent());
for (BillSummary foo : ret) { for (BillSummary foo : ret) {
logger.debug("linesum {}", foo); logger.debug("linesum {}", foo);
} }
...@@ -171,6 +179,8 @@ public class BillBean implements BillBeanLocal { ...@@ -171,6 +179,8 @@ public class BillBean implements BillBeanLocal {
@Override @Override
public void markPaid(Bill bill, Calendar when) { public void markPaid(Bill bill, Calendar when) {
userBean.fatalPermission(Permission.BILL, RolePermission.WRITE, "User tried to mark the bill paid");
Product creditproduct = productBean.findCreditProduct(); Product creditproduct = productBean.findCreditProduct();
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), bill.getUser()); AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), bill.getUser());
...@@ -181,8 +191,23 @@ public class BillBean implements BillBeanLocal { ...@@ -181,8 +191,23 @@ public class BillBean implements BillBeanLocal {
bill.setAccountEvent(ac); bill.setAccountEvent(ac);
bill.setPaidDate(when); bill.setPaidDate(when);
billFacade.merge(bill); billFacade.merge(bill);
} for (BillLine bl : bill.getBillLines()) {
Product prod = bl.getLineProduct();
if (prod != null) {
if (prod.isPrepaidInstant()) {
logger.debug("Creating Bill prepaidInstant product {}, {}", prod.getName(), bl.getQuantity());
if (prod.getPlaces().size() > 0) {
placebean.lockPlaces(bill.getUser(), prod, bl.getQuantity());
}
productBean.createAccountEvent(prod, bl.getQuantity(), bill.getUser());
}
}
}
}
} }
...@@ -27,14 +27,14 @@ public class EventMapBean implements EventMapBeanLocal { ...@@ -27,14 +27,14 @@ public class EventMapBean implements EventMapBeanLocal {
@Override @Override
public EventMap saveMap(EventMap eventmap) { public EventMap saveMap(EventMap eventmap) {
userbean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE); userbean.fatalPermission(Permission.MAP, RolePermission.WRITE);
return eventmapfacade.merge(eventmap); return eventmapfacade.merge(eventmap);
} }
@Override @Override
public EventMap create(String mapname) { public EventMap create(String mapname) {
userbean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE); userbean.fatalPermission(Permission.MAP, RolePermission.WRITE);
EventMap ret = new EventMap(eventbean.getCurrentEvent()); EventMap ret = new EventMap(eventbean.getCurrentEvent());
ret.setName(mapname); ret.setName(mapname);
LanEvent event = eventbean.getCurrentEvent(); LanEvent event = eventbean.getCurrentEvent();
...@@ -46,7 +46,7 @@ public class EventMapBean implements EventMapBeanLocal { ...@@ -46,7 +46,7 @@ public class EventMapBean implements EventMapBeanLocal {
@Override @Override
public void sendImage(int destId, byte[] imagedata) { public void sendImage(int destId, byte[] imagedata) {
userbean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE); userbean.fatalPermission(Permission.MAP, RolePermission.WRITE);
LanEvent event = eventbean.getCurrentEvent(); LanEvent event = eventbean.getCurrentEvent();
EventMap map = eventmapfacade.find(event.getId(), destId); EventMap map = eventmapfacade.find(event.getId(), destId);
if (map != null) { if (map != null) {
......
...@@ -37,7 +37,6 @@ import javax.persistence.RollbackException; ...@@ -37,7 +37,6 @@ import javax.persistence.RollbackException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* *
* @author tuukka * @author tuukka
...@@ -72,7 +71,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -72,7 +71,7 @@ public class PlaceBean implements PlaceBeanLocal {
@Override @Override
public Place mergeChanges(Place place) { public Place mergeChanges(Place place) {
userbean.fatalPermission(Permission.TICKET_SALES, RolePermission.EXECUTE, "User tried to modify place ", place); userbean.fatalPermission(Permission.MAP, RolePermission.WRITE, "User tried to modify place ", place);
return placeFacade.merge(place); return placeFacade.merge(place);
} }
...@@ -117,13 +116,6 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -117,13 +116,6 @@ public class PlaceBean implements PlaceBeanLocal {
} }
//
// @Override
// public List<Place> findPlaces(List<Integer> placeIds) {
//
// return placeFacade.find(eventBean.getCurrentEvent(), placeIds);
// }
// TODO: Kantakysely tähän! // TODO: Kantakysely tähän!
@Override @Override
public Place findPlace(EventMap e, int x, int y) { public Place findPlace(EventMap e, int x, int y) {
...@@ -132,13 +124,13 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -132,13 +124,13 @@ public class PlaceBean implements PlaceBeanLocal {
return place; return place;
} }
} }
return null; return null;
} }
@Override @Override
public boolean reservePlace(Place p, User user) { public boolean reservePlace(Place p, User user) {
userbean.fatalPermission(Permission.MAP, RolePermission.EXECUTE, "User does not have rights to reserve ( and buy) a place");
boolean ret = placeFacade.reservePlace(p, user); boolean ret = placeFacade.reservePlace(p, user);
boolean foundTimeout = false; boolean foundTimeout = false;
...@@ -174,6 +166,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -174,6 +166,7 @@ public class PlaceBean implements PlaceBeanLocal {
@Override @Override
public boolean buySelectedPlaces(EventMap e) throws BortalCatchableException { public boolean buySelectedPlaces(EventMap e) throws BortalCatchableException {
userbean.fatalPermission(Permission.MAP, RolePermission.EXECUTE, "User does not have rights to reserve ( and buy) a place");
User user = userbean.getCurrentUser(); User user = userbean.getCurrentUser();
List<Place> places = placeFacade.findUsersReservations(e, user); List<Place> places = placeFacade.findUsersReservations(e, user);
...@@ -202,6 +195,30 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -202,6 +195,30 @@ public class PlaceBean implements PlaceBeanLocal {
return true; return true;
} }
@Override
public void lockPlaces(User user, Product prod, BigDecimal quantity) {
BigDecimal loop = BigDecimal.ZERO;
PlaceGroup pg = pgbean.createPlaceGroup(user);
for (Place p : prod.getPlaces()) {
if (!p.isTaken()) {
p.reserve(user);
p.buy(pg);
placeFacade.merge(p);
pgbean.createGroupMembership(pg, p);
loop = loop.add(BigDecimal.ONE);
if (loop.compareTo(quantity) >= 0) {
break;
}
}
}
}
@Override
public int setBuyable(EventMap map, String like, boolean b) {
userbean.fatalPermission(Permission.MAP, RolePermission.WRITE, "User tried to change place buyable: " + like + " to " + b);
return placeFacade.setBuyable(map, like, b);
}
} }
...@@ -71,7 +71,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -71,7 +71,7 @@ public class ProductBean implements ProductBeanLocal {
public List<Product> getProducts() { public List<Product> getProducts() {
userbean.fatalPermission(Permission.PRODUCT, RolePermission.READ, "User tried to fetch all products"); userbean.fatalPermission(Permission.PRODUCT, RolePermission.READ, "User tried to fetch all products");
return productFacade.findAll(); return productFacade.findAll(eventBean.getCurrentEvent());
} }
@Override @Override
...@@ -124,17 +124,20 @@ public class ProductBean implements ProductBeanLocal { ...@@ -124,17 +124,20 @@ public class ProductBean implements ProductBeanLocal {
} }
AccountEvent ret = new AccountEvent(eventBean.getCurrentEvent(), user, product, unitPrice, quantity, Calendar.getInstance()); AccountEvent ret = new AccountEvent(eventBean.getCurrentEvent(), user, product, unitPrice, quantity, Calendar.getInstance());
ret.setUser(user);
ret.setDelivered(Calendar.getInstance()); ret.setDelivered(Calendar.getInstance());
ret.setSeller(userbean.getCurrentUser()); ret.setSeller(userbean.getCurrentUser());
accounteventfacade.create(ret); // user.getAccountEvents().add(ret);
accounteventfacade.create(ret);
LanEvent event = eventBean.getCurrentEvent(); LanEvent event = eventBean.getCurrentEvent();
// List<DiscountInstance> discountsArray = ret.getDiscountInstances();
for (Discount d : discounts) { for (Discount d : discounts) {
DiscountInstance discInst = new DiscountInstance(event, ret, d); DiscountInstance discInst = new DiscountInstance(event, ret, d);
discountinstancefacade.create(discInst); // discountsArray.add(discInst);
discountinstancefacade.create(discInst);
} }
// userbean.mergeChanges(user);
accounteventfacade.evict(ret); accounteventfacade.evict(ret);
userFacade.evict(user); userFacade.evict(user);
......
...@@ -258,7 +258,7 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -258,7 +258,7 @@ public class TestDataBean implements TestDataBeanLocal {
public void printPlacesInfo() { public void printPlacesInfo() {
logger.debug("Fetching places"); logger.debug("Fetching places");
List<Place> places = placeFacade.findAll(); List<Place> places = placeFacade.findAll(eventBean.getCurrentEvent());
logger.debug("Got places: {}", places); logger.debug("Got places: {}", places);
logger.info("Printing info from places"); logger.info("Printing info from places");
for (Place place : places) { for (Place place : places) {
......
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.math.BigDecimal;
import java.security.Principal; import java.security.Principal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -22,22 +19,18 @@ import javax.persistence.PersistenceContext; ...@@ -22,22 +19,18 @@ import javax.persistence.PersistenceContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.sun.xml.internal.xsom.impl.scd.Iterators.Map;
import fi.insomnia.bortal.enums.Permission; import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission; import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.exceptions.PermissionDeniedException; import fi.insomnia.bortal.exceptions.PermissionDeniedException;
import fi.insomnia.bortal.facade.RoleFacade; import fi.insomnia.bortal.facade.RoleFacade;
import fi.insomnia.bortal.facade.UserFacade; import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.facade.UserImageFacade; import fi.insomnia.bortal.facade.UserImageFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.Role; import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.RoleRight; import fi.insomnia.bortal.model.RoleRight;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.model.UserImage; import fi.insomnia.bortal.model.UserImage;
import fi.insomnia.bortal.utilities.BortalLocalContextHolder; import fi.insomnia.bortal.utilities.BortalLocalContextHolder;
import fi.insomnia.bortal.utilities.I18n;
/** /**
* Session Bean implementation class UserBean * Session Bean implementation class UserBean
...@@ -71,6 +64,8 @@ public class UserBean implements UserBeanLocal { ...@@ -71,6 +64,8 @@ public class UserBean implements UserBeanLocal {
private UserImageFacade userimagefacade; private UserImageFacade userimagefacade;
@EJB @EJB
private ProductBeanLocal productBean; private ProductBeanLocal productBean;
@EJB
private UtilBeanLocal utilbean;
/** /**
* Default constructor. * Default constructor.
...@@ -154,22 +149,9 @@ public class UserBean implements UserBeanLocal { ...@@ -154,22 +149,9 @@ public class UserBean implements UserBeanLocal {
List<Role> rolelist = rolefacade.findForUser(user, eventBean.getCurrentEvent()); List<Role> rolelist = rolefacade.findForUser(user, eventBean.getCurrentEvent());
ret = getRights(rolelist, target, permission, checkedRoles); ret = getRights(rolelist, target, permission, checkedRoles);
} }
// logger.debug("Perm {} not found from cache. saving to cache: {}", BortalLocalContextHolder.setPermission(target, permission, ret);
// target, ret);
BortalLocalContextHolder.setPermission(target, permission, ret);
} }
// else {
// logger.debug("VALUE {} perm {} from cache: {}", new Object[] {
// target, permission, ret });
// }
// if (logger.isDebugEnabled()) {
// long diffMs = Calendar.getInstance().getTimeInMillis() -
// start.getTimeInMillis();
// logger.debug("User {} Target {}, permission {} checktime {}ms result: {}",
// new Object[] { user.getLogin(), target, permission, diffMs, ret
// });
// }
// TODO: FIX THIS!! really bad idea.... // TODO: FIX THIS!! really bad idea....
if (user.isSuperadmin()) { if (user.isSuperadmin()) {
...@@ -184,9 +166,11 @@ public class UserBean implements UserBeanLocal { ...@@ -184,9 +166,11 @@ public class UserBean implements UserBeanLocal {
return false; return false;
} }
for (Role role : roles) { for (Role role : roles) {
if (role == null) { if (role == null) {
continue; continue;
} }
logger.debug("Checking role permission {}", role.getName());
for (RoleRight rr : role.getRoleRights()) { for (RoleRight rr : role.getRoleRights()) {
BortalLocalContextHolder.setPermission(rr); BortalLocalContextHolder.setPermission(rr);
Boolean hasright = BortalLocalContextHolder.hasPermission(expectedRight, permission); Boolean hasright = BortalLocalContextHolder.hasPermission(expectedRight, permission);
...@@ -287,6 +271,42 @@ public class UserBean implements UserBeanLocal { ...@@ -287,6 +271,42 @@ public class UserBean implements UserBeanLocal {
return user; return user;
} }
@Override
public User findPasswordResetUser(Integer id, String hash) {
User ret = null;
if (id != null && hash != null && id > 0 && !hash.isEmpty()) {
User user = userFacade.find(id);
if (user != null && hash.equals(user.getConfirmHash())) {
ret = user;
}
}
return ret;
}
@Override
public boolean resetPassword(User user, String password, String hash) {
User nuser = userFacade.find(user.getId());
if (user.equals(nuser) && hash.equals(nuser.getConfirmHash())) {
logger.debug("Changing user {} password with confirmhash {}", user, hash);
nuser.setConfirmHash(null);
nuser.resetPassword(password);
userFacade.merge(nuser);
return true;
}
return false;
}
@Override
public boolean initPasswordReset(User user, String hash, String mailpath) {
logger.debug("sending mail! user {} hash {} path {}", new Object[] { user, hash, mailpath });
if (hash == null || hash.length() < 20 || user == null || user.getEmail() == null || user.getEmail().length() <= 5) {
return false;
}
utilbean.sendMail(user, I18n.get("passwordreset.mailSubject"), I18n.get("passwordreset.mailBody", mailpath));
user.setConfirmHash(hash);
userFacade.merge(user);
return true;
}
} }
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.io.UnsupportedEncodingException;
import javax.annotation.Resource;
import javax.ejb.Local;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit; import javax.persistence.PersistenceUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.utilities.I18n;
/** /**
* Session Bean implementation class UtilBean * Session Bean implementation class UtilBean
*/ */
@Stateless @Stateless
@Local
public class UtilBean implements UtilBeanLocal { public class UtilBean implements UtilBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(UtilBean.class);
@Resource(name = "mail/lanbortal")
private Session mailSession;
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
@PersistenceUnit @PersistenceUnit
private EntityManagerFactory emf; private EntityManagerFactory emf;
/** /**
* Default constructor. * Default constructor.
*/ */
public UtilBean() { public UtilBean() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
//
// public void reindexCompass()
// {
// JpaCompassGps gps = EclipseLinkHelper.getCompassGps(emf);
//// JpaCompassGps gps = EclipseLinkHelper.getCompassGps(em);
// gps.index();
// }
@Override
public boolean sendMail(User user, String subject, String message) {
boolean ret = true;
Message msg = new MimeMessage(mailSession);
try {
msg.setSubject(subject);
msg.setFrom(new InternetAddress("info@insomnia.fi", "Insomnia lippukauppa"));
msg.setRecipient(RecipientType.TO, new InternetAddress(user.getEmail(),
user.getFirstnames() + " " + user.getLastname()));
msg.setText(message);
Transport.send(msg);
} catch (MessagingException me) {
logger.info("Error sending email!", me);
ret = false;
} catch (UnsupportedEncodingException uee) {
logger.info("Error sending email!", uee);
ret = false;
}
return ret;
}
} }
package fi.insomnia.bortal.beans.flash;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.utilities.apachecodec.binary.Base64;
/**
* Session Bean implementation class FlashMapBean
*/
@Stateless
public class FlashMapBean implements FlashMapBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(FlashMapBean.class);
@EJB
private EventFacade eventFacade;
@EJB
private EventMapFacade mapFacade;
@PersistenceUnit
private EntityManagerFactory emf;
@EJB
private EventBeanLocal eventbean;
@Inject @Any
Event<TestStr> greetingEvent;
public String testString(String foo)
{
logger.info("Received string {} from flash",foo );
greetingEvent.fire(new TestStr("foo1"));
return "Testinimi1";
}
public void log(Object o)
{
logger.debug("Flash {}", o);
}
public byte[] getMapBackground(Integer mapId) {
LanEvent event = eventbean.getCurrentEvent();
logger.debug("Fetching data with eventid {}, mapid {}", event, mapId);
EntityManager em = emf.createEntityManager();
EventMap map = em.find(EventMap.class, new EventPk(event.getId(), mapId));
logger.debug("Got map: {}", map);
return Base64.decodeBase64(map.getMapData());
}
public List<Place> getMapPlaces(Integer mapId) {
LanEvent event = eventbean.getCurrentEvent();
eventbean.getCurrentEvent();
EventMap map = mapFacade.getMapById(event.getId(), mapId);
List<Place> retplace = map.getPlaces();
retplace.size();
return retplace;
// List<PlaceWrapper> ret = new ArrayList<PlaceWrapper>();
// for (Place p : retplace) {
// ret.add(new PlaceWrapper(p));
// }
// logger.debug("Returning {} places to flash.", ret.size());
// return ret;
}
}
package fi.insomnia.bortal.beans.flash;
import javax.ejb.Stateless;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RemoteDestination
@TideEnabled
@Stateless
public class HelloWorldBean implements HelloWorldBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(HelloWorldBean.class);
public String hello(String name) {
logger .info("Called hello from helloworld!");
return "hello from Bean" + name;
}
}
\ No newline at end of file
package fi.insomnia.bortal.beans.flash;
public class MapTest {
}
package fi.insomnia.bortal.beans.flash;
import javax.ejb.Local;
import javax.ejb.Stateless;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author tuomari
*
*The flash user interface sends log messages to the backend via this class.
*/
@Stateless
@RemoteDestination
@TideEnabled
public class RemoteLogger implements RemoteLoggerLocal{
private static final String PREPEND = "FLASH: ";
private static final Logger logger = LoggerFactory.getLogger(RemoteLogger.class);
public void debug(String msg) {
logger.debug(PREPEND+msg);
}
public void error(String msg) {
logger.error(PREPEND+msg);
}
public void info(String msg) {
logger.info(PREPEND+msg);
}
public void warn(String msg) {
logger.warn(PREPEND+msg);
}
}
...@@ -49,9 +49,9 @@ public class PdfPrinter { ...@@ -49,9 +49,9 @@ public class PdfPrinter {
bill = printable; bill = printable;
} }
public ByteArrayOutputStream output() { public void output(OutputStream ostream) {
try { try {
pdf = new PDF(); pdf = new PDF(ostream);
page = new Page(pdf, A4.PORTRAIT); page = new Page(pdf, A4.PORTRAIT);
...@@ -59,19 +59,18 @@ public class PdfPrinter { ...@@ -59,19 +59,18 @@ public class PdfPrinter {
drawHeader(); drawHeader();
drawProducts(bill.getBillLines()); drawProducts(bill.getBillLines());
pankkisiirto(); pankkisiirto();
pdf.flush();
pdf.wrap(); // pdf.wrap();
// String fileName = "/Users/tuomari/Example_01.pdf"; // String fileName = "/Users/tuomari/Example_01.pdf";
// FileOutputStream fos = new FileOutputStream(fileName); // FileOutputStream fos = new FileOutputStream(fileName);
// pdf.getData().writeTo(fos); // pdf.getData().writeTo(fos);
// fos.close(); // fos.close();
return pdf.getData(); // return pdf.getData();
} catch (Exception e) { } catch (Exception e) {
logger.warn("Error printing bill " + bill + " to stream", e); logger.warn("Error printing bill " + bill + " to stream", e);
} }
return null;
} }
private void drawProducts(List<BillLine> prods) throws Exception { private void drawProducts(List<BillLine> prods) throws Exception {
...@@ -199,13 +198,12 @@ public class PdfPrinter { ...@@ -199,13 +198,12 @@ public class PdfPrinter {
drawText(355, 805, DATE_FORMAT.format(bill.getSentDate().getTime()), infofont); drawText(355, 805, DATE_FORMAT.format(bill.getSentDate().getTime()), infofont);
drawText(442, 812, "Eräpäivä", descriptionfont); drawText(442, 812, "Eräpäivä", descriptionfont);
drawText(485, 805, DATE_FORMAT.format(bill.getDueDate().getTime()), infofont); drawText(485, 805, DATE_FORMAT.format(bill.getDueDate().getTime()), infofont);
drawText(302, 772, "Maksuehdot", descriptionfont); drawText(302, 772, "Maksuehdot", descriptionfont);
String paystr = "Heti"; String paystr = "Heti";
if(bill.getPaymentTime() > 0) if (bill.getPaymentTime() > 0) {
{
paystr = bill.getPaymentTime() + " pv Netto"; paystr = bill.getPaymentTime() + " pv Netto";
} }
drawText(355, 765, paystr, infofont); drawText(355, 765, paystr, infofont);
...@@ -213,9 +211,10 @@ public class PdfPrinter { ...@@ -213,9 +211,10 @@ public class PdfPrinter {
drawText(442, 792, "Laskun numero", descriptionfont); drawText(442, 792, "Laskun numero", descriptionfont);
drawText(510, 785, bill.getBillNumber().toString(), infofont); drawText(510, 785, bill.getBillNumber().toString(), infofont);
/* drawText(442, 772, "Huomautusaika", descriptionfont); /*
drawText(510, 765, bill.getNoticetime(), infofont); * drawText(442, 772, "Huomautusaika", descriptionfont); drawText(510,
*/ * 765, bill.getNoticetime(), infofont);
*/
drawText(302, 792, "Viitenumero", descriptionfont); drawText(302, 792, "Viitenumero", descriptionfont);
drawText(355, 785, BillUtils.createReferenceNumber(bill.getReferenceNumberBase()).toString(), infofont); drawText(355, 785, BillUtils.createReferenceNumber(bill.getReferenceNumberBase()).toString(), infofont);
...@@ -243,10 +242,10 @@ public class PdfPrinter { ...@@ -243,10 +242,10 @@ public class PdfPrinter {
drawText(302, 672, "Yhteensä", descriptionfont); drawText(302, 672, "Yhteensä", descriptionfont);
drawText(355, 665, decRound(bill.totalPrice()) + EURO, infofont); drawText(355, 665, decRound(bill.totalPrice()) + EURO, infofont);
/* /*
drawText(472, 672, "Viivästyskorko", descriptionfont); * drawText(472, 672, "Viivästyskorko", descriptionfont); drawText(530,
drawText(530, 665, bill.getDelayIntrest() + "%", infofont); * 665, bill.getDelayIntrest() + "%", infofont);
*/ */
// drawText( 490, 665, "ALV Rek.",'mediumTeksti'); // drawText( 490, 665, "ALV Rek.",'mediumTeksti');
// Alkuosa loppuu // Alkuosa loppuu
......
package fi.insomnia.bortal.facade; package fi.insomnia.bortal.facade;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
...@@ -11,8 +14,12 @@ import javax.persistence.PersistenceContext; ...@@ -11,8 +14,12 @@ import javax.persistence.PersistenceContext;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.bortal.views.BillSummary; import fi.insomnia.bortal.bortal.views.BillSummary;
import fi.insomnia.bortal.model.BillLine; import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.LanEvent;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -21,6 +28,7 @@ public class BillLineFacade extends EventChildGenericFacade<BillLine> { ...@@ -21,6 +28,7 @@ public class BillLineFacade extends EventChildGenericFacade<BillLine> {
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
private static final Logger logger = LoggerFactory.getLogger(BillLineFacade.class);
@EJB @EJB
private BillFacade billfacade; private BillFacade billfacade;
...@@ -33,16 +41,20 @@ public class BillLineFacade extends EventChildGenericFacade<BillLine> { ...@@ -33,16 +41,20 @@ public class BillLineFacade extends EventChildGenericFacade<BillLine> {
billfacade.evict(entity.getBill()); billfacade.evict(entity.getBill());
} }
public List<BillSummary> getLineSummary() { public Collection<BillSummary> getLineSummary(LanEvent event) {
TypedQuery<Object[]> q = em.createQuery("SELECT l.name as name, sum(l.quantity) as total from BillLine l GROUP BY l.name", Object[].class); List<BillLine> lines = findAll(event);
Map<String, BillSummary> retmap = new HashMap<String, BillSummary>();
List<Object[]> objlist = q.getResultList();
List<BillSummary> ret = new ArrayList<BillSummary>();
for(Object[] obj:objlist) for(BillLine bl:lines)
{ {
ret.add(new BillSummary(obj)); if(!retmap.containsKey(bl.getName()))
} {
return ret; retmap.put(bl.getName(), new BillSummary(bl.getName()));
}
retmap.get(bl.getName()).addLine(bl);
}
return retmap.values();
} }
protected EntityManager getEm() { protected EntityManager getEm() {
......
...@@ -73,17 +73,19 @@ public abstract class EventChildGenericFacade<T extends EventChildInterface> { ...@@ -73,17 +73,19 @@ public abstract class EventChildGenericFacade<T extends EventChildInterface> {
return ret; return ret;
} }
public List<T> findAll() { public List<T> findAll(LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(getEntityClass()); CriteriaQuery<T> cq = cb.createQuery(getEntityClass());
Root<T> root = cq.from(getEntityClass()); Root<T> root = cq.from(getEntityClass());
cq.where(cb.equal(root.get("id").get("eventId"), event.getId()));
cq.orderBy(cb.asc(root.get("id").get("id"))); cq.orderBy(cb.asc(root.get("id").get("id")));
cq.select(cq.from(getEntityClass()));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
public List<T> findRange(int[] range) { public List<T> findRange(LanEvent event, int[] range) {
CriteriaQuery<T> cq = getEm().getCriteriaBuilder().createQuery(getEntityClass()); CriteriaQuery<T> cq = getEm().getCriteriaBuilder().createQuery(getEntityClass());
cq.select(cq.from(getEntityClass())); cq.select(cq.from(getEntityClass()));
TypedQuery<T> q = getEm().createQuery(cq); TypedQuery<T> q = getEm().createQuery(cq);
...@@ -92,14 +94,7 @@ public abstract class EventChildGenericFacade<T extends EventChildInterface> { ...@@ -92,14 +94,7 @@ public abstract class EventChildGenericFacade<T extends EventChildInterface> {
return q.getResultList(); return q.getResultList();
} }
public long count() {
CriteriaQuery<Long> cq = getEm().getCriteriaBuilder().createQuery(Long.class);
Root<T> rt = cq.from(getEntityClass());
cq.select(getEm().getCriteriaBuilder().count(rt));
TypedQuery<Long> q = getEm().createQuery(cq);
return q.getSingleResult();
}
protected static <K> K getSingleNullableResult(TypedQuery<K> q) { protected static <K> K getSingleNullableResult(TypedQuery<K> q) {
K ret = null; K ret = null;
try { try {
......
package fi.insomnia.bortal.facade; package fi.insomnia.bortal.facade;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -13,6 +15,7 @@ import org.slf4j.LoggerFactory; ...@@ -13,6 +15,7 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place; import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
@Stateless @Stateless
...@@ -74,6 +77,7 @@ public class PlaceFacade extends EventChildGenericFacade<Place> { ...@@ -74,6 +77,7 @@ public class PlaceFacade extends EventChildGenericFacade<Place> {
return updated; return updated;
} }
public Long countSelectable(EventMap map) { public Long countSelectable(EventMap map) {
if (map == null) { if (map == null) {
...@@ -110,4 +114,14 @@ public class PlaceFacade extends EventChildGenericFacade<Place> { ...@@ -110,4 +114,14 @@ public class PlaceFacade extends EventChildGenericFacade<Place> {
logger.debug("Released {} places from user {}", updated, user); logger.debug("Released {} places from user {}", updated, user);
} }
public int setBuyable(EventMap map, String like, boolean b) {
Query q = em.createQuery("UPDATE Place p set p.buyable = :b where p.name like :like");
q.setParameter("b", b);
q.setParameter("like", like);
return q.executeUpdate();
}
} }
...@@ -47,13 +47,11 @@ public class RoleFacade extends EventChildGenericFacade<Role> { ...@@ -47,13 +47,11 @@ public class RoleFacade extends EventChildGenericFacade<Role> {
public Collection<Role> findAllParentsExcluding(Collection<Role> roles, Collection<Role> excludedResults) { public Collection<Role> findAllParentsExcluding(Collection<Role> roles, Collection<Role> excludedResults) {
Set<Role> ret = new HashSet<Role>(); Set<Role> ret = new HashSet<Role>();
for (Role r : roles) { for (Role r : roles) {
if (!excludedResults.contains(r)) { ret.addAll(r.getParents());
ret.addAll(r.getParents());
}
} }
ret.removeAll(excludedResults); ret.removeAll(excludedResults);
return ret; return ret;
} }
......
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.List; import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
...@@ -17,7 +19,6 @@ public interface BillBeanLocal { ...@@ -17,7 +19,6 @@ public interface BillBeanLocal {
Bill findById( int id); Bill findById( int id);
ByteArrayOutputStream getPdfBillStream(Bill bill);
Bill createEmptyBill(User shoppingUser); Bill createEmptyBill(User shoppingUser);
...@@ -25,11 +26,13 @@ public interface BillBeanLocal { ...@@ -25,11 +26,13 @@ public interface BillBeanLocal {
List<Bill> findAll(); List<Bill> findAll();
List<BillSummary> getBillLineSummary(); Collection<BillSummary> getBillLineSummary();
void markPaid(Bill bill, Calendar when); void markPaid(Bill bill, Calendar when);
void getPdfBillStream(Bill bill, OutputStream ostream);
} }
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.exceptions.BortalCatchableException; import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
...@@ -14,16 +15,12 @@ import fi.insomnia.bortal.model.Place; ...@@ -14,16 +15,12 @@ import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.Product; import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import javax.ejb.Local;
import org.granite.messaging.service.annotations.RemoteDestination;
/** /**
* *
* @author tuukka * @author tuukka
*/ */
@Local @Local
@RemoteDestination //@RemoteDestination
public interface PlaceBeanLocal { public interface PlaceBeanLocal {
Place mergeChanges(Place place); Place mergeChanges(Place place);
...@@ -40,6 +37,8 @@ public interface PlaceBeanLocal { ...@@ -40,6 +37,8 @@ public interface PlaceBeanLocal {
boolean buySelectedPlaces(EventMap e) throws BortalCatchableException; boolean buySelectedPlaces(EventMap e) throws BortalCatchableException;
void lockPlaces(User user, Product prod, BigDecimal quantity);
int setBuyable(EventMap map, String buyableLike, boolean b);
} }
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
import org.granite.messaging.service.annotations.RemoteDestination;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
@Local @Local
@RemoteDestination
public interface PlaceMapBeanLocal { public interface PlaceMapBeanLocal {
// public String getSelectPlaceMapUrl(EventMap activeMap, List<Place> selectedPlaces, User user); // public String getSelectPlaceMapUrl(EventMap activeMap, List<Place> selectedPlaces, User user);
......
...@@ -44,4 +44,10 @@ public interface UserBeanLocal { ...@@ -44,4 +44,10 @@ public interface UserBeanLocal {
User createNewUser(User user, String password); User createNewUser(User user, String password);
User findPasswordResetUser(Integer id, String hash);
boolean resetPassword(User user, String password, String hash);
boolean initPasswordReset(User user, String hash, String mailpath);
} }
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
@Local
public interface UtilBeanLocal {
}
package fi.insomnia.bortal.beans.flash;
import java.util.List;
import javax.ejb.Local;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled;
import fi.insomnia.bortal.model.Place;
@Local
@RemoteDestination
public interface FlashMapBeanLocal {
byte[] getMapBackground(Integer mapId);
List<Place> getMapPlaces(Integer mapId);
String testString(String foo);
void log(Object o);
}
package fi.insomnia.bortal.beans.flash;
import javax.ejb.Local;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled;
import org.granite.tide.data.DataEnabled;
import org.granite.tide.data.DataEnabled.PublishMode;
@Local
@RemoteDestination
@DataEnabled(topic="helloTopic", params=ObserveAllPublishAll.class, publish=PublishMode.ON_SUCCESS)
@TideEnabled
public interface HelloWorldBeanLocal {
String hello(String name);
}
/*
GRANITE DATA SERVICES
Copyright (C) 2007 ADEQUATE SYSTEMS SARL
This file is part of Granite Data Services.
Granite Data Services is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
Granite Data Services is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
package fi.insomnia.bortal.beans.flash;
import org.granite.tide.data.DataObserveParams;
import org.granite.tide.data.DataPublishParams;
import org.granite.tide.data.DataTopicParams;
public class ObserveAllPublishAll implements DataTopicParams {
@Override
public void observes(DataObserveParams params) {
}
@Override
public void publishes(DataPublishParams params, Object entity) {
}
}
\ No newline at end of file
package fi.insomnia.bortal.beans.flash;
import javax.ejb.Local;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled;
@Local
@RemoteDestination
@TideEnabled
public interface RemoteLoggerLocal {
void debug(String msg);
void error(String msg);
void info(String msg);
void warn(String msg);
}
...@@ -2,33 +2,35 @@ package fi.insomnia.bortal.bortal.views; ...@@ -2,33 +2,35 @@ package fi.insomnia.bortal.bortal.views;
import java.math.BigDecimal; import java.math.BigDecimal;
import fi.insomnia.bortal.model.BillLine;
public class BillSummary { public class BillSummary {
public BillSummary(String name) {
public BillSummary(Object[] o) { this.name = name;
name = o[0].toString();
total = (BigDecimal) o[1];
} }
private String name; private String name;
private BigDecimal total; private BigDecimal total = BigDecimal.ZERO;
private BigDecimal paid = BigDecimal.ZERO;
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) {
this.name = name;
}
public BigDecimal getTotal() { public BigDecimal getTotal() {
return total; return total;
} }
public void setTotal(BigDecimal total) { public void addLine(BillLine bl) {
this.total = total; total = getTotal().add(bl.getQuantity());
if (bl.getBill().getPaidDate() != null) {
paid = getPaid().add(bl.getQuantity());
}
}
public BigDecimal getPaid() {
return paid;
} }
} }
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/LanBortal/ExtraLibs/granite.jar"/> <classpathentry kind="lib" path="/Users/tuomari/bin/glassfishv31_0507_2/glassfish/modules/org.eclipse.persistence.core.jar" sourcepath="/Users/tuomari/bin/glassfishv31_b16_2010_08_16/glassfish/modules/org.eclipse.persistence.core.jar">
<classpathentry kind="lib" path="/Users/tuomari/bin/glassfishv31_0507_2/glassfish/modules/org.eclipse.persistence.core.jar">
<attributes> <attributes>
<attribute name="javadoc_location" value="jar:file:/Applications/eclipse_Helios_m6/plugins/com.sun.enterprise.jst.server.sunappsrv_1.0.53.jar!/javaee6doc"/> <attribute name="javadoc_location" value="jar:file:/Applications/eclipse_Helios_m6/plugins/com.sun.enterprise.jst.server.sunappsrv_1.0.53.jar!/javaee6doc"/>
</attributes> </attributes>
......
...@@ -17,18 +17,19 @@ public enum Permission { ...@@ -17,18 +17,19 @@ public enum Permission {
// PERMISSION("Description"), // PERMISSION("Description"),
LOGIN("User can see loginbutton(r), create new user(w)"), LOGIN("User can see loginbutton(r), create new user(w)"),
USER_MANAGEMENT("User has right to view all users(r), modify users(w), execute actions for user(x) "), USER_MANAGEMENT("User has right to view all users(r), modify users(w), execute actions for user(x) "),
TICKET_SALES("User has right to view(r), administer(w) and buy(x)"), // TICKET_SALES("User has right to view(r), administer(w) and buy(x)"),
BILL("View bills(r), Mark paid & modify(w), and create (buy) bills (x)"),
MAP("view maps(r), Modify(w), reserve places from maps(x)"),
ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"), ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"),
PRODUCT("View(r), modify(w), and shop(x) products"), PRODUCT("View(r), modify(w), and shop(x) products"),
SHOP("View shopped events(r), Modify AccountEvents() and Shop(x)") SHOP("View shopped events(r), Modify AccountEvents() and Shop(x)");
;
private String description; private String description;
private static final Logger logger = LoggerFactory.getLogger(Permission.class); private static final Logger logger = LoggerFactory.getLogger(Permission.class);
public static Permission getPermission(String name) { public static Permission getPermission(String name) {
if (name == null || name.isEmpty()) if (name == null || name.isEmpty()) {
{ logger.warn("Trying to get permission for empty name {}", name);
logger.warn("Trying to get permission for empty name {}" , name);
return null; return null;
} }
try { try {
...@@ -45,10 +46,10 @@ public enum Permission { ...@@ -45,10 +46,10 @@ public enum Permission {
Permission() { Permission() {
} }
public String getName() public String getName() {
{
return name(); return name();
} }
/** /**
* @return the description * @return the description
*/ */
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns; import javax.persistence.JoinColumns;
...@@ -23,8 +23,6 @@ import javax.persistence.OneToOne; ...@@ -23,8 +23,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Version;
/** /**
* Account event contains the money / credit traffic for the user. Each row * Account event contains the money / credit traffic for the user. Each row
...@@ -38,12 +36,8 @@ import javax.persistence.Version; ...@@ -38,12 +36,8 @@ import javax.persistence.Version;
@NamedQuery(name = "AccountEvent.findByQuantity", query = "SELECT a FROM AccountEvent a WHERE a.quantity = :units"), @NamedQuery(name = "AccountEvent.findByQuantity", query = "SELECT a FROM AccountEvent a WHERE a.quantity = :units"),
@NamedQuery(name = "AccountEvent.findByEventTime", query = "SELECT a FROM AccountEvent a WHERE a.eventTime = :eventTime"), @NamedQuery(name = "AccountEvent.findByEventTime", query = "SELECT a FROM AccountEvent a WHERE a.eventTime = :eventTime"),
@NamedQuery(name = "AccountEvent.findByDelivered", query = "SELECT a FROM AccountEvent a WHERE a.delivered = :delivered") }) @NamedQuery(name = "AccountEvent.findByDelivered", query = "SELECT a FROM AccountEvent a WHERE a.delivered = :delivered") })
public class AccountEvent implements EventChildInterface { public class AccountEvent extends GenericEventChild {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
/** /**
* What 1 unit of this product costs. * What 1 unit of this product costs.
*/ */
...@@ -108,8 +102,8 @@ public class AccountEvent implements EventChildInterface { ...@@ -108,8 +102,8 @@ public class AccountEvent implements EventChildInterface {
* What discounts user has for this account event. Some magic is applied to * What discounts user has for this account event. Some magic is applied to
* calculate these.. :) * calculate these.. :)
*/ */
@OneToMany(mappedBy = "accountEvent") @OneToMany(mappedBy = "accountEvent", cascade=CascadeType.ALL)
private List<DiscountInstance> discountInstances; private List<DiscountInstance> discountInstances = new ArrayList<DiscountInstance>();
/** /**
* When user has paid a bill a Account event for product "Credit" is created * When user has paid a bill a Account event for product "Credit" is created
...@@ -122,42 +116,16 @@ public class AccountEvent implements EventChildInterface { ...@@ -122,42 +116,16 @@ public class AccountEvent implements EventChildInterface {
return getQuantity().multiply(getUnitPrice()); return getQuantity().multiply(getUnitPrice());
} }
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public AccountEvent() { public AccountEvent() {
} }
public AccountEvent(LanEvent event) { public AccountEvent(LanEvent event) {
this.id = new EventPk(event); setId(new EventPk(event));
} }
public AccountEvent(LanEvent event, User u, Product prod, BigDecimal unitPrice, BigDecimal quantity, Calendar eventTime) {
public AccountEvent(LanEvent event, User u, Product prod, BigDecimal unitPrice, BigDecimal quantity, Calendar eventTime) { setId(new EventPk(event));
this.id = new EventPk(event);
this.setUnitPrice(unitPrice); this.setUnitPrice(unitPrice);
this.setQuantity(quantity); this.setQuantity(quantity);
this.product = prod; this.product = prod;
...@@ -198,31 +166,8 @@ public class AccountEvent implements EventChildInterface { ...@@ -198,31 +166,8 @@ public class AccountEvent implements EventChildInterface {
} }
@Override @Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the
// id fields are
// not set
if (!(object instanceof AccountEvent)) {
return false;
}
AccountEvent other = (AccountEvent) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.AccountEvent[id=" + id + "]"; return "fi.insomnia.bortal.model.AccountEvent[id=" + getId() + "]";
} }
public void setFoodWave(FoodWave foodWave) { public void setFoodWave(FoodWave foodWave) {
......
...@@ -8,6 +8,7 @@ import java.math.BigDecimal; ...@@ -8,6 +8,7 @@ import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
...@@ -25,6 +26,9 @@ import javax.persistence.Temporal; ...@@ -25,6 +26,9 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Version; import javax.persistence.Version;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.PrivateOwned;
import static javax.persistence.TemporalType.DATE; import static javax.persistence.TemporalType.DATE;
/** /**
...@@ -42,16 +46,13 @@ import static javax.persistence.TemporalType.DATE; ...@@ -42,16 +46,13 @@ import static javax.persistence.TemporalType.DATE;
@NamedQuery(name = "Bill.findByPaidDate", query = "SELECT b FROM Bill b WHERE b.paidDate = :paidDate"), @NamedQuery(name = "Bill.findByPaidDate", query = "SELECT b FROM Bill b WHERE b.paidDate = :paidDate"),
@NamedQuery(name = "Bill.findByNotes", query = "SELECT b FROM Bill b WHERE b.notes = :notes"), @NamedQuery(name = "Bill.findByNotes", query = "SELECT b FROM Bill b WHERE b.notes = :notes"),
@NamedQuery(name = "Bill.findbiggestBillNumber", query = "SELECT max(b.billNumber) from Bill b where b.event = :event") }) @NamedQuery(name = "Bill.findbiggestBillNumber", query = "SELECT max(b.billNumber) from Bill b where b.event = :event") })
public class Bill implements EventChildInterface { public class Bill extends GenericEventChild {
/** /**
* *
*/ */
private static final long serialVersionUID = -6713643278149221869L; private static final long serialVersionUID = -6713643278149221869L;
@EmbeddedId
private EventPk id;
/** /**
* When the bill is due to be paid. * When the bill is due to be paid.
*/ */
...@@ -113,13 +114,14 @@ public class Bill implements EventChildInterface { ...@@ -113,13 +114,14 @@ public class Bill implements EventChildInterface {
* Bill may have multiple items on multiple rows. * Bill may have multiple items on multiple rows.
*/ */
@OneToMany(mappedBy = "bill") @OneToMany(mappedBy = "bill", cascade = CascadeType.ALL)
@OrderBy("id.id") @OrderBy("id.id")
@PrivateOwned
private List<BillLine> billLines; private List<BillLine> billLines;
/** /**
* When the bill is paid this AccountEvent is created and this is a * When the bill is paid this AccountEvent is created and this is a
* reference to that accountAction. * reference to that accountAction. if this bill
*/ */
@JoinColumns({ @JoinColumns({
@JoinColumn(name = "account_event_id", referencedColumnName = "id", updatable = false), @JoinColumn(name = "account_event_id", referencedColumnName = "id", updatable = false),
...@@ -183,30 +185,16 @@ public class Bill implements EventChildInterface { ...@@ -183,30 +185,16 @@ public class Bill implements EventChildInterface {
return total; return total;
} }
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public Bill() { public Bill() {
} }
public Bill(LanEvent event) { public Bill(LanEvent event) {
this.id = new EventPk(event); setId(new EventPk(event));
} }
public Bill(LanEvent event, User user) { public Bill(LanEvent event, User user) {
this.id = new EventPk(event); setId(new EventPk(event));
this.setUser(user); this.setUser(user);
this.setAddr1(user.getFirstnames() + " " + user.getLastname()); this.setAddr1(user.getFirstnames() + " " + user.getLastname());
this.setAddr2(user.getAddress()); this.setAddr2(user.getAddress());
...@@ -261,40 +249,8 @@ public class Bill implements EventChildInterface { ...@@ -261,40 +249,8 @@ public class Bill implements EventChildInterface {
} }
@Override @Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Bill)) {
return false;
}
Bill other = (Bill) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Bill[id=" + id + "]"; return "fi.insomnia.bortal.model.Bill[id=" + getId() + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
} }
public LanEvent getEvent() { public LanEvent getEvent() {
......
...@@ -15,6 +15,8 @@ import javax.persistence.JoinColumns; ...@@ -15,6 +15,8 @@ import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Version; import javax.persistence.Version;
...@@ -81,6 +83,13 @@ public class BillLine implements EventChildInterface { ...@@ -81,6 +83,13 @@ public class BillLine implements EventChildInterface {
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField = 0; private int jpaVersionField = 0;
@JoinColumns({
@JoinColumn(name = "lineProduct_id", referencedColumnName = "id", nullable = true, updatable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@OneToOne
@OrderBy("id.id")
private Product lineProduct;
/** /**
* Calculate the total price for the items on this line * Calculate the total price for the items on this line
* *
...@@ -113,9 +122,9 @@ public class BillLine implements EventChildInterface { ...@@ -113,9 +122,9 @@ public class BillLine implements EventChildInterface {
this.bill = bill; this.bill = bill;
} }
public BillLine( Bill bill, String product, String unitName, BigDecimal units, public BillLine(Bill bill, String product, String unitName, BigDecimal units,
BigDecimal unitPrice, BigDecimal vat) { BigDecimal unitPrice, BigDecimal vat) {
this( bill); this(bill);
this.unitName = unitName; this.unitName = unitName;
this.name = product; this.name = product;
this.setQuantity(units); this.setQuantity(units);
...@@ -218,4 +227,12 @@ public class BillLine implements EventChildInterface { ...@@ -218,4 +227,12 @@ public class BillLine implements EventChildInterface {
return unitName; return unitName;
} }
public void setLineProduct(Product lineProduct) {
this.lineProduct = lineProduct;
}
public Product getLineProduct() {
return lineProduct;
}
} }
...@@ -39,6 +39,9 @@ public class CardTemplate implements EventChildInterface { ...@@ -39,6 +39,9 @@ public class CardTemplate implements EventChildInterface {
@Column(name = "template_name", nullable = false) @Column(name = "template_name", nullable = false)
private String name; private String name;
@Column(name="power", nullable=false)
private int power = 0;
@OneToMany(mappedBy = "cardTemplate") @OneToMany(mappedBy = "cardTemplate")
private List<Role> roles; private List<Role> roles;
...@@ -148,4 +151,12 @@ public class CardTemplate implements EventChildInterface { ...@@ -148,4 +151,12 @@ public class CardTemplate implements EventChildInterface {
return event; return event;
} }
public void setPower(int power) {
this.power = power;
}
public int getPower() {
return power;
}
} }
...@@ -25,12 +25,14 @@ import javax.persistence.Temporal; ...@@ -25,12 +25,14 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Version; import javax.persistence.Version;
import org.eclipse.persistence.annotations.PrivateOwned;
/** /**
* *
*/ */
@Entity @Entity
@Table(name = "entries") @Table(name = "entries")
@NamedQueries( { @NamedQueries({
@NamedQuery(name = "CompoEntry.findAll", query = "SELECT c FROM CompoEntry c"), @NamedQuery(name = "CompoEntry.findAll", query = "SELECT c FROM CompoEntry c"),
@NamedQuery(name = "CompoEntry.findByCreated", query = "SELECT c FROM CompoEntry c WHERE c.created = :created"), @NamedQuery(name = "CompoEntry.findByCreated", query = "SELECT c FROM CompoEntry c WHERE c.created = :created"),
@NamedQuery(name = "CompoEntry.findByName", query = "SELECT c FROM CompoEntry c WHERE c.name = :name"), @NamedQuery(name = "CompoEntry.findByName", query = "SELECT c FROM CompoEntry c WHERE c.name = :name"),
...@@ -63,7 +65,7 @@ public class CompoEntry implements EventChildInterface { ...@@ -63,7 +65,7 @@ public class CompoEntry implements EventChildInterface {
@Column(name = "final_position") @Column(name = "final_position")
private Integer finalPosition; private Integer finalPosition;
@JoinColumns( { @JoinColumns({
@JoinColumn(name = "current_file_id", referencedColumnName = "id"), @JoinColumn(name = "current_file_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@OneToOne @OneToOne
...@@ -72,13 +74,14 @@ public class CompoEntry implements EventChildInterface { ...@@ -72,13 +74,14 @@ public class CompoEntry implements EventChildInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "compoEntry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "compoEntry")
private List<Vote> votes; private List<Vote> votes;
@PrivateOwned
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryFile> files; private List<CompoEntryFile> files;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants; private List<CompoEntryParticipant> participants;
@JoinColumns( { @JoinColumns({
@JoinColumn(name = "compo_id", referencedColumnName = "id", nullable = false), @JoinColumn(name = "compo_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false) @ManyToOne(optional = false)
......
...@@ -28,10 +28,8 @@ import javax.persistence.Version; ...@@ -28,10 +28,8 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "discounts") @Table(name = "discounts")
public class Discount implements EventChildInterface { public class Discount extends GenericEventChild {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "percentage", nullable = false, precision = 9, scale = 6) @Column(name = "percentage", nullable = false, precision = 9, scale = 6)
private BigDecimal percentage = BigDecimal.ZERO; private BigDecimal percentage = BigDecimal.ZERO;
...@@ -45,7 +43,7 @@ public class Discount implements EventChildInterface { ...@@ -45,7 +43,7 @@ public class Discount implements EventChildInterface {
@Column(name = "shortdesc") @Column(name = "shortdesc")
private String shortdesc; private String shortdesc;
@Column(name = "amount_min", nullable = false, precision = 24, scale = 4) @Column(name = "amount_min", nullable = false, precision = 24, scale = 4)
private BigDecimal amountMin = BigDecimal.ZERO; private BigDecimal amountMin = BigDecimal.ZERO;
...@@ -81,15 +79,11 @@ public class Discount implements EventChildInterface { ...@@ -81,15 +79,11 @@ public class Discount implements EventChildInterface {
@ManyToMany(mappedBy = "discounts") @ManyToMany(mappedBy = "discounts")
private List<Product> products; private List<Product> products;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public Discount() { public Discount() {
} }
public Discount(LanEvent event) { public Discount(LanEvent event) {
this.id = new EventPk(event); setId(new EventPk(event));
} }
public BigDecimal getAmountMin() { public BigDecimal getAmountMin() {
...@@ -128,16 +122,7 @@ public class Discount implements EventChildInterface { ...@@ -128,16 +122,7 @@ public class Discount implements EventChildInterface {
return active; return active;
} }
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
public String getCode() { public String getCode() {
return code; return code;
} }
...@@ -167,40 +152,8 @@ public class Discount implements EventChildInterface { ...@@ -167,40 +152,8 @@ public class Discount implements EventChildInterface {
} }
@Override @Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Discount)) {
return false;
}
Discount other = (Discount) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Discount[id=" + id + "]"; return "fi.insomnia.bortal.model.Discount[id=" + getId() + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
} }
public void setRole(Role role) { public void setRole(Role role) {
...@@ -211,7 +164,6 @@ public class Discount implements EventChildInterface { ...@@ -211,7 +164,6 @@ public class Discount implements EventChildInterface {
return role; return role;
} }
public void setPercentage(BigDecimal percentage) { public void setPercentage(BigDecimal percentage) {
this.percentage = percentage; this.percentage = percentage;
} }
......
...@@ -67,6 +67,10 @@ public class EventMap implements EventChildInterface { ...@@ -67,6 +67,10 @@ public class EventMap implements EventChildInterface {
@Column(nullable = false) @Column(nullable = false)
private boolean active = true; private boolean active = true;
@Column(name="notes")
@Lob
private String notes;
public EventMap() { public EventMap() {
} }
...@@ -187,6 +191,14 @@ public class EventMap implements EventChildInterface { ...@@ -187,6 +191,14 @@ public class EventMap implements EventChildInterface {
return active; return active;
} }
public void setNotes(String notes) {
this.notes = notes;
}
public String getNotes() {
return notes;
}
} }
...@@ -4,12 +4,10 @@ ...@@ -4,12 +4,10 @@
*/ */
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns; import javax.persistence.JoinColumns;
...@@ -21,7 +19,6 @@ import javax.persistence.OneToOne; ...@@ -21,7 +19,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Version;
/** /**
* *
...@@ -36,7 +33,7 @@ import javax.persistence.Version; ...@@ -36,7 +33,7 @@ import javax.persistence.Version;
@NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"), @NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"),
@NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"), @NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"),
@NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") }) @NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") })
public class Place implements EventChildInterface, Serializable { public class Place extends GenericEventChild {
public static final int RESERVE_MINUTES = 20; public static final int RESERVE_MINUTES = 20;
...@@ -44,8 +41,7 @@ public class Place implements EventChildInterface, Serializable { ...@@ -44,8 +41,7 @@ public class Place implements EventChildInterface, Serializable {
* *
*/ */
private static final long serialVersionUID = -5314851260772328611L; private static final long serialVersionUID = -5314851260772328611L;
@EmbeddedId
private EventPk id;
@Lob @Lob
@Column(name = "place_description") @Column(name = "place_description")
private String description; private String description;
...@@ -69,6 +65,9 @@ public class Place implements EventChildInterface, Serializable { ...@@ -69,6 +65,9 @@ public class Place implements EventChildInterface, Serializable {
private String code = ""; private String code = "";
@OneToOne(mappedBy = "placeReservation") @OneToOne(mappedBy = "placeReservation")
private GroupMembership placeReserver; private GroupMembership placeReserver;
@Column(name = "buyable", nullable = false)
private boolean buyable = true;
/** /**
* Which group has bought the place * Which group has bought the place
*/ */
...@@ -98,16 +97,14 @@ public class Place implements EventChildInterface, Serializable { ...@@ -98,16 +97,14 @@ public class Place implements EventChildInterface, Serializable {
@JoinColumn(name = "current_user_id", referencedColumnName = "user_id") @JoinColumn(name = "current_user_id", referencedColumnName = "user_id")
@ManyToOne @ManyToOne
private User currentUser; private User currentUser;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public Place() { public Place() {
} }
public Place(EventMap eventMap) { public Place(EventMap eventMap) {
this.id = new EventPk(); super();
this.id.setEventId(eventMap.getId().getEventId()); setId(new EventPk());
getId().setEventId(eventMap.getId().getEventId());
this.map = eventMap; this.map = eventMap;
} }
...@@ -199,66 +196,10 @@ public class Place implements EventChildInterface, Serializable { ...@@ -199,66 +196,10 @@ public class Place implements EventChildInterface, Serializable {
} }
@Override @Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Place)) {
return false;
}
Place other = (Place) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Place[id=" + getId() + "]"; return "fi.insomnia.bortal.model.Place[id=" + getId() + "]";
} }
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public void setPlaceReserver(GroupMembership placeReserver) { public void setPlaceReserver(GroupMembership placeReserver) {
this.placeReserver = placeReserver; this.placeReserver = placeReserver;
} }
...@@ -331,7 +272,7 @@ public class Place implements EventChildInterface, Serializable { ...@@ -331,7 +272,7 @@ public class Place implements EventChildInterface, Serializable {
* @return true when successfull. On any error false. * @return true when successfull. On any error false.
*/ */
public boolean reserve(User user) { public boolean reserve(User user) {
if (getCurrentUser() != null || getGroup() != null) { if (!isBuyable() || getCurrentUser() != null || getGroup() != null) {
return false; return false;
} }
...@@ -369,7 +310,7 @@ public class Place implements EventChildInterface, Serializable { ...@@ -369,7 +310,7 @@ public class Place implements EventChildInterface, Serializable {
* @return true when successfull. On any error false. * @return true when successfull. On any error false.
*/ */
public boolean buy(PlaceGroup group) { public boolean buy(PlaceGroup group) {
if (getCurrentUser() == null || getGroup() != null || !group.getCreator().equals(getCurrentUser())) { if (!isBuyable() || getCurrentUser() == null || getGroup() != null || !group.getCreator().equals(getCurrentUser())) {
return false; return false;
} }
releaseTime = null; releaseTime = null;
...@@ -390,59 +331,20 @@ public class Place implements EventChildInterface, Serializable { ...@@ -390,59 +331,20 @@ public class Place implements EventChildInterface, Serializable {
*/ */
public boolean checkReleased() { public boolean checkReleased() {
boolean ret = false; boolean ret = false;
if (getGroup() == null && Calendar.getInstance().after(releaseTime)) { if (getGroup() == null && releaseTime != null && Calendar.getInstance().after(releaseTime)) {
setCurrentUser(null); setCurrentUser(null);
releaseTime = null; releaseTime = null;
ret = true; ret = true;
} }
return ret; return ret;
} }
// public void drawSelectedPlace(BufferedImage targetImage) {
// Graphics2D g = targetImage.createGraphics(); public void setBuyable(boolean buyable) {
// g.setColor(SELECTED_COLOR); this.buyable = buyable;
// }
// g.fill(new Rectangle(mapX, mapY, width, height));
// } public boolean isBuyable() {
// return buyable;
// public void drawOwnedPlace(BufferedImage targetImage) { }
// Graphics2D g = targetImage.createGraphics();
// g.setColor(OWNED_COLOR);
//
// g.fill(new Rectangle(mapX, mapY, width, height));
// }
// public boolean isReserved() {
//
// if (releaseTime != null) {
// if (getGroup() == null && System.currentTimeMillis() >
// releaseTime.getTimeInMillis()) {
// setReserved(null);
// } else {
// return true;
// }
// }
//
// if (group != null) {
// return true;
// }
//
// return false;
// }
// public void setReserved(User user) {
//
// if (user != null) {
// setShouldMerge(true);
// setCurrentUser(user);
// releaseTime = Calendar.getInstance();
// releaseTime.setTimeInMillis(System.currentTimeMillis() + RESERVE_TIME);
// } else {
// releaseTime = null;
// if (getGroup() == null) {
// setCurrentUser(null);
// setShouldMerge(true);
// }
// }
// }
} }
...@@ -40,7 +40,7 @@ public class PrintedCard implements EventChildInterface { ...@@ -40,7 +40,7 @@ public class PrintedCard implements EventChildInterface {
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
@Column(name = "print_time", nullable = false) @Column(name = "print_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar printTime; private Calendar printTime;
...@@ -56,6 +56,9 @@ public class PrintedCard implements EventChildInterface { ...@@ -56,6 +56,9 @@ public class PrintedCard implements EventChildInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard") @OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
private List<ReaderEvent> readerEvents; private List<ReaderEvent> readerEvents;
@Column(name="print_count" ,nullable = false)
private int printCount = 0;
@JoinColumns( { @JoinColumns( {
@JoinColumn(name = "current_location_id", referencedColumnName = "id"), @JoinColumn(name = "current_location_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
...@@ -201,4 +204,12 @@ public class PrintedCard implements EventChildInterface { ...@@ -201,4 +204,12 @@ public class PrintedCard implements EventChildInterface {
return template; return template;
} }
public void setPrintCount(int printCount) {
this.printCount = printCount;
}
public int getPrintCount() {
return printCount;
}
} }
...@@ -21,7 +21,6 @@ import javax.persistence.Table; ...@@ -21,7 +21,6 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.persistence.Version; import javax.persistence.Version;
/** /**
* *
*/ */
...@@ -55,6 +54,9 @@ public class Product implements EventChildInterface { ...@@ -55,6 +54,9 @@ public class Product implements EventChildInterface {
@Column(name = "prepaid") @Column(name = "prepaid")
private boolean prepaid = false; private boolean prepaid = false;
@Column(name = "instant_shop")
private boolean prepaidInstant = false;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product") @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<Place> places; private List<Place> places;
...@@ -86,7 +88,6 @@ public class Product implements EventChildInterface { ...@@ -86,7 +88,6 @@ public class Product implements EventChildInterface {
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField = 0; private int jpaVersionField = 0;
public Product() { public Product() {
} }
...@@ -257,5 +258,12 @@ public class Product implements EventChildInterface { ...@@ -257,5 +258,12 @@ public class Product implements EventChildInterface {
return unitName; return unitName;
} }
public void setPrepaidInstant(boolean prepaidInstant) {
this.prepaidInstant = prepaidInstant;
}
public boolean isPrepaidInstant() {
return prepaidInstant;
}
} }
...@@ -22,6 +22,7 @@ import javax.persistence.OneToMany; ...@@ -22,6 +22,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.persistence.Version; import javax.persistence.Version;
/** /**
* *
*/ */
...@@ -30,7 +31,8 @@ import javax.persistence.Version; ...@@ -30,7 +31,8 @@ import javax.persistence.Version;
@NamedQueries({ @NamedQueries({
@NamedQuery(name = "Role.findForEvent", query = "SELECT r FROM Role r where r.event = :event"), @NamedQuery(name = "Role.findForEvent", query = "SELECT r FROM Role r where r.event = :event"),
@NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name and r.event = :event"), @NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name and r.event = :event"),
// @NamedQuery(name="Role.findParentsExcluding", query="select r from Role r, RoleRight rr where :user member of r.users ), // @NamedQuery(name="Role.findParentsExcluding", query="select r from
// Role r, RoleRight rr where :user member of r.users ),
@NamedQuery(name = "Role.findForUser", query = "SELECT r FROM Role r WHERE :user MEMBER OF r.users and r.event = :event") }) @NamedQuery(name = "Role.findForUser", query = "SELECT r FROM Role r WHERE :user MEMBER OF r.users and r.event = :event") })
public class Role implements EventChildInterface { public class Role implements EventChildInterface {
...@@ -41,18 +43,20 @@ public class Role implements EventChildInterface { ...@@ -41,18 +43,20 @@ public class Role implements EventChildInterface {
@Column(name = "role_name", nullable = false) @Column(name = "role_name", nullable = false)
private String name; private String name;
@ManyToMany(cascade = CascadeType.ALL, mappedBy="roles") @ManyToMany(mappedBy = "roles")
private List<User> users; private List<User> users;
@ManyToMany @ManyToMany(mappedBy = "parents")
@JoinTable(name = "role_children", joinColumns = {
@JoinColumn(name = "children_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) }, inverseJoinColumns = {
@JoinColumn(name = "parent_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
private List<Role> children = new ArrayList<Role>(); private List<Role> children = new ArrayList<Role>();
@ManyToMany(mappedBy = "children") @ManyToMany()
@JoinTable(name = "role_parents",
inverseJoinColumns = {
@JoinColumn(name = "children_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) },
joinColumns = {
@JoinColumn(name = "parent_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
private List<Role> parents = new ArrayList<Role>(); private List<Role> parents = new ArrayList<Role>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role") @OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
......
...@@ -31,16 +31,16 @@ import fi.insomnia.bortal.enums.Permission; ...@@ -31,16 +31,16 @@ import fi.insomnia.bortal.enums.Permission;
@NamedQueries({ @NamedQuery(name = "RoleRight.findAll", query = "SELECT r FROM RoleRight r"), @NamedQueries({ @NamedQuery(name = "RoleRight.findAll", query = "SELECT r FROM RoleRight r"),
@NamedQuery(name = "RoleRight.findByRightAndRole", query = "SELECT r FROM RoleRight r where r.role = :role and r.permission = :permission "), @NamedQuery(name = "RoleRight.findByRightAndRole", query = "SELECT r FROM RoleRight r where r.role = :role and r.permission = :permission "),
@NamedQuery(name = "RoleRight.findByRolesForPermission", query = "SELECT rr from RoleRight rr where rr.role.id.eventId = :eventId and rr.role.id.id in :roleids and rr.permission = :permission") }) @NamedQuery(name = "RoleRight.findByRolesForPermission", query = "SELECT rr from RoleRight rr where rr.role.id.eventId = :eventId and rr.role.id.id in :roleids and rr.permission = :permission") })
@ObjectTypeConverter(name = "permissionconverter", objectType = Permission.class, dataType = String.class, conversionValues = { @ObjectTypeConverter(name = "permissionconverter", objectType = Permission.class, dataType = String.class, conversionValues = {
@ConversionValue(dataValue = "LOGIN", objectValue = "LOGIN"), @ConversionValue(dataValue = "LOGIN", objectValue = "LOGIN"),
@ConversionValue(dataValue = "USER_MANAGEMENT", objectValue = "USER_MANAGEMENT"), @ConversionValue(dataValue = "USER_MANAGEMENT", objectValue = "USER_MANAGEMENT"),
@ConversionValue(dataValue = "TICKET_SALES", objectValue = "TICKET_SALES"), @ConversionValue(dataValue = "MAP", objectValue = "MAP"),
@ConversionValue(dataValue = "BILL", objectValue = "BILL"),
@ConversionValue(dataValue = "ROLE_MANAGEMENT", objectValue = "ROLE_MANAGEMENT"), @ConversionValue(dataValue = "ROLE_MANAGEMENT", objectValue = "ROLE_MANAGEMENT"),
@ConversionValue(dataValue = "PRODUCT", objectValue = "PRODUCT"), @ConversionValue(dataValue = "PRODUCT", objectValue = "PRODUCT"),
@ConversionValue(dataValue = "SHOP", objectValue = "SHOP") @ConversionValue(dataValue = "SHOP", objectValue = "SHOP")
}) })
public class RoleRight implements EventChildInterface { public class RoleRight implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -86,7 +86,7 @@ public class User implements ModelInterface { ...@@ -86,7 +86,7 @@ public class User implements ModelInterface {
private Calendar birthday; private Calendar birthday;
@NotNull @NotNull
@Size(min = 3) @Size(min = 2, message="{user.nickSizeMessage}")
@Column(name = "nick") @Column(name = "nick")
private String nick = ""; private String nick = "";
...@@ -108,7 +108,7 @@ public class User implements ModelInterface { ...@@ -108,7 +108,7 @@ public class User implements ModelInterface {
@Column(name = "phone") @Column(name = "phone")
private String phone = ""; private String phone = "";
@OneToOne() @OneToOne
private UserImage currentImage; private UserImage currentImage;
@Convert("gender") @Convert("gender")
...@@ -131,7 +131,7 @@ public class User implements ModelInterface { ...@@ -131,7 +131,7 @@ public class User implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "voter") @OneToMany(cascade = CascadeType.ALL, mappedBy = "voter")
private List<Vote> votes; private List<Vote> votes;
@ManyToMany(cascade = CascadeType.ALL) @ManyToMany()
@JoinTable(name = "role_memberships", inverseJoinColumns = { @JoinTable(name = "role_memberships", inverseJoinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "id"), @JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id") }, @JoinColumn(name = "event_id", referencedColumnName = "event_id") },
...@@ -141,7 +141,7 @@ public class User implements ModelInterface { ...@@ -141,7 +141,7 @@ public class User implements ModelInterface {
@OneToMany(mappedBy = "user") @OneToMany(mappedBy = "user")
private List<LogEntry> logEntryList; private List<LogEntry> logEntryList;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY) @OneToMany(mappedBy = "user", fetch = FetchType.LAZY,cascade=CascadeType.ALL)
@OrderBy @OrderBy
private List<UserImage> userImageList; private List<UserImage> userImageList;
......
package fi.insomnia.bortal; package fi.insomnia.bortal.utilities;
import java.text.MessageFormat;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
...@@ -15,27 +16,31 @@ import javax.faces.context.FacesContext; ...@@ -15,27 +16,31 @@ import javax.faces.context.FacesContext;
*/ */
public class I18n { public class I18n {
public static ResourceBundle getResourceBundle() { public static ResourceBundle getResourceBundle() {
FacesContext facesContext = FacesContext.getCurrentInstance(); FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication(); Application app = facesContext.getApplication();
ResourceBundle bundle = app.getResourceBundle(facesContext, "i18n"); ResourceBundle bundle = app.getResourceBundle(facesContext, "i18n");
return bundle; return bundle;
} }
public static String get(String key) { public static String get(String key, Object... params) {
String value = null; return MessageFormat.format(get(key), params);
try { }
value = getResourceBundle().getString(key);
} catch (MissingResourceException e) { public static String get(String key) {
value = null; String value = null;
} try {
value = getResourceBundle().getString(key);
if (key == null) { } catch (MissingResourceException e) {
value = "########"; value = null;
} else if (value == null) { }
value = "???" + key + "???";
if (key == null) {
} value = "########";
return value; } else if (value == null) {
} value = "???" + key + "???";
}
return value;
}
} }
Manifest-Version: 1.0 Manifest-Version: 1.0
Class-Path: lib/granite.jar
...@@ -17,6 +17,8 @@ xmlns:c="http://java.sun.com/jsp/jstl/core"> ...@@ -17,6 +17,8 @@ xmlns:c="http://java.sun.com/jsp/jstl/core">
#{i18n['loginerror.message']} #{i18n['loginerror.message']}
</p> </p>
<login:login /> <login:login />
<p><h:link outcome="/auth/sendResetMail" value="#{i18n['loginerror.resetpassword']}" /></p>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -26,6 +26,14 @@ ...@@ -26,6 +26,14 @@
<f:convertNumber /> <f:convertNumber />
</h:outputText> </h:outputText>
</h:column> </h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.paid']}" />
</f:facet>
<h:outputText value="#{sumline.paid}" >
<f:convertNumber />
</h:outputText>
</h:column>
</h:dataTable> </h:dataTable>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
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:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.bill.edit" /> <ui:param name="thispage" value="page.bill.edit" />
...@@ -14,7 +12,7 @@ ...@@ -14,7 +12,7 @@
<h:form id="billform"> <h:form id="billform">
<h:inputHidden value="#{billManageView.bill.id}" /> <h:inputHidden value="#{billManageView.bill.id}" />
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputLabel for="paidTime" value="#{i18n['bill.paidDate']}:" /> <h:outputLabel for="paidDate" value="#{i18n['bill.paidDate']}:" />
<h:inputText id="paidDate" value="#{billManageView.bill.paidDate.time}"> <h:inputText id="paidDate" value="#{billManageView.bill.paidDate.time}">
<f:convertDateTime /> <f:convertDateTime />
</h:inputText> </h:inputText>
...@@ -35,27 +33,75 @@ ...@@ -35,27 +33,75 @@
<h:inputText id="sentDate" value="#{billManageView.bill.sentDate.time}"> <h:inputText id="sentDate" value="#{billManageView.bill.sentDate.time}">
<f:convertDateTime /> <f:convertDateTime />
</h:inputText> </h:inputText>
<h:outputLabel for="paymenttime" value="#{i18n['bill.paymentTime']}:" /> <h:outputLabel for="paymenttime" value="#{i18n['bill.paymentTime']}:" />
<h:inputText id ="paymenttime" value="#{billManageView.bill.paymentTime}" /> <h:inputText id="paymenttime" value="#{billManageView.bill.paymentTime}" />
<h:outputLabel value="#{i18n['bill.noticetime']}:" /> <h:outputLabel value="#{i18n['bill.noticetime']}:" />
<h:inputText value="#{billManageView.bill.noticetime}" /> <h:inputText value="#{billManageView.bill.noticetime}" />
<h:outputLabel value="#{i18n['bill.theirReference']}:" /> <h:outputLabel value="#{i18n['bill.theirReference']}:" />
<h:inputText value="#{billManageView.bill.theirReference}" /> <h:inputText value="#{billManageView.bill.theirReference}" />
<h:outputLabel value="#{i18n['bill.ourReference']}:" /> <h:outputLabel value="#{i18n['bill.ourReference']}:" />
<h:inputText value="#{billManageView.bill.ourReference}" /> <h:inputText value="#{billManageView.bill.ourReference}" />
<h:outputLabel value="#{i18n['bill.deliveryTerms']}:" /> <h:outputLabel value="#{i18n['bill.deliveryTerms']}:" />
<h:inputText value="#{billManageView.bill.deliveryTerms}" /> <h:inputText value="#{billManageView.bill.deliveryTerms}" />
<h:outputLabel value="#{i18n['bill.notes']}:" /> <h:outputLabel value="#{i18n['bill.notes']}:" />
<h:inputText value="#{billManageView.bill.notes}" /> <h:inputTextarea cols="50" rows="5" value="#{billManageView.bill.notes}" />
<h:commandButton id="commitbtn" action="#{billManageView.save()}" <h:commandButton id="commitbtn" action="#{billManageView.save()}" value="#{i18n['bill.save']}" />
value="#{i18n['bill.save']}" />
</h:panelGrid> </h:panelGrid>
</h:form> </h:form>
<h:form id="billLinesForm">
<h:dataTable border="1" id="user" value="#{billManageView.billLines}" var="billine">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n[billine.name]}" />
</f:facet>
<h:inputHidden value="#{billine.id.id}" />
<h:inputText value="#{billine.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.unitPrice']}" />
</f:facet>
<h:inputText value="#{billine.unitPrice}" size="6"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.quantity']}" />
</f:facet>
<h:inputText value="#{billine.quantity}" size="6"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.unitName']}" />
</f:facet>
<h:inputText value="#{billine.unitName}" size="5"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.vat']}" />
</f:facet>
<h:inputText value="#{billine.vat}" size="4"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['billine.referencedProduct']}" />
</f:facet>
<h:outputText value="#{billine.lineProduct.name}" />
</h:column>
<h:column>
<h:commandButton action="#{billManageView.saveBilline()}" value="#{i18n['billine.save']}" />
</h:column>
</h:dataTable>
</h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.axdt.as3.debug.launcher.type">
<stringAttribute key="ALT_PATH" value="file://${deploy_loc}/${resource_name_noext}.swf"/>
<stringAttribute key="COMPILER_CHOICE" value="org.axdt.flex4sdk.compiler"/>
<booleanAttribute key="FOR_AIR" value="false"/>
<booleanAttribute key="GATHER_LIBS" value="true"/>
<booleanAttribute key="OPEN_SWF" value="true"/>
<stringAttribute key="OPEN_WITH" value="CHOICE_SWFVIEW"/>
<booleanAttribute key="SEARCH_CONFIG" value="true"/>
<booleanAttribute key="USE_ALT_PATH" value="false"/>
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/flashcompile"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="target" value="/LanBortalWeb/as3/fi/insomnia/bortal/flash/eventmap/eventmap.mxml"/>
</launchConfiguration>
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
</ul> </ul>
</tools:canRead> </tools:canRead>
<tools:canWrite target="TICKET_SALES" > <tools:canRead target="BILL" >
#{i18n['sidebar.bills']} #{i18n['sidebar.bills']}
<ul> <ul>
<li><h:link outcome="/bill/listAll" value="#{i18n['sidebar.bill.listAll']}"/></li> <li><h:link outcome="/bill/listAll" value="#{i18n['sidebar.bill.listAll']}"/></li>
<li><h:link outcome="/bill/billSummary" value="#{i18n['sidebar.bill.summary']}"/></li> <li><h:link outcome="/bill/billSummary" value="#{i18n['sidebar.bill.summary']}"/></li>
</ul> </ul>
</tools:canWrite> </tools:canRead>
<tools:canRead target="USER_MANAGEMENT"> <tools:canRead target="USER_MANAGEMENT">
#{i18n['sidebar.users']} #{i18n['sidebar.users']}
<ul> <ul>
...@@ -43,6 +43,14 @@ ...@@ -43,6 +43,14 @@
<li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}"/></li> <li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}"/></li>
</ul> </ul>
</tools:canRead> </tools:canRead>
<tools:canRead target="MAP" >
#{i18n['sidebar.maps']}
<ul>
<li><h:link outcome="/map/list" value="#{i18n['sidebar.map.list']}"/></li>
</ul>
</tools:canRead>
#{i18n['sidebar.other']} #{i18n['sidebar.other']}
<ul> <ul>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
xmlns:c="http://java.sun.com/jsp/jstl/core"> xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:view locale="#{sessionHandler.locale}"> <f:view locale="#{sessionHandler.locale}">
<ui:insert name="metadata"/>
<h:head> <h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><h:outputText value="#{i18n['global.eventname']}" /> - <h:outputText value="#{i18n[util.concat(thispage,'.header') ] }" /></title> <title><h:outputText value="#{i18n['global.eventname']}" /> - <h:outputText value="#{i18n[util.concat(thispage,'.header') ] }" /></title>
......
...@@ -11,17 +11,18 @@ ...@@ -11,17 +11,18 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.role.edit" /> <ui:param name="thispage" value="page.role.edit" />
<ui:define name="content"> <ui:define name="content">
<map:edit /> <map:edit commitaction="#{mapManageView.saveMap()}" commitvalue="#{i18n['mapEdit.save']}"/>
<map:setBuyable />
<img width="600" src="#{request.contextPath}#{mapView.selectPlaceMapUrl}" <img width="600" src="#{request.contextPath}#{mapView.selectPlaceMapUrl}"
alt="placeimage" /> alt="placeimage" />
<map:genplaces /> <map:genplaces />
<map:submitBg /> <map:submitBg />
<map:listPlaces /> <!-- <map:listPlaces />
-->
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:map="http://java.sun.com/jsf/composite/tools/map" xmlns:map="http://java.sun.com/jsf/composite/tools/map" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:tools="http://java.sun.com/jsf/composite/tools"> xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body> <h:body>
...@@ -11,13 +10,14 @@ ...@@ -11,13 +10,14 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.place.placemap" /> <ui:param name="thispage" value="page.place.placemap" />
<ui:define name="content"> <ui:define name="content">
#{mapView.initSelf()}
<tools:isLoggedIn> <map:placeSelect />
<f:facet name="errormessage">
<img src="#{request.contextPath}#{mapView.selectPlaceMapUrl}" alt="placeimage" /> <!-- <h:panelGroup rendered="#{ !mapView.canUserBuy()}">
</f:facet> <img class="imgcenter" src="#{request.contextPath}#{mapView.selectPlaceMapUrl}" alt="placeimage" />
<map:placeSelect /> </h:panelGroup >
</tools:isLoggedIn> -->
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
...@@ -38,6 +38,20 @@ ...@@ -38,6 +38,20 @@
text-decoration: underline; text-decoration: underline;
} }
.placeSelectInfotable tr td
{
padding-left: 20px;
}
.rightalign
{
text-align: right;
}
.placeSelectInfotable tr
{
vertical-align: top;
}
h3 { h3 {
font-size: 18px; font-size: 18px;
color: #01202e; color: #01202e;
......
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface> <composite:interface>
<composite:attribute name="billview" required="true" /> <composite:attribute name="billview" required="true" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
<h:outputText rendered="#{cc.attrs.billview.bills.rowCount le 0}" value="#{i18n['bills.noBills']}" /> <h:outputText rendered="#{cc.attrs.billview.bills.rowCount le 0}" value="#{i18n['bills.noBills']}" />
<h:form rendered="#{cc.attrs.billview.bills.rowCount gt 0}"> <h:form rendered="#{cc.attrs.billview.bills.rowCount gt 0}">
<h:dataTable border="0" id="billList" value="#{cc.attrs.billview.bills}" var="bill"> <h:dataTable border="0" id="billList" value="#{cc.attrs.billview.bills}" var="bill">
<h:column rendered="#{sessionHandler.hasPermission('TICKET_SALES', 'WRITE')}"> <h:column rendered="#{sessionHandler.hasPermission('BILL', 'WRITE')}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['bill.payer']}" /> <h:outputText value="${i18n['bill.payer']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.addr1}" /> <h:outputText value="#{bill.addr1}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['bill.sentDate']}" /> <h:outputText value="${i18n['bill.sentDate']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.sentDate.time}" > <h:outputText value="#{bill.sentDate.time}">
<f:convertDateTime dateStyle="short" /> <f:convertDateTime dateStyle="short" />
</h:outputText> </h:outputText>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['bill.billNumber']}" /> <h:outputText value="${i18n['bill.billNumber']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.billNumber}" /> <h:outputText value="#{bill.billNumber}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['bill.referencenumber']}" /> <h:outputText value="${i18n['bill.referencenumber']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.referenceNumberBase}" > <h:outputText value="#{bill.referenceNumberBase}">
<f:converter binding="#{referenceNumberConverter}" /> <f:converter binding="#{referenceNumberConverter}" />
</h:outputText> </h:outputText>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['bill.totalPrice']}" /> <h:outputText value="${i18n['bill.totalPrice']}" />
</f:facet> </f:facet>
<h:outputText value="#{bill.totalPrice()}" > <h:outputText value="#{bill.totalPrice()}">
<f:convertNumber currencyCode="EUR" maxFractionDigits="2" minFractionDigits="2" type="currency" /> <f:convertNumber currencyCode="EUR" maxFractionDigits="2" minFractionDigits="2" type="currency" />
</h:outputText> </h:outputText>
</h:column> </h:column>
<h:column> <h:column>
<a href="#{request.contextPath}/PrintBill?billid=#{bill.id.id}" target="_blank" >#{i18n['bill.printBill']}</a> <a href="#{request.contextPath}/PrintBill?billid=#{bill.id.id}" target="_blank">#{i18n['bill.printBill']}</a>
</h:column> </h:column>
<h:column rendered="#{cc.attrs.billView.manage}">
<h:commandButton action="#{cc.attrs.billview.edit()}" value="#{i18n['bill.edit']}" />
</h:column>
<h:column rendered="#{cc.attrs.billview.manage}">
<h:commandButton rendered="#{bill.paidDate == null}" action="#{cc.attrs.billview.markPaid()}" value="#{i18n['bill.markPaid']}" />
<h:outputText rendered="#{bill.paidDate != null}" value="#{i18n['bill.isPaid']}" />
</h:column>
</h:dataTable>
</h:form> <h:column rendered="#{cc.attrs.billview.manage}">
<h:commandButton action="#{cc.attrs.billview.edit()}" value="#{i18n['bill.edit']}" />
</h:column>
<h:column rendered="#{cc.attrs.billview.manage}">
<h:commandButton rendered="#{bill.paidDate == null}" action="#{cc.attrs.billview.markPaid()}"
value="#{i18n['bill.markPaid']}" />
<h:outputText rendered="#{bill.paidDate != null}" value="#{i18n['bill.isPaid']}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</composite:implementation>
</html> </html>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<composite:implementation> <composite:implementation>
<tools:fatalPermission target="TICKET_SALES" permission="WRITE" /> <tools:fatalPermission target="MAP" permission="WRITE" />
<h:form> <h:form>
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputText value="#{i18n['map.name']}" /> <h:outputText value="#{i18n['map.name']}" />
......
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/tools/role"> xmlns:role="http://java.sun.com/jsf/composite/tools/role">
<composite:interface> <composite:interface>
<composite:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
<h:form id="productform"> <h:form id="productform">
<h:inputHidden value="#{mapManageView.map.id.id}" /> <h:inputHidden value="#{mapManageView.map.id.id}" />
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputLabel value="#{i18n['product.name']}:" /> <h:outputLabel value="#{i18n['eventmap.name']}:" />
<h:inputText value="#{mapManageView.map.name}" /> <h:inputText value="#{mapManageView.map.name}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" <h:outputLabel value="#{i18n['eventmap.notes']}:" />
value="#{cc.attrs.commitvalue}" /> <h:inputTextarea cols="40" rows="5" value="#{mapManageView.map.notes}" />
<h:outputLabel value="#{i18n['eventmap.active']}:" />
<h:selectBooleanCheckbox value="#{mapManageView.map.active}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid> </h:panelGrid>
</h:form> </h:form>
......
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/tools/role"> xmlns:role="http://java.sun.com/jsf/composite/tools/role">
...@@ -14,16 +11,78 @@ ...@@ -14,16 +11,78 @@
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
<h:form id="placeselectform"> <h:form id="placeselectform">
<h:commandButton value="#{i18n['mapView.buyPlaces']}" action="#{mapView.buySelectedPlaces()}" /> <h:commandButton rendered="#{mapView.canUserBuy()}" value="#{i18n['mapView.buyPlaces']}"
<h:outputText value="#{i18n['placeSelect.placesleft']}: #{mapView.placeLeftToSelect()}" /> action="#{mapView.buySelectedPlaces()}" />
<h:commandButton id="commandbutton" image="#{mapView.selectPlaceMapUrl}" <h:commandButton styleClass="imgcenter" id="commandbutton" image="#{mapView.selectPlaceMapUrl}"
actionListener="#{mapView.placeSelectActionListener}" /> actionListener="#{mapView.placeSelectActionListener}" />
</h:form>
<h:panelGrid styleClass="placeSelectInfotable" columns="3">
<h:panelGrid columns="2">
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: grey; width: 10px; height: 10px;">&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.grey']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: white; width: 10px; height: 10px;">&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.white']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: red; width: 10px; height: 10px;">&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.red']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: green; width: 10px; height: 10px;">&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.green']}" />
<div
style="border-color: black; border-style: solid; border-width: 1px; background-color: blue; width: 10px; height: 10px;">&nbsp;</div>
<h:outputText value="#{i18n['placeSelect.legend.blue']}" />
</h:panelGrid>
<h:panelGroup >
<h:panelGrid columnClasses=",rightalign" columns="2">
<h:outputLabel value="#{i18n['placeSelect.totalPlaces']}:" />
<h:outputText value="#{mapView.activeMap.places.size()}" />
<h:outputLabel value="#{i18n['placeSelect.placesleft']}:" />
<h:outputText value="#{mapView.placeLeftToSelect()}" />
<h:outputLabel rendered="#{mapView.canUserBuy()}" value="#{i18n['user.accountBalance']}:" />
<h:outputText rendered="#{mapView.canUserBuy()}" value="#{mapView.user.accountBalance}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<h:outputLabel rendered="#{mapView.canUserBuy()}" value="#{i18n['placeSelect.reservationPrice']}:" />
<h:outputText rendered="#{mapView.canUserBuy()}" value="#{mapView.reservationPrice}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</h:panelGrid>
</h:panelGroup>
<h:panelGrid columnClasses=",rightalign" columns="2" rendered="#{not empty mapView.clickedplace }">
<h:outputLabel value="#{i18n['placeSelect.placeName']}:" />
<h:outputText value="#{mapView.clickedplace.name}" />
<h:outputLabel value="#{i18n['placeSelect.placeProductName']}:" />
<h:outputText value="#{mapView.clickedplace.product.name}" />
<h:outputLabel value="#{i18n['placeSelect.placePrice']}:" />
<h:outputText class="" value="#{mapView.clickedplace.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</h:panelGrid>
</h:panelGrid>
</h:form>
<div><h:outputText escape="false" value="#{mapView.activeMap.notes}" /></div>
</composite:implementation> </composite:implementation>
</html> </html>
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
<h:outputLabel value="#{i18n['product.prepaid']}" /> <h:outputLabel value="#{i18n['product.prepaid']}" />
<h:selectBooleanCheckbox value="#{productView.product.prepaid}" /> <h:selectBooleanCheckbox value="#{productView.product.prepaid}" />
<h:outputLabel value="#{i18n['product.prepaidInstant']}" />
<h:selectBooleanCheckbox value="#{productView.product.prepaidInstant}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" <h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}"
value="#{cc.attrs.commitvalue}" /> value="#{cc.attrs.commitvalue}" />
......
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" <composite:interface>
xmlns:c="http://java.sun.com/jsp/jstl/core" <composite:attribute name="items" required="true" />
xmlns:tools="http://java.sun.com/jsf/composite/tools"> <composite:attribute name="commitValue" required="true" />
<composite:attribute name="commitaction" method-signature="java.lang.String action()" required="true" />
</composite:interface>
<composite:interface>
<composite:attribute name="items" required="true" /> <composite:implementation>
<composite:attribute name="commitValue" required="true" /> <h:outputScript target="head" library="script" name="jquery.min.js" />
<composite:attribute name="commitaction" method-signature="java.lang.String action()" required="true" /> <h:outputScript target="head" library="script" name="shopscript.js" />
</composite:interface>
<composite:implementation>
<h:outputScript target="head" library="script" name="jquery.min.js" />
<h:outputScript target="head" library="script" name="shopscript.js" />
<h:form id="shopform"> <h:form id="shopform">
<h:dataTable border="0" id="billcart" value="#{cc.attrs.items}" var="cart"> <h:dataTable border="0" id="billcart" value="#{cc.attrs.items}" var="cart">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText id="name" value="${i18n['product.name']}" /> <h:outputText id="name" value="${i18n['product.name']}" />
...@@ -33,28 +28,30 @@ ...@@ -33,28 +28,30 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['product.price']}" /> <h:outputText value="${i18n['product.price']}" />
</f:facet> </f:facet>
<h:outputText id="price" value="#{cart.product.price}" > <h:outputText id="price" value="#{cart.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" /> <f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText> </h:outputText>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText id="count" value="${i18n['product.cart.count']}" /> <h:outputText id="count" value="${i18n['product.cart.count']}" />
</f:facet> </f:facet>
<a href="#" onclick="return changeCartCount($(this).next().next(), -1)" >-1</a> <a href="#" onclick="return changeCartCount($(this).next().next(), -1)">-1</a>
<a href="#" onclick="return changeCartCount($(this).next(), -10)" >-10</a> <a href="#" onclick="return changeCartCount($(this).next(), -10)">-10</a>
<h:inputText size="4" id="cartcount" value="#{cart.count}" /> <h:inputText size="4" id="cartcount" value="#{cart.count}" />
<a href="#" onclick="return changeCartCount($(this).prev(), +1)" >+1</a> <a href="#" onclick="return changeCartCount($(this).prev(), +1)">+1</a>
<a href="#" onclick="return changeCartCount($(this).prev().prev(), +10)" >+10</a> <a href="#" onclick="return changeCartCount($(this).prev().prev(), +10)">+10</a>
<h:inputHidden value="#{cart.id}" />
</h:column> </h:column>
</h:dataTable> </h:dataTable>
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton" value="#{cc.attrs.commitValue}" /> <h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton" value="#{cc.attrs.commitValue}" />
</h:form> </h:form>
</composite:implementation>
</composite:implementation>
</html> </html>
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" <composite:interface>
xmlns:c="http://java.sun.com/jsp/jstl/core" <composite:attribute name="creating" required="false" default="false" />
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
<composite:interface> </composite:interface>
<composite:attribute name="creating" required="false" default="false" />
<composite:implementation>
<composite:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface> <h:form id="userform">
<h:inputHidden rendered="#{!cc.attrs.creating}" value="#{userView.user.id}" />
<composite:implementation> <h:panelGrid columns="3">
<h:outputLabel rendered="#{!cc.attrs.creating}" value="#{i18n['user.login']}:" for="viewlogin" />
<h:outputText rendered="#{!cc.attrs.creating}" disabled="#{!cc.attrs.creating and !userView.canSave()}" id="viewlogin" value="#{userView.user.login}" />
<h:form id="userform"> <h:message rendered="#{!cc.attrs.creating}" for="viewlogin" />
<h:inputHidden rendered="#{!cc.attrs.creating}" value="#{userView.user.id}" />
<h:panelGrid columns="2"> <h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.login']}:" for="login" />
<h:outputLabel rendered="#{!cc.attrs.creating}" value="#{i18n['user.login']}:" for="viewlogin"/> <h:inputText rendered="#{cc.attrs.creating}" disabled="#{!cc.attrs.creating and !userView.canSave()}" id="login" value="#{userView.user.login}" />
<h:outputText rendered="#{!cc.attrs.creating}" id="viewlogin" value="#{userView.user.login}" /> <h:message rendered="#{cc.attrs.creating}" for="login" />
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.login']}:" for="login"/> <h:outputLabel value="#{i18n['user.nick']}:" for="nick" />
<h:inputText rendered="#{cc.attrs.creating}" id="login" value="#{userView.user.login}" /> <h:inputText id="nick" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.nick}" />
<h:message for="nick" />
<h:outputLabel value="#{i18n['user.nick']}:" for="nick" /><h:inputText id="nick" value="#{userView.user.nick}" /> <h:outputLabel value="#{i18n['user.email']}:" for="email" />
<h:outputLabel value="#{i18n['user.email']}:" for="email"/><h:inputText id="email" value="#{userView.user.email}" /> <h:inputText id="email" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.email}" />
<h:outputLabel value="#{i18n['user.firstNames']}:" for="firstnames" /><h:inputText id="firstnames" value="#{userView.user.firstnames}" /> <h:message for="email" />
<h:outputLabel value="#{i18n['user.lastName']}:" for="lastname" /><h:inputText id="lastname" value="#{userView.user.lastname}" />
<h:outputLabel value="#{i18n['user.address']}:" for="address" /><h:inputText id="address" value="#{userView.user.address}" /> <h:outputLabel value="#{i18n['user.firstNames']}:" for="firstnames" />
<h:outputLabel value="#{i18n['user.zipCode']}:" for="zip" /><h:inputText id="zip" value="#{userView.user.zip}" /> <h:inputText id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.firstnames}" />
<h:outputLabel value="#{i18n['user.town']}:" for="town"/><h:inputText id="town" value="#{userView.user.town}" /> <h:message for="firstnames" />
<h:outputLabel rendered="#{sessionHandler.superadmin}" value="#{i18n['user.superadmin']}:" for="superadmin" /> <h:outputLabel value="#{i18n['user.lastName']}:" for="lastname" />
<h:selectBooleanCheckbox rendered="#{sessionHandler.superadmin}" id="superadmin" value="#{userView.user.superadmin}" /> <h:inputText id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.lastname}" />
<!-- <h:message for="lastname" />
<h:outputLabel value="#{i18n['user.address']}:" for="address" />
<h:inputText id="address" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.address}" />
<h:message for="address" />
<h:outputLabel value="#{i18n['user.zipCode']}:" for="zip" />
<h:inputText id="zip" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.zip}" />
<h:message for="zip" />
<h:outputLabel value="#{i18n['user.town']}:" for="town" />
<h:inputText id="town" disabled="#{!cc.attrs.creating and !userView.canSave()}" value="#{userView.user.town}" />
<h:message for="town" />
<h:outputLabel rendered="#{sessionHandler.superadmin}" value="#{i18n['user.superadmin']}:" for="superadmin" />
<h:selectBooleanCheckbox disabled="#{!cc.attrs.creating and !userView.canSave()}" rendered="#{sessionHandler.superadmin}" id="superadmin" value="#{userView.user.superadmin}" />
<h:message rendered="#{sessionHandler.superadmin}" for="superadmin" />
<!--
<h:outputLabel value="#{i18n['user.defaultImage']}:" for="currentImage" /> <h:outputLabel value="#{i18n['user.defaultImage']}:" for="currentImage" />
<h:selectOneMenu rendered="#{sessionHandler.hasPermission('USER', 'READ')}" id="currentImage" value="#{userView.user.currentImage}" converter="#{userimageConverter}" > <h:selectOneMenu rendered="#{sessionHandler.hasPermission('USER', 'READ')}" id="currentImage" value="#{userView.user.currentImage}" converter="#{userimageConverter}" >
<f:selectItems var="image" itemLabel="#{image.description}" value="#{userView.user.userImageList}" /> <f:selectItems var="image" itemLabel="#{image.description}" value="#{userView.user.userImageList}" />
</h:selectOneMenu> </h:selectOneMenu>
--> -->
<h:outputLabel value="#{i18n['user.sex']}:" for="sex"/> <h:outputLabel value="#{i18n['user.sex']}:" for="sex" />
<h:selectOneRadio id="sex" value="#{userView.user.gender}"> <h:selectOneRadio disabled="#{!cc.attrs.creating and !userView.canSave()}" id="sex" value="#{userView.user.gender}">
<f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" /> <f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" />
<f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" /> <f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" />
<f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" /> <f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" />
</h:selectOneRadio> </h:selectOneRadio>
<h:message for="sex" />
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.password']}:" for="password"/>
<h:inputSecret rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}"/>
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.passwordcheck']}:" for="passwordcheck"/> <h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.password']}:" for="password" />
<h:inputSecret rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}"/> <h:inputSecret rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}" />
<h:message rendered="#{cc.attrs.creating}" for="password" />
<h:outputLabel rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" value="#{i18n['user.roles']}:" for="roles"/>
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.passwordcheck']}:" for="passwordcheck" />
<h:selectManyCheckbox converter="#{sessionHandler.roleConverter}" rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" disabled="#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}" layout="pageDirection" id="roles" value="#{userView.user.roles}"> <h:inputSecret rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" />
<f:selectItems var="roleitem" itemLabel="#{roleitem.name}" value="#{userView.userRoles}" /> <h:message rendered="#{cc.attrs.creating}" for="passwordcheck" />
</h:selectManyCheckbox>
<h:outputLabel rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" value="#{i18n['user.roles']}:"
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" /> for="roles" />
</h:panelGrid> <h:selectManyCheckbox converter="#{sessionHandler.roleConverter}"
</h:form> rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}"
disabled="#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}" layout="pageDirection" id="roles"
</composite:implementation> value="#{userView.user.roles}">
<f:selectItems var="roleitem" itemLabel="#{roleitem.name}" value="#{userView.userRoles}" />
</h:selectManyCheckbox>
<h:message rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" for="roles" />
<h:commandButton rendered="#{cc.attrs.creating or userView.canSave()}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
</composite:implementation>
</html> </html>
...@@ -13,8 +13,12 @@ ...@@ -13,8 +13,12 @@
<ui:define name="content"> <ui:define name="content">
<users:edit commitaction="#{userView.saveUser()}" <users:edit commitaction="#{userView.saveUser()}"
commitvalue="#{i18n['user.save']}" /> commitvalue="#{i18n['user.save']}" />
<tools:canRead target="SHOP"> <tools:canRead target="SHOP">
<h:form id="accountform"> <h2>#{i18n['user.accountEventHeader']}</h2>
<h:outputText rendered="#{userView.user.accountEvents.size() le 0}" value="#{i18n['user.noAccountevents']}" />
<h:form rendered="#{userView.user.accountEvents.size() gt 0}" id="accountform">
<h:dataTable border="0" id="accountevent" <h:dataTable border="0" id="accountevent"
value="#{userView.user.accountEvents}" var="event"> value="#{userView.user.accountEvents}" var="event">
<h:column> <h:column>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:users="http://java.sun.com/jsf/composite/tools/user"
xmlns:f="http://java.sun.com/jsf/core"> xmlns:f="http://java.sun.com/jsf/core">
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.user.mygroups" /> <ui:param name="thispage" value="page.user.mygroups" />
<ui:define name="content"> <ui:define name="content">
#{placeGroupView.editSelf()} #{placeGroupView.editSelf()}
userid:#{user.id}
Listsize: #{placeGroupView.user.placeGroups.size()} <h:dataTable value="#{placeGroupView.user.placeGroups}" var="group">
<c:forEach items="#{placeGroupView.user.placeGroups}" var="group"> <h:column>
<p>Id: #{group.id} name #{group.name} <h:dataTable border="1" id="user" <p>Id: #{group.id.id} name #{group.name}
value="#{group.members}" var="member"> <h:dataTable border="1" id="user" value="#{group.members}" var="member">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Id" /> <h:outputText value="Id" />
</f:facet> </f:facet>
<h:outputText value="#{member.id}" /> <h:outputText value="#{member.id.id}" />
</h:column>
</h:dataTable></p> </h:column>
</c:forEach> <h:column>
<f:facet name="header">
<h:outputText value="product" />
</f:facet>
<h:outputText value="#{member.placeReservation.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="token" />
</f:facet>
<h:outputText value="#{member.inviteToken}" />
</h:column>
</h:dataTable></p>
</h:column>
</h:dataTable>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
xmlns:f="http://java.sun.com/jsf/core"> xmlns:f="http://java.sun.com/jsf/core">
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.user.create" /> <ui:param name="thispage" value="page.user.search" />
<ui:define name="content"> <ui:define name="content">
......
...@@ -16,12 +16,9 @@ import org.slf4j.LoggerFactory; ...@@ -16,12 +16,9 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal; import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal; import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.beans.SecurityBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal; import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.beans.UtilBeanLocal;
import fi.insomnia.bortal.enums.Permission; import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission; import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.exceptions.PermissionDeniedException;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.converter.RoleConverter; import fi.insomnia.bortal.web.converter.RoleConverter;
...@@ -36,8 +33,6 @@ public class SessionHandler { ...@@ -36,8 +33,6 @@ public class SessionHandler {
private static final Logger logger = LoggerFactory.getLogger(SessionHandler.class); private static final Logger logger = LoggerFactory.getLogger(SessionHandler.class);
@EJB @EJB
private UtilBeanLocal utilbean;
@EJB
private RoleBeanLocal rolebean; private RoleBeanLocal rolebean;
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
...@@ -86,14 +81,16 @@ public class SessionHandler { ...@@ -86,14 +81,16 @@ public class SessionHandler {
} }
public void fatalPermission(Permission target, RolePermission permission) { public void fatalPermission(Permission target, RolePermission permission) {
userbean.fatalPermission(target, permission, "Fail from MBean SessionHandler"); userbean.fatalPermission(target, permission, new Object[] {});
} }
private HttpSession getHttpSession() { //
FacesContext ctx = FacesContext.getCurrentInstance(); // private HttpSession getHttpSession() {
HttpSession sess = (HttpSession) ctx.getExternalContext().getSession(false); // FacesContext ctx = FacesContext.getCurrentInstance();
return sess; // HttpSession sess = (HttpSession)
} // ctx.getExternalContext().getSession(false);
// return sess;
// }
public boolean hasPermission(Permission target, RolePermission permission) { public boolean hasPermission(Permission target, RolePermission permission) {
if (target == null || permission == null) { if (target == null || permission == null) {
...@@ -122,37 +119,6 @@ public class SessionHandler { ...@@ -122,37 +119,6 @@ public class SessionHandler {
return hasPermission(target, RolePermission.EXECUTE); return hasPermission(target, RolePermission.EXECUTE);
} }
private boolean impersonating = false;
// public void impersonateUser(User user) {
// if (user == null) {
// this.thisuser = getUser();
// impersonating = false;
// } else if (canExecute("user")) {
// secubean.logMessage(userbean.getCurrentUser(),
// "Successfully impersonating user id: " + user.getId() + " and login: " +
// user.getLogin());
// this.thisuser = user;
// impersonating = true;
// } else {
// secubean.logMessage(userbean.getCurrentUser(),
// "User tried to impersonate as id: " + user.getId() + " login: " +
// user.getLogin() + " but did not have enough rights");
// }
// }
//
// public User getUser() {
//
// boolean iscurruser = userbean.isCurrentUser(thisuser);
// logger.debug("Current user {}", (thisuser == null) ? "null" :
// thisuser.getNick());
// if (thisuser == null || (!impersonating && !iscurruser)) {
// thisuser = userbean.getCurrentUser();
// }
//
// return thisuser;
// }
public String logout() { public String logout() {
FacesContext ctx = FacesContext.getCurrentInstance(); FacesContext ctx = FacesContext.getCurrentInstance();
...@@ -192,8 +158,4 @@ public class SessionHandler { ...@@ -192,8 +158,4 @@ public class SessionHandler {
} }
// public String reindexCompass() {
// utilbean.reindexCompass();
// return "Indexed!";
// }
} }
package fi.insomnia.bortal.servlet; package fi.insomnia.bortal.servlet;
//
import org.granite.config.servlet3.FlexFilter; //import org.granite.config.servlet3.FlexFilter;
import org.granite.gravity.config.AbstractMessagingDestination; //import org.granite.gravity.config.AbstractMessagingDestination;
import org.granite.gravity.config.servlet3.MessagingDestination; //import org.granite.gravity.config.servlet3.MessagingDestination;
import org.granite.messaging.service.annotations.RemoteDestination; //import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.annotations.TideEnabled; //import org.granite.tide.annotations.TideEnabled;
import org.granite.tide.ejb.EjbIdentity; //import org.granite.tide.ejb.EjbIdentity;
import org.granite.tide.ejb.EjbServiceFactory; //import org.granite.tide.ejb.EjbServiceFactory;
//
@FlexFilter( //@FlexFilter(
tide = true, // tide = true,
type = "ejb", // type = "ejb",
factoryClass = EjbServiceFactory.class, // factoryClass = EjbServiceFactory.class,
ejbLookup = "java:global/LanBortal/LanBortalBeans/{capitalized.component.name}Bean!fi.insomnia.bortal.beans.flash.{capitalized.component.name}BeanLocal", // ejbLookup = "java:global/LanBortal/LanBortalBeans/{capitalized.component.name}Bean!fi.insomnia.bortal.beans.flash.{capitalized.component.name}BeanLocal",
entityManagerFactoryJndiName = "java:comp/env/BortalEMF", // entityManagerFactoryJndiName = "java:comp/env/BortalEMF",
tideInterfaces = { EjbIdentity.class }, // tideInterfaces = { EjbIdentity.class },
tideAnnotations={TideEnabled.class,RemoteDestination.class} // tideAnnotations={TideEnabled.class,RemoteDestination.class}
) // )
public class GraniteConfig { //public class GraniteConfig {
@MessagingDestination(noLocal = true, sessionSelector = true) // @MessagingDestination(noLocal = true, sessionSelector = true)
AbstractMessagingDestination helloTopic; // AbstractMessagingDestination helloTopic;
} //}
...@@ -83,12 +83,19 @@ public class PlaceMap extends HttpServlet { ...@@ -83,12 +83,19 @@ public class PlaceMap extends HttpServlet {
// PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta. // PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta.
EventMap map = placemapBean.findMap(mapId); EventMap map = placemapBean.findMap(mapId);
logger.debug("Mapid: {}", mapId); logger.debug("Mapid: {}", mapId);
response.setContentType("image/jpeg");
ostream = response.getOutputStream(); ostream = response.getOutputStream();
printPlaceMapToStream(ostream, "jpg", map);
logger.debug("Flushing ostream"); if (map.getMapData() == null) {
ostream.flush(); logger.debug("Map does not have background!");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
ostream.print("Map has no background!");
} else {
response.setContentType("image/jpeg");
printPlaceMapToStream(ostream, "jpg", map);
logger.debug("Flushing ostream");
ostream.flush();
}
/* /*
* TODO output your page here out.println("<html>"); * TODO output your page here out.println("<html>");
* out.println("<head>"); * out.println("<head>");
...@@ -112,7 +119,7 @@ public class PlaceMap extends HttpServlet { ...@@ -112,7 +119,7 @@ public class PlaceMap extends HttpServlet {
private void printPlaceMapToStream(OutputStream outputStream, String filetype, EventMap map) throws IOException { private void printPlaceMapToStream(OutputStream outputStream, String filetype, EventMap map) throws IOException {
userbean.fatalPermission(Permission.TICKET_SALES, RolePermission.READ, "User tried to print the placemap to Stream"); userbean.fatalPermission(Permission.MAP, RolePermission.READ, "User tried to print the placemap to Stream");
User user = userbean.getCurrentUser(); User user = userbean.getCurrentUser();
long begin = new Date().getTime(); long begin = new Date().getTime();
...@@ -217,21 +224,25 @@ public class PlaceMap extends HttpServlet { ...@@ -217,21 +224,25 @@ public class PlaceMap extends HttpServlet {
}// </editor-fold> }// </editor-fold>
private static final Color RESERVED_COLOR = Color.RED; private static final Color RESERVED_COLOR = Color.RED;
private static final Color SELECTED_COLOR = Color.GREEN; private static final Color SELECTED_COLOR = Color.BLUE;
private static final Color OWNED_COLOR = Color.BLUE; private static final Color OWNED_COLOR = Color.GREEN;
private static final Color BORDER_COLOR = Color.BLACK; private static final Color BORDER_COLOR = Color.BLACK;
private static final Color LOCKED_COLOR = Color.DARK_GRAY;
private static final int BORDER_WIDTH = 2; private static final int BORDER_WIDTH = 2;
private static void drawPlace(Place p, Graphics2D g, User user) { private static void drawPlace(Place p, Graphics2D g, User user) {
Color color = null; Color color = null;
if (!p.isBuyable()) {
color = LOCKED_COLOR;
}
if (p.isReservedFor(user)) { if (p.isReservedFor(user)) {
color = RESERVED_COLOR; color = SELECTED_COLOR;
} else if (user.equals(p.getCurrentUser()) } else if (user.equals(p.getCurrentUser())
|| (p.getGroup() != null && user.equals(p.getGroup().getCreator())) || (p.getGroup() != null && user.equals(p.getGroup().getCreator()))
|| (p.getPlaceReserver() != null && user.equals(p.getPlaceReserver().getUser()))) { || (p.getPlaceReserver() != null && user.equals(p.getPlaceReserver().getUser()))) {
color = OWNED_COLOR; color = OWNED_COLOR;
} else if (p.isTaken()) { } else if (p.isTaken()) {
color = SELECTED_COLOR; color = RESERVED_COLOR;
} }
g.setColor(BORDER_COLOR); g.setColor(BORDER_COLOR);
...@@ -239,7 +250,7 @@ public class PlaceMap extends HttpServlet { ...@@ -239,7 +250,7 @@ public class PlaceMap extends HttpServlet {
if (color != null) { if (color != null) {
g.setColor(color); g.setColor(color);
g.fill(new Rectangle(p.getMapX() + BORDER_WIDTH, p.getMapY() + BORDER_WIDTH, p.getWidth() - BORDER_WIDTH * 2, p.getHeight() - BORDER_WIDTH * 2)); g.fill(new Rectangle(p.getMapX() + BORDER_WIDTH, p.getMapY() + BORDER_WIDTH, p.getWidth() - BORDER_WIDTH, p.getHeight() - BORDER_WIDTH));
} }
} }
......
...@@ -46,14 +46,13 @@ public class PrintBill extends HttpServlet { ...@@ -46,14 +46,13 @@ public class PrintBill extends HttpServlet {
private void ouput(HttpServletRequest request, HttpServletResponse response) throws IOException { private void ouput(HttpServletRequest request, HttpServletResponse response) throws IOException {
Integer billid = getIntegerParameter(request, BILL_ID); Integer billid = getIntegerParameter(request, BILL_ID);
Bill bill = billentity.findById( billid); Bill bill = billentity.findById(billid);
if (bill == null) { if (bill == null) {
return; return;
} }
ByteArrayOutputStream billstream = billentity.getPdfBillStream(bill); ByteArrayOutputStream billstream = new ByteArrayOutputStream();
if (billstream == null) { billentity.getPdfBillStream(bill, billstream);
return;
}
response.setContentLength(billstream.size()); response.setContentLength(billstream.size());
response.setContentType("application/pdf"); response.setContentType("application/pdf");
......
...@@ -12,13 +12,16 @@ import org.slf4j.LoggerFactory; ...@@ -12,13 +12,16 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.BillBeanLocal; import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal; import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.beans.UtilBeanLocal;
import fi.insomnia.bortal.enums.Permission; import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission; import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.model.Bill; import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.utilities.I18n;
@ManagedBean(name = "billManageView") @ManagedBean(name = "billManageView")
@SessionScoped @SessionScoped
public class BillManageView { public class BillManageView extends GenericView {
private static final Logger logger = LoggerFactory.getLogger(BillManageView.class); private static final Logger logger = LoggerFactory.getLogger(BillManageView.class);
@EJB @EJB
...@@ -28,6 +31,9 @@ public class BillManageView { ...@@ -28,6 +31,9 @@ public class BillManageView {
private ListDataModel<Bill> bills; private ListDataModel<Bill> bills;
@EJB @EJB
private UserBeanLocal userBean; private UserBeanLocal userBean;
@EJB
private UtilBeanLocal utilbean;
private ListDataModel<BillLine> billines;
public ListDataModel<Bill> getBills() { public ListDataModel<Bill> getBills() {
userBean.fatalNotLoggedIn(); userBean.fatalNotLoggedIn();
...@@ -35,9 +41,23 @@ public class BillManageView { ...@@ -35,9 +41,23 @@ public class BillManageView {
return bills; return bills;
} }
public String saveBilline() {
if (billines != null) {
logger.debug("Saving bill line {}", billines.getRowData());
}
return null;
}
public ListDataModel<BillLine> getBillLines() {
billines = new ListDataModel<BillLine>(bill.getBillLines());
return billines;
}
public String edit() { public String edit() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "User tried to edit bill " + bills.getRowData() + " without sufficient permission"); userBean.fatalPermission(Permission.BILL, RolePermission.WRITE, "User tried to edit bill " + bills.getRowData() + " without sufficient permission");
setBill(bills.getRowData()); setBill(bills.getRowData());
return "edit"; return "edit";
} }
...@@ -49,15 +69,19 @@ public class BillManageView { ...@@ -49,15 +69,19 @@ public class BillManageView {
return bill; return bill;
} }
public String markPaid() { public String markPaid() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "User tried to mark bill " + bills.getRowData() + " paid without sufficient permission"); userBean.fatalPermission(Permission.BILL, RolePermission.WRITE, "User tried to mark bill " + bills.getRowData() + " paid without sufficient permission");
bill = bills.getRowData(); bill = bills.getRowData();
billbean.markPaid(bill, Calendar.getInstance()); billbean.markPaid(bill, Calendar.getInstance());
if (!utilbean.sendMail(bill.getUser(), I18n.get("bill.billMarkedPaidMail.subject"), I18n.get("bill.billMarkedPaidMail.message", (bill.getBillNumber() == null) ? "----" : bill.getBillNumber().toString()))) {
addFaceMessage("email.errorSending");
}
return ""; return "";
} }
public boolean isManage() { public boolean isManage() {
return userBean.hasPermission(Permission.TICKET_SALES, RolePermission.WRITE); return userBean.hasPermission(Permission.BILL, RolePermission.WRITE);
} }
} }
package fi.insomnia.bortal.view; package fi.insomnia.bortal.view;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -37,16 +38,17 @@ public class BillView { ...@@ -37,16 +38,17 @@ public class BillView {
public ListDataModel<Bill> getBills() { public ListDataModel<Bill> getBills() {
userbean.fatalNotLoggedIn(); userbean.fatalNotLoggedIn();
List<Bill> bills = userbean.getCurrentUser().getBills(); List<Bill> bills = userbean.getCurrentUser().getBills();
// logger.debug("found {} bills for user {}", bills.size(), userbean.getCurrentUser().getLogin()); // logger.debug("found {} bills for user {}", bills.size(),
// userbean.getCurrentUser().getLogin());
billList = new ListDataModel<Bill>(bills); billList = new ListDataModel<Bill>(bills);
return billList; return billList;
} }
public DataModel<BillSummary> getBillLineSummary() { public DataModel<BillSummary> getBillLineSummary() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "User tried to get the bill summary page"); userBean.fatalPermission(Permission.BILL, RolePermission.READ, "User tried to get the bill summary page");
return new ListDataModel<BillSummary>(billbean.getBillLineSummary()); return new ListDataModel<BillSummary>(new ArrayList<BillSummary>(billbean.getBillLineSummary()));
} }
public boolean isManage() { public boolean isManage() {
......
...@@ -3,11 +3,12 @@ package fi.insomnia.bortal.view; ...@@ -3,11 +3,12 @@ package fi.insomnia.bortal.view;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import fi.insomnia.bortal.I18n; import fi.insomnia.bortal.utilities.I18n;
public abstract class GenericView { public abstract class GenericView {
protected void addFaceMessage(String string) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get(string))); protected void addFaceMessage(String string, Object ... params) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get(string, params)));
} }
......
package fi.insomnia.bortal.view; package fi.insomnia.bortal.view;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
...@@ -23,7 +25,7 @@ import fi.insomnia.bortal.model.Product; ...@@ -23,7 +25,7 @@ import fi.insomnia.bortal.model.Product;
@ManagedBean(name = "mapManageView") @ManagedBean(name = "mapManageView")
@SessionScoped @SessionScoped
public class MapManageView { public class MapManageView extends GenericView {
private static final Logger logger = LoggerFactory.getLogger(MapManageView.class); private static final Logger logger = LoggerFactory.getLogger(MapManageView.class);
@EJB @EJB
...@@ -39,6 +41,8 @@ public class MapManageView { ...@@ -39,6 +41,8 @@ public class MapManageView {
private EventMap map; private EventMap map;
private String mapname; private String mapname;
private String buyableLike;
private boolean tablesHorizontal = false; private boolean tablesHorizontal = false;
private boolean oneRowTable = false; private boolean oneRowTable = false;
private int placesInRow = 1; private int placesInRow = 1;
...@@ -55,20 +59,34 @@ public class MapManageView { ...@@ -55,20 +59,34 @@ public class MapManageView {
private String namebase; private String namebase;
public ListDataModel<EventMap> getMaps() { public ListDataModel<EventMap> getMaps() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "No right to view all maps in management context"); userBean.fatalPermission(Permission.MAP, RolePermission.WRITE, "No right to view all maps in management context");
eventmaps = new ListDataModel<EventMap>(eventBean.getCurrentEvent().getEventMaps()); eventmaps = new ListDataModel<EventMap>(eventBean.getCurrentEvent().getEventMaps());
return eventmaps; return eventmaps;
} }
public String lockBuyable() {
int count = placebean.setBuyable(map, buyableLike, false);
this.addFaceMessage("mapManage.lockedPlaces", count );
return null;
}
public String releaseBuyable() {
int count = placebean.setBuyable(map, buyableLike, true);
this.addFaceMessage("mapManage.releasedPlaces", count );
return null;
}
public String editMap() { public String editMap() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "No right to view all maps in management context"); userBean.fatalPermission(Permission.MAP, RolePermission.WRITE, "No right to view all maps in management context");
setMap(eventmaps.getRowData()); setMap(eventmaps.getRowData());
return "edit"; return "edit";
} }
public String saveMap() { public String saveMap() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.WRITE, "No right to view all maps in management context"); userBean.fatalPermission(Permission.MAP, RolePermission.WRITE, "No right to view all maps in management context");
eventmapBean.saveMap(getMap()); eventmapBean.saveMap(getMap());
return "edit"; return "edit";
...@@ -82,14 +100,20 @@ public class MapManageView { ...@@ -82,14 +100,20 @@ public class MapManageView {
public void generatePlaces() { public void generatePlaces() {
String[] tablenames = getNamebase().split(";"); String[] tablenames = getNamebase().split(";");
List<Place> mapplaces = map.getPlaces();
logger.debug("places in map before {}", mapplaces.size());
if (mapplaces == null || mapplaces.isEmpty()) {
mapplaces = new ArrayList<Place>();
map.setPlaces(mapplaces);
}
for (int tableI = 0; tableI < tableCount; ++tableI) { for (int tableI = 0; tableI < tableCount; ++tableI) {
int tableXStart = tableI * tableXdiff; int tableXStart = tableI * tableXdiff;
int tableYStart = tableI * tableYdiff; int tableYStart = tableI * tableYdiff;
int rows = isOneRowTable() ? 1 : 2; int rows = isOneRowTable() ? 1 : 2;
for (int rowI = 0; rowI < rows; ++rowI) { for (int rowI = 0; rowI < rows; ++rowI) {
int rowXStart = tableXStart + (tablesHorizontal ? 0 : height * rowI); int rowXStart = tableXStart + (tablesHorizontal ? 0 : width * rowI);
int rowYStart = tableYStart + (tablesHorizontal ? width * rowI : 0); int rowYStart = tableYStart + (tablesHorizontal ? height * rowI : 0);
logger.debug("row start {} {}", rowXStart, rowYStart); logger.debug("row start {} {}", rowXStart, rowYStart);
for (int placeI = 1; placeI <= placesInRow; ++placeI) { for (int placeI = 1; placeI <= placesInRow; ++placeI) {
...@@ -103,12 +127,15 @@ public class MapManageView { ...@@ -103,12 +127,15 @@ public class MapManageView {
place.setMapX(xpos); place.setMapX(xpos);
place.setMapY(ypos); place.setMapY(ypos);
place.setProduct(mapproduct); place.setProduct(mapproduct);
place.setName(tablenames[tableI] + placeI); place.setName(tablenames[tableI] + (placeI + placesInRow * rowI));
map.getPlaces().add(place); mapplaces.add(place);
} }
} }
} }
eventmapBean.saveMap(map); logger.debug("places in map after {}", mapplaces.size());
map = eventmapBean.saveMap(map);
logger.debug("places in map merge {}", map.getPlaces().size());
} }
...@@ -223,4 +250,12 @@ public class MapManageView { ...@@ -223,4 +250,12 @@ public class MapManageView {
public void setNamebase(String namebase) { public void setNamebase(String namebase) {
this.namebase = namebase; this.namebase = namebase;
} }
public void setBuyableLike(String buyableLike) {
this.buyableLike = buyableLike;
}
public String getBuyableLike() {
return buyableLike;
}
} }
...@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; ...@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
*/ */
@ManagedBean(name = "mapView") @ManagedBean(name = "mapView")
@SessionScoped @SessionScoped
public class MapView extends GenericView{ public class MapView extends GenericView {
private Logger logger = LoggerFactory.getLogger(MapView.class); private Logger logger = LoggerFactory.getLogger(MapView.class);
...@@ -55,14 +55,26 @@ public class MapView extends GenericView{ ...@@ -55,14 +55,26 @@ public class MapView extends GenericView{
private Place clickedplace; private Place clickedplace;
private User user;
// private Place selectedPlace = null; // private Place selectedPlace = null;
/** Creates a new instance of MapView */ /** Creates a new instance of MapView */
public MapView() { public MapView() {
} }
public String buySelectedPlaces() public void initSelf() {
{ user = userBean.getCurrentUser();
}
public boolean canUserBuy() {
if (user == null) {
return false;
}
return user.getAccountBalance().compareTo(BigDecimal.ZERO) > 0;
}
public String buySelectedPlaces() {
try { try {
placeBean.buySelectedPlaces(getActiveMap()); placeBean.buySelectedPlaces(getActiveMap());
} catch (BortalCatchableException e) { } catch (BortalCatchableException e) {
...@@ -72,8 +84,12 @@ public class MapView extends GenericView{ ...@@ -72,8 +84,12 @@ public class MapView extends GenericView{
return ""; return "";
} }
public BigDecimal getReservationPrice() {
return placeBean.totalReservationPrice(activeMap, null);
}
public void placeSelectActionListener(ActionEvent e) { public void placeSelectActionListener(ActionEvent e) {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.EXECUTE); userBean.fatalPermission(Permission.MAP, RolePermission.EXECUTE);
User user = userBean.getCurrentUser(); User user = userBean.getCurrentUser();
...@@ -85,32 +101,32 @@ public class MapView extends GenericView{ ...@@ -85,32 +101,32 @@ public class MapView extends GenericView{
int x = new Integer(requestParams.get(clientId + ".x")).intValue(); int x = new Integer(requestParams.get(clientId + ".x")).intValue();
int y = new Integer(requestParams.get(clientId + ".y")).intValue(); int y = new Integer(requestParams.get(clientId + ".y")).intValue();
logger.debug("Clicked position {} {}", x, y); logger.debug("Clicked position {} {}", x, y);
setClickedplace(placeBean.findPlace(getActiveMap(), x, y)); setClickedplace(placeBean.findPlace(getActiveMap(), x, y));
logger.debug("Clicked place: {}", getClickedplace()); logger.debug("Clicked place: {}", getClickedplace());
if (getClickedplace() != null) { if (getClickedplace() != null) {
if (getClickedplace().isReservedFor(user)) { if (getClickedplace().isReservedFor(user)) {
logger.debug("Place was reserved for user. Removing reservation!"); logger.debug("Place {} was reserved for user. Removing reservation!", clickedplace);
if(!placeBean.releasePlace(getClickedplace(), user)) if (!placeBean.releasePlace(getClickedplace(), user)) {
{
this.addFaceMessage("mapView.errorWhenReleasingPlace"); this.addFaceMessage("mapView.errorWhenReleasingPlace");
} }
} else if (!getClickedplace().isTaken()) { } else if (getClickedplace().isBuyable() && !getClickedplace().isTaken()) {
BigDecimal balance = userBean.getCurrentUser().getAccountBalance(); BigDecimal balance = userBean.getCurrentUser().getAccountBalance();
BigDecimal price = placeBean.totalReservationPrice(getActiveMap(),getClickedplace()); BigDecimal price = placeBean.totalReservationPrice(getActiveMap(), getClickedplace());
logger.debug("Balance {}, price {}", balance, price); logger.debug("Balance {}, price {}", balance, price);
if (price.compareTo(balance) <= 0) { if (price.compareTo(balance) <= 0) {
logger.debug("Place was free. Marking for user."); logger.debug("Place was free. Marking for user.");
if(!placeBean.reservePlace(getClickedplace(), user)) if (!placeBean.reservePlace(getClickedplace(), user)) {
{
this.addFaceMessage("mapView.errorWhenReservingPlace"); this.addFaceMessage("mapView.errorWhenReservingPlace");
} }
} else { } else {
addFaceMessage("mapView.notEnoughCreditsToReserve"); if (userBean.getCurrentUser().getAccountBalance().compareTo(BigDecimal.ZERO) > 0) {
addFaceMessage("mapView.notEnoughCreditsToReserve");
}
logger.debug("Did not have enought money to reserve place! required {} , got {}", price, balance); logger.debug("Did not have enought money to reserve place! required {} , got {}", price, balance);
} }
} }
...@@ -145,13 +161,11 @@ public class MapView extends GenericView{ ...@@ -145,13 +161,11 @@ public class MapView extends GenericView{
* this event does not have map, return null. * this event does not have map, return null.
*/ */
public EventMap getActiveMap() { public EventMap getActiveMap() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.READ); userBean.fatalPermission(Permission.MAP, RolePermission.READ);
setUser(userBean.getCurrentUser());
LanEvent event = eventBean.getCurrentEvent(); LanEvent event = eventBean.getCurrentEvent();
for(EventMap map : event.getEventMaps()) for (EventMap map : event.getEventMaps()) {
{ if (map.isActive()) {
if(map.isActive())
{
activeMap = map; activeMap = map;
break; break;
} }
...@@ -180,4 +194,13 @@ public class MapView extends GenericView{ ...@@ -180,4 +194,13 @@ public class MapView extends GenericView{
public Place getClickedplace() { public Place getClickedplace() {
return clickedplace; return clickedplace;
} }
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
} }
...@@ -18,7 +18,6 @@ import javax.faces.model.ListDataModel; ...@@ -18,7 +18,6 @@ import javax.faces.model.ListDataModel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.I18n;
import fi.insomnia.bortal.beans.BillBeanLocal; import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal; import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal; import fi.insomnia.bortal.beans.ProductBeanLocal;
...@@ -29,6 +28,7 @@ import fi.insomnia.bortal.model.Bill; ...@@ -29,6 +28,7 @@ import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.Discount; import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.Product; import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.utilities.I18n;
import fi.insomnia.bortal.view.helpers.ProductShopItem; import fi.insomnia.bortal.view.helpers.ProductShopItem;
@ManagedBean(name = "productShopView") @ManagedBean(name = "productShopView")
...@@ -94,7 +94,7 @@ public class ProductShopView { ...@@ -94,7 +94,7 @@ public class ProductShopView {
public DataModel<ProductShopItem> getBillCart() { public DataModel<ProductShopItem> getBillCart() {
logger.debug("Creating new BillCart"); logger.debug("Creating new BillCart");
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.EXECUTE); userBean.fatalPermission(Permission.BILL, RolePermission.EXECUTE);
billCart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts())); billCart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
return billCart; return billCart;
......
...@@ -74,6 +74,7 @@ public class ProductView { ...@@ -74,6 +74,7 @@ public class ProductView {
public String createDiscount() { public String createDiscount() {
userBean.fatalPermission(Permission.PRODUCT, RolePermission.WRITE, "Tried to create discount without sufficient rights"); userBean.fatalPermission(Permission.PRODUCT, RolePermission.WRITE, "Tried to create discount without sufficient rights");
logger.debug("Creating product discount {} for product {}", discountdesc, product); logger.debug("Creating product discount {} for product {}", discountdesc, product);
discount = discountbean.create(getDiscountdesc()); discount = discountbean.create(getDiscountdesc());
product.getDiscounts().add(discount); product.getDiscounts().add(discount);
productBean.mergeChanges(product); productBean.mergeChanges(product);
...@@ -125,7 +126,7 @@ public class ProductView { ...@@ -125,7 +126,7 @@ public class ProductView {
* @return the activeMap * @return the activeMap
*/ */
public EventMap getActiveMap() { public EventMap getActiveMap() {
userBean.fatalPermission(Permission.TICKET_SALES, RolePermission.READ); userBean.fatalPermission(Permission.MAP, RolePermission.READ);
return activeMap; return activeMap;
} }
......
...@@ -12,7 +12,6 @@ import javax.faces.model.ListDataModel; ...@@ -12,7 +12,6 @@ import javax.faces.model.ListDataModel;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.I18n;
import fi.insomnia.bortal.beans.RoleBeanLocal; import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.beans.SecurityBeanLocal; import fi.insomnia.bortal.beans.SecurityBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal; import fi.insomnia.bortal.beans.UserBeanLocal;
...@@ -21,6 +20,7 @@ import fi.insomnia.bortal.enums.RolePermission; ...@@ -21,6 +20,7 @@ import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.model.AccountEvent; import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Role; import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.utilities.I18n;
@ManagedBean(name = "userView") @ManagedBean(name = "userView")
@SessionScoped @SessionScoped
...@@ -55,11 +55,15 @@ public class UserView extends GenericView { ...@@ -55,11 +55,15 @@ public class UserView extends GenericView {
} }
public List<Role> getUserRoles() { public List<Role> getUserRoles() {
userBean.fatalPermission(Permission.LOGIN, RolePermission.READ, "does not have permission to view roles at userView!"); userBean.fatalPermission(Permission.ROLE_MANAGEMENT, RolePermission.READ, "does not have permission to view roles at userView!");
return roleBean.listRoles(); return roleBean.listRoles();
} }
public boolean canSave() {
return userBean.getCurrentUser().equals(user) || userBean.hasPermission(Permission.USER_MANAGEMENT, RolePermission.WRITE);
}
public void editSelf() { public void editSelf() {
userBean.fatalNotLoggedIn(); userBean.fatalNotLoggedIn();
setUser(userBean.getCurrentUser()); setUser(userBean.getCurrentUser());
...@@ -106,12 +110,16 @@ public class UserView extends GenericView { ...@@ -106,12 +110,16 @@ public class UserView extends GenericView {
} }
public String saveUser() { public String saveUser() {
logger.debug("Saving user at UserView mbean nick: {}", user.getNick()); logger.debug("Saving user at UserView mbean nick: {}", user.getNick());
User thisusr = getUser(); User thisusr = getUser();
if (!userBean.isCurrentUser(thisusr)) { if (!userBean.isCurrentUser(thisusr)) {
logger.debug("user {} is modifying user {}", userBean.getCurrentUser(), thisusr); logger.debug("user {} is modifying user {}", userBean.getCurrentUser(), thisusr);
userBean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.WRITE); userBean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.WRITE);
} }
for (Role r : getUser().getRoles()) {
logger.debug("Users roles: {}", r.getName());
}
setUser(userBean.mergeChanges(getUser())); setUser(userBean.mergeChanges(getUser()));
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("user.successfullySaved"))); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("user.successfullySaved")));
return "edit"; return "edit";
......
...@@ -2,11 +2,10 @@ package fi.insomnia.bortal.view.flash; ...@@ -2,11 +2,10 @@ package fi.insomnia.bortal.view.flash;
import javax.inject.Named; import javax.inject.Named;
import org.granite.messaging.service.annotations.RemoteDestination;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@RemoteDestination //@RemoteDestination
@Named("hvTest") @Named("hvTest")
public class HvTest { public class HvTest {
......
/*
GRANITE DATA SERVICES
Copyright (C) 2007 ADEQUATE SYSTEMS SARL
This file is part of Granite Data Services.
Granite Data Services is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
Granite Data Services is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
package fi.insomnia.bortal.view.flash;
import org.granite.tide.data.DataObserveParams;
import org.granite.tide.data.DataPublishParams;
import org.granite.tide.data.DataTopicParams;
public class ObserveAllPublishAll implements DataTopicParams {
@Override
public void observes(DataObserveParams params) {
}
@Override
public void publishes(DataPublishParams params, Object entity) {
}
}
\ No newline at end of file
...@@ -4,16 +4,21 @@ import java.math.BigDecimal; ...@@ -4,16 +4,21 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.Product; import fi.insomnia.bortal.model.Product;
public class ProductShopItem { public class ProductShopItem {
private static final Logger logger = LoggerFactory.getLogger(ProductShopItem.class);
private Product product; private Product product;
private BigDecimal count = BigDecimal.ZERO; private BigDecimal count = BigDecimal.ZERO;
private Integer id;
public ProductShopItem(Product prod) { public ProductShopItem(Product prod) {
this.product = prod; this.product = prod;
id = this.product.getId().getId();
} }
public static List<ProductShopItem> productList(List<Product> products) { public static List<ProductShopItem> productList(List<Product> products) {
...@@ -37,4 +42,15 @@ public class ProductShopItem { ...@@ -37,4 +42,15 @@ public class ProductShopItem {
return count; return count;
} }
public void setId(Integer setid) {
logger.debug("Setting id {} to cart {}", setid, id);
if (id != setid) {
throw new RuntimeException("Carts mixed up! Please raport an error to coders!");
}
}
public Integer getId() {
return id;
}
} }
...@@ -7,13 +7,13 @@ import javax.faces.component.UIComponent; ...@@ -7,13 +7,13 @@ import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.convert.Converter; import javax.faces.convert.Converter;
import org.granite.logging.Logger; import org.slf4j.LoggerFactory;
@ManagedBean(name = "emptytonullconverter") @ManagedBean(name = "emptytonullconverter")
@NoneScoped @NoneScoped
public class EmptyToNullConverter implements Converter { public class EmptyToNullConverter implements Converter {
private static final Logger logger = Logger.getLogger(EmptyToNullConverter.class); private static final org.slf4j.Logger logger = LoggerFactory.getLogger(EmptyToNullConverter.class);
@Override @Override
public Object getAsObject(FacesContext context, UIComponent component, String value) { public Object getAsObject(FacesContext context, UIComponent component, String value) {
String ret = value; String ret = value;
......
package fi.insomnia.bortal.web.helper; package fi.insomnia.bortal.web.helper;
import org.granite.messaging.service.annotations.RemoteDestination; //
import org.granite.tide.annotations.TideEnabled; //@RemoteDestination
//@TideEnabled
@RemoteDestination
@TideEnabled
public class HelloWorld { public class HelloWorld {
......
...@@ -73,4 +73,6 @@ page.bill.billSummary.pagegroup=admin ...@@ -73,4 +73,6 @@ page.bill.billSummary.pagegroup=admin
page.bill.billSummary.header=Laskujen yhteenveto page.bill.billSummary.header=Laskujen yhteenveto
page.account.list.pagegroup=user page.account.list.pagegroup=user
page.account.list.header=Tilitapahtumat page.account.list.header=Tilitapahtumat
\ No newline at end of file page.auth.resetPassword.pagegroup=user
page.auth.resetPassword.header=Salasanan resetointi
\ No newline at end of file
...@@ -14,6 +14,11 @@ login.submit=Kirjaudu sis\u00e4\u00e4n ...@@ -14,6 +14,11 @@ login.submit=Kirjaudu sis\u00e4\u00e4n
login.username=K\u00e4ytt\u00e4j\u00e4tunnus login.username=K\u00e4ytt\u00e4j\u00e4tunnus
nasty.user=Wait, wot! Mene pois! nasty.user=Wait, wot! Mene pois!
placeSelect.placesleft=Paikkoja j\u00e4ljell\u00e4 placeSelect.placesleft=Paikkoja j\u00e4ljell\u00e4
placeSelect.reservationPrice=Tilauksen hinta
placeSelect.reservedPlaces=Valitut paikat
placeSelect.placePrice=Paikan hinta
placeSelect.placeName=Paikka
placeSelect.placeProductName=Paikan tyyppi
product.barcode=Viivakoodi product.barcode=Viivakoodi
product.create=Luo tuote product.create=Luo tuote
product.edit=Muokkaa product.edit=Muokkaa
...@@ -28,10 +33,19 @@ product.cart.count=Ostoskoriin ...@@ -28,10 +33,19 @@ product.cart.count=Ostoskoriin
products.save=Tallenna products.save=Tallenna
productshop.commit=Osta productshop.commit=Osta
product.boughtTotal=Tuotteita laskutettu product.boughtTotal=Tuotteita laskutettu
product.paid=Maksettu
role.create=Luo rooli role.create=Luo rooli
role.edit=Muokkaa role.edit=Muokkaa
role.name=Nimi role.name=Nimi
role.parents=Periytyy role.parents=Periytyy
role.read=(R)
role.write=(W)
role.execute=(X)
role.description=Kuvaus
role.edit.save=Tallenna
topmenu.adminfront=Admintavaraa topmenu.adminfront=Admintavaraa
topmenu.frontpage=Etusivu topmenu.frontpage=Etusivu
topmenu.shoppings=Kauppa topmenu.shoppings=Kauppa
...@@ -74,6 +88,30 @@ bill.referenceNumberBase=Viitenumeropohja ...@@ -74,6 +88,30 @@ bill.referenceNumberBase=Viitenumeropohja
bill.referencenumber=Viitenumero bill.referencenumber=Viitenumero
bill.markPaid=Maksettu bill.markPaid=Maksettu
bill.isPaid=Maksettu bill.isPaid=Maksettu
bill.paidDate=Maksupiv
bill.addr1=Osoite 1
bill.addr2=Osoite 2
bill.addr3=Osoite 3
bill.addr4=Osoite 4
bill.addr5=Osoite 5
bill.paymentTime=Maksuehdot
bill.noticetime=Huomautusaika
bill.theirReference=Asiakkaan viite
bill.ourReference=Myyjn viite
bill.deliveryTerms=Toimitusehdot
bill.notes=Huomioita
billine.unitPrice=Yksikkhinta
billine.name=Tuote
billine.quantity=Lukumr
billine.unitName=Yksikk
billine.vat=ALV
billine.referencedProduct=Tuoteviittaus
billine.save=Tallenna
user.noAccountevents=Ei tilitapahtumia
user.accountEventHeader=Tilitapahtumat
loginerror.header=Kirjautuminen eponnistui loginerror.header=Kirjautuminen eponnistui
loginerror.message=Kyttjtunnus tai salasana ei ollut oikein. loginerror.message=Kyttjtunnus tai salasana ei ollut oikein.
permissiondenied.alreadyLoggedIn=Sinulla ei ole riittvsti oikeuksia! permissiondenied.alreadyLoggedIn=Sinulla ei ole riittvsti oikeuksia!
...@@ -153,7 +191,9 @@ mapView.errorWhenReservingPlace=Paikkaa varatessa tapahtui virhe. ...@@ -153,7 +191,9 @@ mapView.errorWhenReservingPlace=Paikkaa varatessa tapahtui virhe.
mapView.errorWhenReleasingPlace=Paikkaa vapauttassa tapahtui virhe. mapView.errorWhenReleasingPlace=Paikkaa vapauttassa tapahtui virhe.
mapView.notEnoughCreditsToReserve=Sinulla ei ole riittvsti suoritettuja konepaikkamaksuja tmn paikan varaamiseen. mapView.notEnoughCreditsToReserve=Sinulla ei ole riittvsti suoritettuja konepaikkamaksuja tmn paikan varaamiseen.
mapView.errorWhileBuyingPlaces=Virhe paikkojen ostossa. Ole hyv ja yrit uudelleen. Jos virhe toistuu ota yhteytt jrjestjiin. mapView.errorWhileBuyingPlaces=Virhe paikkojen ostossa. Ole hyv ja yrit uudelleen. Jos virhe toistuu ota yhteytt jrjestjiin.
mapView.buyPlaces=Lukitse paikanvaraus mapView.buyPlaces=Lukitse valitut paikat
userview.userExists=Kyttjtunnus on jo olemassa. Ole hyv ja valitse toinen tunnus.
page.auth.loginerror.header=kirjautuminen eponnistui
accountEvent.unitPrice=Yks. hinta accountEvent.unitPrice=Yks. hinta
accountEvent.quantity=Lkm accountEvent.quantity=Lkm
...@@ -162,4 +202,53 @@ accountEvent.eventTime=Aika ...@@ -162,4 +202,53 @@ accountEvent.eventTime=Aika
accountEvent.delivered=Toimitettu accountEvent.delivered=Toimitettu
accountEvent.edit=Muokkaa accountEvent.edit=Muokkaa
accountEvent.productname=Tuote accountEvent.productname=Tuote
user.accountEvents=Tilitapahtumat user.accountEvents=Tilitapahtumat
\ No newline at end of file bill.billMarkedPaidMail.subject=[INSOMNIA] Lasku merkitty maksetuksi
bill.billMarkedPaidMail.message=Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirty lippukauppaan varamaamaan haluamasi paikat. \nTervetuloa tapahtumaan!\n\nTerveisin,\nInsomnia lippupalvelu\nwww.insomnia.fi
passwordreset.mailSubject=[INSOMNIA] Salasanan vaihtaminen
passwordreset.mailBody=Voit vaihtaa salasanasi osoitteessa {0}\n\nJos et ole pyytnyt unohtuneen salasanan vaihtamista, ei thn viestiin tarvitse reagoida.\n\nTerveisin,\nInsomnia lippupalvelu\nwww.insomnia.fi
passwordReset.hashNotFound=Salasanan vaihto on vanhentunut. Jos haluat vaihtaa salasanan lhet vaihtopyynt uudelleen.
resetMail.header=Unohtuneen salasanan vaihto
resetMail.body=Voit vaihtaa unohtuneen salasanan syttmll kyttjtunnuksesi allaolevaan kenttn. Tunnukseen liitettyyn shkpostiosoitteeseen lhetetn kertakyttinen osoite jossa voit vaihtaa syttmsi kyttjtunnuksen salasanan.
resetmailSent.header=Shkposti lhetetty
resetmailSent.body=Antamasi kyttjtunnuksen shkpostiosoitteeseen on lhetetty osoite jossa voit vaihtaa tunnuksen salasanan.
resetMail.username=Kyttjtunnus
resetMail.send=Lhet shkposti
passwordChanged.header=Salasana vaihdettu onnistuneesti
passwordChanged.body=Voit nyt kirjautua kyttjtunnuksella ja uudella salasanalla sisn jrjestelmn.
loginerror.resetpassword=Salasana unohtunut?
mapManage.lockedPlaces=Lukittu kartasta {0} paikkaa.
mapManage.releasedPlaces=Vapautettu kartasta {0} paikkaa
placeSelect.legend.red=Varattu paikka
placeSelect.legend.green=Oma ostettu paikka
placeSelect.legend.blue=Oma valittu paikka
placeSelect.legend.white=Vapaa paikka
placeSelect.legend.grey=Vapautetaan myhemmin
placeSelect.totalPlaces=Paikkoja yhteens
# Validationmessages
javax.validation.constraints.AssertFalse.message=must be false
javax.validation.constraints.AssertTrue.message=must be true
javax.validation.constraints.DecimalMax.message=must be less than or equal to {value}
javax.validation.constraints.DecimalMin.message=must be greater than or equal to {value}
javax.validation.constraints.Digits.message=numeric value out of bounds (<{integer} digits>.<{fraction} digits> expected)
javax.validation.constraints.Future.message=must be in the future
javax.validation.constraints.Max.message=must be less than or equal to {value}
javax.validation.constraints.Min.message=must be greater than or equal to {value}
javax.validation.constraints.NotNull.message=may not be null
javax.validation.constraints.Null.message=must be null
javax.validation.constraints.Past.message=must be in the past
javax.validation.constraints.Pattern.message=must match "{regexp}"
javax.validation.constraints.Size.message=size must be between {min} and {max}
org.hibernate.validator.constraints.Email.message=not a well-formed email address
org.hibernate.validator.constraints.Length.message=length must be between {min} and {max}
org.hibernate.validator.constraints.NotEmpty.message=may not be empty
org.hibernate.validator.constraints.Range.message=must be between {min} and {max}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!