Commit 4b59652c by Tuukka Kivilahti

Merge branch 'master' into barcodefuckup

Conflicts:
	code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
2 parents 837ac95c df16c9aa
Showing with 657 additions and 136 deletions
package fi.codecrew.moya.beans;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.annotation.security.DeclareRoles;
......@@ -9,6 +11,7 @@ import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.codecrew.moya.facade.ActionLogFacade;
import fi.codecrew.moya.facade.ActionLogMessageTagFacade;
import fi.codecrew.moya.beans.ActionLogBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal;
......@@ -16,6 +19,7 @@ import fi.codecrew.moya.enums.ActionLogMessageState;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.Role;
/**
......@@ -35,15 +39,23 @@ public class ActionLogBean implements ActionLogBeanLocal {
@EJB
private PermissionBeanLocal permissionBean;
@EJB
private ActionLogMessageTagFacade actionLogMessageTagFacade;
@EJB
private EventBean eventBean;
public ActionLogBean() {
// TODO Auto-generated constructor stub
}
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public void createActionLogEvent(String message, Role crew, boolean isTask) {
public void createActionLogEvent(String message, boolean isTask) {
ArrayList<ActionLogMessageTag> almts = resolveTags(message);
ActionLogMessage alm = new ActionLogMessage();
alm.setCrew(crew);
if (isTask) {
alm.setState(ActionLogMessageState.NEW);
} else {
......@@ -53,14 +65,25 @@ public class ActionLogBean implements ActionLogBeanLocal {
alm.setMessage(message);
alm.setUser(permissionBean.getCurrentUser());
alm.setLanEvent(permissionBean.getCurrentUser().getEvent());
alm.setTags(almts);
actionLogFacade.saveToActionLog(alm);
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
@Deprecated
public List<ActionLogMessage> getAllActionLogEvents() {
return actionLogFacade.getAllSortedByTimestamp(permissionBean.getCurrentUser().getEvent());
}
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessage> getAllActionLogEventsByFilter(List<ActionLogMessageTag> filterTags) {
if(filterTags.size() == 0)
return actionLogFacade.getAllSortedByTimestamp(permissionBean.getCurrentUser().getEvent());
else
return actionLogFacade.getAllSortedByTimestampFiltered(permissionBean.getCurrentUser().getEvent(), filterTags);
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<Role> getAssignableRoles() {
......@@ -72,6 +95,12 @@ public class ActionLogBean implements ActionLogBeanLocal {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
return actionLogFacade.getActionLogMessageResponses(alm);
}
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessageTag> getAllTags() {
return actionLogMessageTagFacade.getAllTags(eventBean.getCurrentEvent());
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) {
......@@ -98,4 +127,64 @@ public class ActionLogBean implements ActionLogBeanLocal {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
else return alm;
}
private ArrayList<ActionLogMessageTag> resolveTags(String message) {
ArrayList<ActionLogMessageTag> almts = new ArrayList<>();
StringBuilder sb = null;
boolean rflag = false;
char ch;
for(int i=0; i < message.length(); i++) {
if(rflag) {
if((ch = message.charAt(i)) != ' ') {
sb.append(ch);
} else {
if(sb.length() > 0) {
ActionLogMessageTag almt = getActionLogMessageTagByString(sb.toString());
if(!almts.contains(almt)) {
almts.add(almt);
}
}
rflag = false;
sb = null;
}
} else if(!rflag) {
if(message.charAt(i) == '#') {
rflag=true;
sb=new StringBuilder();
}
}
}
if(sb != null && sb.length() > 0) {
ActionLogMessageTag almt = getActionLogMessageTagByString(sb.toString());
if(!almts.contains(almt)) {
almts.add(almt);
}
}
return almts;
}
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public ActionLogMessageTag getActionLogMessageTagByString(String s) {
s = s.toLowerCase();
ActionLogMessageTag almt = null;
if((almt = actionLogMessageTagFacade.findByTagStringInEvent(s, eventBean.getCurrentEvent())) == null) {
almt = new ActionLogMessageTag();
almt.setEvent(eventBean.getCurrentEvent());
almt.setTag(s);
almt = actionLogMessageTagFacade.create(almt);
System.out.println("creating tag: "+s);
return almt;
} else {
System.out.println("re-using tag: "+s);
return almt;
}
}
}
\ No newline at end of file
......@@ -34,6 +34,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "DELETE FROM application_permissions WHERE application = 'MAP' and permission = 'RELEASE_PLACE'" });
dbUpdates.add(new String[] { "ALTER TABLE site_page_content ADD COLUMN locale varchar(10)" });
dbUpdates.add(new String[] { "ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)" });
dbUpdates.add(new String[] { "ALTER TABLE actionlog_messages DROP COLUMN crew" });
dbUpdates.add(new String[] { "DELETE TABLE card_barcode"});
dbUpdates.add(new String[] { "ALTER TABLE printed_cards DROP COLUMN barcode;"});
dbUpdates.add(new String[] { "ALTER TABLE printed_cards DROP COLUMN rfid_uid;"});
......@@ -42,7 +43,6 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN products_id integer REFERENCES products(id) DEFAULT null;"});
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN type text NOT NULL;"});
dbUpdates.add(new String[] { "ALTER TABLE reader_events DROP COLUMN gamepoint;"});
}
@EJB
......
......@@ -66,8 +66,7 @@ public class CardPrintBean implements CardPrintBeanLocal {
private PrintedCardFacade printedCardFacade;
private static final Logger logger = LoggerFactory.getLogger(CardPrintBean.class);
private int nick_x = 0;
private int nick_y = 0;
public static final double ASPECT_RATIO = 0.7317073170731707;
/**
* Default constructor.
......@@ -144,11 +143,11 @@ public class CardPrintBean implements CardPrintBeanLocal {
int originalHeight = faceBufferedImage.getHeight();
int width = originalWidth;
int height = (int) Math.round(originalWidth * (1 / 0.7317073170731707));
int height = (int) Math.round(originalWidth * (1 / ASPECT_RATIO));
if (height > originalHeight) {
height = originalHeight;
width = (int) Math.round(originalHeight * 0.7317073170731707);
width = (int) Math.round(originalHeight * ASPECT_RATIO);
}
int offsetx = (originalWidth - width) / 2;
......
......@@ -239,8 +239,8 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation lognavi = adminevent.addPage(null, null);
lognavi.setKey("topnavi.log");
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/messagelist"), UserPermission.VIEW_ALL);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), UserPermission.VIEW_ALL).setVisible(false);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/index"), ContentPermission.MANAGE_ACTIONLOG);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), ContentPermission.MANAGE_ACTIONLOG).setVisible(false);
MenuNavigation compoMenu = adminevent.addPage(null, null);
compoMenu.setKey("topnavi.compos");
......@@ -268,6 +268,7 @@ public class MenuBean implements MenuBeanLocal {
tournamentsadm.addPage(menuitemfacade.findOrCreate("/tournaments/admin/view_tournament_team"), TournamentPermission.MANAGE_ALL).setVisible(false);
tournamentsadm.addPage(menuitemfacade.findOrCreate("/tournaments/admin/edit"), TournamentPermission.MANAGE_ALL).setVisible(false);
tournamentsadm.addPage(menuitemfacade.findOrCreate("/tournaments/admin/delete"), TournamentPermission.MANAGE_ALL).setVisible(false);
tournamentsadm.addPage(menuitemfacade.findOrCreate("/tournaments/admin/editrules"), TournamentPermission.MANAGE_ALL).setVisible(false);
/*
* MenuNavigation profileTopmenu = new MenuNavigation(ev,
* "topnavi.profile", menusort = +10);
......@@ -472,8 +473,8 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation lognavi = adminnavi.addPage(null, null);
lognavi.setKey("topnavi.log");
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/messagelist"), UserPermission.VIEW_ALL);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), UserPermission.VIEW_ALL).setVisible(false);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/index"), ContentPermission.MANAGE_ACTIONLOG);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), ContentPermission.MANAGE_ACTIONLOG).setVisible(false);
MenuNavigation foodnavi = adminnavi.addPage(null, null);
foodnavi.setKey("topnavi.foodwave");
......
......@@ -151,7 +151,7 @@ public class PlaceBean implements PlaceBeanLocal {
for (Entry<Product, Integer> entry : mockmap.entrySet()) {
logger.debug("Adding to price {} of {}", entry.getValue(), entry.getKey().getName());
if (entry.getKey() != null) {
total = total.add(productBean.calculateTotal(entry.getKey(), new BigDecimal(entry.getValue()), now));
total = total.add(productBean.calculateTotal(entry.getKey(), new BigDecimal(entry.getValue()), now, user));
}
}
return total;
......
......@@ -285,12 +285,12 @@ public class ProductBean implements ProductBeanLocal {
}
@Override
public BigDecimal calculateTotal(Product product, BigDecimal quantity, Calendar date) {
public BigDecimal calculateTotal(Product product, BigDecimal quantity, Calendar date, EventUser user) {
if (product == null || quantity == null) {
throw new RuntimeException("Some parameter is null!");
}
BigDecimal total = product.getPrice();
for (Discount d : product.getActiveDiscounts(quantity, date)) {
for (Discount d : product.getActiveDiscounts(quantity, date, user)) {
total = total.multiply(d.getPercentage());
}
return total.setScale(2, RoundingMode.HALF_UP).multiply(quantity);
......
......@@ -73,7 +73,7 @@ public class ProductPBean {
}
BigDecimal unitPrice = product.getPrice().negate();
List<Discount> discounts = product.getActiveDiscounts(quantity, date);
List<Discount> discounts = product.getActiveDiscounts(quantity, date, user);
for (Discount d : discounts) {
unitPrice = unitPrice.multiply(d.getPercentage());
}
......
......@@ -100,6 +100,17 @@ public class TournamentBean implements TournamentBeanLocal {
else
throw new Exception("tournament.invalid_event");
}
@Override
@RolesAllowed(TournamentPermission.S_MANAGE_ALL)
public void updateTournamentRules(TournamentRule tr) throws Exception {
// Assert correct event
if(eventBean.getCurrentEvent().equals(tr.getTournamentGame().getLanEvent())) {
tournamentRuleFacade.merge(tr);
} else {
throw new Exception("tournament.invalid_event");
}
}
@Override
@RolesAllowed(TournamentPermission.S_VIEW)
......
......@@ -273,6 +273,8 @@ public class UserBean implements UserBeanLocal {
bimage = resized;
}
bimage = forceCrop(bimage);
ByteArrayOutputStream naamaout = new ByteArrayOutputStream();
try {
......@@ -296,6 +298,44 @@ public class UserBean implements UserBeanLocal {
return userimage;
}
private BufferedImage forceCrop(BufferedImage source) {
int x,y,xl,yl,xh,yh,xc,yc,x0,y0,x1,y1;
double ar = CardPrintBean.ASPECT_RATIO; // x/y
x=source.getWidth();
y=source.getHeight();
xc = x/2;
yc = y/2;
if(y >= x) {
xl = x;
yl = (int)(y*((double)x/(double)y));
} else {
xl = (int)(x*((double)y/(double)x));
yl = y;
}
xh = (int)((xl/2)*ar);
yh = yl/2;
x0 = xc-xh;
x1 = xc+xh;
y0 = yc-yh;
y1 = yc+yh;
int cix = (int)(((double)xl)*ar);
int ciy = yl;
BufferedImage cropped = new BufferedImage(cix, ciy, source.getType());
Graphics2D g = cropped.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(source, 0, 0, cix, ciy, x0, y0, x1, y1, null);
g.dispose();
return cropped;
}
@Override
public UserImage findUserimageFORCE(Integer id)
......
package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.LocalBean;
......@@ -12,6 +13,7 @@ import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.ActionLogMessageResponse_;
import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.ActionLogMessage_;
import fi.codecrew.moya.model.LanEvent;
......@@ -24,6 +26,7 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> {
super(ActionLogMessage.class);
}
public List<ActionLogMessage> getAllSortedByTimestamp(LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ActionLogMessage> cq = cb.createQuery(ActionLogMessage.class);
......@@ -56,4 +59,35 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> {
getEm().persist(almr);
getEm().flush();
}
public List<ActionLogMessage> getAllSortedByTimestampFiltered(LanEvent event, List<ActionLogMessageTag> filterTags) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ActionLogMessage> cq = cb.createQuery(ActionLogMessage.class);
Root<ActionLogMessage> root = cq.from(ActionLogMessage.class);
cq.where(
cb.equal(root.get(ActionLogMessage_.lanEvent), event)
);
cq.orderBy(cb.desc(root.get("time")));
// todo: filter using jpa..
TypedQuery<ActionLogMessage> tq = getEm().createQuery(cq);
List<ActionLogMessage> allResults = tq.getResultList();
List<ActionLogMessage> filteredResults = new ArrayList<>();
boolean containsTag = false;
for(ActionLogMessage alm : allResults) {
for(ActionLogMessageTag almt : alm.getTags()) {
if(filterTags.contains(almt)) {
containsTag = true;
break;
}
}
if(containsTag) {
filteredResults.add(alm);
containsTag = false;
}
}
return filteredResults;
}
}
package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.ActionLogMessageTag_;
import fi.codecrew.moya.model.LanEvent;
@Stateless
@LocalBean
public class ActionLogMessageTagFacade extends IntegerPkGenericFacade<ActionLogMessageTag> {
public ActionLogMessageTagFacade() {
super(ActionLogMessageTag.class);
}
public ActionLogMessageTag findByTagStringInEvent(String tagString, LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ActionLogMessageTag> cq = cb.createQuery(ActionLogMessageTag.class);
Root<ActionLogMessageTag> root = cq.from(ActionLogMessageTag.class);
cq.where(
cb.and(
cb.equal(root.get(ActionLogMessageTag_.event), event),
cb.equal(root.get(ActionLogMessageTag_.tag), tagString)
)
);
TypedQuery<ActionLogMessageTag> tq = getEm().createQuery(cq);
ActionLogMessageTag almt;
try {
almt = tq.getSingleResult();
} catch(Exception e) {
return null;
}
return almt;
}
public List<ActionLogMessageTag> getAllTags(LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ActionLogMessageTag> cq = cb.createQuery(ActionLogMessageTag.class);
Root<ActionLogMessageTag> root = cq.from(ActionLogMessageTag.class);
cq.where(
cb.equal(root.get(ActionLogMessageTag_.event), event)
);
TypedQuery<ActionLogMessageTag> tq = getEm().createQuery(cq);
try {
return tq.getResultList();
} catch(Exception e) {
return new ArrayList<ActionLogMessageTag>();
}
}
}
package fi.codecrew.moya.beans;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Local;
......@@ -6,14 +7,19 @@ import javax.ejb.Local;
import fi.codecrew.moya.enums.ActionLogMessageState;
import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.Role;
@Local
public interface ActionLogBeanLocal {
public List<ActionLogMessage> getAllActionLogEvents();
public List<Role> getAssignableRoles();
public void createActionLogEvent(String message, Role crew, boolean isTask);
public ActionLogMessage find(Integer id);
public List<ActionLogMessageResponse> getActionLogMessageResponses(ActionLogMessage id);
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state);
public void createActionLogEvent(String message, boolean isTask);
List<ActionLogMessageTag> getAllTags();
ActionLogMessageTag getActionLogMessageTagByString(String s);
List<ActionLogMessage> getAllActionLogEventsByFilter(
List<ActionLogMessageTag> filterTags);
}
......@@ -47,7 +47,7 @@ public interface ProductBeanLocal {
Discount save(Discount discount);
BigDecimal calculateTotal(Product product, BigDecimal quantity, Calendar date);
BigDecimal calculateTotal(Product product, BigDecimal quantity, Calendar date, EventUser user);
HashMap<Integer, BigDecimal> getProductLimit(Map<Integer, BigDecimal> prodCounts, EventUser user);
......
......@@ -32,5 +32,6 @@ public interface TournamentBeanLocal {
boolean useTimeConstraints, boolean invertMatch);
List<TournamentParticipant> findOwnParticipations();
void deleteParticipationById(Integer tpid) throws Exception;
void updateTournamentRules(TournamentRule tr) throws Exception;
}
......@@ -10,6 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
......@@ -37,9 +39,6 @@ public class ActionLogMessage extends GenericEntity {
@JoinColumn(name = "lan_event_id")
private LanEvent lanEvent;
@JoinColumn(name = "crew", nullable = false)
private Role crew;
@Column(name = "message", nullable = false)
private String message;
......@@ -49,6 +48,18 @@ public class ActionLogMessage extends GenericEntity {
@OrderBy("id")
private List<ActionLogMessageResponse> actionLogMessageResponses = new ArrayList<ActionLogMessageResponse>();
@ManyToMany()
@JoinTable(
name = "actionlog_message_tag_sets",
joinColumns = {
@JoinColumn(name = "actionlog_message_id", referencedColumnName = ActionLogMessage.ID_COLUMN)
},
inverseJoinColumns = {
@JoinColumn(name = "actionlog_message_tag_id", referencedColumnName = ActionLogMessageTag.ID_COLUMN)
}
)
private List<ActionLogMessageTag> tags = new ArrayList<ActionLogMessageTag>();
@Column(name = "state", nullable = true)
@Enumerated(EnumType.STRING)
private ActionLogMessageState state;
......@@ -77,14 +88,6 @@ public class ActionLogMessage extends GenericEntity {
this.user = user;
}
public Role getCrew() {
return crew;
}
public void setCrew(Role crew) {
this.crew = crew;
}
public String getMessage() {
return message;
}
......@@ -109,4 +112,11 @@ public class ActionLogMessage extends GenericEntity {
this.actionLogMessageResponses = actionLogMessageResponses;
}
public List<ActionLogMessageTag> getTags() {
return tags;
}
public void setTags(List<ActionLogMessageTag> tags) {
this.tags = tags;
}
}
package fi.codecrew.moya.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.eclipse.persistence.annotations.PrivateOwned;
@Entity
@Table(name = "actionlog_message_tags")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class ActionLogMessageTag extends GenericEntity {
private static final long serialVersionUID = -2902547412412000488L;
@Column(name = "tag", nullable = false)
private String tag;
@JoinColumn(name="event")
private LanEvent event;
public LanEvent getEvent() {
return event;
}
public void setEvent(LanEvent lanEvent) {
this.event = lanEvent;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getTag() {
return tag;
}
}
......@@ -364,7 +364,7 @@ public class Bill extends GenericEntity {
}
this.getBillLines().add(new BillLine(this, product, count, foodwave));
for (Discount disc : product.getActiveDiscounts(count, sentDate)) {
for (Discount disc : product.getActiveDiscounts(count, sentDate, this.getUser())) {
this.getBillLines().add(new BillLine(this, product, disc, count));
}
}
......
......@@ -163,15 +163,28 @@ public class Product extends GenericEntity {
}
// TODO: alennukset lasketaan täällä. HUOMHUOM!!
public List<Discount> getActiveDiscounts(BigDecimal quantity, Calendar time) {
// Oikea paikka ois joku kaunis bean, mutta ehkä enskerralla voin
// refactoroida
// tai si sitäseuraavalla -TKjne
public List<Discount> getActiveDiscounts(BigDecimal quantity, Calendar time, EventUser user) {
ArrayList<Discount> ret = new ArrayList<Discount>();
for (Discount d : getDiscounts()) {
if (d.isActive() &&
(d.getValidTo() == null || d.getValidTo().after(time)) &&
(d.getValidFrom() == null || d.getValidFrom().before(time)) &&
quantity.compareTo(d.getAmountMax()) <= 0 &&
quantity.compareTo(d.getAmountMin()) >= 0) {
ret.add(d);
(d.getAmountMax().compareTo(BigDecimal.ZERO) == 0 || quantity.compareTo(d.getAmountMax()) <= 0) &&
(d.getAmountMin().compareTo(BigDecimal.ZERO) == 0 || quantity.compareTo(d.getAmountMin()) >= 0)) {
// plaah, there is role, must do magic
if (d.getRole() != null) {
for (Role role : user.getRoles()) {
if (d.getRole().equals(role)) {
ret.add(d);
}
}
} else {
ret.add(d);
}
}
}
return ret;
......
......@@ -97,11 +97,11 @@
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>actionlog/messagelist</display-name>
<from-view-id>/actionlog/messagelist.xhtml</from-view-id>
<display-name>actionlog/index</display-name>
<from-view-id>/actionlog/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/actionlog/messagelist.xhtml</to-view-id>
<to-view-id>/actionlog/index.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
......
<!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/cditools/user"
xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<!-- f:event type="preRenderView" listener="#{newsListView.initView}" /-->
<f:event type="preRenderView"
listener="#{actionLogMessageView.initView}" />
</f:metadata>
<ui:define name="content">
<h:outputStylesheet library="style" name="templates/insomnia2/css/actionlog.css" />
<h:outputStylesheet library="style"
name="templates/insomnia2/css/actionlog.css" />
<h1>#{i18n['actionlog.messagelist.header']}</h1>
<p>#{i18n['actionlog.messagelist.description']}</p>
<h:form id="actionlog_create">
<h:form id="actionlog">
<h2>#{i18n['actionlog.create.header']}</h2>
<h:messages />
<div class="row">
<h3 class="actionlog_create_role">#{i18n['actionlog.create.role']}</h3>
<h3 class="actionlog_create_message">#{i18n['actionlog.create.message']}</h3>
<h3 class="actionlog_create_istask">#{i18n['actionlog.create.taskradio']}</h3>
</div>
<div class="row">
<div class="actionlog_create_role">
<h:selectOneMenu value="#{actionLogCreateView.role}" converter="#{roleConverter}">
<f:selectItems var="role" itemLabel="#{role.name}" value="#{actionLogCreateView.roles}" />
</h:selectOneMenu>
</div>
<p:messages />
<h:panelGrid columns="2">
<h:panelGrid columns="3">
<h:outputText value="#{i18n['actionlog.create.message']}" />
<h:outputText value="#{i18n['actionlog.create.taskradio']}" />
<h:outputText />
<div class="actionlog_create_message">
<h:inputText value="#{actionLogCreateView.message}" />
</div>
<p:inputText value="#{actionLogCreateView.message}" style="width: 400px;" />
<p:selectBooleanCheckbox value="#{actionLogCreateView.task}" />
<h:commandButton class="sendbutton"
action="#{actionLogCreateView.send}"
value="#{i18n['actionlog.create.submitbutton']}" update="@form" />
</h:panelGrid>
<div class="actionlog_create_istask">
<h:selectBooleanCheckbox value="#{actionLogCreateView.task}" />
</div>
<h:panelGrid columns="1">
<p:tagCloud model="#{actionLogMessageView.tagCloud}">
<p:ajax event="select"
listener="#{actionLogMessageView.onTagSelect}"
update="@form,actionlogtable" />
</p:tagCloud>
<h:commandButton class="sendbutton" action="#{actionLogCreateView.send}" value="#{i18n['actionlog.create.submitbutton']}">
</h:commandButton>
</div>
</h:form>
<div class="clearfix"></div>
<h2>#{i18n['actionlog.tasklist.header']}</h2>
<div id="actionlog">
<h:form id="refresh">
<p:poll interval="10" update="actionlogtable" onerror="location.reload();" />
<p:dataTable styleClass="bordertable" rowStyleClass="#{message.state.name}"
id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="30" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="30,50,100" >
<h:panelGroup layout="block">
<ui:repeat id="selectedtags" var="tag" value="#{actionLogMessageView.activeTags}">
<!-- <span style="border: 1px solid #0af; display: inline-block; padding: 2px">#{tag.tag}</span> -->
<p:commandButton actionListener="#{actionLogMessageView.selectFilterTag(tag.tag)}" value="#{tag.tag}" immediate="true" update="@form" />
</ui:repeat>
</h:panelGroup>
</h:panelGrid>
</h:panelGrid>
<!-- </h:form>-->
<div class="clearfix"></div>
<h2>#{i18n['actionlog.tasklist.header']}</h2>
<div id="actionlog">
<!-- <h:form id="refresh"> -->
<p:poll interval="10" update="actionlogtable"
onerror="location.reload();" />
<p:dataTable styleClass="bordertable"
rowStyleClass="#{message.state.name}" id="actionlogtable"
value="#{actionLogMessageView.messages}" var="message"
paginator="true" rows="30"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="30,50,100">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.time']}" />
</f:facet>
<h:outputText value="#{message.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}"
timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column>
......@@ -63,12 +80,6 @@
<h:outputText value="#{message.user.nick}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.crew']}" />
</f:facet>
<h:outputText value="#{message.crew.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.message']}" />
......@@ -89,8 +100,8 @@
</h:link>
</p:column>
</p:dataTable>
</h:form>
</div>
</div>
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -30,10 +30,6 @@
<td><h:outputText value="#{taskModificationView.message.user.nick}" /></td>
</tr>
<tr>
<td><h:outputText class="taskHeader" value="#{i18n['actionlog.crew']}: " /></td>
<td><h:outputText value="#{taskModificationView.message.crew.name}" /></td>
</tr>
<tr>
<td><h:outputText class="taskHeader" value="#{i18n['actionlog.state']}: " /></td>
<td><h:outputText value="#{i18n[taskModificationView.message.state.key]}" /></td>
</tr>
......@@ -45,7 +41,7 @@
</div>
<div class="clearfix"></div>
<hr style="width: 90%;" />
<div>
<h:form>
<p:poll interval="1" update="messageresponsetable" onerror="location.reload();" />
......
......@@ -31,6 +31,12 @@
<h:inputText id="code" value="#{productView.discount.code}" />
<h:message for="code" />
<h:outputLabel for="role" value="#{i18n['discount.role']}:" />
<h:selectOneMenu id="role" value="#{productView.discount.role}" converter="#{roleConverter}">
<f:selectItems var="role" itemLabel="#{role.name}" value="#{roleDataView.rolesWithEmpty}" />
</h:selectOneMenu>
<h:message for="role" />
<h:outputLabel for="amountMin" value="#{i18n['discount.amountMin']}:" />
<h:inputText id="amountMin" value="#{productView.discount.amountMin}" required="true" />
<h:message for="amountMin" />
......@@ -54,6 +60,8 @@
<h:outputLabel for="active" value="#{i18n['discount.active']}" />
<h:selectBooleanCheckbox id="active" value="#{productView.discount.active}" />
<h:message for="active" />
</h:panelGrid>
......
@CHARSET "utf-8";
/*
#actionlog_create .row {
display: block;
clear: both;
......@@ -81,11 +81,11 @@
.taskHeader {
color: #7DAC0C;
font-size: 120%;
font-size: 120%;
font-weight: bold;
}
.sendbutton2 {
border: 1px solid #aaa;
margin-left: 10px;
}
\ No newline at end of file
}*/
\ No newline at end of file
......@@ -148,6 +148,9 @@ h1 {
width: 200px;
}
nav {
min-width: 200px;
background: white;
......@@ -193,3 +196,13 @@ aside {
th, td {
padding: 5px;
}
#header_center {
position: relative;
text-align: right;
}
#selectLanguage {
padding-left: 10px;
padding-top: 10px;
}
......@@ -79,21 +79,15 @@
</h:link>
</div>
<div id="header_center" class="flex1">
<div>
<h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" onchange="this.form.submit()" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
</p:selectOneButton>
</h:form>
</div>
<ui:fragment rendered="#{layoutView.canManageContent}">
<div>
<h:form>
<h:outputLabel for="manageBtn" value="#{i18n['content.showContentEditLinks']}" />
<h:selectBooleanCheckbox value="#{sessionStore.manageContentLinks}" onclick="this.form.submit()" />
</h:form>
</div>
</ui:fragment>
<div>
<h:form>
<h:outputLabel for="manageBtn" value="#{i18n['content.showContentEditLinks']}" />
<h:selectBooleanCheckbox value="#{sessionStore.manageContentLinks}" onclick="this.form.submit()" />
</h:form>
</div>
</ui:fragment>
</div>
<div id="header_right">
......@@ -115,6 +109,14 @@
</nav>
<section id="main" class="flex2">
<div class="container top">
<h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" onchange="this.form.submit()" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
</p:selectOneButton>
</h:form>
<h:link rendered="#{layoutView.manageContent}" styleClass="editorlink" value="#{i18n['layout.editTop']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}:top" />
</h:link>
......
<!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/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:viewParam name="tournament_id" value="#{tournamentEditRulesView.tournamentId}"/>
<f:event type="preRenderView" listener="#{tournamentEditRulesView.initView()}" />
</f:metadata>
<ui:define name="content">
<h:form>
<h1>#{i18n['tournaments.admin.edit_rules']}</h1>
<h:panelGrid columns="1">
<p:inputText value="#{tournamentEditRulesView.selectedRules.name}" />
<p:inputTextarea value="#{tournamentEditRulesView.selectedRules.rules}" />
<p:commandButton value="#{i18n['tournament.admin.edit']}" action="#{tournamentEditRulesView.commit()}" ajax="false" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -54,7 +54,9 @@
<f:facet name="header">
<h:outputText value="#{i18n['tournament.rules']}" />
</f:facet>
<h:outputText value="#{tournament.rules.name}" />
<h:link value="#{tournament.rules.name}" outcome="/tournaments/showrules.xhtml">
<f:param name="tournament_id" value="#{tournament.id}" />
</h:link>
</p:column>
<p:column>
<f:facet name="header">
......
......@@ -10,15 +10,24 @@
</f:metadata>
<ui:define name="content">
<h:form>
<p>
<h:link outcome="/tournaments/index.xhtml" value="#{i18n['tournaments.back_to_tournament_list']}" />
</p>
<h1>#{i18n['tournament.rules_for_tournament']} #{tournamentRulesView.tournament.tournamentName} (#{tournamentRulesView.tournament.rules.name})</h1>
<h:outputText value="#{tournamentRulesView.tournament.rules.rules}" escape="false" />
<h:panelGroup layout="block" rendered="#{tournamentRulesView.canEdit}" style="margin-bottom: 16px;">
<p:button value="#{i18n['tournaments.admin.edit_rules']}" outcome="/tournaments/admin/editrules.xhtml">
<f:param name="tournament_id" value="#{tournamentRulesView.tournamentId}" />
</p:button>
</h:panelGroup>
<div>
<h:outputText value="#{tournamentRulesView.tournament.rules.rules}" escape="false" />
</div>
<p>
<h:link outcome="/tournaments/index.xhtml" value="#{i18n['tournaments.back_to_tournament_list']}" />
</p>
</ui:define>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -156,7 +156,6 @@ global.notauthorized = You don't have enough rights to enter this site.
global.save = Save
httpsession.creationTime = Created
incomingflow.giveplace = Merkitse annetuksi
lanEventPrivateProperty.defaultValue = Default value
......
......@@ -1045,6 +1045,8 @@ tournament.admin.delete_cancel = Cancel Deletio
tournament.admin.delete_confirm = Confirm Deletion
tournament.admin.edit = Edit
tournament.admin.tournament_edited_successfully = Edited successfully
tournament.admin.tournament_rules_edit_failed = Rule Edit Failed
tournament.admin.tournament_rules_edited_successfully = Rules successfully edited
tournament.admin.view = View
tournament.already_participated_into_tournament = Already participated into the selected tournament!
tournament.backup_player_successfully_added_to_team = Backup player added
......@@ -1095,6 +1097,7 @@ tournaments.admin.create_new_ruleset = Create a new r
tournaments.admin.create_tournament = Create a tournament
tournaments.admin.description = Manage tournaments
tournaments.admin.edit = Edit tournament
tournaments.admin.edit_rules = Edit Rules
tournaments.admin.edit_tournament = Edit Tournament
tournaments.admin.game_description = Game description
tournaments.admin.game_name = Game name
......
......@@ -1030,6 +1030,8 @@ tournament.admin.delete_cancel = Peruuta
tournament.admin.delete_confirm = Vahvista Poisto
tournament.admin.edit = Muokkaa
tournament.admin.tournament_edited_successfully = Turnauksen asetuksia muutettu
tournament.admin.tournament_rules_edit_failed = S\u00E4\u00E4nt\u00F6jen muutos ep\u00E4onnistui
tournament.admin.tournament_rules_edited_successfully = S\u00E4\u00E4nt\u00F6jen muutos tehty
tournament.admin.view = Tarkastele
tournament.already_participated_into_tournament = Olet jo osallistunut valittuun turnaukseen!
tournament.backup_player_successfully_added_to_team = Varapelaaja lis\u00E4tty
......@@ -1080,6 +1082,7 @@ tournaments.admin.create_new_ruleset = Luo uusi s\u00
tournaments.admin.create_tournament = Luo turnaus
tournaments.admin.description = Hallinnoi turnauksia
tournaments.admin.edit = Muokkaa turnausta
tournaments.admin.edit_rules = Editoi s\u00E4\u00E4nt\u00F6j\u00E4
tournaments.admin.edit_tournament = Muokkaa turnausta
tournaments.admin.game_description = Pelin kuvaus
tournaments.admin.game_name = Pelin nimi
......
......@@ -22,23 +22,10 @@ public class ActionLogCreateView extends GenericCDIView {
@Size(min=4,message="{actionlog.message.tooshort}")
private String message;
private Role role;
private boolean task;
private static final long serialVersionUID = 1L;
public List<Role> getRoles() {
return actionLogBean.getAssignableRoles();
}
public Role getRole() {
return this.role;
}
public void setRole(Role role) {
this.role = role;
}
public String getMessage() {
return message;
}
......@@ -56,7 +43,7 @@ public class ActionLogCreateView extends GenericCDIView {
}
public String send() {
actionLogBean.createActionLogEvent(message, role, task);
actionLogBean.createActionLogEvent(message, task);
return "success";
}
}
package fi.codecrew.moya.web.cdiview.actionlog;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.tagcloud.DefaultTagCloudItem;
import org.primefaces.model.tagcloud.DefaultTagCloudModel;
import org.primefaces.model.tagcloud.TagCloudItem;
import org.primefaces.model.tagcloud.TagCloudModel;
import fi.codecrew.moya.beans.ActionLogBeanLocal;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
@ConversationScoped
public class ActionLogMessageView extends GenericCDIView {
private static final long serialVersionUID = 1L;
private boolean updateEnabled = true;
private TagCloudModel tagCloud = null;
private List<ActionLogMessageTag> activeTags = null;
@EJB
private transient ActionLogBeanLocal actionLogBean;
public void initView() {
if(super.requirePermissions(ContentPermission.MANAGE_ACTIONLOG)) {
this.beginConversation();
refreshTagCloud();
if(activeTags == null) {
activeTags = new ArrayList<>();
}
}
}
public void refreshTagCloud() {
tagCloud = new DefaultTagCloudModel();
for(ActionLogMessageTag almt : actionLogBean.getAllTags()) {
tagCloud.addTag(new DefaultTagCloudItem(almt.getTag(), 1));
}
}
public boolean getUpdateEnabled() {
return updateEnabled;
}
......@@ -30,9 +63,32 @@ public class ActionLogMessageView extends GenericCDIView {
}
public List<ActionLogMessage> getMessages() {
if (super.hasPermission(ContentPermission.MANAGE_ACTIONLOG)) {
return actionLogBean.getAllActionLogEvents();
return actionLogBean.getAllActionLogEventsByFilter(activeTags);
}
public TagCloudModel getTagCloud() {
return tagCloud;
}
public void onTagSelect(SelectEvent event) {
TagCloudItem item = (TagCloudItem)event.getObject();
ActionLogMessageTag almt = actionLogBean.getActionLogMessageTagByString(item.getLabel());
if(!activeTags.contains(almt))
activeTags.add(almt);
}
public void selectFilterTag(String tag) {
for(ActionLogMessageTag almt : this.activeTags) {
if(tag.equals(almt.getTag())) {
this.activeTags.remove(almt);
break;
}
}
return null;
}
public List<ActionLogMessageTag> getActiveTags() {
return this.activeTags;
}
}
......@@ -66,7 +66,7 @@ public class FoodWaveFoodView extends GenericCDIView {
foodWave = foodWaveBean.findFoodwave(getFoodwaveid());
logger.debug("Foodwave {}", foodWave);
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(foodWave.getTemplate().getProducts()));
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(foodWave.getTemplate().getProducts(), userview.getUser()));
this.beginConversation();
}
......
......@@ -94,7 +94,7 @@ public class ProductShopView extends GenericCDIView {
public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& shoppingcart == null) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts()));
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts(), user));
updateCartLimits(null);
logger.debug("Initialized billing shoppingcart to {}", shoppingcart);
this.beginConversation();
......@@ -137,7 +137,7 @@ public class ProductShopView extends GenericCDIView {
public void initShopView() {
if (requirePermissions(ShopPermission.SHOP_TO_OTHERS) && shoppingcart == null) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(productBean.findForStaffshop()));
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(productBean.findForStaffshop(), user));
updateCartLimits(null);
LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH);
......
package fi.codecrew.moya.web.cdiview.tournaments;
import java.io.IOException;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.enums.TournamentType;
import fi.codecrew.moya.enums.apps.TournamentPermission;
import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentRule;
import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class TournamentEditRulesView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = -2655058086651272660L;
@EJB
private TournamentBeanLocal tournamentBean;
private Tournament tournament = null;
private Integer tournamentId;
private TournamentRule selectedRules = null;
public void initView()
{
if (super.requirePermissions(TournamentPermission.MANAGE_ALL) && selectedRules == null) {
super.beginConversation();
tournament = tournamentBean.getTournamentById(tournamentId);
selectedRules = tournament.getRules();
System.out.println(this.selectedRules.getName());
}
}
public Integer getTournamentId() {
return tournamentId;
}
public void setTournamentId(Integer tournamentId) {
this.tournamentId = tournamentId;
}
public Tournament getTournament() {
return tournament;
}
public void setTournament(Tournament tournament) {
this.tournament = tournament;
}
public TournamentRule getSelectedRules() {
return selectedRules;
}
public void setSelectedRules(TournamentRule selectedRules) {
this.selectedRules = selectedRules;
}
public String commit() {
if (this.selectedRules != null) {
try {
this.tournamentBean.updateTournamentRules(selectedRules);
MessageHelper.info("tournament.admin.tournament_rules_edited_successfully");
} catch (Exception e) {
MessageHelper.err("tournament.admin.tournament_rules_edit_failed");
}
} else {
MessageHelper.err("tournament.admin.tournament_rules_edit_failed");
}
this.endConversation();
return "/tournaments/admin/index.xhtml";
}
}
......@@ -45,4 +45,8 @@ public class TournamentRulesView extends GenericCDIView {
public void setTournament(Tournament tournament) {
this.tournament = tournament;
}
public Boolean getCanEdit() {
return super.hasPermission(TournamentPermission.MANAGE_ALL);
}
}
......@@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Product;
public class ProductShopItem {
......@@ -23,6 +24,8 @@ public class ProductShopItem {
private Map<Integer, BigDecimal> discountValues;
private BigDecimal price;
private BigDecimal limit;
private EventUser user;
public BigDecimal getCreditPrice()
{
......@@ -42,12 +45,12 @@ public class ProductShopItem {
return BigDecimal.ZERO;
}
public ProductShopItem(Product prod) {
public ProductShopItem(Product prod, EventUser user) {
super();
this.user = user;
this.product = prod;
id = this.product.getId();
setCount(BigDecimal.ZERO);
}
/**
......@@ -56,21 +59,21 @@ public class ProductShopItem {
* @param findForStaffshop
* @return
*/
public static List<ProductShopItem> productGTList(List<Product> products) {
public static List<ProductShopItem> productGTList(List<Product> products, EventUser user) {
List<ProductShopItem> ret = new ArrayList<ProductShopItem>();
for (Product prod : products) {
if (prod.getPrice().compareTo(BigDecimal.ZERO) >= 0) {
ret.add(new ProductShopItem(prod));
ret.add(new ProductShopItem(prod, user));
}
}
return ret;
}
public static List<ProductShopItem> productList(List<Product> products) {
public static List<ProductShopItem> productList(List<Product> products, EventUser user) {
List<ProductShopItem> ret = new ArrayList<ProductShopItem>();
for (Product prod : products) {
ret.add(new ProductShopItem(prod));
ret.add(new ProductShopItem(prod, user));
}
return ret;
......@@ -89,7 +92,7 @@ public class ProductShopItem {
this.count = count;
price = product.getPrice().abs().multiply(count);
discounts = product.getActiveDiscounts(count, Calendar.getInstance());
discounts = product.getActiveDiscounts(count, Calendar.getInstance(), user);
discountValues = new HashMap<Integer, BigDecimal>();
for (Discount d : discounts)
{
......@@ -153,4 +156,12 @@ public class ProductShopItem {
limit = limitValue;
return false;
}
public EventUser getUser() {
return user;
}
public void setUser(EventUser user) {
this.user = user;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!