Commit ff04e892 by Tuomas Riihimäki

Do not generate placelist pdf on init

Especially on big maps this will cause massive delays when generating places
1 parent 7a515e8e
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
</h:form> </h:form>
<h:form> <h:form>
<p:commandButton id="downloadLink" actionListener="mapManageView.generatePlacePdf" value="koodipdf" ajax="false"> <p:commandButton id="downloadLink" actionListener="#{mapManageView.generatePlacePdf()}" value="koodipdf" ajax="false">
<p:fileDownload value="#{mapManageView.streamedFile}" /> <p:fileDownload value="#{mapManageView.placePdf}" />
</p:commandButton> </p:commandButton>
</h:form> </h:form>
</ui:define> </ui:define>
......
...@@ -54,7 +54,7 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView; ...@@ -54,7 +54,7 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
public class MapManageView extends GenericCDIView { public class MapManageView extends GenericCDIView {
/** /**
* *
*/ */
private static final long serialVersionUID = -3276250982780044688L; private static final long serialVersionUID = -3276250982780044688L;
private static final Logger logger = LoggerFactory.getLogger(MapManageView.class); private static final Logger logger = LoggerFactory.getLogger(MapManageView.class);
...@@ -94,10 +94,8 @@ public class MapManageView extends GenericCDIView { ...@@ -94,10 +94,8 @@ public class MapManageView extends GenericCDIView {
private String namebase; private String namebase;
private Integer mapId; private Integer mapId;
private List<Product> productlist; private List<Product> productlist;
private StreamedContent streamedFile;
private EventMap sourceMap; private EventMap sourceMap;
private DefaultStreamedContent placepdf;
public void initCreate() { public void initCreate() {
if (super.requirePermissions(MapPermission.MANAGE_MAPS)) { if (super.requirePermissions(MapPermission.MANAGE_MAPS)) {
...@@ -111,13 +109,11 @@ public class MapManageView extends GenericCDIView { ...@@ -111,13 +109,11 @@ public class MapManageView extends GenericCDIView {
map = eventmapBean.find(getMapId()); map = eventmapBean.find(getMapId());
setProductlist(productbean.getProducts()); setProductlist(productbean.getProducts());
super.beginConversation(); super.beginConversation();
if (map != null && !map.getPlaces().isEmpty())
streamedFile = new DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 18, 15)), "application/pdf", "paikkakoodit");
} }
} }
public List<EventMap> getOldMaps() { public List<EventMap> getOldMaps() {
List<EventMap> ret = placebean.getOrganisationsMaps(); List<EventMap> ret = placebean.getOrganisationsMaps();
if (map != null) { if (map != null) {
...@@ -131,12 +127,10 @@ public class MapManageView extends GenericCDIView { ...@@ -131,12 +127,10 @@ public class MapManageView extends GenericCDIView {
return null; return null;
} }
public String submitBg() public String submitBg() {
{
byte[] bytes = bgFile.getContents(); byte[] bytes = bgFile.getContents();
if (bytes == null && bgFile.getSize() > 0) if (bytes == null && bgFile.getSize() > 0) {
{
bytes = new byte[(int) bgFile.getSize()]; bytes = new byte[(int) bgFile.getSize()];
try { try {
bgFile.getInputstream().read(bytes); bgFile.getInputstream().read(bytes);
...@@ -206,8 +200,7 @@ public class MapManageView extends GenericCDIView { ...@@ -206,8 +200,7 @@ public class MapManageView extends GenericCDIView {
startY = new Integer(requestParams.get(clientId + ".y")).intValue(); startY = new Integer(requestParams.get(clientId + ".y")).intValue();
} }
public String removeAllPlaces() public String removeAllPlaces() {
{
map = eventmapBean.clearPlaces(map); map = eventmapBean.clearPlaces(map);
return null; return null;
} }
...@@ -235,8 +228,8 @@ public class MapManageView extends GenericCDIView { ...@@ -235,8 +228,8 @@ public class MapManageView extends GenericCDIView {
Place place = new Place(map); Place place = new Place(map);
place.setHeight(Math.abs(height)); place.setHeight(Math.abs(height));
place.setWidth(Math.abs(width)); place.setWidth(Math.abs(width));
int xpos = startX + rowXStart + (tablesHorizontal ? (placeI -1) * width : 0); int xpos = startX + rowXStart + (tablesHorizontal ? (placeI - 1) * width : 0);
int ypos = startY + rowYStart + (tablesHorizontal ? 0 : (placeI -1) * height); int ypos = startY + rowYStart + (tablesHorizontal ? 0 : (placeI - 1) * height);
logger.debug("Creating map in {} {}", xpos, ypos); logger.debug("Creating map in {} {}", xpos, ypos);
place.setMapX(xpos); place.setMapX(xpos);
place.setMapY(ypos); place.setMapY(ypos);
...@@ -398,12 +391,14 @@ public class MapManageView extends GenericCDIView { ...@@ -398,12 +391,14 @@ public class MapManageView extends GenericCDIView {
this.bgFile = bgFile; this.bgFile = bgFile;
} }
//StreamedContent new DefaultStreamedContent(pdfstream) public void generatePlacesPdf() {
public StreamedContent getStreamedFile() { placepdf = new DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 18, 15)), "application/pdf", "paikkakoodit");
//DefaultStreamedContent(new ByteArrayInputStream(placebean.generatePlacesPdf(54, 17, 10, 6))); }
return streamedFile; //StreamedContent new DefaultStreamedContent(pdfstream)
public StreamedContent getPlacePdf() {
return placepdf;
} }
public EventMap getSourceMap() { public EventMap getSourceMap() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!