Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a9674789
authored
Apr 10, 2016
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change map rest to cacheable version
1 parent
356d26bf
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
51 deletions
code/moya-parent/pom.xml
code/moya-web/WebContent/neomap/reserve.xhtml
code/moya-web/WebContent/neomap/view.xhtml
code/moya-web/WebContent/resources/seatjs/seatmap.js
code/moya-web/pom.xml
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacemapRestViewV1.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/AjaxMapView.java
code/pom.xml
code/moya-parent/pom.xml
View file @
a967478
...
...
@@ -27,6 +27,12 @@
<version>
1.3.1
</version>
</dependency>
<dependency>
<groupId>
org.primefaces.extensions
</groupId>
<artifactId>
primefaces-extensions
</artifactId>
<version>
${primefaces.extensions}
</version>
</dependency>
<dependency>
<groupId>
commons-digester
</groupId>
<artifactId>
commons-digester
</artifactId>
<version>
2.1
</version>
...
...
@@ -72,7 +78,12 @@
<dependency>
<groupId>
fi.iudex
</groupId>
<artifactId>
utils-standalone
</artifactId>
<version>
1.0.13
</version>
<version>
1.0.22
</version>
</dependency>
<dependency>
<groupId>
org.primefaces.extensions
</groupId>
<artifactId>
resources-ckeditor
</artifactId>
<version>
4.0.0
</version>
</dependency>
<dependency>
<groupId>
net.sf.barcode4j
</groupId>
...
...
code/moya-web/WebContent/neomap/reserve.xhtml
View file @
a967478
...
...
@@ -110,7 +110,7 @@
if
(
queueReserving
)
{
$
.
getJSON
(
"#{request.contextPath}/rest/placemap/v1/queue/#{ajaxMapView.map.id}/#{ajaxMapView.eventuser.id}"
)
.
done
(
function
(
data
)
{
updateQueue
(
data
);
updateQueue
(
data
);
}).
fail
(
function
()
{
location
.
reload
();
});
...
...
@@ -125,7 +125,7 @@
}
if
(
data
.
value
==
0
)
{
updateWholePage
();
updateWholePage
();
}
else
{
$
(
"#queuepos"
).
text
(
data
.
value
);
var
d
=
new
Date
();
...
...
@@ -150,8 +150,9 @@
element
:
document
.
getElementById
(
"seatmap"
),
moyaurl
:
"#{request.contextPath}"
,
map_id
:
#
{
ajaxMapView
.
map
.
id
},
placeurl
:
"/rest/placemap/v1/#{ajaxMapView.map.id}/allplaces"
,
});
px
.
toggleaction
=
function
(
d
){
px
.
toggle_place
(
d
);
updateSlottable
();
...
...
code/moya-web/WebContent/neomap/view.xhtml
View file @
a967478
...
...
@@ -59,6 +59,8 @@
element
:
document
.
getElementById
(
"seatmap"
),
moyaurl
:
"#{request.contextPath}"
,
map_id
:
#
{
ajaxMapView
.
map
.
id
},
placeurl
:
"/rest/placemap/v1/#{ajaxMapView.map.id}/allplaces"
,
});
px
.
toggleaction
=
#
{
ajaxMapView
.
queueEnabled
?
'undefined'
:
'px.toggle_place'
};
...
...
code/moya-web/WebContent/resources/seatjs/seatmap.js
View file @
a967478
...
...
@@ -56,6 +56,7 @@ function placemap(opts)
clicked_place
:
undefined
,
locale
:
opts
.
locale
||
'fi'
,
toggleaction
:
opts
.
toggleaction
,
placeurl
:
opts
.
placeurl
,
};
if
(
px
.
locale
==
"und"
)
px
.
locale
==
"fi"
;
...
...
@@ -381,7 +382,11 @@ function placemap(opts)
}
px
.
update
=
function
()
{
var
url
=
px
.
moyaurl
+
"/rest/placemap/v1/"
+
px
.
map_id
+
"/places"
;
var
url
=
px
.
moyaurl
+
"/rest/placemap/v1/"
+
px
.
map_id
+
"/places"
;
if
(
px
.
placeurl
){
url
=
px
.
moyaurl
+
px
.
placeurl
;
}
if
(
opts
.
hilightUser
)
{
url
=
px
.
moyaurl
+
"/rest/placemap/v1/"
+
px
.
map_id
+
"/hilightedPlaces/"
+
opts
.
hilightUser
;
...
...
code/moya-web/pom.xml
View file @
a967478
...
...
@@ -33,13 +33,9 @@
<dependency>
<groupId>
org.primefaces.extensions
</groupId>
<artifactId>
primefaces-extensions
</artifactId>
<version>
4.0.0
</version>
</dependency>
<dependency>
<groupId>
org.primefaces.extensions
</groupId>
<artifactId>
resources-ckeditor
</artifactId>
<version>
4.0.0
</version>
<version>
${primefaces.extensions}
</version>
</dependency>
<dependency>
<groupId>
org.primefaces.themes
</groupId>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/placemap/v1/PlacemapRestViewV1.java
View file @
a967478
...
...
@@ -123,6 +123,21 @@ public class PlacemapRestViewV1 {
return
Response
.
ok
(
PojoUtils
.
parseSimplePlaces
(
map
.
getPlaces
(),
user
,
permbean
.
hasPermission
(
UserPermission
.
VIEW_ALL
),
true
)).
build
();
}
/**
* This is a cacheable version of {id}/places. This should be reworked, but for now this should do the trick.
* @param mapId
* @return
*/
@GET
@Path
(
"{id}/allplaces"
)
public
SimplePlacelistRoot
getAllPlaces
(
@PathParam
(
"id"
)
Integer
mapId
)
{
EventMap
map
=
placebean
.
findMap
(
mapId
);
return
PojoUtils
.
parseSimplePlaces
(
map
.
getPlaces
(),
null
,
permbean
.
hasPermission
(
UserPermission
.
VIEW_ALL
));
}
@GET
@Path
(
"{id}/places"
)
public
SimplePlacelistRoot
getPlaces
(
@PathParam
(
"id"
)
Integer
mapId
)
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/AjaxMapView.java
View file @
a967478
...
...
@@ -38,8 +38,8 @@ public class AjaxMapView extends GenericCDIView {
*
*/
private
static
final
long
serialVersionUID
=
8203589456357519480L
;
//
@Inject
//
private PlaceView placeview;
//
@Inject
//
private PlaceView placeview;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AjaxMapView
.
class
);;
private
String
testVal
=
"Testval1"
;
...
...
@@ -103,20 +103,25 @@ public class AjaxMapView extends GenericCDIView {
EventMap
map
=
initMap
();
List
<
PlaceSlot
>
usersPlaceslots
=
placebean
.
getPlaceslots
(
u
);
MapQueueI
mapqueue
=
quebean
.
getMapQueue
(
map
);
if
(
usersPlaceslots
==
null
||
usersPlaceslots
.
isEmpty
())
{
logger
.
info
(
"There are no placeslots available for user"
);
map
=
null
;
super
.
navihandler
.
forward
(
"/shop/createBill?faces-redirect=true"
);
}
else
if
(
usersPlaceslots
.
size
()
<
mapqueue
.
getMinimumSlotsInQueue
())
{
map
=
null
;
super
.
navihandler
.
forward
(
"/neomap/notenoughslots?faces-redirect=true"
);
}
else
{
quebean
.
enterQueue
(
map
,
u
);
slotcount
=
countPlaceslots
(
placebean
.
getPlaceslots
(
u
));
// slotcount = countPlaceslots(placebean.getFreePlaceslots(u, map));
if
(!
quebean
.
isReserving
(
map
,
u
))
{
if
(
usersPlaceslots
==
null
||
usersPlaceslots
.
isEmpty
())
{
logger
.
info
(
"There are no placeslots available for user"
);
map
=
null
;
super
.
navihandler
.
forward
(
"/shop/createBill?faces-redirect=true"
);
return
;
}
else
if
(
usersPlaceslots
.
size
()
<
mapqueue
.
getMinimumSlotsInQueue
())
{
map
=
null
;
super
.
navihandler
.
forward
(
"/neomap/notenoughslots?faces-redirect=true"
);
return
;
}
else
{
quebean
.
enterQueue
(
map
,
u
);
// slotcount =
// countPlaceslots(placebean.getFreePlaceslots(u, map));
}
}
slotcount
=
countPlaceslots
(
placebean
.
getPlaceslots
(
u
));
}
}
public
void
initPlacecount
()
{
...
...
@@ -126,7 +131,6 @@ public class AjaxMapView extends GenericCDIView {
}
}
private
static
Collection
<
Slotcounter
>
countPlaceslots
(
List
<
PlaceSlot
>
slots
)
{
Map
<
Product
,
Slotcounter
>
prodmap
=
new
HashMap
<>();
for
(
PlaceSlot
p
:
slots
)
{
...
...
@@ -167,16 +171,16 @@ public class AjaxMapView extends GenericCDIView {
return
queEnabled
;
}
//
public String enterQueue()
//
{
//
logger.info("Entering queue");
//
if (isQueueEnabled())
//
queueEntry = quebean.enterQueue(initMap(), userview.getSelectedUser());
//
else {
//
logger.warn("QueueNot enabled. Not entering queue");
//
}
//
return null;
//
}
//
public String enterQueue()
//
{
//
logger.info("Entering queue");
//
if (isQueueEnabled())
//
queueEntry = quebean.enterQueue(initMap(), userview.getSelectedUser());
//
else {
//
logger.warn("QueueNot enabled. Not entering queue");
//
}
//
return null;
//
}
private
EventMap
initMap
()
{
if
(
map
==
null
&&
mapId
!=
null
)
{
...
...
@@ -212,7 +216,7 @@ public class AjaxMapView extends GenericCDIView {
public
Long
getAvailablePlaces
()
{
Long
ret
=
placebean
.
availablePlaceCount
(
initMap
());
//
logger.debug("Got {} availbale places for map {}", ret, initMap());
//
logger.debug("Got {} availbale places for map {}", ret, initMap());
return
ret
;
}
...
...
@@ -229,9 +233,8 @@ public class AjaxMapView extends GenericCDIView {
}
public
boolean
canUserBuy
()
{
return
permbean
.
hasPermission
(
MapPermission
.
BUY_PLACES
)
&&
(
permbean
.
hasPermission
(
MapPermission
.
MANAGE_OTHERS
)
||
quebean
.
isReserving
(
initMap
(),
userview
.
getSelectedUser
()));
return
permbean
.
hasPermission
(
MapPermission
.
BUY_PLACES
)
&&
(
permbean
.
hasPermission
(
MapPermission
.
MANAGE_OTHERS
)
||
quebean
.
isReserving
(
initMap
(),
userview
.
getSelectedUser
()));
}
public
EventUser
getEventuser
()
{
...
...
@@ -255,16 +258,16 @@ public class AjaxMapView extends GenericCDIView {
return
permbean
.
hasPermission
(
MapPermission
.
MANAGE_OTHERS
);
}
//
public void placeClicked() {
//
public void placeClicked() {
//
//
place = placebean.find(placeId);
//
logger.info("Found place {} with placeid {}", place, placeId);
//
if (place.isReservedFor(permbean.getCurrentUser())) {
//
placebean.releasePlace(place);
//
} else if (place.isBuyable() && !place.isTaken()) {
//
placebean.reservePlace(place, permbean.getCurrentUser());
//
}
//
}
//
place = placebean.find(placeId);
//
logger.info("Found place {} with placeid {}", place, placeId);
//
if (place.isReservedFor(permbean.getCurrentUser())) {
//
placebean.releasePlace(place);
//
} else if (place.isBuyable() && !place.isTaken()) {
//
placebean.reservePlace(place, permbean.getCurrentUser());
//
}
//
}
public
String
getTestVal
()
{
return
testVal
;
...
...
code/pom.xml
View file @
a967478
...
...
@@ -32,9 +32,9 @@
<logback.version>
1.1.3
</logback.version>
<testng.version>
6.8.21
</testng.version>
<javamelody.version>
1.58.0
</javamelody.version>
<primefaces.version>
5.
2
</primefaces.version>
<primefaces.version>
5.
3
</primefaces.version>
<primefaces.themeversion>
1.0.10
</primefaces.themeversion>
<primefaces.extensions>
4.0.0
</primefaces.extensions>
</properties>
<url>
http://codecrew.fi
</url>
...
...
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