Commit 25f43654 by Tuukka Kivilahti

Merge branch 'cachemap' into 'master'

Change map rest to cacheable version

Create allplaces rest function to fetch places without any user reference, so the data can be cached.

See merge request !329
2 parents 356d26bf a9674789
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
<version>1.3.1</version> <version>1.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>${primefaces.extensions}</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId> <groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId> <artifactId>commons-digester</artifactId>
<version>2.1</version> <version>2.1</version>
...@@ -72,7 +78,12 @@ ...@@ -72,7 +78,12 @@
<dependency> <dependency>
<groupId>fi.iudex</groupId> <groupId>fi.iudex</groupId>
<artifactId>utils-standalone</artifactId> <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>
<dependency> <dependency>
<groupId>net.sf.barcode4j</groupId> <groupId>net.sf.barcode4j</groupId>
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
if (queueReserving) { if (queueReserving) {
$.getJSON("#{request.contextPath}/rest/placemap/v1/queue/#{ajaxMapView.map.id}/#{ajaxMapView.eventuser.id}") $.getJSON("#{request.contextPath}/rest/placemap/v1/queue/#{ajaxMapView.map.id}/#{ajaxMapView.eventuser.id}")
.done(function (data) { .done(function (data) {
updateQueue(data); updateQueue(data);
}).fail(function () { }).fail(function () {
location.reload(); location.reload();
}); });
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
} }
if (data.value == 0) { if (data.value == 0) {
updateWholePage(); updateWholePage();
} else { } else {
$("#queuepos").text(data.value); $("#queuepos").text(data.value);
var d = new Date(); var d = new Date();
...@@ -150,8 +150,9 @@ ...@@ -150,8 +150,9 @@
element: document.getElementById("seatmap"), element: document.getElementById("seatmap"),
moyaurl: "#{request.contextPath}", moyaurl: "#{request.contextPath}",
map_id: #{ajaxMapView.map.id}, map_id: #{ajaxMapView.map.id},
placeurl : "/rest/placemap/v1/#{ajaxMapView.map.id}/allplaces",
}); });
px.toggleaction = function(d){ px.toggleaction = function(d){
px.toggle_place(d); px.toggle_place(d);
updateSlottable(); updateSlottable();
......
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
element : document.getElementById("seatmap"), element : document.getElementById("seatmap"),
moyaurl : "#{request.contextPath}", moyaurl : "#{request.contextPath}",
map_id : #{ajaxMapView.map.id}, map_id : #{ajaxMapView.map.id},
placeurl : "/rest/placemap/v1/#{ajaxMapView.map.id}/allplaces",
}); });
px.toggleaction = #{ajaxMapView.queueEnabled?'undefined':'px.toggle_place'}; px.toggleaction = #{ajaxMapView.queueEnabled?'undefined':'px.toggle_place'};
......
...@@ -56,6 +56,7 @@ function placemap(opts) ...@@ -56,6 +56,7 @@ function placemap(opts)
clicked_place: undefined, clicked_place: undefined,
locale: opts.locale || 'fi', locale: opts.locale || 'fi',
toggleaction: opts.toggleaction, toggleaction: opts.toggleaction,
placeurl: opts.placeurl,
}; };
if (px.locale == "und") px.locale == "fi"; if (px.locale == "und") px.locale == "fi";
...@@ -381,7 +382,11 @@ function placemap(opts) ...@@ -381,7 +382,11 @@ function placemap(opts)
} }
px.update = function() { 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) { if(opts.hilightUser) {
url = px.moyaurl + "/rest/placemap/v1/" + px.map_id + "/hilightedPlaces/"+opts.hilightUser; url = px.moyaurl + "/rest/placemap/v1/" + px.map_id + "/hilightedPlaces/"+opts.hilightUser;
......
...@@ -33,13 +33,9 @@ ...@@ -33,13 +33,9 @@
<dependency> <dependency>
<groupId>org.primefaces.extensions</groupId> <groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId> <artifactId>primefaces-extensions</artifactId>
<version>4.0.0</version> <version>${primefaces.extensions}</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>resources-ckeditor</artifactId>
<version>4.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.primefaces.themes</groupId> <groupId>org.primefaces.themes</groupId>
......
...@@ -123,6 +123,21 @@ public class PlacemapRestViewV1 { ...@@ -123,6 +123,21 @@ public class PlacemapRestViewV1 {
return Response.ok(PojoUtils.parseSimplePlaces(map.getPlaces(), user, permbean.hasPermission(UserPermission.VIEW_ALL), true)).build(); 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 @GET
@Path("{id}/places") @Path("{id}/places")
public SimplePlacelistRoot getPlaces(@PathParam("id") Integer mapId) public SimplePlacelistRoot getPlaces(@PathParam("id") Integer mapId)
......
...@@ -38,8 +38,8 @@ public class AjaxMapView extends GenericCDIView { ...@@ -38,8 +38,8 @@ public class AjaxMapView extends GenericCDIView {
* *
*/ */
private static final long serialVersionUID = 8203589456357519480L; private static final long serialVersionUID = 8203589456357519480L;
// @Inject // @Inject
// private PlaceView placeview; // private PlaceView placeview;
private static final Logger logger = LoggerFactory.getLogger(AjaxMapView.class);; private static final Logger logger = LoggerFactory.getLogger(AjaxMapView.class);;
private String testVal = "Testval1"; private String testVal = "Testval1";
...@@ -103,20 +103,25 @@ public class AjaxMapView extends GenericCDIView { ...@@ -103,20 +103,25 @@ public class AjaxMapView extends GenericCDIView {
EventMap map = initMap(); EventMap map = initMap();
List<PlaceSlot> usersPlaceslots = placebean.getPlaceslots(u); List<PlaceSlot> usersPlaceslots = placebean.getPlaceslots(u);
MapQueueI mapqueue = quebean.getMapQueue(map); MapQueueI mapqueue = quebean.getMapQueue(map);
if (usersPlaceslots == null || usersPlaceslots.isEmpty()) { if (!quebean.isReserving(map, u)) {
logger.info("There are no placeslots available for user"); if (usersPlaceslots == null || usersPlaceslots.isEmpty()) {
map = null; logger.info("There are no placeslots available for user");
super.navihandler.forward("/shop/createBill?faces-redirect=true"); map = null;
super.navihandler.forward("/shop/createBill?faces-redirect=true");
} else if (usersPlaceslots.size() < mapqueue.getMinimumSlotsInQueue()) { return;
map = null; } else if (usersPlaceslots.size() < mapqueue.getMinimumSlotsInQueue()) {
super.navihandler.forward("/neomap/notenoughslots?faces-redirect=true"); map = null;
} else { super.navihandler.forward("/neomap/notenoughslots?faces-redirect=true");
quebean.enterQueue(map, u); return;
slotcount = countPlaceslots(placebean.getPlaceslots(u)); } else {
// slotcount = countPlaceslots(placebean.getFreePlaceslots(u, map)); quebean.enterQueue(map, u);
// slotcount =
// countPlaceslots(placebean.getFreePlaceslots(u, map));
}
} }
slotcount = countPlaceslots(placebean.getPlaceslots(u));
} }
} }
public void initPlacecount() { public void initPlacecount() {
...@@ -126,7 +131,6 @@ public class AjaxMapView extends GenericCDIView { ...@@ -126,7 +131,6 @@ public class AjaxMapView extends GenericCDIView {
} }
} }
private static Collection<Slotcounter> countPlaceslots(List<PlaceSlot> slots) { private static Collection<Slotcounter> countPlaceslots(List<PlaceSlot> slots) {
Map<Product, Slotcounter> prodmap = new HashMap<>(); Map<Product, Slotcounter> prodmap = new HashMap<>();
for (PlaceSlot p : slots) { for (PlaceSlot p : slots) {
...@@ -167,16 +171,16 @@ public class AjaxMapView extends GenericCDIView { ...@@ -167,16 +171,16 @@ public class AjaxMapView extends GenericCDIView {
return queEnabled; return queEnabled;
} }
// public String enterQueue() // public String enterQueue()
// { // {
// logger.info("Entering queue"); // logger.info("Entering queue");
// if (isQueueEnabled()) // if (isQueueEnabled())
// queueEntry = quebean.enterQueue(initMap(), userview.getSelectedUser()); // queueEntry = quebean.enterQueue(initMap(), userview.getSelectedUser());
// else { // else {
// logger.warn("QueueNot enabled. Not entering queue"); // logger.warn("QueueNot enabled. Not entering queue");
// } // }
// return null; // return null;
// } // }
private EventMap initMap() { private EventMap initMap() {
if (map == null && mapId != null) { if (map == null && mapId != null) {
...@@ -212,7 +216,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -212,7 +216,7 @@ public class AjaxMapView extends GenericCDIView {
public Long getAvailablePlaces() { public Long getAvailablePlaces() {
Long ret = placebean.availablePlaceCount(initMap()); 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; return ret;
} }
...@@ -229,9 +233,8 @@ public class AjaxMapView extends GenericCDIView { ...@@ -229,9 +233,8 @@ public class AjaxMapView extends GenericCDIView {
} }
public boolean canUserBuy() { public boolean canUserBuy() {
return permbean.hasPermission(MapPermission.BUY_PLACES) && return permbean.hasPermission(MapPermission.BUY_PLACES) && (permbean.hasPermission(MapPermission.MANAGE_OTHERS)
(permbean.hasPermission(MapPermission.MANAGE_OTHERS) || || quebean.isReserving(initMap(), userview.getSelectedUser()));
quebean.isReserving(initMap(), userview.getSelectedUser()));
} }
public EventUser getEventuser() { public EventUser getEventuser() {
...@@ -255,16 +258,16 @@ public class AjaxMapView extends GenericCDIView { ...@@ -255,16 +258,16 @@ public class AjaxMapView extends GenericCDIView {
return permbean.hasPermission(MapPermission.MANAGE_OTHERS); return permbean.hasPermission(MapPermission.MANAGE_OTHERS);
} }
// public void placeClicked() { // public void placeClicked() {
// //
// place = placebean.find(placeId); // place = placebean.find(placeId);
// logger.info("Found place {} with placeid {}", place, placeId); // logger.info("Found place {} with placeid {}", place, placeId);
// if (place.isReservedFor(permbean.getCurrentUser())) { // if (place.isReservedFor(permbean.getCurrentUser())) {
// placebean.releasePlace(place); // placebean.releasePlace(place);
// } else if (place.isBuyable() && !place.isTaken()) { // } else if (place.isBuyable() && !place.isTaken()) {
// placebean.reservePlace(place, permbean.getCurrentUser()); // placebean.reservePlace(place, permbean.getCurrentUser());
// } // }
// } // }
public String getTestVal() { public String getTestVal() {
return testVal; return testVal;
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
<logback.version>1.1.3</logback.version> <logback.version>1.1.3</logback.version>
<testng.version>6.8.21</testng.version> <testng.version>6.8.21</testng.version>
<javamelody.version>1.58.0</javamelody.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.themeversion>1.0.10</primefaces.themeversion>
<primefaces.extensions>4.0.0</primefaces.extensions>
</properties> </properties>
<url>http://codecrew.fi</url> <url>http://codecrew.fi</url>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!