Commit f378d8a0 by Tuomas Riihimäki

Uusi facadetemplate. Lisätty insomnian2 template

1 parent a2492286
Showing with 1566 additions and 1090 deletions
package fi.iki.tuomari.utils.beans.callbacks;
import java.util.Collections;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import fi.insomnia.bortal.utilities.ModelInterface;
public class AndPredicateCreator<A, T extends ModelInterface<?>> implements FacadeCallback<T> {
private final A searchval;
private final List<SingularAttribute<T, A>> attributes;
public AndPredicateCreator(A search, List<SingularAttribute<T, A>> attrs) {
searchval = search;
attributes = attrs;
}
public AndPredicateCreator(A search, SingularAttribute<T, A> attr) {
searchval = search;
attributes = Collections.singletonList(attr);
}
@Override
public void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, List<Predicate> predicates) {
if (searchval == null || attributes == null || attributes.isEmpty()) {
return;
}
if (attributes.size() > 1) {
Predicate[] preds = new Predicate[attributes.size()];
int i = 0;
for (SingularAttribute<T, A> attr : attributes) {
preds[i++] = cb.equal(root.get(attr), searchval);
}
predicates.add(cb.and(preds));
} else {
predicates.add(cb.equal(root.get(attributes.get(0)), searchval));
}
}
}
package fi.iki.tuomari.utils.beans.callbacks;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.utilities.ModelInterface;
public interface FacadeCallback<C extends ModelInterface<?>> {
void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<C> root, List<Predicate> predicates);
}
package fi.iki.tuomari.utils.beans.callbacks;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.utilities.ModelInterface;
public class OrPredicateCreator<A, T extends ModelInterface<?>> implements FacadeCallback<T> {
private final A searchstr;
private final List<SingularAttribute<T, A>> attributes;
private static final Logger logger = LoggerFactory.getLogger(OrPredicateCreator.class);
public OrPredicateCreator(A search, List<SingularAttribute<T, A>> attrs) {
searchstr = search;
attributes = attrs;
}
@Override
public void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, List<Predicate> predicates) {
if (searchstr == null || attributes == null || attributes.isEmpty()) {
return;
}
logger.info("Adding searchstring {}", searchstr);
Predicate[] preds = new Predicate[attributes.size()];
int i = 0;
for (SingularAttribute<T, A> attr : attributes) {
preds[i++] = cb.equal(root.get(attr), searchstr);
}
predicates.add(cb.or(preds));
}
}
package fi.iki.tuomari.utils.beans.callbacks;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import fi.insomnia.bortal.utilities.ModelInterface;
public class OrderCallback<T extends ModelInterface<?>> implements FacadeCallback<T> {
private final SingularAttribute<? super T, ?> sort;
private final boolean asc;
private String sortstr;
public OrderCallback(boolean asc, SingularAttribute<? super T, ?> sortAttr) {
sort = sortAttr;
this.asc = asc;
}
public OrderCallback(boolean asc2, String sort2) {
this.asc = asc2;
sortstr = sort2;
sort = null;
}
@Override
public void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, List<Predicate> predicates) {
if (sort == null) {
return;
}
Expression<?> path = null;
if (sort == null) {
if (sortstr == null) {
return;
}
try {
path = root.get(sortstr);
} catch (IllegalArgumentException e) {
path = null;
}
} else {
path = root.get(sort);
}
if (path == null) {
return;
}
if (asc) {
cb.asc(path);
} else {
cb.desc(path);
}
}
}
package fi.iki.tuomari.utils.beans.callbacks;
import java.util.Collections;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import fi.insomnia.bortal.utilities.ModelInterface;
public class StringSearchPredicateCreator<T extends ModelInterface<?>> implements FacadeCallback<T> {
private static final String WILDCARD = "%";
private String searchstr = null;
private List<SingularAttribute<T, String>> attributes = null;
public StringSearchPredicateCreator(String search, List<SingularAttribute<T, String>> attrs) {
if (addSearch(search)) {
attributes = attrs;
}
}
public StringSearchPredicateCreator(String search, SingularAttribute<T, String> from) {
if (addSearch(search)) {
attributes = Collections.singletonList(from);
}
}
private boolean addSearch(String search) {
if (search != null) {
search = search.trim();
if (!search.isEmpty()) {
searchstr = new StringBuilder().append(WILDCARD).append(search).append(WILDCARD).toString();
return true;
}
}
searchstr = null;
return false;
}
@Override
public void exec(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, List<Predicate> predicates) {
if (searchstr == null || attributes == null || attributes.isEmpty()) {
return;
}
Predicate[] preds = new Predicate[attributes.size()];
int i = 0;
for (SingularAttribute<T, String> attr : attributes) {
preds[i++] = cb.equal(root.get(attr), searchstr);
}
predicates.add(cb.and(preds));
}
}
......@@ -75,7 +75,7 @@ public class BillBean implements BillBeanLocal {
if (id <= 0) {
return null;
}
Bill bill = billFacade.find(event.getId(), id);
Bill bill = billFacade.find(event, id);
User currentuser = permbean.getCurrentUser();
logger.debug("bill {} user {}", bill, currentuser);
......
......@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.CardTemplateFacade;
import fi.insomnia.bortal.facade.PrintedCardFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.CardTemplate;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.PrintedCard;
......@@ -40,13 +41,19 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@EJB
private EventBeanLocal eventBean;
@EJB
private UserBeanLocal userbean;
// @EJB
// private UserBeanLocal userbean;
@EJB
private PrintedCardFacade printedcardfacade;
@EJB
private UtilBeanLocal mailbean;
@EJB
private UserFacade userfacade;
@EJB
private UserBeanLocal userbean;
@Override
@RolesAllowed("USER_MANAGEMENT/WRITE")
public List<CardTemplate> findAll() {
......@@ -80,6 +87,7 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
*/
@Override
public PrintedCard checkPrintedCard(User user) throws PermissionDeniedException {
user = userfacade.find(user.getId());
LanEvent currEvent = eventBean.getCurrentEvent();
List<PrintedCard> myCards = printedcardfacade.findForUser(currEvent, user);
......@@ -111,14 +119,14 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
if (biggestCard != null) {
biggestCard.setEnabled(false);
printedcardfacade.merge(biggestCard);
// biggestCard = printedcardfacade.merge(biggestCard);
}
PrintedCard pc = new PrintedCard(currEvent);
pc.setTemplate(roleCard);
pc.setUser(user);
// user.getPrintedCards().add(pc);
printedcardfacade.create(pc);
user.getPrintedCards().add(pc);
// printedcardfacade.create(pc);
biggestCard = pc;
logger.debug("User {} has too little power old role {} New role {}", new Object[] { user.getLogin(), existingPower, newPower });
} else if (existingPower > newPower) {
......
......@@ -29,20 +29,24 @@ public class DiscountBean implements DiscountBeanLocal {
@Override
public Discount save(Discount discount) {
Discount ret = discountfacade.merge(discount);
productfacade.evictClass();
discountfacade.evictClass();
// productfacade.evictClass();
// discountfacade.evictClass();
return ret;
}
@Override
public Discount create(String discountdesc) {
Discount ret = new Discount(eventbean.getCurrentEvent());
ret.setShortdesc(discountdesc);
discountfacade.create(ret);
eventfacade.evict(eventbean.getCurrentEvent());
return ret;
}
// @Override
// public Discount create(String discountdesc) {
// LanEvent ev = eventbean.getCurrentEvent();
// Discount ret = new Discount(ev);
// ret.setShortdesc(discountdesc);
// ev.getDiscounts().add(ret);
// discountfacade.flush();
//
// // discountfacade.create(ret);
// // eventfacade.evict(eventbean.getCurrentEvent());
//
// return ret;
//
// }
}
......@@ -135,6 +135,9 @@ public class PermissionBean implements PermissionBeanLocal {
@Override
public boolean isLoggedIn() {
logger.info("Anonuser {}, currentuser {}", getAnonUser(), getCurrentUser());
logger.info("Is current superadmin {}", getCurrentUser().isSuperadmin());
return !getAnonUser().equals(getCurrentUser()) || getCurrentUser().isSuperadmin();
}
......
......@@ -35,7 +35,6 @@ import fi.insomnia.bortal.facade.GroupMembershipFacade;
import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.PlaceGroupFacade;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.GroupMembership;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Place;
......@@ -252,7 +251,7 @@ public class PlaceBean implements PlaceBeanLocal {
}
// This method should not be available in the local bean client
public final void lockPlaceProduct(User user, Product prod, BigDecimal quantity) {
public void lockPlaceProduct(User user, Product prod, BigDecimal quantity) {
int loop = quantity.intValue();
// BigDecimal loop = BigDecimal.ZERO;
......@@ -311,11 +310,11 @@ public class PlaceBean implements PlaceBeanLocal {
}
@Override
@RolesAllowed("MAP/READ")
public Place find(EventPk id) {
return placeFacade.find(id);
}
// @Override
// @RolesAllowed("MAP/READ")
// public Place find(EventPk id) {
// return placeFacade.find(id);
// }
// @Override
// public void checkMemberships() {
......@@ -405,4 +404,20 @@ public class PlaceBean implements PlaceBeanLocal {
}
@Override
@RolesAllowed("MAP/EXECUTE")
public Place find(int placeId) {
return placeFacade.find(eventBean.getCurrentEvent(), placeId);
}
@Override
@RolesAllowed("MAP/WRITE")
public void unbuyPlace(Place place) {
place = placeFacade.find(place.getId());
if (place.getGroup() != null) {
place.getGroup().getPlaces().remove(place);
place.setGroup(null);
}
}
}
......@@ -18,7 +18,6 @@ import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.DiscountInstance;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User;
......@@ -123,27 +122,22 @@ public class ProductBean implements ProductBeanLocal {
for (Discount d : discounts) {
unitPrice = unitPrice.multiply(d.getPercentage());
}
user = userFacade.find(user.getId());
AccountEvent ret = new AccountEvent(eventBean.getCurrentEvent(), user, product, unitPrice, quantity, Calendar.getInstance());
ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser());
// user.getAccountEvents().add(ret);
accounteventfacade.create(ret);
LanEvent event = eventBean.getCurrentEvent();
// List<DiscountInstance> discountsArray = ret.getDiscountInstances();
List<DiscountInstance> accEventdiscounts = ret.getDiscountInstances();
for (Discount d : discounts) {
DiscountInstance discInst = new DiscountInstance(event, ret, d);
// discountsArray.add(discInst);
discountinstancefacade.create(discInst);
// discountinstancefacade.create(discInst);
accEventdiscounts.add(new DiscountInstance(ret, d));
}
// userbean.mergeChanges(user);
accounteventfacade.evict(ret);
userFacade.evict(user);
product.getUnitName();
user.getAccountEvents().add(ret);
// flus changes to db.
userFacade.flush();
return ret;
}
......
......@@ -89,10 +89,9 @@ public class UserBean implements UserBeanLocal {
permbean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.WRITE);
}
ctbean.checkPrintedCard(user);
User ret = userFacade.merge(user);
ctbean.checkPrintedCard(user);
userFacade.evict(ret);
return ret;
}
......
......@@ -7,16 +7,22 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.AccountEvent_;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product_;
import fi.insomnia.bortal.model.Role;
import fi.insomnia.bortal.model.Role_;
import fi.insomnia.bortal.model.User;
@Stateless
@LocalBean
public class AccountEventFacade extends EventChildGenericFacade<AccountEvent> {
public class AccountEventFacade extends GenericFacade<EventPk, AccountEvent> {
@PersistenceContext
private EntityManager em;
......@@ -28,20 +34,34 @@ public class AccountEventFacade extends EventChildGenericFacade<AccountEvent> {
super(AccountEvent.class);
}
@Override
protected EntityManager getEm() {
return em;
}
@Override
public void create(AccountEvent event) {
super.create(event);
userfacade.evict(event.getUser());
}
// @Override
// public void create(AccountEvent event) {
// user = userfacade
//
// userfacade.evict(event.getUser());
// }
public List<Role> findProvidedRoles(LanEvent event, User u) {
TypedQuery<Role> q = em.createQuery("select distinct ac.product.provides from AccountEvent ac where ac.id.eventId = :eventid and ac.user = :user and ac.product.provides is not null", Role.class);
q.setParameter("eventid", event.getId());
q.setParameter("user", u);
return q.getResultList();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Role> cq = cb.createQuery(Role.class);
Root<Role> root = cq.from(Role.class);
cq.where(
cb.equal(root.get(Role_.event), event),
cb.equal(root.join(Role_.productsProvide).join(Product_.accountEvents).get(AccountEvent_.user), u)
);
// TypedQuery<Role> q =
// em.createQuery("select distinct ac.product.provides from AccountEvent ac where ac.id.eventId = :eventid and ac.user = :user and ac.product.provides is not null",
// Role.class);
// q.setParameter("eventid", event.getId());
// q.setParameter("user", u);
return em.createQuery(cq).getResultList();
}
}
......@@ -4,10 +4,7 @@ import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.slf4j.Logger;
......@@ -15,7 +12,6 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.User;
@Stateless
@LocalBean
......@@ -32,16 +28,17 @@ public class BillFacade extends EventChildGenericFacade<Bill> {
super(Bill.class);
}
@Override
protected EntityManager getEm() {
return em;
}
@Override
public void create(Bill entity) {
super.create(entity);
userfacade.evict(entity.getUser());
}
// @Override
// public void create(Bill entity) {
// super.create(entity);
// userfacade.evict(entity.getUser());
//
// }
public Integer getBiggestBillNumber(LanEvent e) {
TypedQuery<Integer> q = getEm().createNamedQuery("Bill.findbiggestBillNumber", Integer.class);
......@@ -49,6 +46,4 @@ public class BillFacade extends EventChildGenericFacade<Bill> {
return getSingleNullableResult(q);
}
}
package fi.insomnia.bortal.facade;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
......@@ -11,8 +10,6 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -36,20 +33,18 @@ public class BillLineFacade extends EventChildGenericFacade<BillLine> {
super(BillLine.class);
}
public void create(BillLine entity) {
super.create(entity);
billfacade.evict(entity.getBill());
}
// @Override
// public void create(BillLine entity) {
// super.create(entity);
// billfacade.evict(entity.getBill());
// }
public Collection<BillSummary> getLineSummary(LanEvent event) {
List<BillLine> lines = findAll(event);
Map<String, BillSummary> retmap = new HashMap<String, BillSummary>();
for(BillLine bl:lines)
{
if(!retmap.containsKey(bl.getName()))
{
for (BillLine bl : lines) {
if (!retmap.containsKey(bl.getName())) {
retmap.put(bl.getName(), new BillSummary(bl.getName()));
}
retmap.get(bl.getName()).addLine(bl);
......@@ -57,6 +52,7 @@ public class BillLineFacade extends EventChildGenericFacade<BillLine> {
return retmap.values();
}
@Override
protected EntityManager getEm() {
return em;
}
......
......@@ -4,6 +4,7 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import fi.insomnia.bortal.model.CardTemplate;
@Stateless
......@@ -17,6 +18,7 @@ public class CardTemplateFacade extends EventChildGenericFacade<CardTemplate> {
super(CardTemplate.class);
}
@Override
protected EntityManager getEm() {
return em;
}
......
......@@ -2,9 +2,6 @@ package fi.insomnia.bortal.facade;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
......@@ -12,19 +9,25 @@ import javax.persistence.criteria.Root;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.EventChildInterface;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.GenericEventChild;
import fi.insomnia.bortal.model.GenericEventChild_;
import fi.insomnia.bortal.model.LanEvent;
/**
* Session Bean implementation class GenericFacade
*/
public abstract class EventChildGenericFacade<T extends EventChildInterface> {
public abstract class EventChildGenericFacade<T extends GenericEventChild> extends GenericFacade<EventPk, T> {
private static final Logger logger = LoggerFactory.getLogger(EventChildGenericFacade.class);
public EventChildGenericFacade(Class<T> entityClass) {
super(entityClass);
}
private static final Logger logger =
LoggerFactory.getLogger(EventChildGenericFacade.class);
public T find(LanEvent e, Integer id) {
return find(e.getId(), id);
return find(new EventPk(e.getId(), id));
}
public T find(Integer eventId, Integer id) {
......@@ -32,86 +35,45 @@ public abstract class EventChildGenericFacade<T extends EventChildInterface> {
return find(pk);
}
public long count(LanEvent e) {
CriteriaBuilder builder = getEm().getCriteriaBuilder();
CriteriaQuery<Long> query = builder.createQuery(Long.class);
Root<T> entity = query.from(getEntityClass());
query.where(builder.equal(entity.get("id").get("eventId"), e.getId())).select(getEm().getCriteriaBuilder().count(entity));
TypedQuery<Long> q = getEm().createQuery(query);
return q.getSingleResult();
}
private final Class<T> entClass;
public EventChildGenericFacade(Class<T> entityClass) {
this.entClass = entityClass;
}
protected Class<T> getEntityClass() {
return entClass;
}
protected abstract EntityManager getEm();
public void create(T entity) {
getEm().persist(entity);
}
public void remove(T entity) {
getEm().remove(entity);
}
public T merge(T entity) {
return getEm().merge(entity);
}
public T find(EventPk id) {
T ret = getEm().find(getEntityClass(), id);
return ret;
}
public List<T> findAll(LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(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.where(cb.equal(root.get(GenericEventChild_.event), event));
cq.orderBy(cb.asc(root.get(GenericEventChild_.id)));
return getEm().createQuery(cq).getResultList();
}
public List<T> findRange(LanEvent event, int[] range) {
CriteriaQuery<T> cq = getEm().getCriteriaBuilder().createQuery(getEntityClass());
cq.select(cq.from(getEntityClass()));
TypedQuery<T> q = getEm().createQuery(cq);
q.setMaxResults(range[1] - range[0]);
q.setFirstResult(range[0]);
return q.getResultList();
}
protected static <K> K getSingleNullableResult(TypedQuery<K> q) {
K ret = null;
try {
ret = q.getSingleResult();
} catch (NoResultException e) {
ret = null;
}
return ret;
}
public void evict(T entity) {
if (entity != null && entity.getId() != null) {
getEm().getEntityManagerFactory().getCache().evict(getEntityClass(), entity.getId());
}
}
public void evictClass() {
getEm().getEntityManagerFactory().getCache().evict(getClass());
}
// public List<T> findRange(LanEvent event, int[] range) {
// CriteriaQuery<T> cq =
// getEm().getCriteriaBuilder().createQuery(getEntityClass());
// cq.select(cq.from(getEntityClass()));
// TypedQuery<T> q = getEm().createQuery(cq);
// q.setMaxResults(range[1] - range[0]);
// q.setFirstResult(range[0]);
// return q.getResultList();
// }
//
// protected static <K> K getSingleNullableResult(TypedQuery<K> q) {
// K ret = null;
// try {
// ret = q.getSingleResult();
// } catch (NoResultException e) {
// ret = null;
// }
// return ret;
// }
//
// public void evict(T entity) {
// if (entity != null && entity.getId() != null) {
// getEm().getEntityManagerFactory().getCache().evict(getEntityClass(),
// entity.getId());
// }
// }
//
// public void evictClass() {
// getEm().getEntityManagerFactory().getCache().evict(getClass());
// }
}
package fi.insomnia.bortal.facade;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.persistence.EntityManager;
......@@ -11,73 +13,86 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.model.ModelInterface;
import fi.iki.tuomari.utils.beans.callbacks.FacadeCallback;
import fi.iki.tuomari.utils.jpa.IntegerModelInterface;
import fi.insomnia.bortal.utilities.ModelInterface;
import fi.insomnia.bortal.utilities.SearchResult;
/**
* Session Bean implementation class GenericFacade
*/
public abstract class GenericFacade<PK, T extends ModelInterface> {
public abstract class GenericFacade<I extends Serializable, C extends ModelInterface<I>> {
private static final Logger logger = LoggerFactory.getLogger(GenericFacade.class);
protected static <T, C extends IntegerModelInterface> List<SingularAttribute<C, T>> mkAttrlist(SingularAttribute<C, T>... types) {
List<SingularAttribute<C, T>> ret = new ArrayList<SingularAttribute<C, T>>();
for (SingularAttribute<C, T> a : types) {
ret.add(a);
}
return Collections.unmodifiableList(ret);
private final Class<T> entClass;
}
private final Class<C> entClass;
private static final Logger logger = LoggerFactory.getLogger(GenericFacade.class);
public GenericFacade(Class<T> entityClass) {
public GenericFacade(Class<C> entityClass) {
this.entClass = entityClass;
}
protected Class<T> getEntityClass() {
protected Class<C> getEntityClass() {
return entClass;
}
protected abstract EntityManager getEm();
public void create(T entity) {
public void create(C entity) {
getEm().persist(entity);
}
public void remove(T entity) {
public void remove(C entity) {
getEm().remove(entity);
}
public T merge(T entity) {
public C merge(C entity) {
return getEm().merge(entity);
}
public T find(PK id) {
public C find(I id) {
if (id == null) {
return null;
}
T ret = getEm().find(getEntityClass(), id);
C ret = getEm().find(getEntityClass(), id);
return ret;
}
public List<T> findAll() {
@Deprecated
public List<C> findAll() {
return findAll(null);
}
public List<T> findAll(String sort) {
return search(0, 0, null, null, sort);
@Deprecated
public List<C> findAll(String sort) {
return findAll(0, 0, sort);
}
public List<T> findRange(int[] range) {
CriteriaQuery<T> cq = getEm().getCriteriaBuilder().createQuery(getEntityClass());
@Deprecated
public List<C> findRange(int[] range) {
CriteriaQuery<C> cq = getEm().getCriteriaBuilder().createQuery(getEntityClass());
cq.select(cq.from(getEntityClass()));
TypedQuery<T> q = getEm().createQuery(cq);
TypedQuery<C> q = getEm().createQuery(cq);
q.setMaxResults(range[1] - range[0]);
q.setFirstResult(range[0]);
return q.getResultList();
}
@Deprecated
public long count() {
CriteriaQuery<Long> cq = getEm().getCriteriaBuilder().createQuery(Long.class);
Root<T> rt = cq.from(getEntityClass());
Root<C> rt = cq.from(getEntityClass());
cq.select(getEm().getCriteriaBuilder().count(rt));
TypedQuery<Long> q = getEm().createQuery(cq);
return q.getSingleResult();
......@@ -93,64 +108,163 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
return ret;
}
public void evict(T entity) {
if (entity != null && entity.getId() != null) {
getEm().getEntityManagerFactory().getCache().evict(getEntityClass(), entity.getId());
@Deprecated
protected List<C> search(String query, String[] fields, String orderfield) {
return search(0, 0, query, fields, orderfield);
}
@Deprecated
protected SearchResult<C> searcher(int page, int pagesize, String query, String[] fields, String orderfield) {
SearchResult<C> ret = new SearchResult<C>();
ret.setResults(search(page, pagesize, query, fields, orderfield));
ret.setResultcount(searchCount(query, fields));
return ret;
}
protected List<T> search(String query, String[] fields, String orderfield) {
return search(0, 0, query, fields, orderfield);
// Le fu... Tuota.. generics ei hanskaa ... operaattoria.. tehdään siis
// näin... :(
protected SearchResult<C> searcher(int page, int pagesize, FacadeCallback<C> callback) {
return searcher(page, pagesize, Collections.singletonList(callback));
}
protected SearchResult<C> searcher(int page, int pagesize, FacadeCallback<C> cb1, FacadeCallback<C> cb2) {
ArrayList<FacadeCallback<C>> cbs = new ArrayList<FacadeCallback<C>>();
cbs.add(cb1);
cbs.add(cb2);
return searcher(page, pagesize, cbs);
}
protected SearchResult<C> searcher(int page, int pagesize, FacadeCallback<C> cb1, FacadeCallback<C> cb2, FacadeCallback<C> cb3) {
ArrayList<FacadeCallback<C>> cbs = new ArrayList<FacadeCallback<C>>();
cbs.add(cb1);
cbs.add(cb2);
cbs.add(cb3);
return searcher(page, pagesize, cbs);
}
protected List<T> search(int page, int pagesize, String query, String[] fields, String orderfield) {
protected SearchResult<C> searcher(int page, int pagesize, FacadeCallback<C> cb1, FacadeCallback<C> cb2, FacadeCallback<C> cb3, FacadeCallback<C> cb4) {
ArrayList<FacadeCallback<C>> cbs = new ArrayList<FacadeCallback<C>>();
cbs.add(cb1);
cbs.add(cb2);
cbs.add(cb3);
cbs.add(cb4);
return searcher(page, pagesize, cbs);
}
protected SearchResult<C> searcher(int page, int pagesize, List<FacadeCallback<C>> list) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(getEntityClass());
Root<T> root = cq.from(getEntityClass());
CriteriaQuery<C> listCQuery = cb.createQuery(getEntityClass());
CriteriaQuery<Long> countCQuery = cb.createQuery(Long.class);
searchCallbacks(listCQuery, list);
Root<C> countRoot = searchCallbacks(countCQuery, list);
countCQuery.select(cb.count(countRoot));
TypedQuery<Long> countQ = getEm().createQuery(countCQuery);
TypedQuery<C> listQ = getEm().createQuery(listCQuery);
if (pagesize > 0) {
listQ.setFirstResult(page * pagesize);
listQ.setMaxResults(pagesize);
if (query != null && !query.isEmpty()) {
addPredicates(cb, cq, root, query, fields);
}
if (orderfield != null) {
cq.orderBy(cb.asc(root.get(orderfield)));
return new SearchResult<C>(listQ.getResultList(), countQ.getSingleResult());
}
cq.select(root);
TypedQuery<T> q = getEm().createQuery(cq);
private Root<C> searchCallbacks(CriteriaQuery<?> cq, List<FacadeCallback<C>> list) {
Root<C> root = cq.from(getEntityClass());
CriteriaBuilder cb = getEm().getCriteriaBuilder();
ArrayList<Predicate> predicates = new ArrayList<Predicate>();
for (FacadeCallback<C> fc : list) {
logger.debug("Executing {}, predsize: {}", fc, predicates.size());
fc.exec(cb, cq, root, predicates);
}
if (!predicates.isEmpty()) {
Predicate[] preds = predicates.toArray(new Predicate[predicates.size()]);
cq.where(preds);
}
return root;
}
@Deprecated
protected List<C> search(int page, int pagesize, String query, String[] fields, String orderfield) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<C> cq = cb.createQuery(getEntityClass());
Root<C> root = cq.from(getEntityClass());
addPredicates(cq, root, query, fields);
TypedQuery<C> q = getEm().createQuery(cq);
if (pagesize > 0) {
logger.debug("Setting pagesize {} at facade", pagesize);
q.setFirstResult(page * pagesize);
q.setMaxResults(pagesize);
}
List<T> ret = q.getResultList();
List<C> ret = q.getResultList();
return ret;
}
@Deprecated
protected void addPredicates(CriteriaQuery<?> cq, Root<C> root, String query, String[] fields) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
if (query != null && !query.isEmpty() && fields != null && fields.length > 0) {
List<Predicate> preds = new ArrayList<Predicate>();
for (String field : fields) {
Path<String> rootfield = root.get(field);
preds.add(cb.like(cb.lower(rootfield), query));
}
cq.where(cb.or(preds.toArray(new Predicate[preds.size()])));
}
}
@Deprecated
protected long searchCount(String query, String[] fields) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<T> root = cq.from(getEntityClass());
if (query != null && !query.isEmpty()) {
addPredicates(cb, cq, root, query, fields);
}
Root<C> root = cq.from(getEntityClass());
addPredicates(cq, root, query, fields);
cq.select(getEm().getCriteriaBuilder().count(root));
TypedQuery<Long> q = getEm().createQuery(cq);
return q.getSingleResult();
}
private void addPredicates(CriteriaBuilder cb, CriteriaQuery<?> cq, Root<T> root, String query, String[] fields) {
List<Predicate> preds = new ArrayList<Predicate>();
for (String field : fields) {
Path<String> rootfield = root.get(field);
preds.add(cb.like(cb.lower(rootfield), query));
@Deprecated
public List<C> findAll(int page, int pagesize, String sort) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<C> cq = cb.createQuery(getEntityClass());
Root<C> root = cq.from(getEntityClass());
if (sort != null) {
cq.orderBy(cb.asc(root.get(sort)));
}
cq.select(cq.from(getEntityClass()));
TypedQuery<C> q = getEm().createQuery(cq);
if (pagesize > 0) {
q.setFirstResult(page * pagesize);
q.setMaxResults(pagesize);
}
return q.getResultList();
}
cq.where(cb.or(preds.toArray(new Predicate[preds.size()])));
public void flush() {
getEm().flush();
}
}
package fi.insomnia.bortal.facade;
import fi.insomnia.bortal.model.ModelInterface;
import fi.insomnia.bortal.utilities.ModelInterface;
/**
* Session Bean implementation class GenericFacade
*/
public abstract class IntegerPkGenericFacade<T extends ModelInterface> extends GenericFacade<Integer, T> {
public abstract class IntegerPkGenericFacade<T extends ModelInterface<Integer>> extends GenericFacade<Integer, T> {
public IntegerPkGenericFacade(Class<T> entityClass) {
super(entityClass);
}
}
......@@ -5,6 +5,7 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import fi.insomnia.bortal.model.UserImage;
@Stateless
......@@ -16,19 +17,21 @@ public class UserImageFacade extends GenericFacade<Integer, UserImage> {
@EJB
private UserFacade userfacade;
public UserImageFacade() {
super(UserImage.class);
}
@Override
protected EntityManager getEm() {
return em;
}
@Override
public void create(UserImage entity)
{
super.create(entity);
userfacade.evict(entity.getUser());
}
// @Override
// public void create(UserImage entity)
// {
// super.create(entity);
// userfacade.evict(entity.getUser());
//
// }
}
......@@ -9,6 +9,4 @@ public interface DiscountBeanLocal {
Discount save(Discount discount);
Discount create(String discountdesc);
}
......@@ -11,7 +11,6 @@ import javax.ejb.Local;
import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
......@@ -29,7 +28,7 @@ public interface PlaceBeanLocal {
int setBuyable(EventMap map, String buyableLike, boolean b);
Place find(EventPk id);
// Place find(EventPk id);
boolean releasePlace(Place place);
......@@ -41,4 +40,8 @@ public interface PlaceBeanLocal {
void releaseUsersPlaces(User user) throws PermissionDeniedException;
Place find(int placeId);
void unbuyPlace(Place place);
}
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.util.MailMessage;
@Local
public interface UtilBeanLocal {
// boolean sendMail(User user, String subject, String message);
......
Manifest-Version: 1.0
Class-Path: lib/LanBortalUtilities.jar
......@@ -40,10 +40,10 @@ public class DiscountInstance extends GenericEventChild {
public DiscountInstance() {
}
public DiscountInstance(LanEvent event, AccountEvent ac, Discount d) {
public DiscountInstance(AccountEvent ac, Discount d) {
accountEvent = ac;
discount = d;
setId(new EventPk(event));
setId(new EventPk(ac.getEvent()));
}
public AccountEvent getAccountEvent() {
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model;
import java.io.Serializable;
/**
*
* @author tuukka
*/
public interface EventChildInterface extends Serializable {
EventPk getId();
void setId(EventPk id);
void setJpaVersionField(int jpaVersionField);
int getJpaVersionField();
}
......@@ -7,8 +7,10 @@ import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import fi.insomnia.bortal.utilities.ModelInterface;
@MappedSuperclass
public class GenericEntity extends EntityEquals implements ModelInterface {
public class GenericEntity extends EntityEquals implements ModelInterface<Integer> {
private static final long serialVersionUID = -9041737052951021560L;
@Id
......@@ -31,12 +33,12 @@ public class GenericEntity extends EntityEquals implements ModelInterface {
}
@Override
public Integer getId() {
public final Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
public final void setId(Integer id) {
this.id = id;
}
......
......@@ -7,8 +7,10 @@ import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import fi.insomnia.bortal.utilities.ModelInterface;
@MappedSuperclass
public abstract class GenericEventChild extends EntityEquals implements EventChildInterface {
public abstract class GenericEventChild extends EntityEquals implements ModelInterface<EventPk> {
private static final long serialVersionUID = -9041737052951021560L;
......
......@@ -10,9 +10,6 @@ import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
......@@ -20,26 +17,20 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "event_log")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "LogEntry.findAll", query = "SELECT l FROM LogEntry l"),
@NamedQuery(name = "LogEntry.findByTime", query = "SELECT l FROM LogEntry l WHERE l.time = :time"),
@NamedQuery(name = "LogEntry.findByDescription", query = "SELECT l FROM LogEntry l WHERE l.description = :description") })
public class LogEntry implements ModelInterface {
public class LogEntry extends GenericEntity {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "log_id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne
private LanEvent parentEvent;
......@@ -59,12 +50,8 @@ public class LogEntry implements ModelInterface {
@ManyToOne
private User user;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public LogEntry()
{}
public LogEntry() {
}
public LogEntry(Calendar eventTime) {
this.time = eventTime;
......@@ -102,62 +89,6 @@ public class LogEntry implements ModelInterface {
this.user = usersId;
}
@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 LogEntry)) {
return false;
}
LogEntry other = (LogEntry) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.LogEntry[eventLogId=" + getId() + "]";
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
public void setParentEvent(LanEvent parentEvent) {
this.parentEvent = parentEvent;
}
......
package fi.insomnia.bortal.enums;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.enums.apps.LoginPermissions;
import fi.insomnia.bortal.enums.apps.UserPermissions;
public enum BortalApplication {
// NOTE. add conversion Value to RoleRight
// PERMISSION("Description"),
LOGIN("Login related permissions", LoginPermissions.class),
USER("User management related", UserPermissions.class),
USER_MANAGEMENT("View all users(r), modify users(w), execute actions for user(x) "),
ACCOUNT_MANAGEMENT("Manage others account events. view(r), modify(w) and create (shop)(x)"),
BILL("View all bills(r), Mark paid & modify(w), and create own 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"),
PRODUCT("View(r), modify(w), and shop(x) products"),
SHOP("View own shopped events(r), Modify own AccountEvents() and Shop(x)"),
GAME("View(r) own, modify(w), view all(X)"),
POLL("View answers(r), create polls (w), answer to polls(x)");
private String description;
private Class<? extends IAppPermission> permissions;
private BortalApplication(String descr, Class<? extends IAppPermission> perms) {
this.permissions = perms;
this.setDescription(descr);
}
public IAppPermission[] getPermissions() {
return permissions.getEnumConstants();
}
private BortalApplication(String descr) {
this.permissions = LoginPermissions.class;
this.setDescription(descr);
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
package fi.insomnia.bortal.enums;
public enum RolePermission {
@Deprecated
public enum OldRolePermission {
READ, WRITE, EXECUTE
}
......@@ -62,7 +62,4 @@ public enum Permission {
return description;
}
public String append(RolePermission permission) {
return name() + "/" + permission.name();
}
}
package fi.insomnia.bortal.enums.apps;
import java.io.Serializable;
import fi.insomnia.bortal.enums.BortalApplication;
public interface IAppPermission extends Serializable {
public BortalApplication getParent();
public String getDescription();
}
package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum LoginPermissions implements IAppPermission {
LOGIN("Can login"), LOGOUT("Can logout");
private String description;
private LoginPermissions(String desc) {
this.description = desc;
}
@Override
public BortalApplication getParent() {
return BortalApplication.LOGIN;
}
public String getDescription() {
return this.description;
}
}
package fi.insomnia.bortal.enums.apps;
import fi.insomnia.bortal.enums.BortalApplication;
public enum UserPermissions implements IAppPermission {
VIEW("View all users"), MODIFY("Modify users");
private String description;
private UserPermissions(String desc) {
description = desc;
}
@Override
public BortalApplication getParent() {
return BortalApplication.USER;
}
@Override
public String getDescription() {
return description;
}
}
package fi.insomnia.bortal.model;
package fi.insomnia.bortal.utilities;
import java.io.Serializable;
public interface ModelInterface extends Serializable {
public interface ModelInterface<T extends Serializable> extends Serializable {
Integer getId();
T getId();
void setId(Integer id);
void setId(T id);
int getJpaVersionField();
......
package fi.insomnia.bortal.utilities;
import java.io.Serializable;
import java.util.List;
public class SearchResult<T extends ModelInterface<?>> implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4689034448242002367L;
private List<T> results;
private long resultcount;
public SearchResult() {
}
public SearchResult(List<T> resultList, Long rescount) {
results = resultList;
resultcount = rescount;
}
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
public long getResultcount() {
return resultcount;
}
public void setResultcount(long resultcount) {
this.resultcount = resultcount;
}
}
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:account="http://java.sun.com/jsf/composite/tools/account" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/template.xhtml">
<f:metadata>
<f:viewParam name="locid" value="#{requestCalendarView.locid}" />
<f:viewParam name="slotid" value="#{requestCalendarView.slotid}" />
<f:event type="preRenderView" listener="#{requestCalendarView.editCell()}" />
</f:metadata>
<ui:define name="content">
<h:panelGrid columns="2">
<h:form id="reserveField">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['reservation.location']}" />
<h:outputText value="#{calendarView.reservation.location.name}" />
<h:outputLabel value="#{i18n['reservation.date']}:" />
<h:outputText value="#{calendarView.reservation.reservationDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText>
<h:outputLabel value="#{i18n['reservation.start']}" />
<h:outputText value="#{calendarView.reservation.firstSlotToday.slot.startTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText>
<h:outputLabel value="#{i18n['reservation.end']}" />
<h:outputText value="#{calendarView.reservation.lastSlotToday.endTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText>
<h:outputLabel value="#{i18n['reservation.reserver']}" />
<h:inputText value="#{calendarView.reservation.reserverName}" />
<h:outputLabel value="#{i18n['reservation.reserverLastname']}" />
<h:inputText value="#{calendarView.reservation.reserverLastname}" />
<h:outputLabel value="#{i18n['reservation.email']}" />
<h:inputText value="#{calendarView.reservation.email}" />
<h:outputLabel value="#{i18n['reservation.phone']}" />
<h:inputText value="#{calendarView.reservation.phone}" />
<h:commandButton action="#{calendarView.savePlace()}" value="#{i18n['reservation.save']}" />
<h:commandButton onclick="return confirm('#{i18n['reservation.confirmdelete']}')"
action="#{calendarView.deleteReservation()}" value="#{i18n['reservation.delete']}"
/>
</h:panelGrid>
</h:form>
<h:dataTable value="#{requestCalendarView.reservationDates}" var="resdate">
<h:column>
<h:outputText value="#{resdate.date.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText>
</h:column>
<h:column>
<h:dataTable value="#{resdate.locations}" var="loc">
<h:column>
<h:outputText value="#{loc.location.name}" />
</h:column>
<h:column>
<table border="0">
<ui:repeat var="tg" value="#{loc.timegroups}">
<tr>
<td><h:outputText value="#{tg.first.slot.startTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText></td>
<td><h:outputText value="#{tg.last.slot.endTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText></td>
<td><h:outputText value="#{tg.first.reservationDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></td>
<td><h:outputText value="#{tg.last.reservationDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></td>
</tr>
</ui:repeat>
</table>
</h:column>
</h:dataTable>
</h:column>
</h:dataTable>
</h:panelGrid>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{requestCalendarView.initCalendars()}" />
</f:metadata>
<ui:define name="content">
<h:outputText value="#{sessionHandler.getDynatext('calendar-top')}" escape="false" />
<table border="0" class="dateformtable">
<tr>
<td id="datepickedcell">
<h:outputScript target="head" library="script" name="jquery.min.js" />
<h:outputScript target="head" library="script" name="clockscript.js" />
<div class="clock bigclock">&nbsp;</div>
<tools:dateselect id="dselect" submitaction="#{calendarView.sendDate()}" datefield="#{calendarView.currentDate}" /></td>
<td>
<h2><h:outputText value="#{requestCalendarView.date.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></h2>
<h1>Alakerta</h1>
<tools:locationDaytableSimple id="alalyonti" actionview="#{calendarView}"
calendar="#{requestCalendarView.getCalendar('alakerta')}"
/></td>
</tr>
<tr>
<td>
<h2><h:outputText value="#{calendarView.currentDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></h2>
<h1>Simulaattori</h1>
<tools:locationDaytableSimple id="simut" actionview="#{calendarView}"
calendar="#{requestCalendarView.getCalendar('simut')}"
/></td>
<td>
<h2><h:outputText value="#{calendarView.currentDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></h2>
<h1>Yläkerta</h1>
<tools:locationDaytableSimple id="ylalyonti" actionview="#{calendarView}"
calendar="#{requestCalendarView.getCalendar('ylakerta')}"
/></td>
</tr>
</table>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/template.xhtml">
<ui:define name="content">
#{calendarView.initLoc()}
<h:outputText value="#{sessionHandler.getDynatext('calendar-top')}" escape="false" />
<table border="0" class="dateformtable">
<tr>
<td id="datepickedcell">
<h:outputScript target="head" library="script" name="jquery.min.js" />
<h:outputScript target="head" library="script" name="clockscript.js" />
<div class="clock bigclock">&nbsp;</div>
<tools:dateselect id="dselect" submitaction="#{calendarView.sendDate()}" datefield="#{calendarView.currentDate}" /></td>
<td>
<h2><h:outputText value="#{calendarView.currentDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></h2>
<h1>Alakerta</h1>
<tools:locationDaytable colstart="0" colend="9" actionview="#{calendarView}" colname='lyontipaikat'
rows="#{calendarView.getFormattedTimestuff('lyontipaikat').rows}"
cols="#{calendarView.getFormattedTimestuff('lyontipaikat').locations}" /></td>
</tr>
<tr>
<td>
<h2><h:outputText value="#{calendarView.currentDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></h2>
<h1>Simulaattori</h1>
<tools:locationDaytable colstart="0" colend="1" actionview="#{calendarView}" colname='simulaattori'
rows="#{calendarView.getFormattedTimestuff('simulaattori').rows}"
cols="#{calendarView.getFormattedTimestuff('simulaattori').locations}" /></td>
<td>
<h2><h:outputText value="#{calendarView.currentDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText></h2>
<h1>Yläkerta</h1>
<tools:locationDaytable colstart="10" colend="19" actionview="#{calendarView}" colname='lyontipaikat'
rows="#{calendarView.getFormattedTimestuff('lyontipaikat').rows}"
cols="#{calendarView.getFormattedTimestuff('lyontipaikat').locations}" /></td>
</tr>
</table>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/template.xhtml">
<ui:define name="content">
<h:form id="repeatForm">
<h:dataTable id="repeattable" value="#{calendarView.repeatReservations}" var="repeat">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['repeat.enabled']}" />
</f:facet>
<h:selectBooleanCheckbox value="#{repeat.enable}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['repeat.reservationOk']}" />
</f:facet>
<h:outputText value="#{repeat.reservationOk}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['reservation.date']}" />
</f:facet>
<h:outputText value="#{repeat.date.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['reservation.start']}" />
</f:facet>
<h:outputText value="#{repeat.startTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['reservation.end']}" />
</f:facet>
<h:outputText value="#{repeat.endTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
#{i18n['repeatview.locations']}
</f:facet>
<div jsfc="ui:repeat" value="#{repeat.locations}" var="loc">#{loc.name}</div>
</h:column>
<h:column>
<f:facet name="header">
#{i18n['repeatview.skippedSlots']}
</f:facet>
<div jsfc="ui:repeat" value="#{repeat.sloterror}" var="errslot"><h:outputText
value="#{errslot.slot.startTime.time}"
>
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText> / #{errslot.wholeName} / #{errslot.location.name}</div>
</h:column>
</h:dataTable>
<h:commandButton action="#{calendarView.reserveRepeat()}" value="#{i18n['repeat.reservePlaces']}" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/template.xhtml">
<f:metadata>
<f:viewParam name="locid" value="#{requestCalendarView.locid}" />
<f:viewParam name="slotid" value="#{requestCalendarView.slotid}" />
<f:event type="preRenderView" listener="#{requestCalendarView.reserveCell()}" />
</f:metadata>
<ui:define name="content">
<h:form id="reserveField">
<h:panelGrid columns="3">
<h:outputLabel for="name" value="#{i18n['reservation.location']}" />
<h:outputText id="name" value="#{calendarView.reservation.location.name}" />
<h:message for="name" />
<h:outputLabel for="resdate" value="#{i18n['reservation.date']}:" />
<h:outputText id="resdate" value="#{calendarView.reservation.reservationDate.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:outputText>
<h:message for="resdate" />
<h:outputLabel for="starttime" value="#{i18n['reservation.start']}:" />
<h:outputText id="starttime" value="#{calendarView.reservation.slot.startTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText>
<h:message for="starttime" />
<h:outputLabel for="selectone" value="#{i18n['reservation.end']}:" />
<h:selectOneMenu id="selectone" converter="#{reservationSlotConverter}" value="#{calendarView.reservationEndtime}">
<f:selectItems var="time" itemLabel="#{timeConverter.getEndTime(time)}" value="#{calendarView.availableTimes}" />
</h:selectOneMenu>
<h:message for="selectone" />
<h:outputLabel for="reserver" value="#{i18n['reservation.reserver']}:" />
<h:inputText id="reserver" value="#{calendarView.reservation.reserverName}"
required="#{!sessionHandler.hasPermission('CALENDAR_MANAGE')}"
/>
<h:message for="reserver" />
<h:outputLabel for="reserverlastname" value="#{i18n['reservation.reserverLastname']}:" />
<h:inputText id="reserverlastname" value="#{calendarView.reservation.reserverLastname}"
required="#{!sessionHandler.hasPermission('CALENDAR_MANAGE')}"
/>
<h:message for="reserverlastname" />
<h:outputLabel for="email" value="#{i18n['reservation.email']}:" />
<h:inputText id="email" value="#{calendarView.reservation.email}"
required="#{!sessionHandler.hasPermission('CALENDAR_MANAGE')}"
/>
<h:message for="email" />
<h:outputLabel for="phone" value="#{i18n['reservation.phone']}:" />
<h:inputText id="phone" value="#{calendarView.reservation.phone}"
required="#{!sessionHandler.hasPermission('CALENDAR_MANAGE')}"
/>
<h:message for="phone" />
<h:commandButton action="#{calendarView.reservePlace()}" value="#{i18n['reservation.reserve']}" />
<h:outputText />
<h:outputText />
<h:commandButton rendered="#{sessionHandler.hasPermission('CALENDAR_MANAGE')}"
action="#{calendarView.checkRepeat()}" value="Toisto"
/>
<h:outputLabel rendered="#{sessionHandler.hasPermission('CALENDAR_MANAGE')}" for="repeatStart"
value="#{i18n['repeat.end']}:"
/>
<h:inputText rendered="#{sessionHandler.hasPermission('CALENDAR_MANAGE')}" id="repeatStart"
value="#{calendarView.repeatEnd.time}"
>
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.datePattern}" />
</h:inputText>
<h:message for="repeatStart" rendered="#{sessionHandler.hasPermission('CALENDAR_MANAGE')}" />
<h:selectManyCheckbox rendered="#{sessionHandler.hasPermission('CALENDAR_MANAGE')}"
converter="#{reservationLocationConverter}" layout="pageDirection" id="locations"
value="#{calendarView.selectedLocations}"
>
<f:selectItems var="location" itemLabel="#{location.name}" value="#{calendarView.availableLocations}" />
</h:selectManyCheckbox>
</h:panelGrid>
<h:commandButton rendered="#{sessionHandler.hasPermission('CALENDAR_MANAGE')}"
action="#{calendarView.checkRepeat()}" value="Toisto"
/>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -24,8 +24,6 @@
<br />
<h:commandButton value="Multipart mailtest" action="#{TestDataView.multiparttest}" />
<br />
<h:commandButton value="Check Gms" action="#{placeView.checkMemberships()}" />
<br />
<h:commandButton value="Check all cards" action="#{TestDataView.checkCards()}" />
<br />
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.index" />
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{productShopView.initView}" />
</f:metadata>
<ui:define name="content">
<h3>Lippujen hinnat</h3>
<ul>
<li>1-4 konepaikkaa 30e/paikka</li>
<li>5-8 konepaikkaa 28e/paikka</li>
<li>9 tai useampi konepaikkaa 26e/paikka</li>
<li>Konepaikat ovelta 32e/paikka</li>
<li>PRO-paikka 45e/paikka</li>
<li>Vierailijalippu 10e/lippu</li>
</ul>
<h3>Rekisteröityminen ja lippujen tilaaminen</h3>
<p>Tilataksesi konepaikkoja sinun tulee rekisteröityä Insomnian
lippukauppaan. Rekisteröitymisvaiheessa teet käyttäjätunnuksen ja tilaat
haluamasi määrän konepaikkoja.</p>
<h3>Maksaminen</h3>
<p>
Lippukauppaan ilmestyy lasku tilaamiesi konepaikkojen ja lippujen mukaisesti.
Laskusta löydät kaikki maksamiseen tarvittavat tiedot.<br />
<br />
<b>Muista käyttää viitenumeroa laskua maksaessasi!</b> Huomioithan myös
pankkiviiveet maksaessasi muusta pankista kuin Osuuspankista. Maksut
tarkastetaan pari kertaa päivässä. Maksuja ei palauteta ilman erittäin hyvää
syytä (esimerkiksi sairaustapauksissa lääkärintodistusta vastaan).</p>
<h3>Paikkojen varaaminen</h3>
<p>
Kun olet maksanut saamasi laskun ja olemme kirjanneet maksusi, saat
sähköpostiisi ilmoituksen kun voit varata paikkoja. Tällöin voit varata
paikkakartalta tilaamasi määrän konepaikkoja.</p>
<h3>Lippujen lunastaminen tapahtuman yhteydessä</h3>
<p>
Kun olet täyttänyt tietosi järjestelmään, tulosta tilauksesi mukaiset
viivakoodit ja jaa ne ryhmäsi jäsenille. Viivakoodin avulla nopeutat lippujen
lunastusta huomattavasti.</p>
<h3>Tavalliset konepaikat ja pro-konepaikat</h3>
<p>
Tapahtumassa on tarjolla sekä tavallisia 80cm leveitä konepaikkoja että myös
rajattu määrä normaaleista konepaikoista poikkeavia pro-konepaikkoja.<br />
<br />
Pro-konepaikoilla pääsee nauttimaan suuremmasta tilasta, sillä konepaikan
leveys on 100cm ja lisäksi paikat on jaoteltu viiden konepaikan riveihin.
Pro-konepaikkojen käytävävälit ovat myös leveämmät.</p>
<h3>Kysymykset</h3>
<p>
Mikäli mieltäsi askarruttaa jokin liittyen tapahtuman konepaikkoihin tai
lippukauppaan, ota rohkeasti yhteyttä sähköpostilla osoitteeseen info
[at] insomnia.fi.</p>
</ui:define>
</ui:composition>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.index" />
<ui:define name="content">
<h3>Lippujen hinnat</h3>
<ul>
<li>1-4 konepaikkaa 30e/paikka</li>
<li>5-8 konepaikkaa 28e/paikka</li>
<li>9 tai useampi konepaikkaa 26e/paikka</li>
<li>Konepaikat ovelta 32e/paikka</li>
<li>PRO-paikka 45e/paikka</li>
<li>Vierailijalippu 10e/lippu</li>
</ul>
<h3>Rekisteröityminen ja lippujen tilaaminen</h3>
<p>Tilataksesi konepaikkoja sinun tulee rekisteröityä Insomnian
lippukauppaan. Rekisteröitymisvaiheessa teet käyttäjätunnuksen ja tilaat
haluamasi määrän konepaikkoja.</p>
<h3>Maksaminen</h3>
<p>
Lippukauppaan ilmestyy lasku tilaamiesi konepaikkojen ja lippujen mukaisesti.
Laskusta löydät kaikki maksamiseen tarvittavat tiedot.<br />
<br />
<b>Muista käyttää viitenumeroa laskua maksaessasi!</b> Huomioithan myös
pankkiviiveet maksaessasi muusta pankista kuin Osuuspankista. Maksut
tarkastetaan pari kertaa päivässä. Maksuja ei palauteta ilman erittäin hyvää
syytä (esimerkiksi sairaustapauksissa lääkärintodistusta vastaan).</p>
<h3>Paikkojen varaaminen</h3>
<p>
Kun olet maksanut saamasi laskun ja olemme kirjanneet maksusi, saat
sähköpostiisi ilmoituksen kun voit varata paikkoja. Tällöin voit varata
paikkakartalta tilaamasi määrän konepaikkoja.</p>
<h3>Lippujen lunastaminen tapahtuman yhteydessä</h3>
<p>
Kun olet täyttänyt tietosi järjestelmään, tulosta tilauksesi mukaiset
viivakoodit ja jaa ne ryhmäsi jäsenille. Viivakoodin avulla nopeutat lippujen
lunastusta huomattavasti.</p>
<h3>Tavalliset konepaikat ja pro-konepaikat</h3>
<p>
Tapahtumassa on tarjolla sekä tavallisia 80cm leveitä konepaikkoja että myös
rajattu määrä normaaleista konepaikoista poikkeavia pro-konepaikkoja.<br />
<br />
Pro-konepaikoilla pääsee nauttimaan suuremmasta tilasta, sillä konepaikan
leveys on 100cm ja lisäksi paikat on jaoteltu viiden konepaikan riveihin.
Pro-konepaikkojen käytävävälit ovat myös leveämmät.</p>
<h3>Kysymykset</h3>
<p>
Mikäli mieltäsi askarruttaa jokin liittyen tapahtuman konepaikkoihin tai
lippukauppaan, ota rohkeasti yhteyttä sähköpostilla osoitteeseen info
[at] insomnia.fi.</p>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools">
<h:body>
<ui:composition rendered="#{sessionHandler.loggedIn}" template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="true" />
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools">
<h:body>
<ui:composition rendered="#{sessionHandler.loggedIn}" template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="true" />
<ui:define name="sidebarcontent">
<ul>
<tools:canRead target="ROLE_MANAGEMENT">
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.roles']}" />
<ul>
<li><h:link outcome="/role/create" value="#{i18n['sidebar.role.create']}" /></li>
<li><h:link outcome="/role/list" value="#{i18n['sidebar.role.list']}" /></li>
<li><h:link outcome="/user/createCardTemplate" value="#{i18n['sidebar.cardTemplate.create']}" /></li>
<li><h:link outcome="/user/listCardTemplates" value="#{i18n['sidebar.cardTemplate.list']}" /></li>
</ul>
</li>
</tools:canRead>
<tools:canRead target="BILL">
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.bills']}" />
<ul>
<li><h:link outcome="/bill/list" value="#{i18n['sidebar.bill.listAll']}" /></li>
<li><h:link outcome="/bill/billSummary" value="#{i18n['sidebar.bill.summary']}" /></li>
</ul>
</li>
</tools:canRead>
<tools:canRead target="USER_MANAGEMENT">
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.users']}" />
<ul>
<li><h:link outcome="/user/create" value="#{i18n['sidebar.user.create']}" /></li>
<li><h:link outcome="/user/list" value="#{i18n['sidebar.user.list']}" /></li>
</ul>
</li>
</tools:canRead>
<tools:canRead target="PRODUCT">
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.products']}" />
<ul>
<li><h:link outcome="/product/create" value="#{i18n['sidebar.product.create']}" /></li>
<li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}" /></li>
</ul>
</li>
</tools:canRead>
<tools:canRead target="MAP">
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.maps']}" />
<ul>
<li><h:link outcome="/map/list" value="#{i18n['sidebar.map.list']}" /></li>
</ul>
</li>
</tools:canRead>
<li><h:outputText styleClass="sidebartitle" value="#{i18n['sidebar.other']}" />
<ul>
<li><h:link outcome="/eventorg/list" value="#{i18n['sidebar.eventorg.list']}" /></li>
<li><h:link outcome="/utils/flushCache" value="#{i18n['sidebar.utils.flushCache']}" /></li>
<li><h:link outcome="/generateTestData" value="#{i18n['sidebar.utils.testdata']}" /></li>
</ul>
</li>
</ul>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="#{!sessionHandler.isLoggedIn()}" />
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/user/create.xhtml" value="#{i18n['sidebar.createuser']}"/></li>
</ul>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="false" />
<ui:define name="sidebarcontent">
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/user/create.xhtml" value="#{i18n['sidebar.user.create']}"/></li>
</ul>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="false" />
<ui:define name="sidebarcontent">
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="false" />
<ui:define name="sidebarcontent">
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="true" />
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/shop/listReaders" value="#{i18n['sidebar.shop.readerlist']}" /></li>
<li><h:link outcome="/shop/showReaderEvents" value="#{i18n['sidebar.shop.readerEvents']}" /></li>
</ul>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="true" />
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/bill/list" value="#{i18n['sidebar.bill.list']}"/></li>
</ul>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="#{sessionHandler.isLoggedIn()}" />
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/user/sendPicture" value="#{i18n['user.sendPicture']}"/></li>
<li><h:link outcome="/user/changePassword" value="#{i18n['user.changePassword']}"/></li>
<li><h:link outcome="/user/accountEvents" value="#{i18n['user.accountEvents']}"/></li>
<li><h:link outcome="/place/myGroups" value="#{i18n['user.myGroups']}"/></li>
<li><h:link outcome="/place/insertToken" value="#{i18n['user.insertToken']}"/></li>
</ul>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:component>
<c:if test="#{rendered}">
<div id="sidebar"><ui:insert name="sidebarcontent" /></div>
</c:if>
</ui:component>
</h:body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<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:tools="http://java.sun.com/jsf/composite/cditools" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<f:view locale="#{sessionHandler.locale}">
<ui:insert name="metadata" />
<h:head>
<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>
<meta name="description" content="Insomnia lippukauppa" />
<meta name="author" content="Niko Juusela, csharp" />
<meta http-equiv="Content-Language" content="fi" />
<link rel="stylesheet" type="text/css" href="#{request.contextPath}/resources/style/insomnia2/css/tyyli.css" />
</h:head>
<h:body>
<div id="header">
<div id="logo">
<img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
</div>
<div id="login">
<tools:isLoggedIn>#{sessionHandler.currentUser.nick}</tools:isLoggedIn>
<tools:loginLogout />
</div>
</div>
<div id="wrapper">
<div id="navigation">
<ul class="menu">
<li><h:link outcome="/index" value="#{i18n['topmenu.frontpage']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'frontpage'?'active':''}"
/></li>
<li>
<h:link outcome="/user/edit" value="#{i18n['topmenu.usersPreferences']}" styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'user'?'active':''}" />
</li>
<li><h:link outcome="/poll/start" value="#{i18n['topmenu.poll']}" styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'poll'?'active': ''}" /></li>
<li><h:link outcome="/place/placemap" value="#{i18n['topmenu.placemap']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'placemap'?'active':''}"
/>
</li>
<li><h:link outcome="/product/list" value="#{i18n['topmenu.adminfront']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'admin'?'active':''}"
/></li>
<li><h:link outcome="/shop/showReaderEvents" value="#{i18n['topmenu.rfidshop']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'rfidshop'?'active':''}"
/>
</li>
<li><h:link outcome="/game/start" value="#{i18n['topmenu.game']}"
styleClass="#{i18n[util.concat(thispage,'.pagegroup')] == 'game'?'active':''}"
/>
</li>
</ul>
</div>
<div id="container" class="top"></div>
<div id="container" class="clearfix">
<div id="left">
<h:messages globalOnly="true" />
<ui:insert name="content" />
</div>
<div id="right">
<ui:include src="/layout/insomnia2/sidebar-#{i18n[util.concat(thispage,'.pagegroup')]}.xhtml" />
</div>
</div>
<div id="container" class="bottom"></div>
</div>
</h:body>
</f:view>
</html>
\ No newline at end of file
......@@ -9,6 +9,10 @@
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.place.edit" />
<f:metadata>
<f:viewParam name="placeid" value="#{placeView.placeId}" />
<f:event type="preRenderView" listener="#{placeView.initView}" />
</f:metadata>
<ui:define name="content">
<h1>#{i18n['editplace.header']}</h1>
......@@ -101,7 +105,6 @@
</h:dataTable>
</h:form>
#{placeView.initGroupsPlacelist()}
<h:form rendered="#{!empty placeView.place.group and placeView.place.group.places.size() gt 0}">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['placegroup.name']}:" />
......@@ -124,22 +127,23 @@
</h:form>
<h:form rendered="#{!empty placeView.place.group and placeView.place.group.places.size() gt 0}">
<h:dataTable border="0" id="placelist" value="#{placeView.placesGroupPlaces}" var="place">
<h:dataTable border="0" id="placelist" value="#{placeView.place.group.places}" var="place">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['place.name']}" />
</f:facet>
<h:outputText value="#{place.name}" />
<h:link outcome="/place/edit" value="#{place.name}">
<f:param name="placeid" value="#{place.id.id}" />
</h:link>
</h:column>
<h:column>
<h:commandButton action="#{placeView.editPlacegroupPlace()}" value="#{i18n['place.edit']}" />
</h:column>
<h:column>
<h:link outcome="/user/edit">
<h:outputText value="#{place.placeReserver.user.wholeName}" />
(<h:outputText value="#{place.placeReserver.user.nick}" />)
<f:param name="userid" value="#{place.placeReserver.user.id}" />
</h:link>
</h:column>
<h:column>
</h:column>
......@@ -147,7 +151,6 @@
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
/* JPEGCam v1.0.9 */
/* Webcam library for capturing JPEG images and submitting to a server */
/* Copyright (c) 2008 - 2009 Joseph Huckaby <jhuckaby@goldcartridge.com> */
/* Licensed under the GNU Lesser Public License */
/* http://www.gnu.org/licenses/lgpl.html */
/* Usage:
<script language="JavaScript">
document.write( webcam.get_html(320, 240) );
webcam.set_api_url( 'test.php' );
webcam.set_hook( 'onComplete', 'my_callback_function' );
function my_callback_function(response) {
alert("Success! PHP returned: " + response);
}
</script>
<a href="javascript:void(webcam.snap())">Take Snapshot</a>
*/
// Everything is under a 'webcam' Namespace
window.webcam = {
version: '1.0.9',
// globals
ie: !!navigator.userAgent.match(/MSIE/),
protocol: location.protocol.match(/https/i) ? 'https' : 'http',
callback: null, // user callback for completed uploads
swf_url: 'webcam.swf', // URI to webcam.swf movie (defaults to cwd)
shutter_url: 'shutter.mp3', // URI to shutter.mp3 sound
api_url: '', // URL to upload script
loaded: false, // true when webcam movie finishes loading
quality: 90, // JPEG quality (1 - 100)
shutter_sound: true, // shutter sound effect on/off
stealth: false, // stealth mode (do not freeze image upon capture)
hooks: {
onLoad: null,
onComplete: null,
onError: null
}, // callback hook functions
set_hook: function(name, callback) {
// set callback hook
// supported hooks: onLoad, onComplete, onError
if (typeof(this.hooks[name]) == 'undefined')
return alert("Hook type not supported: " + name);
this.hooks[name] = callback;
},
fire_hook: function(name, value) {
// fire hook callback, passing optional value to it
if (this.hooks[name]) {
if (typeof(this.hooks[name]) == 'function') {
// callback is function reference, call directly
this.hooks[name](value);
}
else if (typeof(this.hooks[name]) == 'array') {
// callback is PHP-style object instance method
this.hooks[name][0][this.hooks[name][1]](value);
}
else if (window[this.hooks[name]]) {
// callback is global function name
window[ this.hooks[name] ](value);
}
return true;
}
return false; // no hook defined
},
set_api_url: function(url) {
// set location of upload API script
this.api_url = url;
},
set_swf_url: function(url) {
// set location of SWF movie (defaults to webcam.swf in cwd)
this.swf_url = url;
},
get_html: function(width, height, server_width, server_height) {
// Return HTML for embedding webcam capture movie
// Specify pixel width and height (640x480, 320x240, etc.)
// Server width and height are optional, and default to movie width/height
if (!server_width) server_width = width;
if (!server_height) server_height = height;
var html = '';
var flashvars = 'shutter_enabled=' + (this.shutter_sound ? 1 : 0) +
'&shutter_url=' + escape(this.shutter_url) +
'&width=' + width +
'&height=' + height +
'&server_width=' + server_width +
'&server_height=' + server_height;
if (this.ie) {
html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+this.protocol+'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="webcam_movie" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+this.swf_url+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/></object>';
}
else {
html += '<embed id="webcam_movie" src="'+this.swf_url+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="webcam_movie" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" />';
}
this.loaded = false;
return html;
},
get_movie: function() {
// get reference to movie object/embed in DOM
if (!this.loaded) return alert("ERROR: Movie is not loaded yet");
var movie = document.getElementById('webcam_movie');
if (!movie) alert("ERROR: Cannot locate movie 'webcam_movie' in DOM");
return movie;
},
set_stealth: function(stealth) {
// set or disable stealth mode
this.stealth = stealth;
},
snap: function(url, callback, stealth) {
// take snapshot and send to server
// specify fully-qualified URL to server API script
// and callback function (string or function object)
if (callback) this.set_hook('onComplete', callback);
if (url) this.set_api_url(url);
if (typeof(stealth) != 'undefined') this.set_stealth( stealth );
this.get_movie()._snap( this.api_url, this.quality, this.shutter_sound ? 1 : 0, this.stealth ? 1 : 0 );
},
freeze: function() {
// freeze webcam image (capture but do not upload)
this.get_movie()._snap('', this.quality, this.shutter_sound ? 1 : 0, 0 );
},
upload: function(url, callback) {
// upload image to server after taking snapshot
// specify fully-qualified URL to server API script
// and callback function (string or function object)
if (callback) this.set_hook('onComplete', callback);
if (url) this.set_api_url(url);
this.get_movie()._upload( this.api_url );
},
reset: function() {
// reset movie after taking snapshot
this.get_movie()._reset();
},
configure: function(panel) {
// open flash configuration panel -- specify tab name:
// "camera", "privacy", "default", "localStorage", "microphone", "settingsManager"
if (!panel) panel = "camera";
this.get_movie()._configure(panel);
},
set_quality: function(new_quality) {
// set the JPEG quality (1 - 100)
// default is 90
this.quality = new_quality;
},
set_shutter_sound: function(enabled, url) {
// enable or disable the shutter sound effect
// defaults to enabled
this.shutter_sound = enabled;
this.shutter_url = url ? url : 'shutter.mp3';
},
flash_notify: function(type, msg) {
// receive notification from flash about event
switch (type) {
case 'flashLoadComplete':
// movie loaded successfully
this.loaded = true;
this.fire_hook('onLoad');
break;
case 'error':
// HTTP POST error most likely
if (!this.fire_hook('onError', msg)) {
alert("JPEGCam Flash Error: " + msg);
}
break;
case 'success':
// upload complete, execute user callback function
// and pass raw API script results to function
this.fire_hook('onComplete', msg.toString());
break;
default:
// catch-all, just in case
alert("jpegcam flash_notify: " + type + ": " + msg);
break;
}
}
};
body, html {width: 100%; height: 100%; color: #343434; font-family: trebuchet ms; background:url('../img/tausta.png') repeat-x #fff; margin: 0px;}
#header {width: 970px; height: 52px; margin: 0 auto;}
#logo {width: 255px; height: 52px; float: left;}
#login {width: 290px; height: 23px; float: right; margin-top: 15px;}
#login input {background:url('../img/input.png') no-repeat; width: 130px; height: 23px; color:#fff; border:0px;padding-left: 10px;}
#wrapper {width: 970px; margin: 0 auto;}
#navigation {margin: 15px 0px; height: 33px; width: 100%;}
#navigation ul {list-style-type:none; margin: 0px; padding: 0px;}
#navigation ul li {float: left; margin-right: 10px;}
#navigation ul li a {display: block; height: 33px; padding: 0px 10px; line-height: 33px; text-decoration: none; font-weight: bold; color: #0073bc;}
#navigation ul li a:hover, .active {background:#fff; border-radius: 5px; border: 1px solid #c0c0c0; color:#7dac0c !important;}
a {color: #0037bc;}
a:hover {color: #7dac0c;}
#container {width: 100%; background:url(../img/container.png) repeat-y; font-size: 13px;}
#container #left {width: 680px; float: left; padding: 10px 20px;}
#left h1 {color:#7dac0c; font-size: 24px; padding-top:0px; margin-top: 0px;}
#left h2 {color:#7dac0c; font-size: 18px;}
#left h3 {color:#7dac0c; font-size: 16px;}
#right {float:left; border-left: 1px dotted #c0c0c0; padding: 10px 20px; width: 200px;}
#right h2 {color:#7dac0c; font-size: 18px; padding-top: 0px; margin-top:0px;}
#container.top {width: 100%; background:url(../img/container-top.png) no-repeat; height: 15px;}
#container.bottom {width: 100%; background:url(../img/container-bottom.png) no-repeat; height: 16px;}
.clearfix:after {content: ".";display: block;clear: both;visibility: hidden;line-height: 0;height: 0;}
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns: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:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
<composite:attribute name="datefield" required="true" />
<composite:attribute name="submitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<h:outputScript target="head" library="script" name="jquery.min.js" />
<h:outputScript target="head" library="script" name="date.js" />
<h:outputStylesheet library="style" name="datePicker.css" />
<h:outputScript target="head" library="script" name="jquery.datePicker.js" />
<h:outputScript target="head" library="script" name="date_fi.js" />
<h:outputScript target="head">
Date.format = 'dd/mm/yyyy';
$(function()
{
$('#currdatePick').datePicker({inline:true#{sessionHandler.hasPermission('CALENDAR_MANAGE')?', startDate: \'01/01/1970\'':''}})
.dpSetSelected($('#dselect\\:dateform\\:dateField').val())
.bind('dateSelected',
function(e, selectedDate, $td)
{
var formatted = selectedDate.asString()
$('#dselect\\:dateform\\:dateField').val(formatted);
var subbutt = $('#dselect\\:dateform\\:sub');
subbutt.click();
}
);
});
</h:outputScript>
<div id="currdatePick" />
<h:form id="dateform">
<h:inputHidden id="dateField" value="#{cc.attrs.datefield.time}">
<!-- date format Fixed for dateselector! -->
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:inputHidden>
<h:commandButton style="display: none" id="sub" action="#{cc.attrs.submitaction}" value="foobar" />
</h:form>
</composite:implementation>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<body>
<composite:interface>
<composite:attribute name="calendar" required="true" />
</composite:interface>
<composite:implementation>
<table class="datetable">
<tr>
<th>Aika</th>
<th jsfc="ui:repeat" var="resloc" value="#{cc.attrs.calendar[0].locations}">
<h:outputText value="#{resloc.location.name}" />
</th>
</tr>
<tr id="timeRow" jsfc="ui:repeat" value="#{cc.attrs.calendar}" var="slotLocWrap">
<td><h:outputText value="#{slotLocWrap.slot.startTime.time}">
<f:convertDateTime timeZone="#{userprefs.timezone}" pattern="#{sessionHandler.timePattern}" />
</h:outputText></td>
<td id="itemCell" jsfc="ui:repeat" var="locWrap" value="#{slotLocWrap.locations}">
<div class="#{locWrap.taken?'taken':'free'}">
<h:link rendered="#{!locWrap.taken or requestCalendarView.calmanage}"
outcome="#{locWrap.taken?'/calendar/edit':'/calendar/reserve'}"
value="#{locWrap.taken?locWrap.reservation.wholeName:'Varaa'}"
title="#{locWrap.taken?locWrap.reservation.wholeName:'Varaa paikka'}"
>
<f:param name="locid" value="#{locWrap.location.id}" />
<f:param name="slotid" value="#{slotLocWrap.slot.id}" />
</h:link>
</div>
</td>
</tr>
</table>
</composite:implementation>
</body>
</html>
......@@ -4,7 +4,8 @@
<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: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"
xmlns:role="http://java.sun.com/jsf/composite/tools/role">
xmlns:role="http://java.sun.com/jsf/composite/tools/role"
>
<composite:interface>
......@@ -13,35 +14,41 @@
<composite:implementation>
<h:form id="placeselectform">
<h:commandButton rendered="#{mapView.canUserBuy()}" value="#{i18n['mapView.buyPlaces']}"
action="#{mapView.buySelectedPlaces()}" />
action="#{mapView.buySelectedPlaces()}"
/>
<h:commandButton styleClass="imgcenter" id="commandbutton" image="/PlaceMap?mapid=#{mapView.activeMap.id.id}"
actionListener="#{mapView.placeSelectActionListener}" />
actionListener="#{placeView.placeSelectActionListener}"
/>
<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>
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>
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>
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>
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>
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:panelGroup>
<h:panelGrid columnClasses=",rightalign" columns="2">
<h:outputLabel value="#{i18n['placeSelect.totalPlaces']}:" />
<h:outputText value="#{mapView.activeMap.places.size()}" />
......@@ -63,21 +70,20 @@
</h:panelGroup>
<h:panelGrid columnClasses=",rightalign" columns="2" rendered="#{not empty mapView.clickedplace }">
<h:panelGrid columnClasses=",rightalign" columns="2" rendered="#{not empty placeView.place }">
<h:outputLabel value="#{i18n['placeSelect.placeName']}:" />
<h:outputText value="#{mapView.clickedplace.name}" />
<h:outputText value="#{placeView.place.name}" />
<h:outputLabel value="#{i18n['placeSelect.placeProductName']}:" />
<h:outputText value="#{mapView.clickedplace.product.name}" />
<h:outputText value="#{placeView.place.product.name}" />
<h:outputLabel value="#{i18n['placeSelect.placePrice']}:" />
<h:outputText class="" value="#{mapView.clickedplace.product.price}">
<h:outputText class="" value="#{placeView.place.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<h:commandButton rendered="#{sessionHandler.canWrite('MAP')}" value="#{i18n['place.edit']}"
action="#{placeView.editPlace()}" />
<h:commandButton rendered="#{sessionHandler.canWrite('MAP')}" value="#{i18n['place.edit']}" action="/place/edit" />
</h:panelGrid>
</h:panelGrid>
......@@ -85,7 +91,9 @@
</h:form>
<div><h:outputText escape="false" value="#{mapView.activeMap.notes}" /></div>
<div>
<h:outputText escape="false" value="#{mapView.activeMap.notes}" />
</div>
</composite:implementation>
</html>
......@@ -58,7 +58,7 @@
<f:facet name="header">
<h:outputText value="#{i18n['user.image']}" />
</f:facet>
<h:commandLink action="#{userView.showImage()}"
<h:link action="#{userView.showImage()}"
value="#{(empty user.currentImage)?i18n['user.noImage']:i18n['user.hasImage']}"
/>
</h:column>
......
......@@ -3,17 +3,48 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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: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">
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<a href="#{request.contextPath}/flash/Uploader.swf" onclick="var newwin = window.open('#{request.contextPath}/flash/Uploader.swf?userid=#{userView.user.id}', 'imagesubmitpopup', 'height=480,width=640'); this.target='imagesubmitpopup'; newwin.focus(); return false; " target="_blank">#{i18n['userimage.webcam']}</a>
<h:outputScript target="head" library="script" name="jquery.min.js" />
<h:outputScript target="head" library="jpegcam" name="webcam.js" />
<h:outputScript target="head">
webcam.set_api_url( '#{request.contextPath}/UploadServlet?type=userimage&amp;id=#{userView.user.id}' );
webcam.set_hook('onComplete', 'my_completion_handler');
webcam.set_swf_url('#{request.contextPath}/resources/jpegcam/webcam.swf');
webcam.set_shutter_sound(true,'#{request.contextPath}/resources/jpegcam/shutter.mp3');
function my_completion_handler(msg) {
// extract URL out of PHP output
if (msg.match(/(http\:\/\/\S+)/)) {
var image_url = RegExp.$1;
alert(image_url);
}
}
</h:outputScript>
<button onclick="$('#webcamcontainer').prepend(webcam.get_html(320, 240));$('#webcamcontainer').show();$(this).hide();">#{i18n['userimage.webcam']}</button>
<div id="webcamcontainer" style="display: none;">
asd
<button onclick="webcam.configure()">Configure</button>
<button onclick="webcam.snap()">Ota kuva</button>
</div>
<form
onsubmit="window.open('', 'imagesubmitpopup', 'height=240,width=320'); this.target='imagesubmitpopup'; return true; "
action="#{request.contextPath}/UploadServlet?type=userimage" enctype="multipart/form-data" method="post">
<p><input type="hidden" name="id" value="#{userView.user.id}" /> Voit lisätä kuvan kävijälippuasi varten. Näin
nopeutat asiointiasi tapahtumaan tullessasi.</p>
action="#{request.contextPath}/UploadServlet?type=userimage" enctype="multipart/form-data" method="post"
>
<p>
<input type="hidden" name="id" value="#{userView.user.id}" /> Voit lisätä kuvan kävijälippuasi varten. Näin nopeutat
asiointiasi tapahtumaan tullessasi.
</p>
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['imagefile.file']}" />
<input type="file" name="file" />
......@@ -21,10 +52,11 @@
<h:panelGroup>
<input type="submit" name="submit" value="#{i18n['user.imagesubmit']}" />
</h:panelGroup>
</h:panelGrid></form>
</h:panelGrid>
</form>
<h2>#{i18n['user.thisIsCurrentImage']}</h2>
<h:form>
<h:form>
<h:commandButton action="#{userView.reloadUser()}" value="Päivitä kuva" />
</h:form>
<h:outputText rendered="#{empty userView.user.currentImage}" value="#{i18n['user.noCurrentImage']}" />
......@@ -33,9 +65,12 @@
</h:panelGroup>
<tools:canWrite rendered="#{!empty userView.user.currentImage}" target="USER_MANAGEMENT">
<div><h:outputText value="Mime: #{userView.user.currentImage.mimeType}" /> <h:form id="imageconvert">
<div>
<h:outputText value="Mime: #{userView.user.currentImage.mimeType}" />
<h:form id="imageconvert">
<h:commandButton action="#{userView.recheckImagetype()}" value="Check imagetype" />
</h:form></div>
</h:form>
</div>
</tools:canWrite>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:users="http://java.sun.com/jsf/composite/tools/user"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/tools/user"
xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{userCreateView.initView}" />
</f:metadata>
<ui:param name="thispage" value="page.user.create" />
<ui:define name="content">
#{userView.initCreateuser()}
<users:edit creating="true" commitaction="#{createUserView.create()}"
commitvalue="#{i18n['user.create']}" />
<users:edit creating="true" commitaction="#{createUserView.create()}" commitvalue="#{i18n['user.create']}" />
......
......@@ -3,10 +3,15 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.user.create" />
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" />
</f:metadata>
<ui:define name="content">
<users:sendImage />
......
......@@ -58,7 +58,7 @@ public class SessionHandler {
public String getLayout() {
// TODO: layout selection code missing!!
// return "stream1";
return "insomnia1";
return "insomnia2";
}
public boolean hasPermission(String target, String permission) {
......
......@@ -80,6 +80,7 @@ public class PlaceMap extends HttpServlet {
Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID);
// Integer userId = getIntegerParameter(request,
// PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta.
EventMap map = placemapBean.findMap(mapId);
logger.debug("Mapid: {}", mapId);
ostream = response.getOutputStream();
......
......@@ -6,8 +6,6 @@ import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
......@@ -27,15 +25,6 @@ public class CreateUserView extends GenericCDIView {
private String password;
public void initView() {
if (super.requirePermissions(permbean.hasPermission(Permission.LOGIN, RolePermission.WRITE))) {
if (user == null) {
user = new User();
}
super.beginConversation();
}
}
public String create() {
user = userbean.createNewUser(user, password);
......
......@@ -47,8 +47,14 @@ public abstract class GenericCDIView implements Serializable {
}
protected boolean requirePermissions(Permission perm, RolePermission rp) {
return requirePermissions(permbean.hasPermission(perm, rp));
protected boolean requirePermissions(Permission perm, RolePermission rp, boolean... externalChecks) {
boolean[] perms = new boolean[externalChecks.length + 1];
perms[0] = permbean.hasPermission(perm, rp);
if (externalChecks.length == 0) {
System.arraycopy(externalChecks, 0, perms, 1, externalChecks.length);
}
return requirePermissions(perms);
}
protected boolean requirePermissions(boolean... externalChecks) {
......
package fi.insomnia.bortal.web.cdiview;
import java.math.BigDecimal;
import java.util.Map;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
......@@ -14,12 +12,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceBeanLocal;
import fi.insomnia.bortal.beans.PlaceMapBeanLocal;
import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
......@@ -34,8 +32,8 @@ public class MapView extends GenericCDIView {
@Inject
@SelectedUser
private User user;
private EventMap activeMap;
private Place clickedplace;
@EJB
private PlaceBeanLocal placeBean;
......@@ -51,65 +49,22 @@ public class MapView extends GenericCDIView {
return user.getAccountBalance().compareTo(BigDecimal.ZERO) > 0;
}
public String buySelectedPlaces() {
public String buySelectedPlaces() throws PermissionDeniedException {
try {
placeBean.buySelectedPlaces(getActiveMap());
placeBean.buySelectedPlaces(user);
} catch (BortalCatchableException e) {
addFaceMessage("mapView.errorWhileBuyingPlaces");
placeBean.releaseUsersPlaces();
placeBean.releaseUsersPlaces(user);
}
return "";
}
public void placeSelectActionListener(ActionEvent e) {
FacesContext context = FacesContext.getCurrentInstance();
String clientId = e.getComponent().getClientId(context);
Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap();
int x = new Integer(requestParams.get(clientId + ".x")).intValue();
int y = new Integer(requestParams.get(clientId + ".y")).intValue();
logger.debug("Clicked position {} {}", x, y);
setClickedplace(placeBean.findPlace(getActiveMap(), x, y));
logger.debug("Clicked place: {}", getClickedplace());
if (getClickedplace() != null) {
if (getClickedplace().isReservedFor(user)) {
logger.debug("Place {} was reserved for user. Removing reservation!", clickedplace);
if (!placeBean.releasePlace(getClickedplace(), user)) {
this.addFaceMessage("mapView.errorWhenReleasingPlace");
public BigDecimal getReservationPrice() throws PermissionDeniedException {
return placeBean.totalReservationPrice(user, null);
}
} else if (getClickedplace().isBuyable() && !getClickedplace().isTaken()) {
BigDecimal balance = permbean.getCurrentUser().getAccountBalance();
BigDecimal price = placeBean.totalReservationPrice(getActiveMap(), getClickedplace());
logger.debug("Balance {}, price {}", balance, price);
if (price.compareTo(balance) <= 0) {
logger.debug("Place was free. Marking for user.");
if (!placeBean.reservePlace(getClickedplace(), user)) {
this.addFaceMessage("mapView.errorWhenReservingPlace");
}
} else {
if (permbean.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("Done calling PlaceSelectActionListener");
}
public BigDecimal getReservationPrice() {
return placeBean.totalReservationPrice(activeMap, null);
}
public String releaseUsersPlaces() {
placeBean.releaseUsersPlaces();
public String releaseUsersPlaces() throws PermissionDeniedException {
placeBean.releaseUsersPlaces(user);
return "";
}
......@@ -118,6 +73,7 @@ public class MapView extends GenericCDIView {
}
@Produces
public EventMap getActiveMap() {
if (activeMap == null) {
LanEvent event = eventBean.getCurrentEvent();
......@@ -131,14 +87,6 @@ public class MapView extends GenericCDIView {
return activeMap;
}
public void setClickedplace(Place clickedplace) {
this.clickedplace = clickedplace;
}
public Place getClickedplace() {
return clickedplace;
}
public void setActiveMap(EventMap activeMap) {
this.activeMap = activeMap;
}
......
package fi.insomnia.bortal.web.cdiview;
import java.math.BigDecimal;
import java.util.Map;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
......@@ -12,42 +17,107 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionDeniedException;
import fi.insomnia.bortal.beans.PlaceBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.web.annotations.SelectedUser;
@Named
@ConversationScoped
public class PlaceView {
public class PlaceView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = -6975041831787940421L;
private static final Logger logger = LoggerFactory.getLogger(PlaceView.class);
private Integer placeId;
private Place place;
@EJB
private UserBeanLocal userbean;
@EJB
private PlaceBeanLocal placebean;
private ListDataModel<Place> placesPlacegroup;
@Inject
@SelectedUser
private User user;
@Inject
private EventMap currentMap;
private String searchuser;
private ListDataModel<User> userlist;
@Inject
private MapView mapview;
public void placeSelectActionListener(ActionEvent e) throws PermissionDeniedException {
super.beginConversation();
FacesContext context = FacesContext.getCurrentInstance();
String clientId = e.getComponent().getClientId(context);
Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap();
int x = new Integer(requestParams.get(clientId + ".x")).intValue();
int y = new Integer(requestParams.get(clientId + ".y")).intValue();
logger.debug("Clicked position {} {}", x, y);
place = placebean.findPlace(getCurrentMap(), x, y);
logger.debug("Clicked place: {}", place);
if (place != null) {
public String editPlace() {
if (place.isReservedFor(user)) {
logger.debug("Place {} was reserved for user. Removing reservation!", place);
if (!placebean.releasePlace(place)) {
this.addFaceMessage("mapView.errorWhenReleasingPlace");
}
} else if (place.isBuyable() && !place.isTaken()) {
BigDecimal balance = permbean.getCurrentUser().getAccountBalance();
BigDecimal price = placebean.totalReservationPrice(user, place);
logger.debug("Balance {}, price {}", balance, price);
if (price.compareTo(balance) <= 0) {
logger.debug("Place was free. Marking for user.");
if (!placebean.reservePlace(place, user)) {
this.addFaceMessage("mapView.errorWhenReservingPlace");
}
} else {
if (permbean.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("Done calling PlaceSelectActionListener");
}
this.place = mapview.getClickedplace();
logger.debug("editing place {}", place);
return "/place/edit";
public void initView() {
if (super.requirePermissions(Permission.MAP, RolePermission.WRITE)) {
if (getPlaceId() != null) {
this.place = placebean.find(getPlaceId());
}
beginConversation();
}
public String reserveForUser() {
}
public String reserveForUser() throws PermissionDeniedException {
try {
place = placebean.lockPlaces(userlist.getRowData(), place);
} catch (PermissionDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
User user = userlist.getRowData();
if (placebean.reservePlace(place, userlist.getRowData())) {
placebean.buySelectedPlaces(user);
}
} catch (BortalCatchableException e) {
super.addFaceMessage("Error reserving place for user");
}
searchuser = null;
userlist = null;
return null;
......@@ -64,33 +134,17 @@ public class PlaceView {
public String releasePlace() {
if (!placebean.releasePlace(place, place.getCurrentUser())) {
if (!placebean.releasePlace(place)) {
logger.debug("Error releasing place.");
}
return null;
}
public void initGroupsPlacelist() {
if (place.getGroup() != null && !place.getGroup().getPlaces().isEmpty()) {
placesPlacegroup = new ListDataModel<Place>(place.getGroup().getPlaces());
} else {
placesPlacegroup = null;
}
}
public ListDataModel<Place> getPlacesGroupPlaces() {
return placesPlacegroup;
}
public String removePlaceFromGroup() {
public String editPlacegroupPlace() {
place = placesPlacegroup.getRowData();
return "/place/edit";
}
placebean.unbuyPlace(place);
addFaceMessage("place.unbought", place.getName());
public String removePlaceFromGroup() {
place.getGroup().getPlaces().remove(place);
place.setGroup(null);
place = placebean.mergeChanges(place);
return null;
}
......@@ -99,11 +153,6 @@ public class PlaceView {
return null;
}
public String checkMemberships() {
placebean.checkMemberships();
return null;
}
public void setSearchuser(String searchuser) {
this.searchuser = searchuser;
}
......@@ -119,4 +168,20 @@ public class PlaceView {
public ListDataModel<User> getUserlist() {
return userlist;
}
public void setCurrentMap(EventMap currentMap) {
this.currentMap = currentMap;
}
public EventMap getCurrentMap() {
return currentMap;
}
public void setPlaceId(Integer placeId) {
this.placeId = placeId;
}
public Integer getPlaceId() {
return placeId;
}
}
......@@ -52,6 +52,15 @@ public class UserView extends GenericCDIView {
return user;
}
public void initCreateView() {
if (super.requirePermissions(permbean.hasPermission(Permission.LOGIN, RolePermission.WRITE))) {
if (user == null) {
user = new User();
}
super.beginConversation();
}
}
public void initView() {
/*
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!