Commit 3fd67c49 by Tuomas Riihimäki

Code cleanup and formatting

1 parent cad83996
......@@ -85,7 +85,7 @@ public interface ProductBeanLocal {
AccountEvent find(Integer id);
void shopCash(EventUser shoppingUser, Map<Product, BigDecimal> shopMap, boolean buyInstant);
// void shopCash(EventUser shoppingUser, Map<Product, BigDecimal> shopMap, boolean buyInstant);
List<Role> getRolesFromAccountEvents(EventUser u);
......
......@@ -483,49 +483,60 @@ public class ProductBean implements ProductBeanLocal {
return accounteventfacade.findProvidedRoles(eventBean.getCurrentEvent(), u);
}
/**
* Create accountevents for the products in the parameter shopMap
*/
@Override
@RolesAllowed(ShopPermission.S_SHOP_PRODUCTS)
public void shopCash(EventUser shoppingUser, Map<Product, BigDecimal> shopMap, boolean buyInstant) {
logger.debug("Shoping cash. buyinstant {}", buyInstant);
EventUser seller = permbean.getCurrentUser();
shoppingUser = userbean.findByEventUserId(shoppingUser.getId());
BigDecimal tot = BigDecimal.ZERO;
for (Entry<Product, BigDecimal> prodentry : shopMap.entrySet()) {
// Create account event for the product.
AccountEvent ac = new AccountEvent(shoppingUser, prodentry.getKey(), prodentry.getKey().getPrice(), prodentry.getValue(), Calendar.getInstance());
ac.setSeller(seller);
accounteventfacade.create(ac);
if (buyInstant && prodentry.getKey().getPrice().compareTo(BigDecimal.ZERO) > 0) {
tot = tot.add(prodentry.getValue().multiply(prodentry.getKey().getPrice()));
}
if (prodentry.getKey().getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT) || prodentry.getKey().getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
logger.debug("Prepaidplace");
placebean.lockPlaceProduct(shoppingUser, prodentry.getKey(), BigDecimal.ONE);
}
}
logger.debug("ShopCash price {}", tot);
if (buyInstant && tot.compareTo(BigDecimal.ZERO) > 0) {
logger.debug("Creating buy instant product!");
Product creditProd = findCreditProduct();
AccountEvent ac = new AccountEvent(shoppingUser, creditProd, creditProd.getPrice(), tot, Calendar.getInstance());
accounteventfacade.create(ac);
}
userbean.mergeEventUserChanges(shoppingUser);
}
// /**
// * Create accountevents for the products in the parameter shopMap
// */
// @Override
// @RolesAllowed(ShopPermission.S_SHOP_PRODUCTS)
// public void shopCash(EventUser shoppingUser, Map<Product, BigDecimal>
// shopMap, boolean buyInstant) {
// logger.debug("Shoping cash. buyinstant {}", buyInstant);
// EventUser seller = permbean.getCurrentUser();
// shoppingUser = userbean.findByEventUserId(shoppingUser.getId());
//
// BigDecimal tot = BigDecimal.ZERO;
//
// for (Entry<Product, BigDecimal> prodentry : shopMap.entrySet()) {
//
// // Create account event for the product.
// AccountEvent ac = new AccountEvent(shoppingUser, prodentry.getKey(),
// prodentry.getKey().getPrice(), prodentry.getValue(),
// Calendar.getInstance());
// ac.setSeller(seller);
// accounteventfacade.create(ac);
//
// if (buyInstant &&
// prodentry.getKey().getPrice().compareTo(BigDecimal.ZERO) > 0) {
// tot =
// tot.add(prodentry.getValue().multiply(prodentry.getKey().getPrice()));
// }
//
// if
// (prodentry.getKey().getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
// ||
// prodentry.getKey().getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT))
// {
// logger.debug("Prepaidplace");
//
// placebean.lockPlaceProduct(shoppingUser, prodentry.getKey(),
// BigDecimal.ONE);
//
// }
//
// }
//
// logger.debug("ShopCash price {}", tot);
// if (buyInstant && tot.compareTo(BigDecimal.ZERO) > 0) {
// logger.debug("Creating buy instant product!");
// Product creditProd = findCreditProduct();
// AccountEvent ac = new AccountEvent(shoppingUser, creditProd,
// creditProd.getPrice(), tot, Calendar.getInstance());
// accounteventfacade.create(ac);
// }
//
// userbean.mergeEventUserChanges(shoppingUser);
//
// }
@Override
public AccountEvent markDelivered(AccountEvent e, Calendar c) {
......
......@@ -76,7 +76,6 @@ import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Feedback;
import fi.codecrew.moya.model.GameID;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.IUser;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.PlaceGroup;
......@@ -714,7 +713,7 @@ public class UserBean implements UserBeanLocal {
@Override
public boolean userExists(String login) {
IUser usr = userFacade.findByLogin(login);
User usr = userFacade.findByLogin(login);
return usr != null;
}
......
......@@ -139,6 +139,10 @@ public class Place extends GenericEntity implements Comparable<Place> {
return ret;
}
@OneToOne(mappedBy = "place")
@JoinColumn(nullable = true)
private PlaceSlot reserverSlot;
public Place() {
super();
}
......@@ -346,13 +350,13 @@ public class Place extends GenericEntity implements Comparable<Place> {
if (this.getName() == null || o.getName() == null) {
if (this.getName() == null) {
return 1;
}
}
if (o.getName() == null) {
return -1;
}
return -1;
}
// both names are null. Compare IDs
return this.getNonNullId().compareTo(o.getNonNullId());
}
}
if (this.getName().equals(o.getName())) {
return 0;
......
......@@ -20,9 +20,11 @@ package fi.codecrew.moya.model;
public enum ProductFlag {
// FOODWAVE_ITEM, Äy... Ei kai tämän täällä tarvitse olla....
PREPAID_CREDIT, // Tämä ei ole missään käytössä. Poistetaas jossain
// vaiheessa --tuomari
/**
* Tämä tuote lisää käyttäjälle merkityn määrän kredittejä tilille mutta ei
* luo vastatuotetta.
*/
PREPAID_CREDIT,
/**
* Luodaan uusi paikka kun tuote ostetaan. Esim sisäänpääsylipuille kun
* halutaan GroupMembership mutta ei ole tarpeellista valita tiettyä
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!