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