The new support for parametrizing the clearing of handlers is used
This avoid to keep referencing objects longer than necessary. FEA: ItEr74S08DeployFramework
This commit is contained in:
parent
0d49317ada
commit
341ab3b93c
3 changed files with 53 additions and 55 deletions
|
|
@ -33,10 +33,10 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -57,6 +57,7 @@ import org.zkforge.timeplot.geometry.DefaultValueGeometry;
|
|||
import org.zkforge.timeplot.geometry.TimeGeometry;
|
||||
import org.zkforge.timeplot.geometry.ValueGeometry;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet.DisposalMode;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet.IServletRequestHandler;
|
||||
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
|
@ -581,23 +582,20 @@ public abstract class ChartFiller implements IChartFiller {
|
|||
|
||||
protected Plotinfo createPlotinfo(SortedMap<LocalDate, BigDecimal> map,
|
||||
Interval interval, boolean justDaysWithInformation) {
|
||||
return createPlotInfoFrom(createDataSourceUri(map, interval,
|
||||
justDaysWithInformation));
|
||||
}
|
||||
|
||||
private String createDataSourceUri(SortedMap<LocalDate, BigDecimal> map,
|
||||
Interval interval, boolean justDaysWithInformation) {
|
||||
return getServletUri(
|
||||
map,
|
||||
interval.getStart(),
|
||||
interval.getFinish(),
|
||||
createGraphicSpecification(map, interval,
|
||||
justDaysWithInformation));
|
||||
if (!map.isEmpty()) {
|
||||
setMinimumValueForChartIfLess(Collections.min(map.values()));
|
||||
setMaximumValueForChartIfGreater(Collections.max(map.values()));
|
||||
}
|
||||
return createPlotInfoFrom(createGraphicSpecification(map,
|
||||
interval, justDaysWithInformation));
|
||||
}
|
||||
|
||||
private GraphicSpecificationCreator createGraphicSpecification(
|
||||
SortedMap<LocalDate, BigDecimal> map, Interval interval,
|
||||
boolean justDaysWithInformation) {
|
||||
if (map.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (justDaysWithInformation) {
|
||||
return new JustDaysWithInformationGraphicSpecificationCreator(
|
||||
interval.getFinish(), map, interval.getStart());
|
||||
|
|
@ -608,31 +606,26 @@ public abstract class ChartFiller implements IChartFiller {
|
|||
}
|
||||
|
||||
private String getServletUri(
|
||||
final SortedMap<LocalDate, BigDecimal> mapDayAssignments,
|
||||
final LocalDate start, final LocalDate finish,
|
||||
final GraphicSpecificationCreator graphicSpecificationCreator) {
|
||||
if (mapDayAssignments.isEmpty()) {
|
||||
if (graphicSpecificationCreator == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
setMinimumValueForChartIfLess(Collections.min(mapDayAssignments
|
||||
.values()));
|
||||
setMaximumValueForChartIfGreater(Collections.max(mapDayAssignments
|
||||
.values()));
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) Executions
|
||||
.getCurrent().getNativeRequest();
|
||||
String uri = CallbackServlet.registerAndCreateURLFor(request,
|
||||
graphicSpecificationCreator);
|
||||
return uri;
|
||||
return CallbackServlet.registerAndCreateURLFor(request,
|
||||
graphicSpecificationCreator,
|
||||
DisposalMode.WHEN_NO_LONGER_REFERENCED);
|
||||
}
|
||||
|
||||
private Plotinfo createPlotInfoFrom(String dataSourceUri) {
|
||||
private Plotinfo createPlotInfoFrom(
|
||||
GraphicSpecificationCreator graphicSpecificationCreator) {
|
||||
PlotDataSource pds = new PlotDataSource();
|
||||
pds.setDataSourceUri(dataSourceUri);
|
||||
pds.setDataSourceUri(getServletUri(graphicSpecificationCreator));
|
||||
pds.setSeparator(" ");
|
||||
|
||||
Plotinfo plotinfo = new Plotinfo();
|
||||
plotinfo.setAttribute("keep-chart-specification-creator-referenced",
|
||||
graphicSpecificationCreator);
|
||||
plotinfo.setPlotDataSource(pds);
|
||||
return plotinfo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet.DisposalMode;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet.IServletRequestHandler;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
|
@ -164,24 +165,25 @@ public class ReportAdvancesController extends GenericForwardComposer {
|
|||
Button exportButton = new Button(_("XML"));
|
||||
exportButton.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
|
||||
IServletRequestHandler requestHandler = new IServletRequestHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/xml");
|
||||
String xml = reportAdvancesModel.exportXML(order);
|
||||
response.getWriter().write(xml);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
String uri = CallbackServlet.registerAndCreateURLFor(
|
||||
(HttpServletRequest) Executions.getCurrent()
|
||||
.getNativeRequest(),
|
||||
new IServletRequestHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/xml");
|
||||
String xml = reportAdvancesModel
|
||||
.exportXML(order);
|
||||
response.getWriter().write(xml);
|
||||
}
|
||||
|
||||
}, false);
|
||||
.getNativeRequest(), requestHandler, false,
|
||||
DisposalMode.WHEN_NO_LONGER_REFERENCED);
|
||||
|
||||
Executions.getCurrent().sendRedirect(uri, "_blank");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet.DisposalMode;
|
||||
import org.zkoss.ganttz.servlets.CallbackServlet.IServletRequestHandler;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
|
@ -160,24 +161,26 @@ public class SubcontractedTasksController extends GenericForwardComposer {
|
|||
Button exportButton = new Button(_("XML"));
|
||||
exportButton.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
|
||||
IServletRequestHandler requestHandler = new IServletRequestHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/xml");
|
||||
String xml = subcontractedTasksModel
|
||||
.exportXML(subcontractedTaskData);
|
||||
response.getWriter().write(xml);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
String uri = CallbackServlet.registerAndCreateURLFor(
|
||||
(HttpServletRequest) Executions.getCurrent()
|
||||
.getNativeRequest(),
|
||||
new IServletRequestHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/xml");
|
||||
String xml = subcontractedTasksModel
|
||||
.exportXML(subcontractedTaskData);
|
||||
response.getWriter().write(xml);
|
||||
}
|
||||
|
||||
}, false);
|
||||
.getNativeRequest(), requestHandler, false,
|
||||
DisposalMode.WHEN_NO_LONGER_REFERENCED);
|
||||
|
||||
Executions.getCurrent().sendRedirect(uri, "_blank");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue