Commit 3fd67c49 by Tuomas Riihimäki

Code cleanup and formatting

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