Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 2465b0a9
authored
Dec 07, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'neomap' into 'master'
Fix place locking See merge request !141
2 parents
2f422ce5
c89b2886
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
198 additions
and
2 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/moya-web/WebContent/place/unlockedPlaces.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/AjaxMapView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/UnlockedPlaceView.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
2465b0a
...
@@ -345,8 +345,10 @@ public class PlaceBean implements PlaceBeanLocal {
...
@@ -345,8 +345,10 @@ public class PlaceBean implements PlaceBeanLocal {
return
null
;
return
null
;
}
}
// Check wether we should reserve places via credit or plcaeslot
boolean
placePrepaidcredit
=
places
.
get
(
0
).
getProduct
().
getProductFlags
().
contains
(
ProductFlag
.
PREPAID_CREDIT
);
// PlaceGroup pg = pgbean.createPlaceGroup(user);
// PlaceGroup pg = pgbean.createPlaceGroup(user);
if
(
createAccountevents
)
if
(
placePrepaidcredit
&&
createAccountevents
)
{
{
BigDecimal
totalprice
=
addAndCalcPrice
(
user
,
null
);
BigDecimal
totalprice
=
addAndCalcPrice
(
user
,
null
);
BigDecimal
balance
=
user
.
getAccountBalance
();
BigDecimal
balance
=
user
.
getAccountBalance
();
...
...
code/moya-web/WebContent/place/unlockedPlaces.xhtml
0 → 100644
View file @
2465b0a
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:p=
"http://primefaces.org/ui"
xmlns:f=
"http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:param
name=
"thispage"
value=
"page.place.mygroups"
/>
<f:metadata>
<f:viewParam
name=
"mapid"
value=
"#{unlockedPlaceView.mapId}"
/>
<f:event
type=
"preRenderView"
listener=
"#{unlockedPlaceView.init}"
/>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['placegroupview.header']}
</h1>
<!-- <users:usertabs tabId="groups" /> -->
</ui:define>
<ui:define
name=
"content"
>
<ui:fragment
rendered=
"#{!empty unlockedPlaceView.newPg}"
>
created placegroup
<h:outputText
value=
"#{unlockedPlaceView.newPg}"
/>
</ui:fragment>
<h:form>
<p:dataTable
var=
"pc"
value=
"#{unlockedPlaceView.places}"
>
<p:column>
<h:outputText
value=
"#{pc.user.user.login} #{pc.user.user.wholeName}"
/>
</p:column>
<p:column>
<p:dataTable
var=
"p"
value=
"#{pc.places}"
>
<p:column>
<h:outputText
value=
"#{p.name}"
/>
</p:column>
<p:column>
<h:outputText
value=
"#{p.releaseTime.time}"
>
<f:convertDateTime
/>
</h:outputText>
</p:column>
</p:dataTable>
</p:column>
<p:column>
<p:commandButton
ajax=
"false"
value=
"#{i18n['placegroup.lock']}"
action=
"#{unlockedPlaceView.lockUser()}"
/>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/AjaxMapView.java
View file @
2465b0a
...
@@ -102,7 +102,7 @@ public class AjaxMapView extends GenericCDIView {
...
@@ -102,7 +102,7 @@ public class AjaxMapView extends GenericCDIView {
public
String
buySelectedPlaces
()
{
public
String
buySelectedPlaces
()
{
try
{
try
{
EventUser
user
=
userview
.
getSelectedUser
();
EventUser
user
=
userview
.
getSelectedUser
();
placebean
.
reserve
SelectedPlaces
(
user
);
placebean
.
buy
SelectedPlaces
(
user
);
return
"/place/myGroups"
;
return
"/place/myGroups"
;
}
catch
(
BortalCatchableException
e
)
{
}
catch
(
BortalCatchableException
e
)
{
addFaceMessage
(
"mapView.errorWhileBuyingPlaces"
);
addFaceMessage
(
"mapView.errorWhileBuyingPlaces"
);
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/UnlockedPlaceView.java
0 → 100644
View file @
2465b0a
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
map
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@ConversationScoped
public
class
UnlockedPlaceView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
7430277821503568386L
;
private
ListDataModel
<
UnlockedPlaceContainer
>
places
;
private
Integer
mapId
;
public
static
class
UnlockedPlaceContainer
{
public
UnlockedPlaceContainer
(
EventUser
currentUser
)
{
user
=
currentUser
;
places
=
new
ArrayList
<>();
}
private
final
EventUser
user
;
private
final
List
<
Place
>
places
;
public
void
addPlace
(
Place
p
)
{
places
.
add
(
p
);
}
public
EventUser
getUser
()
{
return
user
;
}
public
List
<
Place
>
getPlaces
()
{
return
places
;
}
}
@EJB
private
PlaceBeanLocal
placebean
;
private
PlaceGroup
newPg
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UnlockedPlaceContainer
.
class
);
public
String
lockUser
()
{
UnlockedPlaceContainer
uc
=
places
.
getRowData
();
logger
.
info
(
"Locking places for user {}"
,
uc
.
getUser
());
newPg
=
placebean
.
buySelectedPlaces
(
uc
.
getUser
());
places
=
null
;
init
();
return
null
;
}
public
void
init
()
{
if
(
places
==
null
)
{
HashMap
<
EventUser
,
UnlockedPlaceContainer
>
usermap
=
new
HashMap
<
EventUser
,
UnlockedPlaceContainer
>();
EventMap
map
=
null
;
if
(
getMapId
()
!=
null
)
{
map
=
placebean
.
findMap
(
getMapId
());
}
else
{
List
<
EventMap
>
maps
=
placebean
.
getMaps
();
for
(
EventMap
m
:
maps
)
{
if
(!
m
.
isActive
())
continue
;
map
=
m
;
}
}
mapId
=
map
.
getId
();
for
(
Place
p
:
map
.
getPlaces
())
{
if
(
p
.
getReleaseTime
()
!=
null
)
{
UnlockedPlaceContainer
uc
=
usermap
.
get
(
p
.
getCurrentUser
());
if
(
uc
==
null
)
{
uc
=
new
UnlockedPlaceContainer
(
p
.
getCurrentUser
());
usermap
.
put
(
p
.
getCurrentUser
(),
uc
);
}
uc
.
addPlace
(
p
);
}
}
places
=
new
ListDataModel
<>(
new
ArrayList
<>(
usermap
.
values
()));
super
.
beginConversation
();
}
}
public
ListDataModel
<
UnlockedPlaceContainer
>
getPlaces
()
{
return
places
;
}
public
void
setPlaces
(
ListDataModel
<
UnlockedPlaceContainer
>
places
)
{
this
.
places
=
places
;
}
public
PlaceGroup
getNewPg
()
{
return
newPg
;
}
public
void
setNewPg
(
PlaceGroup
newPg
)
{
this
.
newPg
=
newPg
;
}
public
Integer
getMapId
()
{
return
mapId
;
}
public
void
setMapId
(
Integer
mapId
)
{
this
.
mapId
=
mapId
;
}
}
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