Commit 3af76726 by Tuomas Riihimäki

Lippukauppa avattu :)

1 parent aedf7b75
Showing with 1317 additions and 432 deletions
......@@ -2,6 +2,7 @@ package fi.insomnia.bortal.beans;
import java.io.ByteArrayOutputStream;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.List;
import javax.ejb.EJB;
......@@ -24,6 +25,7 @@ import fi.insomnia.bortal.facade.BillLineFacade;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User;
......@@ -35,7 +37,9 @@ import fi.insomnia.bortal.model.User;
public class BillBean implements BillBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(BillBean.class);
private static final MathContext MATHCONTEXT_TWOSCALE = new MathContext(2);;
@EJB
private BillFacade billFacade;
......@@ -55,6 +59,7 @@ public class BillBean implements BillBeanLocal {
private BillLineFacade billLineFacade;
@PersistenceContext
private EntityManager em;
/**
* Default constructor.
*/
......@@ -133,7 +138,20 @@ public class BillBean implements BillBeanLocal {
}
BillLine line = new BillLine(bill, product.getName(), product.getUnitName(), count, product.getPrice(), product.getVat());
billLineFacade.create(line);
line.setBill(bill);
for (Discount disc : product.getDiscounts()) {
if (disc.isActive() && count.compareTo(disc.getAmountMax()) <= 0 && count.compareTo(disc.getAmountMin()) >= 0) {
BigDecimal disccounts = count;
if (disc.getMaxNum().compareTo(disccounts) >= 0) {
disccounts = disc.getMaxNum();
}
BillLine discountLine = new BillLine(bill, disc.getShortdesc(), product.getUnitName(), disccounts,
product.getPrice().subtract(product.getPrice().multiply(disc.getPercentage(), MATHCONTEXT_TWOSCALE)).negate(),
product.getVat().subtract(product.getVat().multiply(disc.getPercentage(), MATHCONTEXT_TWOSCALE)).negate());
billLineFacade.create(discountLine);
}
}
em.flush();
return line;
}
......
package fi.insomnia.bortal.beans;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.DiscountFacade;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.facade.ProductFacade;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.Product;
/**
* Session Bean implementation class DiscountBean
*/
@Stateless
public class DiscountBean implements DiscountBeanLocal {
@EJB
private DiscountFacade discountfacade;
@EJB
private EventBeanLocal eventbean;
@EJB
private ProductFacade productfacade;
@EJB
private EventFacade eventfacade;
public DiscountBean() {
}
@Override
public Discount save(Discount discount) {
Discount ret = discountfacade.merge(discount);
productfacade.evict(discount.getProduct());
return ret;
}
@Override
public Discount create(Product product,String discountdesc) {
Discount ret = new Discount(eventbean.getCurrentEvent());
ret.setShortdesc(discountdesc);
ret.setProduct(product);
discountfacade.create(ret);
eventfacade.evict(eventbean.getCurrentEvent());
productfacade.evict(product);
return ret;
}
}
......@@ -89,7 +89,8 @@ public class EventBean implements EventBeanLocal {
@Override
public LanEvent mergeChanges(LanEvent event) {
if(!userBean.isCurrentUser(event.getOrganiser().getAdmin()))
//TODO: Hmm..
if(!userBean.isCurrentUser(event.getOrganiser().getAdmin()) && !userBean.getCurrentUser().isSuperadmin())
{
throw new PermissionDeniedException(secubean, userBean.getCurrentUser(), "User tried to merge event: " + event + " without being admin of that group");
}
......@@ -98,7 +99,8 @@ public class EventBean implements EventBeanLocal {
@Override
public void create(LanEvent event) {
if (!userBean.isCurrentUser(event.getOrganiser().getAdmin())) {
//TODO: Hmm..
if (!userBean.isCurrentUser(event.getOrganiser().getAdmin()) && !userBean.getCurrentUser().isSuperadmin()) {
throw new PermissionDeniedException(secubean, userBean.getCurrentUser(), "User tried to create a new event for organiser " + event.getOrganiser() + " without being admin of that group");
}
......@@ -106,4 +108,9 @@ public class EventBean implements EventBeanLocal {
}
public String flushCache()
{
return eventFacade.flushCache();
}
}
package fi.insomnia.bortal.beans;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.LanEvent;
/**
* Session Bean implementation class EventMapBean
*/
@Stateless
public class EventMapBean implements EventMapBeanLocal {
@EJB
private EventMapFacade eventmapfacade;
public EventMapBean() {
// TODO Auto-generated constructor stub
}
@Override
public EventMap saveMap(EventMap eventmap) {
return eventmapfacade.merge(eventmap);
}
@Override
public EventMap create(LanEvent event, String mapname) {
EventMap ret = new EventMap(event);
ret.setName(mapname);
eventmapfacade.create(ret);
return ret;
}
}
package fi.insomnia.bortal.beans;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
......@@ -22,7 +23,6 @@ import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.exceptions.PermissionDeniedException;
import fi.insomnia.bortal.facade.RoleFacade;
import fi.insomnia.bortal.facade.RoleRightFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.facade.UserImageFacade;
import fi.insomnia.bortal.model.Role;
......@@ -93,7 +93,9 @@ public class UserBean implements UserBeanLocal {
fatalPermission(Permission.USER_MANAGEMENT, RolePermission.WRITE);
}
return userFacade.merge(user);
User ret = userFacade.merge(user);
userFacade.evict(ret);
return ret;
}
public User getUser(String nick) {
......@@ -145,10 +147,13 @@ public class UserBean implements UserBeanLocal {
ret = false;
Set<Role> checkedRoles = new HashSet<Role>();
List<Role> defaultrole = new ArrayList<Role>();
defaultrole.add(eventBean.getCurrentEvent().getDefaultRole());
ret = getRights(defaultrole, target, permission, checkedRoles);
List<Role> rolelist = rolefacade.findForUser(user, eventBean.getCurrentEvent());
if (getRights(rolelist, target, permission, checkedRoles)) {
ret = true;
if (!ret) {
List<Role> rolelist = rolefacade.findForUser(user, eventBean.getCurrentEvent());
ret = getRights(rolelist, target, permission, checkedRoles);
}
// logger.debug("Perm {} not found from cache. saving to cache: {}",
// target, ret);
......@@ -179,30 +184,21 @@ public class UserBean implements UserBeanLocal {
if (roles == null || roles.isEmpty()) {
return false;
}
for (Role role : roles)
for (Role role : roles) {
if (role == null) {
continue;
}
for (RoleRight rr : role.getRoleRights()) {
BortalLocalContextHolder.setPermission(rr);
if (rr.getPermission().equals(expectedRight)) {
switch (permission) {
case READ:
if (rr.isRead()) {
return true;
}
break;
case WRITE:
if (rr.isWrite()) {
return true;
}
break;
case EXECUTE:
if (rr.isExecute()) {
return true;
}
}
Boolean hasright = BortalLocalContextHolder.hasPermission(expectedRight, permission);
if (hasright != null) {
return hasright;
}
}
checkedRoles.addAll(roles);
}
checkedRoles.addAll(roles);
return getRights(rolefacade.findAllParentsExcluding(roles, checkedRoles), expectedRight, permission, checkedRoles);
}
......@@ -266,9 +262,14 @@ public class UserBean implements UserBeanLocal {
@Override
public UserImage findUserImage(int id) {
UserImage ret = userimagefacade.find(id);
if (ret != null && !this.isCurrentUser(ret.getUser())) {
fatalPermission(Permission.USER_MANAGEMENT, RolePermission.READ, "Not enough rights to access image id: " + id + " for user " + ret.getUser());
UserImage ret = null;
if (id == 0 && isLoggedIn()) {
ret = getCurrentUser().getCurrentImage();
} else {
ret = userimagefacade.find(id);
if (ret != null && !this.isCurrentUser(ret.getUser())) {
fatalPermission(Permission.USER_MANAGEMENT, RolePermission.READ, "Not enough rights to access image id: " + id + " for user " + ret.getUser());
}
}
return ret;
}
......
......@@ -199,17 +199,23 @@ public class PdfPrinter {
drawText(355, 805, DATE_FORMAT.format(bill.getSentDate().getTime()), infofont);
drawText(442, 812, "Eräpäivä", descriptionfont);
drawText(485, 805, DATE_FORMAT.format(bill.getDueDate().getTime()), infofont);
drawText(302, 772, "Maksuehdot", descriptionfont);
drawText(355, 765, bill.getPaymentTime() + " pv Netto", infofont);
String paystr = "Heti";
if(bill.getPaymentTime() > 0)
{
paystr = bill.getPaymentTime() + " pv Netto";
}
drawText(355, 765, paystr, infofont);
drawText(442, 792, "Laskun numero", descriptionfont);
drawText(510, 785, bill.getBillNumber().toString(), infofont);
drawText(442, 772, "Huomautusaika", descriptionfont);
/* drawText(442, 772, "Huomautusaika", descriptionfont);
drawText(510, 765, bill.getNoticetime(), infofont);
*/
drawText(302, 792, "Viitenumero", descriptionfont);
drawText(355, 785, BillUtils.createReferenceNumber(bill.getReferenceNumberBase()).toString(), infofont);
......@@ -237,10 +243,10 @@ public class PdfPrinter {
drawText(302, 672, "Yhteensä", descriptionfont);
drawText(355, 665, decRound(bill.totalPrice()) + EURO, infofont);
/*
drawText(472, 672, "Viivästyskorko", descriptionfont);
drawText(530, 665, bill.getDelayIntrest() + "%", infofont);
*/
// drawText( 490, 665, "ALV Rek.",'mediumTeksti');
// Alkuosa loppuu
......
......@@ -3,6 +3,7 @@ package fi.insomnia.bortal.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NamedQuery;
import javax.persistence.PersistenceContext;
import fi.insomnia.bortal.model.Discount;
......@@ -20,5 +21,4 @@ public class DiscountFacade extends EventChildGenericFacade<Discount> {
protected EntityManager getEm() {
return em;
}
}
......@@ -38,5 +38,11 @@ public class EventFacade extends GenericFacade<Integer, LanEvent> {
return getSingleNullableResult(q);
}
public String flushCache() {
getEm().getEntityManagerFactory().getCache().evictAll();
return "Evicted all!";
}
}
......@@ -43,6 +43,7 @@ public abstract class GenericFacade<PK, T extends ModelInterface> {
public T merge(T entity) {
return getEm().merge(entity);
}
public T find(PK id) {
......
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.Product;
@Local
public interface DiscountBeanLocal {
Discount save(Discount discount);
Discount create(Product product, String discountdesc);
}
......@@ -15,4 +15,5 @@ public interface EventBeanLocal {
void create(LanEvent event);
String flushCache();
}
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.LanEvent;
@Local
public interface EventMapBeanLocal {
EventMap saveMap(EventMap eventmap);
EventMap create(LanEvent currentEvent, String mapname);
}
......@@ -200,9 +200,9 @@ public class Bill implements EventChildInterface {
public Bill(LanEvent event, User user) {
this.id = new EventPk(event);
this.setUser(user);
this.setAddr1(user.getFirstnames() + user.getLastname());
this.setAddr1(user.getFirstnames() +" " + user.getLastname());
this.setAddr2(user.getAddress());
this.setAddr3(user.getZip() + user.getPostalTown());
this.setAddr3(user.getZip() +" "+ user.getTown());
}
public Calendar getDueDate() {
......
......@@ -27,62 +27,52 @@ import javax.persistence.Version;
*/
@Entity
@Table(name = "discounts")
@NamedQueries( {
@NamedQuery(name = "Discount.findAll", query = "SELECT d FROM Discount d"),
@NamedQuery(name = "Discount.findByPercentage", query = "SELECT d FROM Discount d WHERE d.percentage = :percentage"),
@NamedQuery(name = "Discount.findByCode", query = "SELECT d FROM Discount d WHERE d.code = :code"),
@NamedQuery(name = "Discount.findByDetails", query = "SELECT d FROM Discount d WHERE d.details = :details"),
@NamedQuery(name = "Discount.findByAmountMin", query = "SELECT d FROM Discount d WHERE d.amountMin = :amountMin"),
@NamedQuery(name = "Discount.findByAmountMax", query = "SELECT d FROM Discount d WHERE d.amountMax = :amountMax"),
@NamedQuery(name = "Discount.findByActive", query = "SELECT d FROM Discount d WHERE d.active = :active"),
@NamedQuery(name = "Discount.findByMaxNum", query = "SELECT d FROM Discount d WHERE d.maxNum = :maxNum"),
@NamedQuery(name = "Discount.findByPerUser", query = "SELECT d FROM Discount d WHERE d.perUser = :perUser") })
public class Discount implements EventChildInterface {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "percentage", nullable = false, columnDefinition = "integer default 0")
private int percentage = 0;
@Column(name = "percentage", nullable = false, precision = 9, scale = 6)
private BigDecimal percentage = BigDecimal.ZERO;
@Column(name = "unitPrice", nullable = false,precision = 24, scale = 4)
private BigDecimal unitPrice;
@Column(name = "code")
private String code;
@Lob
@Column(name = "details")
private String details;
@Column(name = "amount_min", nullable = false, columnDefinition = "integer default 0")
private int amountMin = 0;
@Column(name = "shortdesc")
private String shortdesc;
@Column(name = "amount_min", nullable = false, precision = 24, scale = 4)
private BigDecimal amountMin = BigDecimal.ZERO;
@Column(name = "amount_max", nullable = false, columnDefinition = "integer default 0")
private int amountMax = 0;
@Column(name = "amount_max", nullable = false, precision = 24, scale = 4)
private BigDecimal amountMax = BigDecimal.ZERO;
@Column(name = "active", nullable = false, columnDefinition = "boolean default false")
@Column(name = "active", nullable = false)
private boolean active = false;
@Column(name = "max_num", nullable = false, columnDefinition = "integer default 0")
private int maxNum = 0;
@Column(name = "max_num", nullable = false, precision = 24, scale = 4)
private BigDecimal maxNum = BigDecimal.ZERO;
@Column(name = "per_user", nullable = false, columnDefinition = "integer default 0")
private int perUser = 0;
@Column(name = "per_user", nullable = false, precision = 24, scale = 4)
private BigDecimal perUser = BigDecimal.ZERO;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "discount")
private List<DiscountInstance> discountInstances;
@JoinColumns( {
@JoinColumn(name = "role_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumns({
@JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false)
@ManyToOne()
private Role role;
@JoinColumns( {
@JoinColumn(name = "product_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumns({
@JoinColumn(name = "product_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false)
})
......@@ -100,81 +90,70 @@ public class Discount implements EventChildInterface {
this.id = new EventPk(event);
}
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
public BigDecimal getAmountMin() {
return amountMin;
}
public Discount(LanEvent event, int percentage, int amountMin,
int amountMax, boolean active, int maxNum, int perUser) {
this(event);
this.setPercentage(percentage);
public void setAmountMin(BigDecimal amountMin) {
this.amountMin = amountMin;
this.amountMax = amountMax;
this.active = active;
this.maxNum = maxNum;
this.perUser = perUser;
}
public String getCode() {
return code;
public BigDecimal getAmountMax() {
return amountMax;
}
public void setCode(String code) {
this.code = code;
public void setAmountMax(BigDecimal amountMax) {
this.amountMax = amountMax;
}
public String getDetails() {
return details;
public BigDecimal getMaxNum() {
return maxNum;
}
public void setDetails(String details) {
this.details = details;
public void setMaxNum(BigDecimal maxNum) {
this.maxNum = maxNum;
}
public int getAmountMin() {
return amountMin;
public BigDecimal getPerUser() {
return perUser;
}
public void setAmountMin(int amountMin) {
this.amountMin = amountMin;
public void setPerUser(BigDecimal perUser) {
this.perUser = perUser;
}
public int getAmountMax() {
return amountMax;
public boolean isActive() {
return active;
}
public void setAmountMax(int amountMax) {
this.amountMax = amountMax;
@Override
public EventPk getId() {
return id;
}
public boolean getActive() {
return active;
@Override
public void setId(EventPk id) {
this.id = id;
}
public void setActive(boolean active) {
this.active = active;
public String getCode() {
return code;
}
public int getMaxNum() {
return maxNum;
public void setCode(String code) {
this.code = code;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
public String getDetails() {
return details;
}
public int getPerUser() {
return perUser;
public void setDetails(String details) {
this.details = details;
}
public void setPerUser(int perUser) {
this.perUser = perUser;
public void setActive(boolean active) {
this.active = active;
}
public List<DiscountInstance> getDiscountInstances() {
......@@ -222,14 +201,6 @@ public class Discount implements EventChildInterface {
return jpaVersionField;
}
public void setPercentage(int percentage) {
this.percentage = percentage;
}
public int getPercentage() {
return percentage;
}
public void setRole(Role role) {
this.role = role;
}
......@@ -246,12 +217,20 @@ public class Discount implements EventChildInterface {
return product;
}
public void setUnitPrice(BigDecimal unitPrice) {
this.unitPrice = unitPrice;
public void setPercentage(BigDecimal percentage) {
this.percentage = percentage;
}
public BigDecimal getPercentage() {
return percentage;
}
public void setShortdesc(String shortdesc) {
this.shortdesc = shortdesc;
}
public BigDecimal getUnitPrice() {
return unitPrice;
public String getShortdesc() {
return shortdesc;
}
}
......@@ -42,10 +42,7 @@ public class Role implements EventChildInterface {
@Column(name = "role_name", nullable = false)
private String name;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "role_memberships", joinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id") }, inverseJoinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "user_id") })
@ManyToMany(cascade = CascadeType.ALL, mappedBy="roles")
private List<User> users;
@ManyToMany
......
......@@ -15,6 +15,8 @@ import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
......@@ -82,35 +84,35 @@ public class User implements ModelInterface {
private String password;
@Column(name = "lastname")
private String lastname;
private String lastname ="";
@Column(name = "firstnames")
private String firstnames;
private String firstnames ="";
@Column(name = "birthday")
@Temporal(TemporalType.TIMESTAMP)
private Calendar birthday;
@Column(name = "nick")
private String nick;
private String nick ="";
@Column(name = "email")
private String email;
private String email = "";
@Column(name = "address")
private String address;
private String address ="";
@Column(name = "zip")
private String zip;
private String zip ="";
@Column(name = "postal_town")
private String postalTown;
private String postalTown ="";
@Column(name = "town")
private String town;
private String town ="";
@Column(name = "phone")
private String phone;
private String phone ="";
@OneToOne()
private UserImage currentImage;
......@@ -135,7 +137,12 @@ public class User implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "voter")
private List<Vote> votes;
@ManyToMany(cascade = CascadeType.ALL, mappedBy = "users")
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "role_memberships", inverseJoinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id") },
joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "user_id") })
private List<Role> roles = new ArrayList<Role>();
@OneToMany(mappedBy = "user")
......
......@@ -14,29 +14,26 @@ public class BortalLocalContextHolder {
private String hostname;
private Map<Permission, Map<RolePermission, Boolean>> rightcache = new HashMap<Permission, Map<RolePermission, Boolean>>();
public BortalLocalContextHolder(String hostname) {
this.hostname = hostname;
public BortalLocalContextHolder() {
}
public static void setHostname(String hostname) {
if (THREAD_WITH_CONTEXT.get() == null) {
THREAD_WITH_CONTEXT.set(new BortalLocalContextHolder(hostname));
}
getThread().hostname = hostname;
}
public static String getHostname() {
return THREAD_WITH_CONTEXT.get().getHolderHostname();
return getThread().getHolderHostname();
}
public static void cleanupThread() {
THREAD_WITH_CONTEXT.remove();
if (THREAD_WITH_CONTEXT != null) {
THREAD_WITH_CONTEXT.remove();
}
}
......@@ -45,7 +42,14 @@ public class BortalLocalContextHolder {
}
public static Boolean hasPermission(Permission target, RolePermission permission) {
return THREAD_WITH_CONTEXT.get().hasHolderPermission(target, permission);
return getThread().hasHolderPermission(target, permission);
}
private static BortalLocalContextHolder getThread() {
if (THREAD_WITH_CONTEXT.get() == null) {
THREAD_WITH_CONTEXT.set(new BortalLocalContextHolder());
}
return THREAD_WITH_CONTEXT.get();
}
private Boolean hasHolderPermission(Permission target, RolePermission permission) {
......@@ -58,7 +62,7 @@ public class BortalLocalContextHolder {
}
public static void setPermission(Permission target, RolePermission permission, Boolean ret) {
THREAD_WITH_CONTEXT.get().setHolderPermission(target, permission, ret);
getThread().setHolderPermission(target, permission, ret);
}
......@@ -71,7 +75,7 @@ public class BortalLocalContextHolder {
permmap.put(permission, ret);
}
public static void setPermission( RoleRight rr) {
public static void setPermission(RoleRight rr) {
if (rr.isExecute()) {
setPermission(rr.getPermission(), RolePermission.EXECUTE, true);
}
......@@ -83,5 +87,4 @@ public class BortalLocalContextHolder {
}
}
}
\ No newline at end of file
Manifest-Version: 1.0
Class-Path: lib/log4j.jar
lib/granite.jar
Class-Path: lib/granite.jar
......@@ -33,6 +33,15 @@
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/UploadServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>UserImageServlet</servlet-name>
<servlet-class>fi.insomnia.bortal.servlet.UserImageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UserImageServlet</servlet-name>
<url-pattern>/Userimage</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>PlaceMap</servlet-name>
<servlet-class>fi.insomnia.bortal.servlet.PlaceMap</servlet-class>
......
......@@ -7,6 +7,9 @@
<ui:param name="thispage" value="page.auth.logout" />
<ui:define name="content">
<h:outputText value="#{i18n['login.logoutmessage']}" />
<h:outputScript>
window.location="#{request.contextPath}"
</h:outputScript>
</ui:define>
</ui:composition>
</h:body>
......
<!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:bills="http://java.sun.com/jsf/composite/tools/bills"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.bill.placemap" />
<ui:define name="content">
<img class="imgcenter"
src="#{request.contextPath}/resources/style/insomnia1/konepaikat.png"
alt="Konepaikat" />
</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: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.eventorg.edit" />
<ui:define name="content">
<h:form id="orgform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['eventmap.name']}:" /><h:inputText value="#{eventView.eventmap.name}" />
<h:commandButton id="commitbtn" action="#{eventView.saveMap()}" value="#{i18n['eventmap.save']}" />
</h:panelGrid>
</h:form>
<h2>#{i18n['eventmap.places']}</h2>
<h:form id="eventmapPlacelist">
<h:dataTable border="1" id="places" value="#{eventView.mapPlaces}" var="place">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['place.name']}" />
</f:facet>
<h:outputText value="#{place.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['place.description']}" />
</f:facet>
<h:outputText value="#{place.description}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['place.details']}" />
</f:facet>
<h:outputText value="#{place.details}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['place.mapX']}" />
</f:facet>
<h:outputText value="#{place.mapX}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['place.mapY']}" />
</f:facet>
<h:outputText value="#{place.mapY}" />
</h:column>
<h:column >
<h:commandButton action="#{eventView.editPlace()}" value="#{i18n['place.edit']}" />
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:products="http://java.sun.com/jsf/composite/tools/products"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param
name="thispage"
value="page.product.create" />
<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">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.edit" />
<ui:define name="content">
<tools:fatalPermission
target="EVENT"
permission="EXECUTE" />
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['event.name']}:" />
<h:inputText value="#{eventView.name}" />
<h:outputLabel value="#{i18n['event']}:" />
<h:inputText value="#{productView.productprice}" />
<h:commandButton
action="#{productView.createProduct()}"
value="#{i18n['product.create']}" />
</h:panelGrid>
<h:form id="orgform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['eventmap.name']}:" /><h:inputText value="#{eventView.eventmap.name}" />
<h:commandButton id="commitbtn" action="#{eventView.saveMap()}" value="#{i18n['eventmap.save']}" />
</h:panelGrid>
</h:form>
</h:dataTable>
</h:form>
</ui:define>
</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: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.eventorg.list" />
<ui:define name="content">
<h:form>
<h:dataTable border="1" id="maps" value="#{eventView.eventmaps}" var="maps">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['eventmap.name']}" />
</f:facet>
<h:outputText value="#{maps.name}" />
</h:column>
<h:column >
<h:commandButton action="#{eventView.editMap()}" value="#{i18n['eventmap.edit']}" />
</h:column>
</h:dataTable>
</h:form>
</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: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.eventorg.edit" />
<ui:define name="content">
#{sessionHandler.flushCache()}
</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"
<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>
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/insomnia1/template.xhtml">
<ui:param name="thispage" value="page.index" />
<ui:param name="thispage" value="page.index" />
<ui:define name="content">
<h:form>
<ul>
<li><h:commandLink action="generateTestData">Generate test data</h:commandLink></li>
<li><h:commandLink action="user/list">List users</h:commandLink></li>
<li><h:commandLink action="user/create">Create user</h:commandLink></li>
<li><h:commandLink action="tests/placemap">Placemap test</h:commandLink></li>
<li><h:commandLink action="PlaceMap?mapid=1">Show map 1</h:commandLink></li>
</ul>
</h:form>
<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>
......
......@@ -9,6 +9,7 @@
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="/role/create" value="#{i18n['sidebar.role.create']}"/></li>
......
......@@ -8,6 +8,14 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:component />
</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.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
......@@ -5,17 +5,23 @@
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="/product/create" value="#{i18n['sidebar.product.create']}"/></li>
<li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}"/></li>
<tools:canWrite target="PRODUCT" >
<li><h:link outcome="/product/create" value="#{i18n['sidebar.product.create']}"/></li>
<li><h:link outcome="/product/list" value="#{i18n['sidebar.product.list']}"/></li>
</tools:canWrite>
<li><h:link outcome="/user/createBill" value="#{i18n['sidebar.product.createBill']}"/></li>
<li><h:link outcome="/map/placemap" value="#{i18n['sidebar.map.placemap']}"/></li>
</ul>
<!-- <li><h:link outcome="/map/placemap" value="#{i18n['sidebar.map.placemap']}"/></li>
-->
</ul>
</ui:define>
</ui:composition>
......
......@@ -6,15 +6,20 @@
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/editself.xhtml" value="#{i18n['sidebar.user.editself']}"/></li>
<li><h:link outcome="/user/list.xhtml" value="#{i18n['sidebar.user.list']}"/></li>
<li><h:link outcome="/user/create.xhtml" value="#{i18n['sidebar.user.create']}"/></li>
<tools:canRead target="USER_MANAGEMENT">
<li><h:link outcome="/user/list" value="#{i18n['sidebar.user.list']}"/></li>
<li><h:link outcome="/user/create" value="#{i18n['sidebar.user.create']}"/></li>
</tools:canRead>
<li><h:link outcome="/bill/list" value="#{i18n['sidebar.bill.list']}"/></li>
<li><h:link outcome="/user/sendPicture" value="#{i18n['user.sendPicture']}"/></li>
<li><h:link outcome="/user/changePassword" value="#{i18n['user.changePassword']}"/></li>
</ul>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns: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: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>
<div id="sidebar"><ui:insert name="sidebarcontent" /></div>
<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
......@@ -5,7 +5,9 @@
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:ui="http://java.sun.com/jsf/facelets">
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:view locale="#{sessionHandler.locale}">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
......@@ -21,23 +23,27 @@
<div>
<div class="link#{i18n[util.concat(thispage,'.pagegroup')] == 'frontpage'?'a':''}"> <h:link outcome="/index" value="#{i18n['topmenu.frontpage']}" /></div>
<tools:isLoggedIn>
<f:facet name="errormessage">
<div class="link#{i18n[util.concat(thispage,'.pagegroup')] == 'login'?'a': ''}"> <h:link outcome="/auth/login" value="#{i18n['login.login']}" /></div>
</f:facet>
<div class="link#{i18n[util.concat(thispage,'.pagegroup')] == 'user'?'a':''}"> <h:link outcome="/user/editself" value="#{i18n['topmenu.usersPreferences']}" /></div>
<div class="link#{i18n[util.concat(thispage,'.pagegroup')] == 'shop'?'a': ''}"> <h:link outcome="/product/createBill" value="#{i18n['topmenu.shoppings']}" /></div>
</tools:isLoggedIn>
<div class="link#{i18n[util.concat(thispage,'.pagegroup')] == 'placemap'?'a':''}"> <h:link outcome="/bill/placemap" value="#{i18n['topmenu.placemap']}" /></div>
<!--
<tools:canRead target="USER_MANAGEMENT">
<div class="link#{i18n[util.concat(thispage,'.pagegroup')] == 'admin'?'a':''}"> <h:link outcome="/product/list" value="#{i18n['topmenu.adminfront']}" /></div>
</tools:canRead>
-->
</div>
</div>
</div>
<div id="content">
<div id="cwrap">
<ui:include src="/layout/insomnia1/sidebar-#{i18n[util.concat(thispage,'.pagegroup')]}.xhtml" />
<ui:include src="/layout/insomnia1/sidebar-#{i18n[util.concat(thispage,'.pagegroup')]}.xhtml" />
<c:if test="#{sessionHandler.hasPermission('USER_MANAGEMENT', 'READ')}">
<ui:include src="/layout/insomnia1/sidebar-admin.xhtml" />
</c:if>
<h:messages globalOnly="true" />
<ui:insert name="content" />
</div>
......
<!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:h="http://java.sun.com/jsf/html"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
......
<!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"
<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: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:products="http://java.sun.com/jsf/composite/tools/products">
<h:head>
<title></title>
</h:head>
......@@ -17,8 +16,9 @@
<ui:param name="thispage" value="page.product.edit" />
<ui:define name="content">
<tools:fatalPermission target="PRODUCT" permission="WRITE" />
<products:edit commitaction="#{productView.saveProduct()}" commitvalue="#{i18n['products.save']}" />
<products:edit commitaction="#{productView.saveProduct()}"
commitvalue="#{i18n['products.save']}" />
</ui:define>
</ui:composition>
</h:body>
......
<!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/tools">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.product.edit" />
<ui:define name="content">
<tools:fatalPermission target="PRODUCT" permission="WRITE" />
<h:form id="discountform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['discount.shortdesc']}:" />
<h:inputText value="#{productView.discount.shortdesc}" />
<h:outputLabel value="#{i18n['discount.percentage']}:" />
<h:inputText value="#{productView.discount.percentage}" />
<h:outputLabel value="#{i18n['discount.code']}:" />
<h:inputText value="#{productView.discount.code}" />
<h:outputLabel value="#{i18n['discount.amountMin']}:" />
<h:inputText value="#{productView.discount.amountMin}" />
<h:outputLabel value="#{i18n['discount.amountMax']}:" />
<h:inputText value="#{productView.discount.amountMax}" />
<h:outputLabel value="#{i18n['discount.maxNum']}:" />
<h:inputText value="#{productView.discount.maxNum}" />
<h:outputLabel value="#{i18n['discount.active']}" />
<h:selectBooleanCheckbox value="#{productView.discount.active}" />
<h:outputLabel value="#{i18n['discount.role']}:" />
<h:commandButton id="commitbtn" action="#{productView.saveDiscount()}"
value="#{i18n['discount.save']}" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -90,10 +90,18 @@ body {
float: left;
}
#cwrap {
padding: 3px 3px 3px 3px;
padding: 10px;
min-height: 100px;
}
#footer {
background-image:url('img/bottom.gif');
height: 21px;
text-align:center;
}
\ No newline at end of file
}
.imgcenter
{
display: block;
margin-left: auto;
margin-right: auto;
}
\ No newline at end of file
......@@ -18,7 +18,7 @@
<composite:implementation>
<h:form>
<h:dataTable border="1" id="billList" value="#{cc.attrs.billview.bills}" var="bill">
<h:dataTable border="0" id="billList" value="#{cc.attrs.billview.bills}" var="bill">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['bill.sentDate']}" />
......
<?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="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<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="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true"
method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<h:form id="productform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['product.name']}:" />
<h:inputText value="#{productView.product.name}" />
<h:outputLabel value="#{i18n['product.price']}:" />
<h:inputText value="#{productView.product.price}" />
<h:outputLabel value="#{i18n['product.unitName']}:" />
<h:inputText value="#{productView.product.unitName}" />
<h:outputLabel value="#{i18n['product.vat']}:" />
<h:inputText value="#{productView.product.vat}" />
<h:outputLabel value="#{i18n['product.sort']}:" />
<h:inputText value="#{productView.product.sort}" />
<h:outputLabel value="#{i18n['product.barcode']}:" />
<h:inputText value="#{productView.product.barcode}" />
<h:outputLabel value="#{i18n['product.prepaid']}" />
<h:selectBooleanCheckbox value="#{productView.product.prepaid}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}"
value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
<h:form id="productform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['product.name']}:" /><h:inputText value="#{productView.product.name}" />
<h:outputLabel value="#{i18n['product.price']}:" /><h:inputText value="#{productView.product.price}" />
<h:outputLabel value="#{i18n['product.unitName']}:" /><h:inputText value="#{productView.product.unitName}" />
<h:outputLabel value="#{i18n['product.vat']}:" /><h:inputText value="#{productView.product.vat}" />
<h:outputLabel value="#{i18n['product.sort']}:" /><h:inputText value="#{productView.product.sort}" />
<h:outputLabel value="#{i18n['product.barcode']}:" /><h:inputText value="#{productView.product.barcode}" />
<h:outputLabel value="#{i18n['product.prepaid']}" /><h:selectBooleanCheckbox value="#{productView.product.prepaid}" />
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
</composite:implementation>
<tools:canWrite target="PRODUCT">
<h2>#{productview.discounts}</h2>
<h:form id="creatediscount">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['discount.shortdesc']}" />
<h:inputText value="#{productView.discountdesc}" />
<h:commandButton value="#{i18n['discount.create']}" action="#{productView.createDiscount()}" />
</h:panelGrid>
</h:form>
<h:form id="discounts">
<h:dataTable border="1" id="discount" value="#{productView.productDiscounts}"
var="discount">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.percentage']}" />
</f:facet>
<h:outputText value="#{discount.percentage}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.code']}" />
</f:facet>
<h:outputText value="#{discount.code}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.details']}" />
</f:facet>
<h:outputText value="#{discount.details}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.shortdesc']}" />
</f:facet>
<h:outputText value="#{discount.shortdesc}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.amountMin']}" />
</f:facet>
<h:outputText value="#{discount.amountMin}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.amountMax']}" />
</f:facet>
<h:outputText value="#{discount.amountMax}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.maxNum']}" />
</f:facet>
<h:outputText value="#{discount.maxNum}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['discount.perUser']}" />
</f:facet>
<h:outputText value="#{discount.perUser}" />
</h:column>
<h:column>
<h:commandButton action="#{productView.editDiscount()}"
value="#{i18n['discount.edit']}" />
</h:column>
</h:dataTable>
</h:form>
</tools:canWrite>
</composite:implementation>
</html>
<?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:interface>
<composite:implementation>
<h:form>
<h:dataTable border="1" id="product" value="#{productView.products}" var="product">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.name']}" />
</f:facet>
<h:outputText value="#{product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:outputText value="#{product.price}" />
</h:column>
<h:column >
<h:commandButton action="#{productView.edit()}" value="#{i18n['product.edit']}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
<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:interface>
<composite:implementation>
<h:form>
<h:dataTable border="1" id="product" value="#{productView.products}"
var="product">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.name']}" />
</f:facet>
<h:outputText value="#{product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:outputText value="#{product.price}" />
</h:column>
<h:column>
<h:commandButton action="#{productView.edit()}"
value="#{i18n['product.edit']}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
......@@ -22,7 +22,7 @@
<h:outputScript target="head" library="script" name="shopscript.js" />
<h:form id="shopform">
<h:dataTable border="1" id="billcart" value="#{cc.attrs.items}" var="cart">
<h:dataTable border="0" id="billcart" value="#{cc.attrs.items}" var="cart">
<h:column>
<f:facet name="header">
<h:outputText id="name" value="${i18n['product.name']}" />
......@@ -33,7 +33,9 @@
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:outputText id="price" value="#{cart.product.price}" />
<h:outputText id="price" value="#{cart.product.price}" >
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
......
......@@ -21,7 +21,7 @@
<h:form id="userform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['user.login']}:" for="login"/><h:inputText id="login" value="#{userView.user.login}" />
<h:outputLabel value="#{i18n['user.login']}:" for="login"/><h:outputText id="login" value="#{userView.user.login}" />
<h:outputLabel value="#{i18n['user.nick']}:" for="nick" /><h:inputText id="nick" value="#{userView.user.nick}" />
<h:outputLabel value="#{i18n['user.email']}:" for="email"/><h:inputText id="email" value="#{userView.user.email}" />
<h:outputLabel value="#{i18n['user.firstNames']}:" for="firstnames" /><h:inputText id="firstnames" value="#{userView.user.firstnames}" />
......@@ -32,18 +32,19 @@
<h:outputLabel rendered="#{sessionHandler.superadmin}" value="#{i18n['user.superadmin']}:" for="superadmin" />
<h:selectBooleanCheckbox rendered="#{sessionHandler.superadmin}" id="superadmin" value="#{userView.user.superadmin}" />
<h:outputLabel value="#{i18n['user.superadmin']}:" for="currentImage" />
<h:selectOneMenu id="currentImage" value="#{userView.user.currentImage}" converter="#{userimageConverter}" >
<!--
<h:outputLabel value="#{i18n['user.defaultImage']}:" for="currentImage" />
<h:selectOneMenu rendered="#{sessionHandler.hasPermission('USER', 'READ')}" id="currentImage" value="#{userView.user.currentImage}" converter="#{userimageConverter}" >
<f:selectItems var="image" itemLabel="#{image.description}" value="#{userView.user.userImageList}" />
</h:selectOneMenu>
-->
<h:outputLabel value="#{i18n['user.sex']}:" for="sex"/>
<h:selectOneRadio id="sex" value="#{userView.user.gender}">
<f:selectItem id="undefined" itemLabel="#{i18n['user.sex.UNDEFINED']}" itemValue="UNDEFINED" />
<f:selectItem id="male" itemLabel="#{i18n['user.sex.MALE']}" itemValue="MALE" />
<f:selectItem id="female" itemLabel="#{i18n['user.sex.FEMALE']}" itemValue="FEMALE" />
</h:selectOneRadio>
<h:outputLabel value="#{i18n['user.roles']}:" for="roles"/>
<h:outputLabel rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" value="#{i18n['user.roles']}:" for="roles"/>
<h:selectManyCheckbox converter="#{sessionHandler.roleConverter}" rendered="#{sessionHandler.hasPermission('ROLE_MANAGEMENT', 'READ')}" disabled="#{!sessionHandler.hasPermission('ROLE_MANAGEMENT', 'WRITE')}" layout="pageDirection" id="roles" value="#{userView.user.roles}">
<f:selectItems var="roleitem" itemLabel="#{roleitem.name}" value="#{userView.userRoles}" />
......@@ -52,33 +53,7 @@
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGrid>
</h:form>
<h2>#{i18n['user.uploadimage']}</h2>
<form onsubmit="window.open('', 'imagesubmitpopup', 'height=200,width=400'); this.target='imagesubmitpopup'; return true; " action="#{request.contextPath}/UploadServlet" enctype="multipart/form-data" method="post">
<input type="hidden" name="userid" value="#{userView.user.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['imagefile.file']}" /><input type="file" name="imagefile" />
<h:outputLabel value="#{i18n['imagefile.description']}"/><input type="text" name="description" />
<h:panelGroup><input type="submit" name="submit" value="#{i18n['user.imagesubmit']}" /></h:panelGroup>
</h:panelGrid>
</form>
<h2>#{i18n['user.imagelist']}</h2>
<h:form id="imagelist">
<h:dataTable value="#{userView.user.userImageList}" id="imagelist" var="image">
<h:column>
<h:outputText value="#{image.name}" />
</h:column>
<h:column>
<h:outputText value="#{image.description}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<!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/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.user.create" />
<ui:define name="content">
#{userView.editSelf()}
<h:form id="userform">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['user.password']}:" /><h:inputSecret id="password" value="#{userView.password}" />
<h:outputLabel value="#{i18n['user.passwordcheck']}:" /><h:inputSecret id="passwordcheck" value="#{userView.passwordcheck}" />
<h:commandButton id="createuserbtn" action="#{userView.changePassword()}" value="#{i18n['user.changePassword']}" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -14,6 +14,7 @@
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['user.username']}:" /><h:inputText id="username" value="#{userView.login}" />
<h:outputLabel value="#{i18n['user.password']}:" /><h:inputSecret id="password" value="#{userView.password}" />
<h:outputLabel value="#{i18n['user.passwordcheck']}:" /><h:inputSecret id="passwordcheck" value="#{userView.passwordcheck}" />
<h:commandButton id="createuserbtn" action="#{userView.createUser()}" value="#{i18n['user.create']}" />
</h:panelGrid>
</h:form>
......
<!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:login="http://java.sun.com/jsf/composite/tools/login"
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" />
<ui:define name="content">
<p>#{i18n['user.createdmessage']}</p>
</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: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" />
<ui:define name="content">
<form
onsubmit="window.open('', 'imagesubmitpopup', 'height=200,width=400'); this.target='imagesubmitpopup'; return true; "
action="#{request.contextPath}/UploadServlet" enctype="multipart/form-data"
method="post">
<p>Voit lisätä kuvan kävijälippuasi varten. Näin nopeutat asiointiasi tapahtumaan tullessasi.</p>
<input type="hidden" name="userid" value="#{userView.user.id}" />
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['imagefile.file']}" />
<input type="file" name="imagefile" />
<!-- <h:outputLabel value="#{i18n['imagefile.description']}"/><input type="text" name="description" /> -->
<h:panelGroup>
<input type="submit" name="submit" value="#{i18n['user.imagesubmit']}" />
</h:panelGroup>
</h:panelGrid>
</form>
<h2>#{i18n['user.thisIsCurrentImage']}</h2>
<img width="100" src="#{request.contextPath}/Userimage" alt="" />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -47,7 +47,7 @@ public class SessionHandler {
public String getLocale() {
// TODO: Locale selection code missing
// return "en_ST_v7";
// return "en_ST_v7";
return "fi_IN_XII";
}
......@@ -57,34 +57,33 @@ public class SessionHandler {
}
public boolean hasPermission(String target, String permission) {
RolePermission perm = RolePermission.valueOf(permission.toUpperCase());
// RolePermission perm = null;
// if (permission.equalsIgnoreCase("read")) {
// perm = RolePermission.READ;
// } else if (permission.equals("write")) {
// perm = RolePermission.WRITE;
// } else if (permission.equals("execute")) {
// perm = RolePermission.EXECUTE;
// }else {
// throw new RuntimeException("permission " + permission + " does not match any")
// }
if(perm == null)
{
RolePermission perm = RolePermission.valueOf(permission.toUpperCase());
// RolePermission perm = null;
// if (permission.equalsIgnoreCase("read")) {
// perm = RolePermission.READ;
// } else if (permission.equals("write")) {
// perm = RolePermission.WRITE;
// } else if (permission.equals("execute")) {
// perm = RolePermission.EXECUTE;
// }else {
// throw new RuntimeException("permission " + permission +
// " does not match any")
// }
if (perm == null) {
logger.warn("Permission {} does not have matching value in RolePermission enum!");
throw new RuntimeException("Matching role permission could not be found!");
}
return hasPermission(target, perm);
}
public void fatalPermission(String target, String permission)
{
public void fatalPermission(String target, String permission) {
fatalPermission(Permission.getPermission(target), RolePermission.valueOf(permission));
}
public void fatalPermission(Permission target, RolePermission permission )
{
userbean.fatalPermission(target, permission,"Fail from MBean SessionHandler");
public void fatalPermission(Permission target, RolePermission permission) {
userbean.fatalPermission(target, permission, "Fail from MBean SessionHandler");
}
private HttpSession getHttpSession() {
......@@ -122,29 +121,34 @@ public class SessionHandler {
private boolean impersonating = false;
// public void impersonateUser(User user) {
// if (user == null) {
// this.thisuser = getUser();
// impersonating = false;
// } else if (canExecute("user")) {
// secubean.logMessage(userbean.getCurrentUser(), "Successfully impersonating user id: " + user.getId() + " and login: " + user.getLogin());
// this.thisuser = user;
// impersonating = true;
// } else {
// secubean.logMessage(userbean.getCurrentUser(), "User tried to impersonate as id: " + user.getId() + " login: " + user.getLogin() + " but did not have enough rights");
// }
// }
//
// public User getUser() {
//
// boolean iscurruser = userbean.isCurrentUser(thisuser);
// logger.debug("Current user {}", (thisuser == null) ? "null" : thisuser.getNick());
// if (thisuser == null || (!impersonating && !iscurruser)) {
// thisuser = userbean.getCurrentUser();
// }
//
// return thisuser;
// }
// public void impersonateUser(User user) {
// if (user == null) {
// this.thisuser = getUser();
// impersonating = false;
// } else if (canExecute("user")) {
// secubean.logMessage(userbean.getCurrentUser(),
// "Successfully impersonating user id: " + user.getId() + " and login: " +
// user.getLogin());
// this.thisuser = user;
// impersonating = true;
// } else {
// secubean.logMessage(userbean.getCurrentUser(),
// "User tried to impersonate as id: " + user.getId() + " login: " +
// user.getLogin() + " but did not have enough rights");
// }
// }
//
// public User getUser() {
//
// boolean iscurruser = userbean.isCurrentUser(thisuser);
// logger.debug("Current user {}", (thisuser == null) ? "null" :
// thisuser.getNick());
// if (thisuser == null || (!impersonating && !iscurruser)) {
// thisuser = userbean.getCurrentUser();
// }
//
// return thisuser;
// }
public String logout() {
......@@ -162,22 +166,26 @@ public class SessionHandler {
boolean ret = userbean.isLoggedIn();
return ret;
}
public boolean isSuperadmin()
{
public boolean isSuperadmin() {
return userbean.getCurrentUser().isSuperadmin();
}
public String getLoginname()
{
public String getLoginname() {
return userbean.getCurrentUser().getLogin();
}
public User getCurrentUser()
{
public User getCurrentUser() {
return userbean.getCurrentUser();
}
public RoleConverter getRoleConverter()
{
public RoleConverter getRoleConverter() {
return new RoleConverter(rolebean, eventbean.getCurrentEvent());
}
public String flushCache() {
return eventbean.flushCache();
}
}
......@@ -104,7 +104,7 @@ public class UploadServlet extends HttpServlet {
logger.warn("Error uploading image", e);
}
PrintWriter writer = response.getWriter();
writer.append("File upload successfull");
writer.append("Kuva tallennettu onnistuneesti.");
}
......
package fi.insomnia.bortal.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.List;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.model.UserImage;
/**
* Servlet implementation class UploadServlet
*/
public class UserImageServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public UserImageServlet() {
super();
// TODO Auto-generated constructor stub
}
private static final Logger logger = LoggerFactory.getLogger(UserImageServlet.class);
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
@EJB
private UserBeanLocal userbean;
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String imageidobj = request.getParameter("imageid");
int imageid = 0;
if (imageidobj != null) {
imageid = Integer.parseInt(imageidobj);
}
UserImage image = userbean.findUserImage(imageid);
if (image == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
response.setContentType(image.getMimeType());
response.getOutputStream().write(image.getImageData());
}
}
......@@ -148,10 +148,7 @@ public class EventOrganiserView {
}
event.setDefaultRole(nrole);
}
public RoleConverter getRoleconverter()
{
return new RoleConverter(rolebean, event);
}
public void setEventname(String eventname) {
this.eventname = eventname;
......@@ -160,4 +157,9 @@ public class EventOrganiserView {
public String getEventname() {
return eventname;
}
public RoleConverter getRoleconverter()
{
return new RoleConverter(rolebean, event);
}
}
package fi.insomnia.bortal.view;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.ListDataModel;
import javax.faces.model.ListDataModel;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.EventMapBeanLocal;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
@ManagedBean(name = "eventView")
@SessionScoped
public class EventView {
@EJB
private EventBeanLocal eventbean;
@EJB
private EventMapBeanLocal eventmapbean;
private ListDataModel<EventMap> eventmaps;
private ListDataModel<Place> mapPlaces;
private EventMap eventmap;
private String mapname;
private Place place;
public ListDataModel<EventMap> getEventmaps() {
eventmaps = new ListDataModel<EventMap>(eventbean.getCurrentEvent().getEventMaps());
return eventmaps;
}
public String editMap() {
setEventmap(eventmaps.getRowData());
return "editMap";
}
public EventMap getEventMap() {
return getEventmap();
}
public String saveMap() {
setEventmap(eventmapbean.saveMap(getEventmap()));
return "editMap";
}
public String createMap() {
setEventmap(eventmapbean.create(eventbean.getCurrentEvent(), getMapname()));
return "editMap";
}
public ListDataModel<Place> getMapPlaces() {
mapPlaces = new ListDataModel<Place>(eventmap.getPlaces());
return mapPlaces;
}
public String editPlace()
{
place = mapPlaces.getRowData();
return "editPlace";
}
public void setMapname(String mapname) {
this.mapname = mapname;
}
public String getMapname() {
return mapname;
}
public void setEventmap(EventMap eventmap) {
this.eventmap = eventmap;
}
public EventMap getEventmap() {
return eventmap;
}
}
\ No newline at end of file
......@@ -8,14 +8,17 @@ import java.math.BigDecimal;
import java.util.Iterator;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.I18n;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
......@@ -23,6 +26,7 @@ import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.view.helpers.ProductShopItem;
......@@ -55,8 +59,25 @@ public class ProductShopView {
userBean.fatalPermission(Permission.PRODUCT, RolePermission.EXECUTE);
logger.debug("Committing billCart");
Iterator<ProductShopItem> cartIter = billCart.iterator();
Iterator<ProductShopItem> nullcheckIter = billCart.iterator();
boolean hasItems = false;
while (nullcheckIter.hasNext()) {
if (nullcheckIter.next().getCount().compareTo(BigDecimal.ZERO) > 0) {
logger.debug("Found items from cart");
hasItems = true;
break;
}
}
if(!hasItems)
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("productshop.noItemsInCart")));
return "createBill";
}
Iterator<ProductShopItem> cartIter = billCart.iterator();
Bill bill = null;
bill = billBean.createEmptyBill(getShoppingUser());
......@@ -65,6 +86,7 @@ public class ProductShopView {
ProductShopItem shopitem = cartIter.next();
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
billBean.addProductToBill(bill, shopitem.getProduct(), shopitem.getCount());
}
}
return "success";
......
......@@ -10,6 +10,7 @@ import java.util.Iterator;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.convert.Converter;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
......@@ -17,12 +18,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.DiscountBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.BillLine;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.view.helpers.ProductShopItem;
......@@ -43,7 +46,7 @@ public class ProductView {
@EJB
private UserBeanLocal userBean;
private String productname = "";
private BigDecimal productprice = BigDecimal.ZERO;
private EventMap activeMap = null;
......@@ -51,15 +54,45 @@ public class ProductView {
private Product product;
private ListDataModel<Product> products;
private DataModel<Discount> discounts;
private Discount discount;
private String discountdesc;
@EJB
private DiscountBeanLocal discountbean;
public DataModel<Discount> getProductDiscounts() {
discounts = new ListDataModel<Discount>(product.getDiscounts());
return discounts;
}
public String editDiscount() {
discount = discounts.getRowData();
return "editDiscount";
}
public String createDiscount() {
userBean.fatalPermission(Permission.PRODUCT, RolePermission.WRITE, "Tried to create discount without sufficient rights");
logger.debug("Creating product discount {} for product {}", discountdesc, product);
discount = discountbean.create(product, getDiscountdesc());
return "editDiscount";
}
public String saveDiscount() {
userBean.fatalPermission(Permission.PRODUCT, RolePermission.WRITE, "Tried to edit discount without sufficient rights");
discount = discountbean.save(discount);
return "editDiscount";
}
public DataModel<Product> getProducts() {
userBean.fatalPermission(Permission.PRODUCT, RolePermission.READ,"User has no right to view products");
userBean.fatalPermission(Permission.PRODUCT, RolePermission.READ, "User has no right to view products");
products = new ListDataModel<Product>(productBean.getProducts());
return products;
}
public void createProduct() {
userBean.fatalPermission(Permission.PRODUCT, RolePermission.WRITE);
......@@ -67,7 +100,7 @@ public class ProductView {
productprice = BigDecimal.ZERO;
productname = "";
// return "edit";
// return "edit";
}
public String edit() {
......@@ -121,6 +154,18 @@ public class ProductView {
return product;
}
public void setDiscountdesc(String discountdesc) {
this.discountdesc = discountdesc;
}
public String getDiscountdesc() {
return discountdesc;
}
public Discount getDiscount() {
return discount;
}
/*
* public String placeMapActionListener(ActionEvent e) {
*
......
......@@ -28,7 +28,6 @@ import fi.insomnia.bortal.model.User;
@SessionScoped
public class UserView {
@EJB
private UserBeanLocal userBean;
@EJB
......@@ -41,6 +40,7 @@ public class UserView {
private ListDataModel<User> items;
private String login;
private String password;
private String passwordcheck;
public String edit() {
userBean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.READ);
......@@ -49,7 +49,6 @@ public class UserView {
return "userEdit";
}
public List<Role> getUserRoles() {
userBean.fatalPermission(Permission.LOGIN, RolePermission.READ, "does not have permission to view roles at userView!");
......@@ -57,7 +56,6 @@ public class UserView {
return roleBean.listRoles();
}
public void editSelf() {
userBean.fatalNotLoggedIn();
setUser(userBean.getCurrentUser());
......@@ -66,31 +64,41 @@ public class UserView {
public String createUser() {
userBean.fatalPermission(Permission.LOGIN, RolePermission.WRITE, "does not have permission to create user!");
String ret = "create";
if (null != userBean.getUser(login)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("userview.userExists")));
return "create";
}
logger.debug("Creating new user: {}", login);
// Luodaan uusi käyttäjä UserBeanin funktiolla createNewUser jolle
// annetaan parametrina pakolliset tiedot ( login ja salasana )
// Paluuarvona saadaan uusi uljas käyttäjä-olio.
setUser(userBean.createNewUser(login, password));
login = "";
password = "";
if (getUser() == null) {
logger.warn("Could not create user. function returned null!");
return "create";
} else if (!password.equals(passwordcheck)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("userview.passwordsDontMatch")));
password = "";
passwordcheck = "";
} else {
logger.debug("Creating new user: {}", login);
// Luodaan uusi käyttäjä UserBeanin funktiolla createNewUser jolle
// annetaan parametrina pakolliset tiedot ( login ja salasana )
// Paluuarvona saadaan uusi uljas käyttäjä-olio.
setUser(userBean.createNewUser(login, password));
login = "";
password = "";
if (getUser() == null) {
logger.warn("Could not create user. function returned null!");
} else {
securitybean.logMessage(userBean.getCurrentUser(), "Created new user ", getUser().getLogin(), " with id: ", getUser().getId().toString());
if (!userBean.isLoggedIn()) {
ret = "created";
} else {
ret = "edit";
}
}
}
securitybean.logMessage(userBean.getCurrentUser(), "Created new user ", getUser().getLogin(), " with id: ", getUser().getId().toString());
return "edit";
return ret;
}
public String saveUser() {
logger.debug("Saving user at UserView mbean nick: {}", user.getNick());
User thisusr = getUser();
if (!userBean.isCurrentUser(thisusr)) {
logger.debug("user {} is modifying user {}",userBean.getCurrentUser(), thisusr);
logger.debug("user {} is modifying user {}", userBean.getCurrentUser(), thisusr);
userBean.fatalPermission(Permission.USER_MANAGEMENT, RolePermission.WRITE);
}
setUser(userBean.mergeChanges(getUser()));
......@@ -130,11 +138,32 @@ public class UserView {
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
public void setPasswordcheck(String passwordcheck) {
this.passwordcheck = passwordcheck;
}
public String getPasswordcheck() {
return passwordcheck;
}
public String changePassword() {
if (!password.equals(passwordcheck)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("userview.passwordsDontMatch")));
return "changePassword";
}
user.resetPassword(password);
userBean.mergeChanges(user);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(I18n.get("userview.passwordsChanged")));
password = "";
passwordcheck = "";
return "edit";
}
}
......@@ -10,28 +10,34 @@ import javax.faces.convert.Converter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Role;
public class RoleConverter implements Converter {
private RoleBeanLocal rolebean;
private LanEvent event;
private LanEvent myevent;
private static final Logger logger = LoggerFactory.getLogger(RoleConverter.class);
public RoleConverter(RoleBeanLocal rbean, LanEvent event) {
this.rolebean = rbean;
this.event = event;
this.myevent = event;
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
logger.debug("converting string {} to Object", value);
Role ret = rolebean.find(Integer.parseInt(value), event);
Role ret = rolebean.find(Integer.parseInt(value), getEvent());
return ret;
}
private LanEvent getEvent() {
return myevent;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
String ret = "";
......
global.copyright=Insomnia Ry, Stream Ry
global.copyright=Verkkopeliyhdistys Insomnia ry
global.productname=Omnia
navi.auth.login=frontpage
navi.auth.loginerror=frontpage
navi.auth.logout=frontpage
......@@ -13,6 +14,7 @@ page.auth.login.header=Login error
page.auth.login.title=Login error
page.index.pagegroup=frontpage
page.index.header=Etusivu
page.auth.login.pagegroup=login
page.auth.loginerror.pagegroup=frontpage
......@@ -40,12 +42,21 @@ page.role.list.pagegroup=admin
page.map.placemap.pagegroup=shop
page.user.create.pagegroup=user
page.user.create.header=Uusi kyttj
page.user.edit.pagegroup=user
page.user.edit.header=Kyttjn muokkaus
page.user.list.pagegroup=user
page.user.list.header=Kyttjt
page.user.editself.pagegroup=user
page.user.editself.header=Omat tiedot
page.auth.login.loginerror.pagegroup=frontpage
page.auth.login.loginerror.header=Kirjautumisvirhe
page.auth.login.logout.pagegroup=frontpage
page.auth.login.logout.header=Uloskirjautuminen
page.viewexpired.pagegroup=frontpage
page.permissionDenied.pagegroup=frontpage
\ No newline at end of file
page.permissionDenied.pagegroup=frontpage
page.permissionDenied.header=Psy kielletty
page.bill.placemap.pagegroup=placemap
page.bill.placemap.header=Paikkakartta
\ No newline at end of file
......@@ -34,7 +34,7 @@ role.parents=Periytyy
topmenu.adminfront=Admintavaraa
topmenu.frontpage=Etusivu
topmenu.shoppings=Kauppa
topmenu.usersPreferences=Omat asetukset
topmenu.usersPreferences=Omat tiedot
user.bank=Pankki
user.bankaccount=Pankkitili
user.edit=Muokkaa
......@@ -45,7 +45,7 @@ user.phone=Puhelin
user.realname=Nimi
user.save=Tallenna
user.login=Kyttjtunnus
user.firstNames=Etunimet
user.firstNames=Etunimi
user.lastName=Sukunimi
user.address=Osoite
user.zipCode=Postinumero
......@@ -53,6 +53,14 @@ user.town=Kaupunki
user.sex=Sukupuoli
user.superadmin=Superadmin
user.rolesave=Tallenna roolit
user.defaultImage=Oletukuva
user.thisIsCurrentImage=Nykyinen kuva
user.passwordcheck=Salasana ( uudelleen )
user.createdmessage=Kyttjtunnus on luotu onnistuneesti. Voit nyt kirjautua sisn.
user.create=Luo kyttj
user.sendPicture=Kuvan lhetys
user.changePassword=Vaihda salasana
userview.passwordsDontMatch=Salasanat eivt ole samat! Ole hyv ja syt salasanat uudelleen.
bill.billNumber=Laskun numero
bill.sentDate=Pivys
bill.totalPrice=Laskun summa
......@@ -80,10 +88,26 @@ eventorg.events=Organisaation tapahtumat
eventorgView.eventname=Tapahtuman nimi
eventorg.createEvent=Luo tapahtuma
place.details=Tiedot
place.description=Kuvaus
place.name=Nimi
place.mapX=X
place.mapY=Y
place.edit=Muokkaa
discount.percentage=Alennusprosentti
discount.code=Alennuskoodi
discount.details=Tiedot
discount.shortdesc=Kuvaus
discount.amountMin=Vhimmismr
discount.amountMax=Enimmismr
discount.maxNum=Alennusten enimmislkm
discount.perUser=Alennuksia per kyttj
discount.edit=Muokkaa
discount.create=Luo uusi
sidebar.user.editself=Omat tiedot
sidebar.user.list=Kyttjt
sidebar.user.create=Uusi kyttj
sidebar.user.create=Rekisteridy uudeksi kyttjksi
sidebar.bill.list=Omat laskut
sidebar.product.create=Uusi tuote
......@@ -94,3 +118,7 @@ sidebar.map.placemap=Paikkakartta
sidebar.role.create=Uusi rooli
sidebar.role.list=Roolit
sidebar.eventorg.list=Omat organisaatiot
topmenu.placemap=Paikkakartta
userview.passwordsChanged=Salasana vaihdettu
productshop.noItemsInCart=Ostoskorissa ei ole tuotteita
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!