Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3fd67c49
authored
Aug 20, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup and formatting
1 parent
cad83996
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
53 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/ProductBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ProductBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/UserBean.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
code/moya-database/src/main/java/fi/codecrew/moya/model/ProductFlag.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/ProductBeanLocal.java
View file @
3fd67c4
...
...
@@ -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
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/ProductBean.java
View file @
3fd67c4
...
...
@@ -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
)
{
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
3fd67c4
...
...
@@ -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
)
{
I
User
usr
=
userFacade
.
findByLogin
(
login
);
User
usr
=
userFacade
.
findByLogin
(
login
);
return
usr
!=
null
;
}
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
View file @
3fd67c4
...
...
@@ -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
;
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/ProductFlag.java
View file @
3fd67c4
...
...
@@ -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ä
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment