Commit dd0d268f by Tuomas Riihimäki

Merge remote-tracking branch 'origin/master' into groupmgmt

Conflicts:
	code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
2 parents 9a8d8d05 5533d232
Showing with 846 additions and 276 deletions
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.annotation.security.DeclareRoles; import javax.annotation.security.DeclareRoles;
...@@ -9,6 +11,7 @@ import javax.ejb.EJB; ...@@ -9,6 +11,7 @@ import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import fi.codecrew.moya.facade.ActionLogFacade; import fi.codecrew.moya.facade.ActionLogFacade;
import fi.codecrew.moya.facade.ActionLogMessageTagFacade;
import fi.codecrew.moya.beans.ActionLogBeanLocal; import fi.codecrew.moya.beans.ActionLogBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal; import fi.codecrew.moya.beans.RoleBeanLocal;
...@@ -16,6 +19,7 @@ import fi.codecrew.moya.enums.ActionLogMessageState; ...@@ -16,6 +19,7 @@ import fi.codecrew.moya.enums.ActionLogMessageState;
import fi.codecrew.moya.enums.apps.ContentPermission; import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.model.ActionLogMessage; import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse; import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
/** /**
...@@ -35,15 +39,23 @@ public class ActionLogBean implements ActionLogBeanLocal { ...@@ -35,15 +39,23 @@ public class ActionLogBean implements ActionLogBeanLocal {
@EJB @EJB
private PermissionBeanLocal permissionBean; private PermissionBeanLocal permissionBean;
@EJB
private ActionLogMessageTagFacade actionLogMessageTagFacade;
@EJB
private EventBean eventBean;
public ActionLogBean() { public ActionLogBean() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG) @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(); ActionLogMessage alm = new ActionLogMessage();
alm.setCrew(crew);
if (isTask) { if (isTask) {
alm.setState(ActionLogMessageState.NEW); alm.setState(ActionLogMessageState.NEW);
} else { } else {
...@@ -53,14 +65,25 @@ public class ActionLogBean implements ActionLogBeanLocal { ...@@ -53,14 +65,25 @@ public class ActionLogBean implements ActionLogBeanLocal {
alm.setMessage(message); alm.setMessage(message);
alm.setUser(permissionBean.getCurrentUser()); alm.setUser(permissionBean.getCurrentUser());
alm.setLanEvent(permissionBean.getCurrentUser().getEvent()); alm.setLanEvent(permissionBean.getCurrentUser().getEvent());
alm.setTags(almts);
actionLogFacade.saveToActionLog(alm); actionLogFacade.saveToActionLog(alm);
} }
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG) @RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
@Deprecated
public List<ActionLogMessage> getAllActionLogEvents() { public List<ActionLogMessage> getAllActionLogEvents() {
return actionLogFacade.getAllSortedByTimestamp(permissionBean.getCurrentUser().getEvent()); 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) @RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<Role> getAssignableRoles() { public List<Role> getAssignableRoles() {
...@@ -72,6 +95,12 @@ public class ActionLogBean implements ActionLogBeanLocal { ...@@ -72,6 +95,12 @@ public class ActionLogBean implements ActionLogBeanLocal {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null; if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
return actionLogFacade.getActionLogMessageResponses(alm); return actionLogFacade.getActionLogMessageResponses(alm);
} }
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessageTag> getAllTags() {
return actionLogMessageTagFacade.getAllTags(eventBean.getCurrentEvent());
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG) @RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) { public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) {
...@@ -98,4 +127,64 @@ public class ActionLogBean implements ActionLogBeanLocal { ...@@ -98,4 +127,64 @@ public class ActionLogBean implements ActionLogBeanLocal {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null; if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
else return alm; 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
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -27,7 +29,9 @@ import fi.codecrew.moya.facade.EventUserFacade; ...@@ -27,7 +29,9 @@ import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.model.AccountEvent; import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.BillLine; import fi.codecrew.moya.model.BillLine;
import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
...@@ -68,6 +72,9 @@ public class BillBean implements BillBeanLocal { ...@@ -68,6 +72,9 @@ public class BillBean implements BillBeanLocal {
private EventUserFacade eventUserFacade; private EventUserFacade eventUserFacade;
@EJB @EJB
private ProductPBean productPBean; private ProductPBean productPBean;
@EJB
private DiscountBean discountBean;
/** /**
* Default constructor. * Default constructor.
...@@ -304,5 +311,38 @@ public class BillBean implements BillBeanLocal { ...@@ -304,5 +311,38 @@ public class BillBean implements BillBeanLocal {
bill.markExpired(); bill.markExpired();
return bill; return bill;
} }
@Override
public Bill addProductToBill(Bill bill, Product product, BigDecimal count) {
return this.addProductToBill(bill, product, count, null);
}
@Override
public Bill addProductToBill(Bill bill, Product product, BigDecimal count, FoodWave foodwave) {
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "User tried to modify bill ", bill,
// "without sufficient permissions");
// }
if (bill.getBillLines() == null) {
bill.setBillLines(new ArrayList<BillLine>());
}
bill.getBillLines().add(new BillLine(bill, product, count, foodwave));
for (Discount disc : discountBean.getActiveDiscountsByProduct(product, count, bill.getSentDate(), bill.getUser())) {
bill.getBillLines().add(new BillLine(bill, product, disc, count));
}
return bill;
}
} }
...@@ -34,7 +34,8 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -34,7 +34,8 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "DELETE FROM application_permissions WHERE application = 'MAP' and permission = 'RELEASE_PLACE'" }); 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 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 products ALTER COLUMN vat TYPE NUMERIC(4,3)" });
dbUpdates.add(new String[] { dbUpdates.add(new String[] { "ALTER TABLE actionlog_messages DROP COLUMN crew" });
dbUpdates.add(new String[] {
"ALTER TABLE organisation_roles ADD ldap_role boolean not null default false", "ALTER TABLE organisation_roles ADD ldap_role boolean not null default false",
"ALTER TABLE organisation_roles add ldap_weight integer NOT NULL default 100" "ALTER TABLE organisation_roles add ldap_weight integer NOT NULL default 100"
}); });
......
...@@ -66,8 +66,7 @@ public class CardPrintBean implements CardPrintBeanLocal { ...@@ -66,8 +66,7 @@ public class CardPrintBean implements CardPrintBeanLocal {
private PrintedCardFacade printedCardFacade; private PrintedCardFacade printedCardFacade;
private static final Logger logger = LoggerFactory.getLogger(CardPrintBean.class); private static final Logger logger = LoggerFactory.getLogger(CardPrintBean.class);
private int nick_x = 0; public static final double ASPECT_RATIO = 0.7317073170731707;
private int nick_y = 0;
/** /**
* Default constructor. * Default constructor.
...@@ -144,11 +143,11 @@ public class CardPrintBean implements CardPrintBeanLocal { ...@@ -144,11 +143,11 @@ public class CardPrintBean implements CardPrintBeanLocal {
int originalHeight = faceBufferedImage.getHeight(); int originalHeight = faceBufferedImage.getHeight();
int width = originalWidth; int width = originalWidth;
int height = (int) Math.round(originalWidth * (1 / 0.7317073170731707)); int height = (int) Math.round(originalWidth * (1 / ASPECT_RATIO));
if (height > originalHeight) { if (height > originalHeight) {
height = originalHeight; height = originalHeight;
width = (int) Math.round(originalHeight * 0.7317073170731707); width = (int) Math.round(originalHeight * ASPECT_RATIO);
} }
int offsetx = (originalWidth - width) / 2; int offsetx = (originalWidth - width) / 2;
......
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import fi.codecrew.moya.facade.DiscountFacade; import fi.codecrew.moya.facade.DiscountFacade;
import fi.codecrew.moya.facade.EventFacade;
import fi.codecrew.moya.facade.ProductFacade;
import fi.codecrew.moya.beans.DiscountBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.Discount; import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.Role;
/** /**
* Session Bean implementation class DiscountBean * Session Bean implementation class DiscountBean
*/ */
@Stateless @Stateless
@LocalBean
public class DiscountBean implements DiscountBeanLocal { public class DiscountBean implements DiscountBeanLocal {
@EJB @EJB
private DiscountFacade discountfacade; private DiscountFacade discountfacade;
@EJB @EJB
private EventBeanLocal eventbean; private UserBean userBean;
@EJB
private ProductFacade productfacade;
@EJB
private EventFacade eventfacade;
public DiscountBean() { public DiscountBean() {
} }
...@@ -36,6 +39,35 @@ public class DiscountBean implements DiscountBeanLocal { ...@@ -36,6 +39,35 @@ public class DiscountBean implements DiscountBeanLocal {
return ret; return ret;
} }
@Override
public List<Discount> getActiveDiscountsByProduct(Product product, BigDecimal quantity, Calendar time, EventUser user) {
ArrayList<Discount> ret = new ArrayList<Discount>();
for (Discount d : product.getDiscounts()) {
if (d.isActive() &&
(d.getValidTo() == null || d.getValidTo().after(time)) &&
(d.getValidFrom() == null || d.getValidFrom().before(time)) &&
(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 stuff
if (d.getRole() != null) {
for (Role role : userBean.localFindUsersRoles(user)) {
if (d.getRole().equals(role)) {
ret.add(d);
}
}
} else {
ret.add(d);
}
}
}
return ret;
}
// @Override // @Override
// public Discount create(String discountdesc) { // public Discount create(String discountdesc) {
// LanEvent ev = eventbean.getCurrentEvent(); // LanEvent ev = eventbean.getCurrentEvent();
......
...@@ -187,6 +187,22 @@ public class EventBean implements EventBeanLocal { ...@@ -187,6 +187,22 @@ public class EventBean implements EventBeanLocal {
public LanEventProperty getProperty(LanEventPropertyKey property) { public LanEventProperty getProperty(LanEventPropertyKey property) {
return eventPropertyFacade.find(getCurrentEvent(), property); return eventPropertyFacade.find(getCurrentEvent(), property);
} }
@Override
public long getPropertyLong(LanEventPropertyKey property)
{
LanEventProperty retProp = eventPropertyFacade.find(getCurrentEvent(), property);
long ret = 0;
if (retProp == null) {
ret = Long.parseLong(property.getDefaultvalue());
} else {
ret = retProp.getLongValue();
}
return ret;
}
@Override @Override
public String getPropertyString(LanEventPropertyKey property) public String getPropertyString(LanEventPropertyKey property)
......
...@@ -239,8 +239,8 @@ public class MenuBean implements MenuBeanLocal { ...@@ -239,8 +239,8 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation lognavi = adminevent.addPage(null, null); MenuNavigation lognavi = adminevent.addPage(null, null);
lognavi.setKey("topnavi.log"); lognavi.setKey("topnavi.log");
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/messagelist"), UserPermission.VIEW_ALL); lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/index"), ContentPermission.MANAGE_ACTIONLOG);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), UserPermission.VIEW_ALL).setVisible(false); lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), ContentPermission.MANAGE_ACTIONLOG).setVisible(false);
MenuNavigation compoMenu = adminevent.addPage(null, null); MenuNavigation compoMenu = adminevent.addPage(null, null);
compoMenu.setKey("topnavi.compos"); compoMenu.setKey("topnavi.compos");
...@@ -473,8 +473,8 @@ public class MenuBean implements MenuBeanLocal { ...@@ -473,8 +473,8 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation lognavi = adminnavi.addPage(null, null); MenuNavigation lognavi = adminnavi.addPage(null, null);
lognavi.setKey("topnavi.log"); lognavi.setKey("topnavi.log");
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/messagelist"), UserPermission.VIEW_ALL); lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/index"), ContentPermission.MANAGE_ACTIONLOG);
lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), UserPermission.VIEW_ALL).setVisible(false); lognavi.addPage(menuitemfacade.findOrCreate("/actionlog/taskview"), ContentPermission.MANAGE_ACTIONLOG).setVisible(false);
MenuNavigation foodnavi = adminnavi.addPage(null, null); MenuNavigation foodnavi = adminnavi.addPage(null, null);
foodnavi.setKey("topnavi.foodwave"); foodnavi.setKey("topnavi.foodwave");
......
...@@ -151,7 +151,7 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -151,7 +151,7 @@ public class PlaceBean implements PlaceBeanLocal {
for (Entry<Product, Integer> entry : mockmap.entrySet()) { for (Entry<Product, Integer> entry : mockmap.entrySet()) {
logger.debug("Adding to price {} of {}", entry.getValue(), entry.getKey().getName()); logger.debug("Adding to price {} of {}", entry.getValue(), entry.getKey().getName());
if (entry.getKey() != null) { 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; return total;
......
...@@ -91,6 +91,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -91,6 +91,7 @@ public class ProductBean implements ProductBeanLocal {
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
@EJB @EJB
private BillLineFacade billLineFacade; private BillLineFacade billLineFacade;
@EJB @EJB
private ProductPBean productPBean; private ProductPBean productPBean;
...@@ -99,6 +100,9 @@ public class ProductBean implements ProductBeanLocal { ...@@ -99,6 +100,9 @@ public class ProductBean implements ProductBeanLocal {
@EJB @EJB
private PlaceBean placebean; private PlaceBean placebean;
@EJB
private DiscountBean discountBean;
private static final Logger logger = LoggerFactory.getLogger(ProductBean.class); private static final Logger logger = LoggerFactory.getLogger(ProductBean.class);
...@@ -285,12 +289,12 @@ public class ProductBean implements ProductBeanLocal { ...@@ -285,12 +289,12 @@ public class ProductBean implements ProductBeanLocal {
} }
@Override @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) { if (product == null || quantity == null) {
throw new RuntimeException("Some parameter is null!"); throw new RuntimeException("Some parameter is null!");
} }
BigDecimal total = product.getPrice(); BigDecimal total = product.getPrice();
for (Discount d : product.getActiveDiscounts(quantity, date)) { for (Discount d : discountBean.getActiveDiscountsByProduct(product, quantity, date, user)) {
total = total.multiply(d.getPercentage()); total = total.multiply(d.getPercentage());
} }
return total.setScale(2, RoundingMode.HALF_UP).multiply(quantity); return total.setScale(2, RoundingMode.HALF_UP).multiply(quantity);
......
...@@ -30,6 +30,9 @@ public class ProductPBean { ...@@ -30,6 +30,9 @@ public class ProductPBean {
@EJB @EJB
private PermissionBean permbean; private PermissionBean permbean;
@EJB
private DiscountBean discountBean;
@EJB @EJB
private AccountEventFacade accounteventfacade; private AccountEventFacade accounteventfacade;
private static final Logger logger = LoggerFactory private static final Logger logger = LoggerFactory
...@@ -73,7 +76,7 @@ public class ProductPBean { ...@@ -73,7 +76,7 @@ public class ProductPBean {
} }
BigDecimal unitPrice = product.getPrice().negate(); BigDecimal unitPrice = product.getPrice().negate();
List<Discount> discounts = product.getActiveDiscounts(quantity, date); List<Discount> discounts = discountBean.getActiveDiscountsByProduct(product, quantity, date, user);
for (Discount d : discounts) { for (Discount d : discounts) {
unitPrice = unitPrice.multiply(d.getPercentage()); unitPrice = unitPrice.multiply(d.getPercentage());
} }
......
...@@ -275,6 +275,8 @@ public class UserBean implements UserBeanLocal { ...@@ -275,6 +275,8 @@ public class UserBean implements UserBeanLocal {
bimage = resized; bimage = resized;
} }
bimage = forceCrop(bimage);
ByteArrayOutputStream naamaout = new ByteArrayOutputStream(); ByteArrayOutputStream naamaout = new ByteArrayOutputStream();
try { try {
...@@ -298,6 +300,44 @@ public class UserBean implements UserBeanLocal { ...@@ -298,6 +300,44 @@ public class UserBean implements UserBeanLocal {
return userimage; 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 @Override
public UserImage findUserimageFORCE(Integer id) public UserImage findUserimageFORCE(Integer id)
......
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
...@@ -12,6 +13,7 @@ import javax.persistence.criteria.Root; ...@@ -12,6 +13,7 @@ import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.ActionLogMessageResponse_; import fi.codecrew.moya.model.ActionLogMessageResponse_;
import fi.codecrew.moya.model.ActionLogMessage; import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse; import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.ActionLogMessage_; import fi.codecrew.moya.model.ActionLogMessage_;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
...@@ -24,6 +26,7 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> { ...@@ -24,6 +26,7 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> {
super(ActionLogMessage.class); super(ActionLogMessage.class);
} }
public List<ActionLogMessage> getAllSortedByTimestamp(LanEvent event) { public List<ActionLogMessage> getAllSortedByTimestamp(LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ActionLogMessage> cq = cb.createQuery(ActionLogMessage.class); CriteriaQuery<ActionLogMessage> cq = cb.createQuery(ActionLogMessage.class);
...@@ -56,4 +59,35 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> { ...@@ -56,4 +59,35 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> {
getEm().persist(almr); getEm().persist(almr);
getEm().flush(); 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; package fi.codecrew.moya.beans;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
...@@ -6,14 +7,19 @@ import javax.ejb.Local; ...@@ -6,14 +7,19 @@ import javax.ejb.Local;
import fi.codecrew.moya.enums.ActionLogMessageState; import fi.codecrew.moya.enums.ActionLogMessageState;
import fi.codecrew.moya.model.ActionLogMessage; import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse; import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
@Local @Local
public interface ActionLogBeanLocal { public interface ActionLogBeanLocal {
public List<ActionLogMessage> getAllActionLogEvents(); public List<ActionLogMessage> getAllActionLogEvents();
public List<Role> getAssignableRoles(); public List<Role> getAssignableRoles();
public void createActionLogEvent(String message, Role crew, boolean isTask);
public ActionLogMessage find(Integer id); public ActionLogMessage find(Integer id);
public List<ActionLogMessageResponse> getActionLogMessageResponses(ActionLogMessage id); public List<ActionLogMessageResponse> getActionLogMessageResponses(ActionLogMessage id);
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state); 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);
} }
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -10,6 +11,8 @@ import javax.ejb.Local; ...@@ -10,6 +11,8 @@ import javax.ejb.Local;
import fi.codecrew.moya.bortal.views.BillSummary; import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.Product;
@Local @Local
public interface BillBeanLocal { public interface BillBeanLocal {
...@@ -37,5 +40,9 @@ public interface BillBeanLocal { ...@@ -37,5 +40,9 @@ public interface BillBeanLocal {
List<Bill> find(EventUser user); List<Bill> find(EventUser user);
Bill expireBill(Bill bill); Bill expireBill(Bill bill);
Bill addProductToBill(Bill bill, Product product, BigDecimal count, FoodWave foodwave);
Bill addProductToBill(Bill bill, Product product, BigDecimal count);
} }
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.model.Discount; import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Product;
@Local @Local
public interface DiscountBeanLocal { public interface DiscountBeanLocal {
Discount save(Discount discount); Discount save(Discount discount);
public List<Discount> getActiveDiscountsByProduct(Product product, BigDecimal quantity, Calendar time, EventUser user);
} }
...@@ -35,5 +35,7 @@ public interface EventBeanLocal { ...@@ -35,5 +35,7 @@ public interface EventBeanLocal {
List<LanEventPrivateProperty> getPrivateProperties(); List<LanEventPrivateProperty> getPrivateProperties();
LanEventPrivateProperty saveOrCreatePrivateProperty(LanEventPrivateProperty privateProperty); LanEventPrivateProperty saveOrCreatePrivateProperty(LanEventPrivateProperty privateProperty);
long getPropertyLong(LanEventPropertyKey property);
} }
...@@ -47,7 +47,7 @@ public interface ProductBeanLocal { ...@@ -47,7 +47,7 @@ public interface ProductBeanLocal {
Discount save(Discount discount); 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); HashMap<Integer, BigDecimal> getProductLimit(Map<Integer, BigDecimal> prodCounts, EventUser user);
......
...@@ -10,6 +10,8 @@ import javax.persistence.Entity; ...@@ -10,6 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.EnumType; import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -37,9 +39,6 @@ public class ActionLogMessage extends GenericEntity { ...@@ -37,9 +39,6 @@ public class ActionLogMessage extends GenericEntity {
@JoinColumn(name = "lan_event_id") @JoinColumn(name = "lan_event_id")
private LanEvent lanEvent; private LanEvent lanEvent;
@JoinColumn(name = "crew", nullable = false)
private Role crew;
@Column(name = "message", nullable = false) @Column(name = "message", nullable = false)
private String message; private String message;
...@@ -49,6 +48,18 @@ public class ActionLogMessage extends GenericEntity { ...@@ -49,6 +48,18 @@ public class ActionLogMessage extends GenericEntity {
@OrderBy("id") @OrderBy("id")
private List<ActionLogMessageResponse> actionLogMessageResponses = new ArrayList<ActionLogMessageResponse>(); 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) @Column(name = "state", nullable = true)
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private ActionLogMessageState state; private ActionLogMessageState state;
...@@ -77,14 +88,6 @@ public class ActionLogMessage extends GenericEntity { ...@@ -77,14 +88,6 @@ public class ActionLogMessage extends GenericEntity {
this.user = user; this.user = user;
} }
public Role getCrew() {
return crew;
}
public void setCrew(Role crew) {
this.crew = crew;
}
public String getMessage() { public String getMessage() {
return message; return message;
} }
...@@ -109,4 +112,11 @@ public class ActionLogMessage extends GenericEntity { ...@@ -109,4 +112,11 @@ public class ActionLogMessage extends GenericEntity {
this.actionLogMessageResponses = actionLogMessageResponses; 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;
}
}
...@@ -195,24 +195,35 @@ public class Bill extends GenericEntity { ...@@ -195,24 +195,35 @@ public class Bill extends GenericEntity {
return total; return total;
} }
public Bill(LanEvent event, EventUser user) { public Bill(LanEvent event, EventUser user, Calendar expires) {
this(event); this(event, expires);
this.setUser(user); this.setUser(user);
this.setAddr1(user.getUser().getFirstnames() + " " + user.getUser().getLastname()); this.setAddr1(user.getUser().getFirstnames() + " " + user.getUser().getLastname());
this.setAddr2(user.getUser().getAddress()); this.setAddr2(user.getUser().getAddress());
this.setAddr3(user.getUser().getZip() + " " + user.getUser().getTown()); this.setAddr3(user.getUser().getZip() + " " + user.getUser().getTown());
} }
public Bill(LanEvent event) { public Bill(LanEvent event, Calendar expires) {
this(); this();
this.expires = expires;
this.event = event; this.event = event;
} }
public Bill(LanEvent event, EventUser user, long expireTimeHours) {
this(event, user, Calendar.getInstance());
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours*60*60 * 1000 )));
}
public Bill(LanEvent event, long expireTimeHours) {
this(event, Calendar.getInstance());
this.expires.setTimeInMillis((System.currentTimeMillis() + (expireTimeHours*60*60 * 1000 )));
}
public Bill() { public Bill() {
super(); super();
this.expires = Calendar.getInstance(); this.expires = Calendar.getInstance();
this.expires.setTimeInMillis((System.currentTimeMillis() + 1814400000l)); // 3vk this.expires.setTimeInMillis((System.currentTimeMillis() + 1209600000)); // 2vk
} }
public Calendar getDueDate() { public Calendar getDueDate() {
...@@ -347,28 +358,6 @@ public class Bill extends GenericEntity { ...@@ -347,28 +358,6 @@ public class Bill extends GenericEntity {
return delayIntrest; return delayIntrest;
} }
public void addProduct(Product product, BigDecimal count) {
this.addProduct(product, count, null);
}
public void addProduct(Product product, BigDecimal count, FoodWave foodwave) {
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
// permbean.fatalPermission(BillPermission.WRITE_ALL,
// "User tried to modify bill ", bill,
// "without sufficient permissions");
// }
if (this.billLines == null) {
billLines = new ArrayList<BillLine>();
}
this.getBillLines().add(new BillLine(this, product, count, foodwave));
for (Discount disc : product.getActiveDiscounts(count, sentDate)) {
this.getBillLines().add(new BillLine(this, product, disc, count));
}
}
public void setBillNumber(Integer billNumber) { public void setBillNumber(Integer billNumber) {
this.billNumber = billNumber; this.billNumber = billNumber;
} }
...@@ -463,3 +452,10 @@ public class Bill extends GenericEntity { ...@@ -463,3 +452,10 @@ public class Bill extends GenericEntity {
...@@ -17,6 +17,7 @@ public enum LanEventPropertyKey { ...@@ -17,6 +17,7 @@ public enum LanEventPropertyKey {
CHECK_BILL_STATS_PERMISSION(Type.BOOL, null), CHECK_BILL_STATS_PERMISSION(Type.BOOL, null),
GATHER_OTHER_BILL_INFO(Type.BOOL, null), GATHER_OTHER_BILL_INFO(Type.BOOL, null),
ALLOW_BILLING(Type.BOOL, null), ALLOW_BILLING(Type.BOOL, null),
BILL_EXPIRE_HOURS(Type.LONG, "168"),
TEMPLATE_PROPERTY1(Type.TEXT, null), TEMPLATE_PROPERTY1(Type.TEXT, null),
TEMPLATE_PROPERTY2(Type.TEXT, null), TEMPLATE_PROPERTY2(Type.TEXT, null),
TEMPLATE_PROPERTY3(Type.TEXT, null), TEMPLATE_PROPERTY3(Type.TEXT, null),
...@@ -26,7 +27,7 @@ public enum LanEventPropertyKey { ...@@ -26,7 +27,7 @@ public enum LanEventPropertyKey {
; ;
private enum Type { private enum Type {
TEXT, DATE, DATA, BOOL TEXT, DATE, DATA, BOOL, LONG
}; };
private final String defaultvalue; private final String defaultvalue;
...@@ -47,6 +48,10 @@ public enum LanEventPropertyKey { ...@@ -47,6 +48,10 @@ public enum LanEventPropertyKey {
public boolean isBoolean() { public boolean isBoolean() {
return Type.BOOL.equals(type); return Type.BOOL.equals(type);
} }
public boolean isLong() {
return Type.LONG.equals(type);
}
private LanEventPropertyKey(Type t, String def) private LanEventPropertyKey(Type t, String def)
{ {
......
...@@ -162,21 +162,6 @@ public class Product extends GenericEntity { ...@@ -162,21 +162,6 @@ public class Product extends GenericEntity {
return tot; return tot;
} }
// TODO: alennukset lasketaan täällä. HUOMHUOM!!
public List<Discount> getActiveDiscounts(BigDecimal quantity, Calendar time) {
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);
}
}
return ret;
}
public BigDecimal getInventoryCount() { public BigDecimal getInventoryCount() {
BigDecimal ret = new BigDecimal(0); BigDecimal ret = new BigDecimal(0);
......
...@@ -97,11 +97,11 @@ ...@@ -97,11 +97,11 @@
</navigation-case> </navigation-case>
</navigation-rule> </navigation-rule>
<navigation-rule> <navigation-rule>
<display-name>actionlog/messagelist</display-name> <display-name>actionlog/index</display-name>
<from-view-id>/actionlog/messagelist.xhtml</from-view-id> <from-view-id>/actionlog/index.xhtml</from-view-id>
<navigation-case> <navigation-case>
<from-outcome>success</from-outcome> <from-outcome>success</from-outcome>
<to-view-id>/actionlog/messagelist.xhtml</to-view-id> <to-view-id>/actionlog/index.xhtml</to-view-id>
<redirect /> <redirect />
</navigation-case> </navigation-case>
</navigation-rule> </navigation-rule>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 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" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> 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> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<!-- f:event type="preRenderView" listener="#{newsListView.initView}" /--> <f:event type="preRenderView"
listener="#{actionLogMessageView.initView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <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> <h1>#{i18n['actionlog.messagelist.header']}</h1>
<p>#{i18n['actionlog.messagelist.description']}</p> <p>#{i18n['actionlog.messagelist.description']}</p>
<h:form id="actionlog_create"> <h:form id="actionlog">
<h2>#{i18n['actionlog.create.header']}</h2> <h2>#{i18n['actionlog.create.header']}</h2>
<h:messages /> <p:messages />
<div class="row"> <h:panelGrid columns="2">
<h3 class="actionlog_create_role">#{i18n['actionlog.create.role']}</h3> <h:panelGrid columns="3">
<h3 class="actionlog_create_message">#{i18n['actionlog.create.message']}</h3> <h:outputText value="#{i18n['actionlog.create.message']}" />
<h3 class="actionlog_create_istask">#{i18n['actionlog.create.taskradio']}</h3> <h:outputText value="#{i18n['actionlog.create.taskradio']}" />
</div> <h:outputText />
<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>
<div class="actionlog_create_message"> <p:inputText value="#{actionLogCreateView.message}" style="width: 400px;" />
<h:inputText value="#{actionLogCreateView.message}" /> <p:selectBooleanCheckbox value="#{actionLogCreateView.task}" />
</div> <h:commandButton class="sendbutton"
action="#{actionLogCreateView.send}"
value="#{i18n['actionlog.create.submitbutton']}" update="@form" />
</h:panelGrid>
<div class="actionlog_create_istask"> <h:panelGrid columns="1">
<h:selectBooleanCheckbox value="#{actionLogCreateView.task}" /> <p:tagCloud model="#{actionLogMessageView.tagCloud}">
</div> <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:panelGroup layout="block">
</h:commandButton> <ui:repeat id="selectedtags" var="tag" value="#{actionLogMessageView.activeTags}">
</div> <!-- <span style="border: 1px solid #0af; display: inline-block; padding: 2px">#{tag.tag}</span> -->
</h:form> <p:commandButton actionListener="#{actionLogMessageView.selectFilterTag(tag.tag)}" value="#{tag.tag}" immediate="true" update="@form" />
<div class="clearfix"></div> </ui:repeat>
<h2>#{i18n['actionlog.tasklist.header']}</h2> </h:panelGroup>
<div id="actionlog"> </h:panelGrid>
<h:form id="refresh"> </h:panelGrid>
<p:poll interval="10" update="actionlogtable" onerror="location.reload();" /> <!-- </h:form>-->
<p:dataTable styleClass="bordertable" rowStyleClass="#{message.state.name}" <div class="clearfix"></div>
id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="30" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="30,50,100" > <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> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{i18n['actionlog.time']}" /> <h:outputText value="#{i18n['actionlog.time']}" />
</f:facet> </f:facet>
<h:outputText value="#{message.time}"> <h:outputText value="#{message.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}"
timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column> <p:column>
...@@ -63,12 +80,6 @@ ...@@ -63,12 +80,6 @@
<h:outputText value="#{message.user.nick}" /> <h:outputText value="#{message.user.nick}" />
</p:column> </p:column>
<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"> <f:facet name="header">
<h:outputText value="#{i18n['actionlog.message']}" /> <h:outputText value="#{i18n['actionlog.message']}" />
...@@ -89,8 +100,8 @@ ...@@ -89,8 +100,8 @@
</h:link> </h:link>
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</h:form> </div>
</div> </h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -30,10 +30,6 @@ ...@@ -30,10 +30,6 @@
<td><h:outputText value="#{taskModificationView.message.user.nick}" /></td> <td><h:outputText value="#{taskModificationView.message.user.nick}" /></td>
</tr> </tr>
<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 class="taskHeader" value="#{i18n['actionlog.state']}: " /></td>
<td><h:outputText value="#{i18n[taskModificationView.message.state.key]}" /></td> <td><h:outputText value="#{i18n[taskModificationView.message.state.key]}" /></td>
</tr> </tr>
...@@ -45,7 +41,7 @@ ...@@ -45,7 +41,7 @@
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<hr style="width: 90%;" /> <hr style="width: 90%;" />
<div> <div>
<h:form> <h:form>
<p:poll interval="1" update="messageresponsetable" onerror="location.reload();" /> <p:poll interval="1" update="messageresponsetable" onerror="location.reload();" />
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<f:event type="preRenderView" listener="#{authView.executeAdduserViewLogin}" /> <f:event type="preRenderView" listener="#{authView.executeAdduserViewLogin}" />
</f:metadata> </f:metadata>
<ui:define name="topbar"> <ui:define name="topbar">
<h:link styleClass="userbackbutton" outcome="/admin/adduser/start"> <h:link styleClass="userbackbutton" outcome="/admin/adduser/index">
<div>#{i18n['adduser.back']}</div> <div>#{i18n['adduser.back']}</div>
</h:link> </h:link>
</ui:define> </ui:define>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<f:event type="preRenderView" listener="#{userView.initCreateView}" /> <f:event type="preRenderView" listener="#{userView.initCreateView}" />
</f:metadata> </f:metadata>
<ui:define name="topbar"> <ui:define name="topbar">
<h:link styleClass="userbackbutton" outcome="/admin/adduser/start"> <h:link styleClass="userbackbutton" outcome="/admin/adduser/index">
<div>#{i18n['adduser.back']}</div> <div>#{i18n['adduser.back']}</div>
</h:link> </h:link>
</ui:define> </ui:define>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</f:metadata> </f:metadata>
<ui:define name="topbar"> <ui:define name="topbar">
<h:link styleClass="userbackbutton" outcome="/admin/adduser/start"> <h:link styleClass="userbackbutton" outcome="/admin/adduser/index">
<div>#{i18n['adduser.back']}</div> <div>#{i18n['adduser.back']}</div>
</h:link> </h:link>
</ui:define> </ui:define>
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
</h:form> </h:form>
</div> </div>
<div style=""> <div style="">
<h:link style="margin: 0 auto; font-size: 3em;" outcome="/admin/adduser/start" value="Valmis"/> <h:link style="margin: 0 auto; font-size: 3em;" outcome="/admin/adduser/index" value="Valmis"/>
</div> </div>
<script> <script>
......
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
<h:form> <h:form>
<p:poll interval="1" listener="#{incomingView.polledRead}" onerror="location.reload();" /> <p:poll interval="1" listener="#{incomingView.polledRead}" onerror="location.reload();" />
</h:form> </h:form>
<h1>#{i18n['incomingflow.userdetails']} (RFID-lukija: #{incomingView.readerId})</h1> <h:form>
<h1>#{i18n['incomingflow.userdetails']} (RFID-lukija: #{incomingView.readerId})</h1><h:commandButton action="#{incomingView.changeReader}" value="#{i18n['incomingflow.changereader']}" />
</h:form>
<h:panelGrid id="cropper" columns="3"> <h:panelGrid id="cropper" columns="3">
<h:panelGroup> <h:panelGroup>
<user:edit id="usereditor" commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" camAlwaysOn="true" /> <user:edit id="usereditor" commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" camAlwaysOn="true" />
...@@ -41,9 +43,9 @@ ...@@ -41,9 +43,9 @@
</h:panelGrid> </h:panelGrid>
<h:outputText rendered="#{empty incomingView.groupMemberships}" value="#{i18n['placegroupview.noMemberships']}" /> <h:outputText rendered="#{empty incomingView.groupMemberships}" value="#{i18n['placegroupview.noMemberships']}" />
<h:form rendered="#{!empty incomingViewgroupMemberships}" id="placelistform"> <h:form rendered="#{!empty incomingView.groupMemberships}" id="placelistform">
<p:dataTable value="#{incomingView.groupMemberships}" var="member"> <p:dataTable value="#{incomingView.groupMemberships}" var="member" rowStyleClass="#{member.enteredEvent != null ? 'success':''}">
<p:column> <p:column>
<f:facet name="header"> <f:facet name="header">
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
<h:outputText rendered="#{prop.key.text}" value="#{prop.textvalue}" /> <h:outputText rendered="#{prop.key.text}" value="#{prop.textvalue}" />
<h:outputText rendered="#{prop.key.boolean and prop.booleanValue}" value="true" /> <h:outputText rendered="#{prop.key.boolean and prop.booleanValue}" value="true" />
<h:outputText rendered="#{prop.key.boolean and ( not prop.booleanValue)}" value="false" /> <h:outputText rendered="#{prop.key.boolean and ( not prop.booleanValue)}" value="false" />
<h:outputText rendered="#{prop.key.long}" value="#{prop.longValue}" />
<h:outputText rendered="#{prop.key.date}" value="#{prop.dateValue}"> <h:outputText rendered="#{prop.key.date}" value="#{prop.dateValue}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
...@@ -130,6 +131,12 @@ ...@@ -130,6 +131,12 @@
<h:outputLabel rendered="#{eventPropertyView.property.key.boolean}" for="booleanval" value="#{i18n['lanEventProperty.booleanValue']}" /> <h:outputLabel rendered="#{eventPropertyView.property.key.boolean}" for="booleanval" value="#{i18n['lanEventProperty.booleanValue']}" />
<h:selectBooleanCheckbox rendered="#{eventPropertyView.property.key.boolean}" id="booleanval" value="#{eventPropertyView.property.booleanValue}" /> <h:selectBooleanCheckbox rendered="#{eventPropertyView.property.key.boolean}" id="booleanval" value="#{eventPropertyView.property.booleanValue}" />
<h:message rendered="#{eventPropertyView.property.key.boolean}" for="booleanval" /> <h:message rendered="#{eventPropertyView.property.key.boolean}" for="booleanval" />
<h:outputLabel rendered="#{eventPropertyView.property.key.long}" for="longval" value="#{i18n['lanEventProperty.longValue']}" />
<h:inputText rendered="#{eventPropertyView.property.key.long}" id="longval" value="#{eventPropertyView.property.longValue}" >
<f:convertNumber type="number" />
</h:inputText>
<h:message rendered="#{eventPropertyView.property.key.long}" for="longval" />
</h:panelGrid> </h:panelGrid>
<h:commandButton action="#{eventPropertyView.saveProperty}" value="#{i18n['lanEventProperty.save']}" /> <h:commandButton action="#{eventPropertyView.saveProperty}" value="#{i18n['lanEventProperty.save']}" />
......
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
<h:inputText id="code" value="#{productView.discount.code}" /> <h:inputText id="code" value="#{productView.discount.code}" />
<h:message for="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:outputLabel for="amountMin" value="#{i18n['discount.amountMin']}:" />
<h:inputText id="amountMin" value="#{productView.discount.amountMin}" required="true" /> <h:inputText id="amountMin" value="#{productView.discount.amountMin}" required="true" />
<h:message for="amountMin" /> <h:message for="amountMin" />
...@@ -54,6 +60,8 @@ ...@@ -54,6 +60,8 @@
<h:outputLabel for="active" value="#{i18n['discount.active']}" /> <h:outputLabel for="active" value="#{i18n['discount.active']}" />
<h:selectBooleanCheckbox id="active" value="#{productView.discount.active}" /> <h:selectBooleanCheckbox id="active" value="#{productView.discount.active}" />
<h:message for="active" /> <h:message for="active" />
</h:panelGrid> </h:panelGrid>
......
...@@ -40,10 +40,9 @@ ...@@ -40,10 +40,9 @@
<h:commandButton action="#{productShopView.addMinusOne}" value="#{i18n['productshop.minusOne']}"> <h:commandButton action="#{productShopView.addMinusOne}" value="#{i18n['productshop.minusOne']}">
<f:ajax render="@form" /> <f:ajax render="@form" />
</h:commandButton> </h:commandButton>
<h:inputText size="4" id="cartcount" value="#{cart.count}"> <h:outputText id="cartcount" escape="false" value="&nbsp;&nbsp;#{cart.count}&nbsp;&nbsp;">
<f:convertNumber maxIntegerDigits="2" minFractionDigits="0" /> <f:convertNumber maxIntegerDigits="2" minFractionDigits="0" />
<f:ajax render="@form" event="valueChange" listener="#{productShopView.updateAllCartLimits()}" /> </h:outputText>
</h:inputText>
<h:commandButton action="#{productShopView.addOne}" value="#{i18n['productshop.plusOne']}"> <h:commandButton action="#{productShopView.addOne}" value="#{i18n['productshop.plusOne']}">
<f:ajax render="@form" /> <f:ajax render="@form" />
</h:commandButton> </h:commandButton>
......
...@@ -45,10 +45,9 @@ ...@@ -45,10 +45,9 @@
<h:outputText value="#{i18n['shop.count']}" /> <h:outputText value="#{i18n['shop.count']}" />
</f:facet> </f:facet>
<p:inplace> <p:inplace>
<p:inputText value="#{prods.count}" size="4"> <h:outputText value="#{prods.count}" size="4">
<f:ajax event="valueChange" render="@form" />
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" /> <f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</p:inputText> </h:outputText>
</p:inplace> </p:inplace>
</p:column> </p:column>
......
...@@ -285,4 +285,10 @@ label { ...@@ -285,4 +285,10 @@ label {
#header_right { #header_right {
text-align: right; text-align: right;
}
.success {
color: #006600;
} }
\ No newline at end of file
...@@ -111,4 +111,8 @@ ...@@ -111,4 +111,8 @@
.paid { .paid {
color: #006600; color: #006600;
}
.success {
color: #006600;
} }
\ No newline at end of file
@CHARSET "utf-8"; @CHARSET "utf-8";
/*
#actionlog_create .row { #actionlog_create .row {
display: block; display: block;
clear: both; clear: both;
...@@ -81,11 +81,11 @@ ...@@ -81,11 +81,11 @@
.taskHeader { .taskHeader {
color: #7DAC0C; color: #7DAC0C;
font-size: 120%; font-size: 120%;
font-weight: bold; font-weight: bold;
} }
.sendbutton2 { .sendbutton2 {
border: 1px solid #aaa; border: 1px solid #aaa;
margin-left: 10px; margin-left: 10px;
} }*/
\ No newline at end of file \ No newline at end of file
...@@ -148,6 +148,9 @@ h1 { ...@@ -148,6 +148,9 @@ h1 {
width: 200px; width: 200px;
} }
nav { nav {
min-width: 200px; min-width: 200px;
background: white; background: white;
...@@ -193,3 +196,13 @@ aside { ...@@ -193,3 +196,13 @@ aside {
th, td { th, td {
padding: 5px; padding: 5px;
} }
#header_center {
position: relative;
text-align: right;
}
#selectLanguage {
padding-left: 10px;
padding-top: 10px;
}
...@@ -79,21 +79,15 @@ ...@@ -79,21 +79,15 @@
</h:link> </h:link>
</div> </div>
<div id="header_center" class="flex1"> <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}"> <ui:fragment rendered="#{layoutView.canManageContent}">
<div> <div>
<h:form> <h:form>
<h:outputLabel for="manageBtn" value="#{i18n['content.showContentEditLinks']}" /> <h:outputLabel for="manageBtn" value="#{i18n['content.showContentEditLinks']}" />
<h:selectBooleanCheckbox value="#{sessionStore.manageContentLinks}" onclick="this.form.submit()" /> <h:selectBooleanCheckbox value="#{sessionStore.manageContentLinks}" onclick="this.form.submit()" />
</h:form> </h:form>
</div> </div>
</ui:fragment> </ui:fragment>
</div> </div>
<div id="header_right"> <div id="header_right">
...@@ -115,6 +109,14 @@ ...@@ -115,6 +109,14 @@
</nav> </nav>
<section id="main" class="flex2"> <section id="main" class="flex2">
<div class="container top"> <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"> <h:link rendered="#{layoutView.manageContent}" styleClass="editorlink" value="#{i18n['layout.editTop']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}:top" /> <f:param name="pagename" value="#{layoutView.pagepath}:top" />
</h:link> </h:link>
......
...@@ -156,8 +156,7 @@ global.notauthorized = You don't have enough rights to enter this site. ...@@ -156,8 +156,7 @@ global.notauthorized = You don't have enough rights to enter this site.
global.save = Save global.save = Save
httpsession.creationTime = Created httpsession.creationTime = Created
incomingflow.giveplace = Merkitse annetuksi
incomingflow.giveplace = Merkitse annetuksi
lanEventPrivateProperty.defaultValue = Default value lanEventPrivateProperty.defaultValue = Default value
lanEventPrivateProperty.editProperty = Edit property lanEventPrivateProperty.editProperty = Edit property
......
...@@ -408,12 +408,13 @@ imagefile.file = Imagefile ...@@ -408,12 +408,13 @@ imagefile.file = Imagefile
importuser.file = File importuser.file = File
importuser.template = Template importuser.template = Template
incomingflow.barcode = Barcode incomingflow.barcode = Barcode
incomingflow.giveplace = Mark given incomingflow.changereader = Change Reader
incomingflow.multisearch = Multisearch incomingflow.giveplace = Mark given
incomingflow.search = Search incomingflow.multisearch = Multisearch
incomingflow.ungiveplace = Mark not given incomingflow.search = Search
incomingflow.userdetails = User details incomingflow.ungiveplace = Mark not given
incomingflow.userdetails = User details
infoview.back = Back infoview.back = Back
infoview.computerplace = Computer places infoview.computerplace = Computer places
...@@ -750,7 +751,7 @@ product.shopInstant = Create automatic cashpayment ...@@ -750,7 +751,7 @@ product.shopInstant = Create automatic cashpayment
product.sort = Sort nr product.sort = Sort nr
product.totalPrice = Total product.totalPrice = Total
product.unitName = Unit name product.unitName = Unit name
product.vat = VAT-% product.vat = VAT-% (0.0 - 0.99)
productFlag.CREATE_NEW_PLACE_WHEN_BOUGHT = Create new place bought productFlag.CREATE_NEW_PLACE_WHEN_BOUGHT = Create new place bought
productFlag.PREPAID_CREDIT = Prepaid credit productFlag.PREPAID_CREDIT = Prepaid credit
......
...@@ -417,12 +417,13 @@ imagefile.file = Kuvatiedosto ...@@ -417,12 +417,13 @@ imagefile.file = Kuvatiedosto
importuser.file = Tiedosto importuser.file = Tiedosto
importuser.template = Malli importuser.template = Malli
incomingflow.barcode = Viivakoodi incomingflow.barcode = Viivakoodi
incomingflow.giveplace = Merkitse annetuksi incomingflow.changereader = Vaihda lukijaa
incomingflow.multisearch = Monihaku incomingflow.giveplace = Merkitse annetuksi
incomingflow.search = Etsi incomingflow.multisearch = Monihaku
incomingflow.ungiveplace = Ei olekkaan annettu incomingflow.search = Etsi
incomingflow.userdetails = K\u00E4ytt\u00E4j\u00E4n tiedot incomingflow.ungiveplace = Ei olekkaan annettu
incomingflow.userdetails = K\u00E4ytt\u00E4j\u00E4n tiedot
index.title = Etusivu index.title = Etusivu
...@@ -734,7 +735,7 @@ product.shopInstant = Luo k\u00E4teismaksu tuotteille ...@@ -734,7 +735,7 @@ product.shopInstant = Luo k\u00E4teismaksu tuotteille
product.sort = J\u00E4rjestys luku product.sort = J\u00E4rjestys luku
product.totalPrice = Summa product.totalPrice = Summa
product.unitName = Tuoteyksikk\u00F6 product.unitName = Tuoteyksikk\u00F6
product.vat = ALV-% product.vat = ALV-% (0.0 - 0.99)
productFlag.CREATE_NEW_PLACE_WHEN_BOUGHT = Luo uusi paikka ostettaessa productFlag.CREATE_NEW_PLACE_WHEN_BOUGHT = Luo uusi paikka ostettaessa
productFlag.PREPAID_CREDIT = Prepaid credit productFlag.PREPAID_CREDIT = Prepaid credit
......
...@@ -22,23 +22,10 @@ public class ActionLogCreateView extends GenericCDIView { ...@@ -22,23 +22,10 @@ public class ActionLogCreateView extends GenericCDIView {
@Size(min=4,message="{actionlog.message.tooshort}") @Size(min=4,message="{actionlog.message.tooshort}")
private String message; private String message;
private Role role;
private boolean task; private boolean task;
private static final long serialVersionUID = 1L; 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() { public String getMessage() {
return message; return message;
} }
...@@ -56,7 +43,7 @@ public class ActionLogCreateView extends GenericCDIView { ...@@ -56,7 +43,7 @@ public class ActionLogCreateView extends GenericCDIView {
} }
public String send() { public String send() {
actionLogBean.createActionLogEvent(message, role, task); actionLogBean.createActionLogEvent(message, task);
return "success"; return "success";
} }
} }
package fi.codecrew.moya.web.cdiview.actionlog; package fi.codecrew.moya.web.cdiview.actionlog;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Named; 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.beans.ActionLogBeanLocal;
import fi.codecrew.moya.enums.apps.ContentPermission; import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.model.ActionLogMessage; import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageTag;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named @Named
@RequestScoped @ConversationScoped
public class ActionLogMessageView extends GenericCDIView { public class ActionLogMessageView extends GenericCDIView {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private boolean updateEnabled = true; private boolean updateEnabled = true;
private TagCloudModel tagCloud = null;
private List<ActionLogMessageTag> activeTags = null;
@EJB @EJB
private transient ActionLogBeanLocal actionLogBean; 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() { public boolean getUpdateEnabled() {
return updateEnabled; return updateEnabled;
} }
...@@ -30,9 +63,32 @@ public class ActionLogMessageView extends GenericCDIView { ...@@ -30,9 +63,32 @@ public class ActionLogMessageView extends GenericCDIView {
} }
public List<ActionLogMessage> getMessages() { public List<ActionLogMessage> getMessages() {
if (super.hasPermission(ContentPermission.MANAGE_ACTIONLOG)) { return actionLogBean.getAllActionLogEventsByFilter(activeTags);
return actionLogBean.getAllActionLogEvents(); }
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;
} }
} }
...@@ -20,9 +20,11 @@ import fi.codecrew.moya.beans.ProductBeanLocal; ...@@ -20,9 +20,11 @@ import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission; import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.model.Bill; import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.FoodWave; import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
import fi.codecrew.moya.web.helper.ProductShopItemHelper;
import fi.codecrew.moya.web.helpers.ProductShopItem; import fi.codecrew.moya.web.helpers.ProductShopItem;
@Named @Named
...@@ -36,6 +38,9 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -36,6 +38,9 @@ public class FoodWaveFoodView extends GenericCDIView {
@EJB @EJB
private FoodWaveBeanLocal foodWaveBean; private FoodWaveBeanLocal foodWaveBean;
@Inject
private ProductShopItemHelper psiHelper;
@EJB @EJB
EventBeanLocal eventBean; EventBeanLocal eventBean;
...@@ -66,7 +71,7 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -66,7 +71,7 @@ public class FoodWaveFoodView extends GenericCDIView {
foodWave = foodWaveBean.findFoodwave(getFoodwaveid()); foodWave = foodWaveBean.findFoodwave(getFoodwaveid());
logger.debug("Foodwave {}", foodWave); 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(); this.beginConversation();
} }
...@@ -99,7 +104,8 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -99,7 +104,8 @@ public class FoodWaveFoodView extends GenericCDIView {
public String add(Integer count) { public String add(Integer count) {
ProductShopItem item = getShoppingcart().getRowData(); ProductShopItem item = getShoppingcart().getRowData();
item.setCount(item.getCount().add(BigDecimal.valueOf(count))); psiHelper.setProductShopItemCount(item, item.getCount().add(BigDecimal.valueOf(count)));
System.out.println("foobar" + item.getCount()); System.out.println("foobar" + item.getCount());
return null; return null;
} }
...@@ -128,12 +134,12 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -128,12 +134,12 @@ public class FoodWaveFoodView extends GenericCDIView {
* @return * @return
*/ */
public Bill createBillFromShoppingcart() { public Bill createBillFromShoppingcart() {
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser()); Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser(), eventBean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_HOURS));
bill.setOurReference(eventBean.getCurrentEvent().getName()); bill.setOurReference(eventBean.getCurrentEvent().getName());
for (ProductShopItem shopitem : shoppingcart) { for (ProductShopItem shopitem : shoppingcart) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) { if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
bill.addProduct(shopitem.getProduct(), shopitem.getCount(), getFoodWave()); billBean.addProductToBill(bill, shopitem.getProduct(), shopitem.getCount(), getFoodWave());
} }
} }
logger.warn("Committing shoppingcart for user {}. Cart prize: {}", userview.getSelectedUser().getWholeName(), bill.getTotalPrice()); logger.warn("Committing shoppingcart for user {}. Cart prize: {}", userview.getSelectedUser().getWholeName(), bill.getTotalPrice());
...@@ -198,4 +204,12 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -198,4 +204,12 @@ public class FoodWaveFoodView extends GenericCDIView {
this.billEditView = billEditView; this.billEditView = billEditView;
} }
public ProductShopItemHelper getPsiHelper() {
return psiHelper;
}
public void setPsiHelper(ProductShopItemHelper psiHelper) {
this.psiHelper = psiHelper;
}
} }
...@@ -31,6 +31,7 @@ import fi.codecrew.moya.web.annotations.SelectedUser; ...@@ -31,6 +31,7 @@ import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView; import fi.codecrew.moya.web.cdiview.reader.ReaderView;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
import fi.codecrew.moya.web.helper.ProductShopItemHelper;
import fi.codecrew.moya.web.helpers.ProductShopItem; import fi.codecrew.moya.web.helpers.ProductShopItem;
@Named @Named
...@@ -53,6 +54,8 @@ public class ProductShopView extends GenericCDIView { ...@@ -53,6 +54,8 @@ public class ProductShopView extends GenericCDIView {
@EJB @EJB
private transient EventBeanLocal eventbean; private transient EventBeanLocal eventbean;
public void cashChanged() public void cashChanged()
{ {
payInstant = false; payInstant = false;
...@@ -78,6 +81,18 @@ public class ProductShopView extends GenericCDIView { ...@@ -78,6 +81,18 @@ public class ProductShopView extends GenericCDIView {
@Inject @Inject
private BillEditView billEditView; private BillEditView billEditView;
@Inject
private ProductShopItemHelper psiHelper;
public ProductShopItemHelper getPsiHelper() {
return psiHelper;
}
public void setPsiHelper(ProductShopItemHelper psiHelper) {
this.psiHelper = psiHelper;
}
private boolean hasLimits = false; private boolean hasLimits = false;
private boolean blip = false; private boolean blip = false;
private ListDataModel<ProductShopItem> boughtItems; private ListDataModel<ProductShopItem> boughtItems;
...@@ -94,7 +109,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -94,7 +109,7 @@ public class ProductShopView extends GenericCDIView {
public void initBillView() { public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS) if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& shoppingcart == null) { && shoppingcart == null) {
shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts())); shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productList(productBean.listUserShoppableProducts(), user));
updateCartLimits(null); updateCartLimits(null);
logger.debug("Initialized billing shoppingcart to {}", shoppingcart); logger.debug("Initialized billing shoppingcart to {}", shoppingcart);
this.beginConversation(); this.beginConversation();
...@@ -137,7 +152,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -137,7 +152,7 @@ public class ProductShopView extends GenericCDIView {
public void initShopView() { public void initShopView() {
if (requirePermissions(ShopPermission.SHOP_TO_OTHERS) && shoppingcart == null) { 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); updateCartLimits(null);
LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH); LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH);
...@@ -151,7 +166,8 @@ public class ProductShopView extends GenericCDIView { ...@@ -151,7 +166,8 @@ public class ProductShopView extends GenericCDIView {
public String add(Integer count) { public String add(Integer count) {
ProductShopItem item = shoppingcart.getRowData(); ProductShopItem item = shoppingcart.getRowData();
item.setCount(item.getCount().add(BigDecimal.valueOf(count)));
psiHelper.setProductShopItemCount(item, item.getCount().add(BigDecimal.valueOf(count)));
updateCartLimits(item); updateCartLimits(item);
return null; return null;
...@@ -196,7 +212,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -196,7 +212,7 @@ public class ProductShopView extends GenericCDIView {
// Update the updated cart first // Update the updated cart first
if (item != null) { if (item != null) {
BigDecimal l = limits.get(item.getProduct().getId()); BigDecimal l = limits.get(item.getProduct().getId());
if (item.updateLimit(l)) { if (psiHelper.updateProductShopItemLimit(item, l)) {
updateCartLimits(null); updateCartLimits(null);
return; return;
} }
...@@ -207,14 +223,16 @@ public class ProductShopView extends GenericCDIView { ...@@ -207,14 +223,16 @@ public class ProductShopView extends GenericCDIView {
if (l != null) { if (l != null) {
hasLimits = true; hasLimits = true;
} }
n.updateLimit(l);
psiHelper.updateProductShopItemLimit(n,l);
} }
} }
public String removeBought() { public String removeBought() {
ProductShopItem row = boughtItems.getRowData(); ProductShopItem row = boughtItems.getRowData();
row.setCount(row.getCount().subtract(BigDecimal.ONE));
psiHelper.setProductShopItemCount(row, row.getCount().subtract(BigDecimal.ONE));
updateCartLimits(row); updateCartLimits(row);
return null; return null;
...@@ -278,13 +296,13 @@ public class ProductShopView extends GenericCDIView { ...@@ -278,13 +296,13 @@ public class ProductShopView extends GenericCDIView {
return null; return null;
} }
Bill bill = new Bill(eventbean.getCurrentEvent(), user); Bill bill = new Bill(eventbean.getCurrentEvent(), user, eventbean.getPropertyLong(LanEventPropertyKey.BILL_EXPIRE_HOURS));
bill.setNotes(otherInfo); bill.setNotes(otherInfo);
bill.setOurReference(eventbean.getCurrentEvent().getName()); bill.setOurReference(eventbean.getCurrentEvent().getName());
for (ProductShopItem shopitem : shoppingcart) { for (ProductShopItem shopitem : shoppingcart) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) { if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
bill.addProduct(shopitem.getProduct(), shopitem.getCount()); billbean.addProductToBill(bill, shopitem.getProduct(), shopitem.getCount());
} }
} }
billbean.createBill(bill); billbean.createBill(bill);
......
...@@ -227,7 +227,7 @@ public class IncomingView extends GenericCDIView { ...@@ -227,7 +227,7 @@ public class IncomingView extends GenericCDIView {
public ListDataModel<GroupMembership> getGroupMemberships() { public ListDataModel<GroupMembership> getGroupMemberships() {
memberlist = new ListDataModel<GroupMembership>( memberlist = new ListDataModel<GroupMembership>(
placegroupBean.getMembershipsAndCreations(user)); placegroupBean.getMembershipsAndCreations(userview.getUser()));
return memberlist; return memberlist;
} }
...@@ -249,4 +249,12 @@ public class IncomingView extends GenericCDIView { ...@@ -249,4 +249,12 @@ public class IncomingView extends GenericCDIView {
return null; return null;
} }
public void changeReader() {
namecontainer.setReaderId(null);
super.navihandler.redirectNavigation("index.jsf");
}
} }
package fi.codecrew.moya.web.helper;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.HashMap;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.DiscountBeanLocal;
import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.helpers.ProductShopItem;
@Named
@ConversationScoped
public class ProductShopItemHelper extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = 1L;
@EJB
private DiscountBeanLocal discountBean;
public void setProductShopItemCount(ProductShopItem item, BigDecimal count) {
if (count == null || count.compareTo(BigDecimal.ZERO) < 0)
{
count = BigDecimal.ZERO;
}
item.setInternalCount(count);
item.setInternalPrice(item.getProduct().getPrice().abs().multiply(count));
item.setInternalDiscounts(discountBean.getActiveDiscountsByProduct(item.getProduct(),count, Calendar.getInstance(), item.getUser()) );
item.setInternalDiscountValues(new HashMap<Integer, BigDecimal>());
for (Discount d : item.getDiscounts())
{
BigDecimal newprice = item.getPrice().multiply(d.getPercentage());
item.getInternalDiscountValues().put(d.getId(), item.getPrice().subtract(newprice));
item.setInternalPrice(newprice);
}
}
public boolean updateProductShopItemLimit(ProductShopItem item, BigDecimal limitValue) {
if (limitValue != null && limitValue.compareTo(BigDecimal.ZERO) < 0)
{
this.setProductShopItemCount(item, item.getCount().add(limitValue));
if (item.getCount().compareTo(BigDecimal.ZERO) < 0) {
this.setProductShopItemCount(item,BigDecimal.ZERO);
}
item.setLimit(BigDecimal.ZERO);
return true;
}
item.setLimit(limitValue);
return false;
}
}
...@@ -2,8 +2,6 @@ package fi.codecrew.moya.web.helpers; ...@@ -2,8 +2,6 @@ package fi.codecrew.moya.web.helpers;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -11,6 +9,7 @@ import org.slf4j.Logger; ...@@ -11,6 +9,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.Discount; import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
public class ProductShopItem { public class ProductShopItem {
...@@ -23,6 +22,7 @@ public class ProductShopItem { ...@@ -23,6 +22,7 @@ public class ProductShopItem {
private Map<Integer, BigDecimal> discountValues; private Map<Integer, BigDecimal> discountValues;
private BigDecimal price; private BigDecimal price;
private BigDecimal limit; private BigDecimal limit;
private EventUser user;
public BigDecimal getCreditPrice() public BigDecimal getCreditPrice()
{ {
...@@ -42,12 +42,13 @@ public class ProductShopItem { ...@@ -42,12 +42,13 @@ public class ProductShopItem {
return BigDecimal.ZERO; return BigDecimal.ZERO;
} }
public ProductShopItem(Product prod) { public ProductShopItem(Product prod, EventUser user) {
super(); super();
this.user = user;
this.product = prod; this.product = prod;
id = this.product.getId(); id = this.product.getId();
setCount(BigDecimal.ZERO); setInternalCount(BigDecimal.ZERO);
setInternalPrice(BigDecimal.ZERO);
} }
/** /**
...@@ -56,21 +57,21 @@ public class ProductShopItem { ...@@ -56,21 +57,21 @@ public class ProductShopItem {
* @param findForStaffshop * @param findForStaffshop
* @return * @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>(); List<ProductShopItem> ret = new ArrayList<ProductShopItem>();
for (Product prod : products) { for (Product prod : products) {
if (prod.getPrice().compareTo(BigDecimal.ZERO) >= 0) { if (prod.getPrice().compareTo(BigDecimal.ZERO) >= 0) {
ret.add(new ProductShopItem(prod)); ret.add(new ProductShopItem(prod, user));
} }
} }
return ret; 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>(); List<ProductShopItem> ret = new ArrayList<ProductShopItem>();
for (Product prod : products) { for (Product prod : products) {
ret.add(new ProductShopItem(prod)); ret.add(new ProductShopItem(prod, user));
} }
return ret; return ret;
...@@ -80,36 +81,35 @@ public class ProductShopItem { ...@@ -80,36 +81,35 @@ public class ProductShopItem {
return this.product; return this.product;
} }
public void setCount(BigDecimal count) { /**
* DO NOT USE THIS.
if (count == null || count.compareTo(BigDecimal.ZERO) < 0) *
{ * Use ProductShopIteHelper.setProductShopItemCount instead.
count = BigDecimal.ZERO; * @param count
} */
public void setInternalCount(BigDecimal count) {
this.count = count; this.count = count;
price = product.getPrice().abs().multiply(count);
discounts = product.getActiveDiscounts(count, Calendar.getInstance());
discountValues = new HashMap<Integer, BigDecimal>();
for (Discount d : discounts)
{
BigDecimal newprice = price.multiply(d.getPercentage());
discountValues.put(d.getId(), price.subtract(newprice));
price = newprice;
}
} }
public void setInternalPrice(BigDecimal price) {
this.price = price;
}
public List<Discount> getDiscounts() public List<Discount> getDiscounts()
{ {
return discounts; return discounts;
} }
public void setInternalDiscounts(List<Discount> discounts) {
this.discounts = discounts;
}
public BigDecimal getDiscount(Integer discId) public BigDecimal getDiscount(Integer discId)
{ {
return discountValues.get(discId); return discountValues.get(discId);
} }
public BigDecimal getPrice() public BigDecimal getPrice()
{ {
return price; return price;
...@@ -138,19 +138,19 @@ public class ProductShopItem { ...@@ -138,19 +138,19 @@ public class ProductShopItem {
return limit; return limit;
} }
public boolean updateLimit(BigDecimal limitValue) { public EventUser getUser() {
return user;
}
if (limitValue != null && limitValue.compareTo(BigDecimal.ZERO) < 0) public void setUser(EventUser user) {
{ this.user = user;
logger.info("product limit {}, count {}", limitValue, count); }
setCount(getCount().add(limitValue));
if (count.compareTo(BigDecimal.ZERO) < 0) { public Map<Integer, BigDecimal> getInternalDiscountValues() {
setCount(BigDecimal.ZERO); return discountValues;
} }
limit = BigDecimal.ZERO;
return true; public void setInternalDiscountValues(Map<Integer, BigDecimal> discountValues) {
} this.discountValues = discountValues;
limit = limitValue;
return false;
} }
} }
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
<string name="seenInMoya">(as seen in Moya)</string> <string name="seenInMoya">(as seen in Moya)</string>
<string name="shared_pref_readername">readername</string> <string name="shared_pref_readername">readername</string>
<string name="change">Change</string> <string name="change">Change</string>
<string name="success">Success</string> <string name="success">Success!</string>
</resources> </resources>
...@@ -5,12 +5,13 @@ import org.apache.http.HttpResponse; ...@@ -5,12 +5,13 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.StrictMode;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
...@@ -18,10 +19,16 @@ import android.widget.EditText; ...@@ -18,10 +19,16 @@ import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
public class MainActivity extends Activity { public class MainActivity extends Activity {
private static String URL = "http://demo.codecrew.fi/MoyaWeb/shop/rfidListener.jsf"; private static String URL = "http://lantrek.moya.fi/MoyaWeb/shop/rfidListener.jsf";
@SuppressLint("NewApi")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
...@@ -116,11 +123,13 @@ public class MainActivity extends Activity { ...@@ -116,11 +123,13 @@ public class MainActivity extends Activity {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e);
} }
return false; return false;
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!