Commit b197f1a6 by Tuomas Riihimäki

Random stuff.

1 parent 0cbebcb7
Showing with 212 additions and 98 deletions
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.eclipse.wst.validation.validationbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
...@@ -26,5 +31,6 @@ ...@@ -26,5 +31,6 @@
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
...@@ -72,6 +72,8 @@ public class BillBean implements BillBeanLocal { ...@@ -72,6 +72,8 @@ public class BillBean implements BillBeanLocal {
private LoggingBeanLocal loggingBean; private LoggingBeanLocal loggingBean;
@EJB @EJB
private EventUserFacade eventUserFacade; private EventUserFacade eventUserFacade;
@EJB
private ProductPBean productPBean;
/** /**
* Default constructor. * Default constructor.
...@@ -238,7 +240,7 @@ public class BillBean implements BillBeanLocal { ...@@ -238,7 +240,7 @@ public class BillBean implements BillBeanLocal {
placebean.lockPlaceProduct(bill.getUser(), prod, bl.getQuantity()); placebean.lockPlaceProduct(bill.getUser(), prod, bl.getQuantity());
} }
AccountEvent ac2 = productBean.createAccountEvent(prod, bl.getQuantity(), user, bill.getSentDate()); AccountEvent ac2 = productPBean.createAccountEvent(prod, bl.getQuantity(), user, bill.getSentDate());
logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size()); logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size());
ac2.setSeller(permbean.getCurrentUser()); ac2.setSeller(permbean.getCurrentUser());
......
...@@ -86,9 +86,9 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -86,9 +86,9 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
@Override @Override
public boolean isPaymentEnabled() public boolean isPaymentEnabled()
{ {
LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.CHECKOUT_FI_KEY_EXPIRE); final LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.CHECKOUT_FI_KEY_EXPIRE);
String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_ID); final String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_ID);
String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_PASSWORD); final String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_PASSWORD);
return !((expire != null && new Date().after(expire.getDateValue())) return !((expire != null && new Date().after(expire.getDateValue()))
|| merchantid == null || merchantid.isEmpty() || merchantid == null || merchantid.isEmpty()
|| merchantPassword == null || merchantPassword.isEmpty()); || merchantPassword == null || merchantPassword.isEmpty());
...@@ -107,24 +107,25 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -107,24 +107,25 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
@RolesAllowed(BillPermission.S_CREATE_VERKKOMAKSU) @RolesAllowed(BillPermission.S_CREATE_VERKKOMAKSU)
public List<CheckoutBank> getToken(Bill bill) public List<CheckoutBank> getToken(Bill bill)
{ {
LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.CHECKOUT_FI_KEY_EXPIRE); final LanEventPrivateProperty expire = eventbean.getPrivateProperty(LanEventPrivatePropertyKey.CHECKOUT_FI_KEY_EXPIRE);
String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_ID); final String merchantid = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_ID);
String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_PASSWORD); final String merchantPassword = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.CHECKOUT_FI_MERCHANT_PASSWORD);
if ((expire != null && new Date().after(expire.getDateValue())) if ((expire != null && new Date().after(expire.getDateValue()))
|| merchantid == null || merchantid.isEmpty() || merchantid == null || merchantid.isEmpty()
|| merchantPassword == null || merchantPassword.isEmpty()) || merchantPassword == null || merchantPassword.isEmpty())
{ {
return null; return null;
} }
String priceInCents = Integer.valueOf(bill.totalPrice().multiply(TO_CENTS).intValue()).toString(); final String priceInCents = Integer.valueOf(bill.totalPrice().multiply(TO_CENTS).intValue()).toString();
Map<CheckoutFiParam, String> postParams = new HashMap<CheckoutFiParam, String>(); final Map<CheckoutFiParam, String> postParams = new HashMap<CheckoutFiParam, String>();
String returnUrl = new StringBuilder(BortalLocalContextHolder.isSsl() ? "https://" : "http://") final String returnUrl = new StringBuilder(BortalLocalContextHolder.isSsl() ? "https://" : "http://")
.append(BortalLocalContextHolder.getHostname()) .append(BortalLocalContextHolder.getHostname())
.append("/LanBortalWeb/checkout/") .append("/LanBortalWeb/checkout/")
.toString(); .toString();
StringBuilder stamp = new StringBuilder(); final StringBuilder stamp = new StringBuilder();
stamp.append(bill.getId()); stamp.append(bill.getId());
stamp.append(STAMP_SPLITCHAR); stamp.append(STAMP_SPLITCHAR);
stamp.append(bill.getSentDate().getTimeInMillis() / 1000); stamp.append(bill.getSentDate().getTimeInMillis() / 1000);
...@@ -167,14 +168,16 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal { ...@@ -167,14 +168,16 @@ public class CheckoutFiBean implements CheckoutFiBeanLocal {
nameValuePairs.add(new BasicNameValuePair("MAC", calculatedHash)); nameValuePairs.add(new BasicNameValuePair("MAC", calculatedHash));
HttpPost postRequest = new HttpPost(REMOTE_URL); final HttpPost postRequest = new HttpPost(REMOTE_URL);
postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs)); postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs));
DefaultHttpClient client = new DefaultHttpClient();
final DefaultHttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(postRequest); HttpResponse response = client.execute(postRequest);
StringWriter writer = new StringWriter(); final StringWriter writer = new StringWriter();
IOUtils.copy(response.getEntity().getContent(), writer, "UTF8"); IOUtils.copy(response.getEntity().getContent(), writer, "UTF8");
String xmlReturn = writer.toString();
final String xmlReturn = writer.toString();
// logger.info("Got response from checkout.fi msg {}, {} ", // logger.info("Got response from checkout.fi msg {}, {} ",
// response.getStatusLine().getStatusCode(), xmlReturn); // response.getStatusLine().getStatusCode(), xmlReturn);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
...@@ -53,9 +54,11 @@ import fi.insomnia.bortal.model.ProductFlag; ...@@ -53,9 +54,11 @@ import fi.insomnia.bortal.model.ProductFlag;
*/ */
@Stateless @Stateless
@LocalBean @LocalBean
@DeclareRoles({ MapPermission.S_BUY_PLACES, @DeclareRoles({
MapPermission.S_BUY_PLACES,
MapPermission.S_MANAGE_MAPS, MapPermission.S_MANAGE_MAPS,
MapPermission.S_VIEW, MapPermission.S_VIEW,
MapPermission.S_MANAGE_OTHERS,
}) })
public class PlaceBean implements PlaceBeanLocal { public class PlaceBean implements PlaceBeanLocal {
private static final String PLACE_RESERVE_TIMEOUTER = "Map reserve timeouter"; private static final String PLACE_RESERVE_TIMEOUTER = "Map reserve timeouter";
...@@ -93,6 +96,8 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -93,6 +96,8 @@ public class PlaceBean implements PlaceBeanLocal {
private AccountEventBeanLocal acbean; private AccountEventBeanLocal acbean;
@EJB @EJB
private PlaceGroupFacade pgfacade; private PlaceGroupFacade pgfacade;
@EJB
private ProductPBean productPBean;
@Override @Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS) @RolesAllowed(MapPermission.S_MANAGE_MAPS)
...@@ -231,12 +236,12 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -231,12 +236,12 @@ public class PlaceBean implements PlaceBeanLocal {
// } // }
@Override @Override
@RolesAllowed(MapPermission.S_BUY_PLACES) @RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS })
public PlaceGroup buySelectedPlaces(EventUser user) throws BortalCatchableException { public PlaceGroup buySelectedPlaces(EventUser user) throws BortalCatchableException {
if (user == null) { if (user == null) {
user = permbean.getCurrentUser(); user = permbean.getCurrentUser();
} else { } else {
if (!user.equals(permbean.getCurrentUser())) { if (!user.equals(permbean.getCurrentUser()) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Can not buy places for user " + user); loggerbean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Can not buy places for user " + user);
throw new EJBAccessException("Not enough permissions to buy place"); throw new EJBAccessException("Not enough permissions to buy place");
} }
...@@ -253,13 +258,13 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -253,13 +258,13 @@ public class PlaceBean implements PlaceBeanLocal {
BigDecimal totalprice = addAndCalcPrice(user, null); BigDecimal totalprice = addAndCalcPrice(user, null);
BigDecimal balance = user.getAccountBalance(); BigDecimal balance = user.getAccountBalance();
if (balance.compareTo(totalprice) < 0) { if (balance.compareTo(totalprice) < 0 && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
logger.info("User {} Could not buy things because account balance {} is too low for purchase {}", new Object[] { user, balance, totalprice }); logger.info("User {} Could not buy things because account balance {} is too low for purchase {}", new Object[] { user, balance, totalprice });
return null;
} }
for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) { for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) {
productBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user); productPBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user, Calendar.getInstance());
} }
PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true); PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true);
...@@ -357,6 +362,13 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -357,6 +362,13 @@ public class PlaceBean implements PlaceBeanLocal {
GroupMembership membership = new GroupMembership(pg, p, gmemfacade.createInviteToken()); GroupMembership membership = new GroupMembership(pg, p, gmemfacade.createInviteToken());
pg.getMembers().add(membership); pg.getMembers().add(membership);
p.setPlaceReserver(membership); p.setPlaceReserver(membership);
if (pg.getPlaces() == null) {
pg.setPlaces(new ArrayList<Place>());
}
if (!pg.getPlaces().contains(p))
{
pg.getPlaces().add(p);
}
return membership; return membership;
} }
......
...@@ -23,6 +23,7 @@ import com.pdfjet.TextLine; ...@@ -23,6 +23,7 @@ import com.pdfjet.TextLine;
import fi.insomnia.bortal.enums.apps.MapPermission; import fi.insomnia.bortal.enums.apps.MapPermission;
import fi.insomnia.bortal.enums.apps.SpecialPermission; import fi.insomnia.bortal.enums.apps.SpecialPermission;
import fi.insomnia.bortal.facade.EventUserFacade;
import fi.insomnia.bortal.facade.GroupMembershipFacade; import fi.insomnia.bortal.facade.GroupMembershipFacade;
import fi.insomnia.bortal.facade.PlaceGroupFacade; import fi.insomnia.bortal.facade.PlaceGroupFacade;
import fi.insomnia.bortal.model.EventUser; import fi.insomnia.bortal.model.EventUser;
...@@ -53,6 +54,8 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -53,6 +54,8 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
private LoggingBeanLocal loggerbean; private LoggingBeanLocal loggerbean;
@EJB @EJB
private PlaceGroupFacade pgfacade; private PlaceGroupFacade pgfacade;
@EJB
private EventUserFacade eventuserfacade;
/** /**
* Default constructor. * Default constructor.
...@@ -102,17 +105,18 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal { ...@@ -102,17 +105,18 @@ public class PlaceGroupBean implements PlaceGroupBeanLocal {
@Override @Override
@RolesAllowed(MapPermission.S_BUY_PLACES) @RolesAllowed(MapPermission.S_BUY_PLACES)
public boolean associateToToken(EventUser user, String token) { public boolean associateToToken(EventUser user, String token) {
user = eventuserfacade.reload(user);
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) { if (!permbean.isCurrentUser(user) && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
throw new EJBAccessException(); throw new EJBAccessException();
} }
token = token.trim(); token = token.trim();
GroupMembership mem = gmemfacade.findByToken(token); GroupMembership mem = gmemfacade.findByToken(token);
boolean ret = false; boolean ret = false;
if (mem != null && mem.getUser() == null) { if (mem != null && mem.getUser() == null) {
mem.setUser(user); mem.setUser(user);
gmemfacade.merge(mem); // gmemfacade.merge(mem);
ret = true; ret = true;
} }
......
...@@ -2,7 +2,6 @@ package fi.insomnia.bortal.beans; ...@@ -2,7 +2,6 @@ package fi.insomnia.bortal.beans;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -28,7 +27,6 @@ import fi.insomnia.bortal.facade.ProductFacade; ...@@ -28,7 +27,6 @@ import fi.insomnia.bortal.facade.ProductFacade;
import fi.insomnia.bortal.facade.UserFacade; import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.AccountEvent; import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount; import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.DiscountInstance;
import fi.insomnia.bortal.model.EventUser; import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.LanEvent; import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product; import fi.insomnia.bortal.model.Product;
...@@ -78,6 +76,8 @@ public class ProductBean implements ProductBeanLocal { ...@@ -78,6 +76,8 @@ public class ProductBean implements ProductBeanLocal {
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
@EJB @EJB
private BillLineFacade billLineFacade; private BillLineFacade billLineFacade;
@EJB
private ProductPBean productPBean;
private static final Logger logger = LoggerFactory.getLogger(ProductBean.class); private static final Logger logger = LoggerFactory.getLogger(ProductBean.class);
...@@ -290,36 +290,6 @@ public class ProductBean implements ProductBeanLocal { ...@@ -290,36 +290,6 @@ public class ProductBean implements ProductBeanLocal {
// return ret; // return ret;
// } // }
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Calendar date) {
BigDecimal unitPrice = product.getPrice().negate();
List<Discount> discounts = product.getActiveDiscounts(quantity, date);
for (Discount d : discounts) {
unitPrice = unitPrice.multiply(d.getPercentage());
}
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, Calendar.getInstance());
ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser());
List<DiscountInstance> accEventdiscounts = ret.getDiscountInstances();
for (Discount d : discounts) {
// discountsArray.add(discInst);
// discountinstancefacade.create(discInst);
accEventdiscounts.add(new DiscountInstance(ret, d));
}
if (user.getAccountEvents() == null) {
user.setAccountEvents(new ArrayList<AccountEvent>());
}
user.getAccountEvents().add(ret);
accounteventfacade.create(ret);
// flush changes to db.
// userFacade.flush();
return ret;
}
@Override @Override
public Product findById(int id) { public Product findById(int id) {
Product ret = productFacade.find(id); Product ret = productFacade.find(id);
...@@ -354,14 +324,15 @@ public class ProductBean implements ProductBeanLocal { ...@@ -354,14 +324,15 @@ public class ProductBean implements ProductBeanLocal {
@Override @Override
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user) { public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user) {
return createAccountEvent(product, quantity, user, Calendar.getInstance()); user = eventUserFacade.reload(user);
AccountEvent ret = productPBean.createAccountEvent(product, quantity, user, Calendar.getInstance());
return ret;
} }
@Override @Override
//@RolesAllowed(ShopPermission.S_LIST_ALL_PRODUCTS) // @RolesAllowed(ShopPermission.S_LIST_ALL_PRODUCTS)
public Product findByBarcode(String barcode) { public Product findByBarcode(String barcode) {
return productFacade.findProductByBarcode(barcode); return productFacade.findProductByBarcode(barcode);
} }
} }
package fi.insomnia.bortal.beans;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.AccountEventFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.DiscountInstance;
import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.Product;
/**
* Session Bean implementation class ProductPBean
*/
@Stateless
@LocalBean
public class ProductPBean {
@EJB
private PermissionBean permbean;
private AccountEventFacade accounteventfacade;
/**
* Default constructor.
*/
public ProductPBean() {
// TODO Auto-generated constructor stub
}
/**
* Creates new AccountEvent from provided product to provided user <br>
* <strong>Notice</strong>, that this function expects the user parameter to
* be attached entity!
*
* @param product
* Product to create the account event from
* @param quantity
* How many products have been bought
* @param user
* user to whom the product should be created. MUST BE ATTACHED
* ENTITY!
* @param date
* AccountEvent creation time
* @return The created AccountEvent entity
*/
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Calendar date) {
BigDecimal unitPrice = product.getPrice().negate();
List<Discount> discounts = product.getActiveDiscounts(quantity, date);
for (Discount d : discounts) {
unitPrice = unitPrice.multiply(d.getPercentage());
}
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, Calendar.getInstance());
ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser());
List<DiscountInstance> accEventdiscounts = ret.getDiscountInstances();
for (Discount d : discounts) {
// discountsArray.add(discInst);
// discountinstancefacade.create(discInst);
accEventdiscounts.add(new DiscountInstance(ret, d));
}
if (user.getAccountEvents() == null) {
user.setAccountEvents(new ArrayList<AccountEvent>());
}
user.getAccountEvents().add(ret);
accounteventfacade.create(ret);
// flush changes to db.
// userFacade.flush();
return ret;
}
}
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.eclipse.wst.validation.validationbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
...@@ -26,5 +31,6 @@ ...@@ -26,5 +31,6 @@
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
...@@ -36,9 +36,9 @@ public interface ProductBeanLocal { ...@@ -36,9 +36,9 @@ public interface ProductBeanLocal {
// List<Discount> getActiveDiscounts(Product product, BigDecimal quantity); // List<Discount> getActiveDiscounts(Product product, BigDecimal quantity);
Product findById(int parseInt); Product findById(int parseInt);
Product findByBarcode(String barcode); Product findByBarcode(String barcode);
List<Product> findForStaffshop(); List<Product> findForStaffshop();
Discount findDiscount(Integer discountid); Discount findDiscount(Integer discountid);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
...@@ -43,5 +48,6 @@ ...@@ -43,5 +48,6 @@
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.axdt.as3.imp.nature</nature> <nature>org.axdt.as3.imp.nature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
Manifest-Version: 1.0 Manifest-Version: 1.0
Class-Path: lib/LanBortalUtilities.jar Class-Path: bcprov-jdk16-146.jar
bcprov-jdk16-146.jar bcmail-jdk16-146.jar
bcmail-jdk16-146.jar LanBortalUtilities.jar
...@@ -26,7 +26,9 @@ public abstract class EntityEquals { ...@@ -26,7 +26,9 @@ public abstract class EntityEquals {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
boolean ret = false; boolean ret = false;
if (o != null && o instanceof EntityEquals && this.getClass().getCanonicalName().equals(o.getClass().getCanonicalName())) { if (this == o) {
ret = true;
} else if (o != null && o instanceof EntityEquals && this.getClass().getCanonicalName().equals(o.getClass().getCanonicalName())) {
EntityEquals oobj = (EntityEquals) o; EntityEquals oobj = (EntityEquals) o;
if (getId() == null) { if (getId() == null) {
ret = (getRndid().equals(oobj.rndid)); ret = (getRndid().equals(oobj.rndid));
......
...@@ -16,7 +16,6 @@ import javax.persistence.OneToOne; ...@@ -16,7 +16,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.OptimisticLocking; import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType; import org.eclipse.persistence.annotations.OptimisticLockingType;
...@@ -25,7 +24,9 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -25,7 +24,9 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
* *
*/ */
@Entity @Entity
@Table(name = "group_memberships", uniqueConstraints = { @UniqueConstraint(columnNames = { GroupMembership.EVENTUSER_ID, GroupMembership.GROUP_ID }) }) @Table(name = "group_memberships")
// , uniqueConstraints = { @UniqueConstraint(columnNames = {
// GroupMembership.EVENTUSER_ID, GroupMembership.GROUP_ID }) })
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class GroupMembership extends GenericEntity { public class GroupMembership extends GenericEntity {
......
...@@ -17,7 +17,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -17,7 +17,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.eclipse.persistence.annotations.PrivateOwned; import org.eclipse.persistence.annotations.PrivateOwned;
@Entity @Entity
@Table(name = "site_pages", uniqueConstraints = @UniqueConstraint(columnNames = { "event_id", "name" })) @Table(name = "site_pages", uniqueConstraints = @UniqueConstraint(columnNames = { SitePage.EVENT_ID_COLUMN, "name" }))
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class SitePage extends GenericEntity { public class SitePage extends GenericEntity {
......
...@@ -5,7 +5,7 @@ import javax.persistence.metamodel.ListAttribute; ...@@ -5,7 +5,7 @@ import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel; import javax.persistence.metamodel.StaticMetamodel;
@Generated(value="Dali", date="2012-05-12T14:43:39.125+0300") @Generated(value="Dali", date="2012-10-04T21:02:39.749+0300")
@StaticMetamodel(SitePage.class) @StaticMetamodel(SitePage.class)
public class SitePage_ extends GenericEntity_ { public class SitePage_ extends GenericEntity_ {
public static volatile SingularAttribute<SitePage, LanEvent> event; public static volatile SingularAttribute<SitePage, LanEvent> event;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
...@@ -32,5 +37,6 @@ ...@@ -32,5 +37,6 @@
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.axdt.as3.imp.nature</nature> <nature>org.axdt.as3.imp.nature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
<h:inputTextarea value="#{placeView.place.group.details}" /> <h:inputTextarea value="#{placeView.place.group.details}" />
<h:outputLabel value="#{i18n['placegroup.creator']}" /> <h:outputLabel value="#{i18n['placegroup.creator']}" />
<h:link outcome="/user/edit" value="#{placeView.place.group.creator.wholeName}" > <h:link outcome="/useradmin/edit" value="#{placeView.place.group.creator.wholeName}" >
<f:param name="userid" value="#{placeView.place.group.creator.id}"/> <f:param name="userid" value="#{placeView.place.group.creator.id}"/>
</h:link> </h:link>
</h:panelGrid> </h:panelGrid>
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
<h:column> <h:column>
<h:outputText rendered="#{empty place.placeReserver.user}" value="#{i18n['place.noReserver']}" /> <h:outputText rendered="#{empty place.placeReserver.user}" value="#{i18n['place.noReserver']}" />
<h:link rendered="#{!empty place.placeReserver.user}" outcome="/user/edit"> <h:link rendered="#{!empty place.placeReserver.user}" outcome="/useradmin/edit">
<h:outputText value="#{place.placeReserver.user.wholeName}" /> <h:outputText value="#{place.placeReserver.user.wholeName}" />
(<h:outputText value="#{place.placeReserver.user.nick}" />) (<h:outputText value="#{place.placeReserver.user.nick}" />)
<f:param name="userid" value="#{place.placeReserver.user.user.id}" /> <f:param name="userid" value="#{place.placeReserver.user.user.id}" />
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
<div style="margin-top: 5px;"> <div style="margin-top: 5px;">
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-top" value="#{cc.attrs.commitValue}" /> <h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-top" value="#{cc.attrs.commitValue}" />
</div> </div>
<h:dataTable columnClasses=",numalign,numalign,,numalign" styleClass="bordertable" id="billcart" value="#{cc.attrs.items}" var="cart">
<h:dataTable columnClasses="nowrap,numalign,numalign,nowrap,numalign" styleClass="bordertable" id="billcart" value="#{cc.attrs.items}" var="cart">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText id="name" value="${i18n['product.name']}" /> <h:outputText id="name" value="${i18n['product.name']}" />
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<h2>#{i18n['role.permissionheader']}</h2> <h2>#{i18n['role.permissionheader']}</h2>
<p> <p>
<h:form id="permissionform"> <h:form id="permissionform">
<h:commandButton id="save" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" /> <h:commandButton id="save1" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
<h:dataTable border="1" id="bortalApps" value="#{roleView.rolePermissions}" var="bapp"> <h:dataTable border="1" id="bortalApps" value="#{roleView.rolePermissions}" var="bapp">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<!-- </ui:repeat> --> <!-- </ui:repeat> -->
<!-- </h:column> --> <!-- </h:column> -->
</h:dataTable> </h:dataTable>
<h:commandButton id="save" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" /> <h:commandButton id="save2" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
</h:form> </h:form>
</p> </p>
......
...@@ -172,7 +172,7 @@ a:hover { ...@@ -172,7 +172,7 @@ a:hover {
width: 100%; width: 100%;
background: url(../img/container-top.png) no-repeat; background: url(../img/container-top.png) no-repeat;
height: 15px; height: 15px;
padding-left: 1em; padding-left: 1em;
} }
.container.bottom { .container.bottom {
...@@ -231,7 +231,7 @@ td ul { ...@@ -231,7 +231,7 @@ td ul {
#right ul { #right ul {
color: #7dac0c; color: #7dac0c;
list-style-type: square; list-style-type: square;
list-style-position:inside; list-style-position: inside;
} }
#right ul li { #right ul li {
...@@ -240,19 +240,22 @@ td ul { ...@@ -240,19 +240,22 @@ td ul {
#right ul li a { #right ul li a {
color: #0073bc; color: #0073bc;
text-decoration: none; text-decoration: none;
} }
#right ul li a:hover { #right ul li a:hover {
color: #7dac0c; color: #7dac0c;
text-decoration: none; text-decoration: none;
} }
table { table {
border-collapse: collapse; border-collapse: collapse;
} }
table.border td,table.border th { table.border td,table.border th {
padding: 1px 4px; padding: 1px 4px;
}
.nowrap {
white-space: nowrap;
} }
\ No newline at end of file
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
<h:form id="shoppingcartform"> <h:form id="shoppingcartform">
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.accountBalance']}" /> <h:outputLabel value="#{i18n['shop.accountBalance']}" />
...@@ -47,7 +44,6 @@ ...@@ -47,7 +44,6 @@
<f:ajax render="@form" event="valueChange" /> <f:ajax render="@form" event="valueChange" />
<f:convertNumber /> <f:convertNumber />
</h:inputText> </h:inputText>
</h:panelGrid> </h:panelGrid>
<h:panelGroup> <h:panelGroup>
<h:outputLabel value="#{i18n['shop.readBarcode']}" /> <h:outputLabel value="#{i18n['shop.readBarcode']}" />
......
...@@ -22,6 +22,7 @@ import fi.insomnia.bortal.exceptions.BortalCatchableException; ...@@ -22,6 +22,7 @@ import fi.insomnia.bortal.exceptions.BortalCatchableException;
import fi.insomnia.bortal.model.EventMap; import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventUser; import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.Place; import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.utilities.SearchQuery; import fi.insomnia.bortal.utilities.SearchQuery;
import fi.insomnia.bortal.web.annotations.SelectedUser; import fi.insomnia.bortal.web.annotations.SelectedUser;
...@@ -105,20 +106,18 @@ public class PlaceView extends GenericCDIView { ...@@ -105,20 +106,18 @@ public class PlaceView extends GenericCDIView {
price = placebean.getTotalReservationPrice(place); price = placebean.getTotalReservationPrice(place);
} else { } else {
price = placebean.getTotalReservationPrice(user, place); price = placebean.getTotalReservationPrice(user, place);
} }
logger.debug("Balance {}, price {}", balance, price); logger.debug("Balance {}, price {}", balance, price);
if (price.compareTo(balance) <= 0) { if (price.compareTo(balance) <= 0) {
logger.debug("Place was free. Marking for user."); logger.debug("Place was free. Marking for user.");
if (!placebean.reservePlace(place, user)) { if (!placebean.reservePlace(place, user)) {
this.addFaceMessage("mapView.errorWhenReservingPlace"); this.addFaceMessage("mapView.errorWhenReservingPlace");
} }
} else { } else {
if (balance.compareTo(BigDecimal.ZERO) > 0) { if (balance.compareTo(BigDecimal.ZERO) > 0) {
addFaceMessage("mapView.notEnoughCreditsToReserve"); addFaceMessage("mapView.notEnoughCreditsToReserve");
} }
logger.debug("Did not have enought money to reserve place! required {} , got {}", price, balance); logger.debug("Did not have enought credits to reserve place! required {} , got {}", price, balance);
} }
} }
} }
...@@ -140,7 +139,12 @@ public class PlaceView extends GenericCDIView { ...@@ -140,7 +139,12 @@ public class PlaceView extends GenericCDIView {
try { try {
EventUser user = userbean.getEventUser(userlist.getRowData()); EventUser user = userbean.getEventUser(userlist.getRowData());
if (placebean.reservePlace(place, user)) { if (placebean.reservePlace(place, user)) {
placebean.buySelectedPlaces(user); PlaceGroup newgroup = placebean.buySelectedPlaces(user);
for (Place p : newgroup.getPlaces()) {
if (p.equals(place)) {
place = p;
}
}
} }
} catch (BortalCatchableException e) { } catch (BortalCatchableException e) {
......
...@@ -33,13 +33,12 @@ public class TokenView extends GenericCDIView { ...@@ -33,13 +33,12 @@ public class TokenView extends GenericCDIView {
return null; return null;
} }
String ret = "myGroups"; // String ret = "myGroups";
if (!placegroupbean.associateToToken(user, getToken())) { if (!placegroupbean.associateToToken(user, getToken())) {
this.addFaceMessage("placetoken.tokenNotFound"); this.addFaceMessage("placetoken.tokenNotFound");
ret = null;
} }
return ret; return null;
} }
public void setToken(String token) { public void setToken(String token) {
......
...@@ -176,15 +176,13 @@ public class ProductShopView extends GenericCDIView { ...@@ -176,15 +176,13 @@ public class ProductShopView extends GenericCDIView {
EventUser retuser = null; EventUser retuser = null;
for (ProductShopItem shopitem : shoppingcart) { for (ProductShopItem shopitem : shoppingcart) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) { if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
retuser = productBean.createAccountEvent(shopitem.getProduct(), retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user).getUser();
shopitem.getCount(), user).getUser();
} }
} }
if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) { if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) {
Product credProd = productBean.findCreditProduct(); Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user) retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
.getUser();
} }
if (user != null) { if (user != null) {
user = retuser; user = retuser;
......
...@@ -10,8 +10,19 @@ ...@@ -10,8 +10,19 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!