Commit a9674789 by Tuomas Riihimäki

Change map rest to cacheable version

1 parent 356d26bf
...@@ -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>
......
...@@ -150,6 +150,7 @@ ...@@ -150,6 +150,7 @@
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){
......
...@@ -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,14 +33,10 @@ ...@@ -33,14 +33,10 @@
<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>
<artifactId>all-themes</artifactId> <artifactId>all-themes</artifactId>
......
...@@ -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)
......
...@@ -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 (!quebean.isReserving(map, u)) {
if (usersPlaceslots == null || usersPlaceslots.isEmpty()) { if (usersPlaceslots == null || usersPlaceslots.isEmpty()) {
logger.info("There are no placeslots available for user"); logger.info("There are no placeslots available for user");
map = null; map = null;
super.navihandler.forward("/shop/createBill?faces-redirect=true"); super.navihandler.forward("/shop/createBill?faces-redirect=true");
return;
} else if (usersPlaceslots.size() < mapqueue.getMinimumSlotsInQueue()) { } else if (usersPlaceslots.size() < mapqueue.getMinimumSlotsInQueue()) {
map = null; map = null;
super.navihandler.forward("/neomap/notenoughslots?faces-redirect=true"); super.navihandler.forward("/neomap/notenoughslots?faces-redirect=true");
return;
} else { } else {
quebean.enterQueue(map, u); quebean.enterQueue(map, u);
slotcount = countPlaceslots(placebean.getPlaceslots(u)); // slotcount =
// slotcount = countPlaceslots(placebean.getFreePlaceslots(u, map)); // 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) {
...@@ -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() {
......
...@@ -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!