diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/print/GanttDiagramURIStore.java b/ganttzk/src/main/java/org/zkoss/ganttz/print/GanttDiagramURIStore.java
deleted file mode 100644
index b9134a8e2..000000000
--- a/ganttzk/src/main/java/org/zkoss/ganttz/print/GanttDiagramURIStore.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * This file is part of NavalPlan
- *
- * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
- * Desenvolvemento Tecnolóxico de Galicia
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package org.zkoss.ganttz.print;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.management.timer.Timer;
-
-/**
- *
- * @author Diego Pino Garcia
- *
- */
-public class GanttDiagramURIStore {
-
- private static Map resources = new HashMap();
-
- public static String storeURI(String URI) {
- List URIs = new ArrayList();
- URIs.add(URI);
- return storeURIs(URIs);
- }
-
- public static String storeURIs(List URIs) {
- String key = UUID.randomUUID().toString();
- resources.put(key, new GanttDiagramURIData(URIs));
- return key;
- }
-
- public static List getURIsById(String id) {
- clean();
- final GanttDiagramURIData data = resources.get(id);
- if (data != null) {
- return data.getURIs();
- }
- return new ArrayList();
- }
-
- public static void clean() {
- clean(GanttDiagramURIData.EXPIRE_TIME);
- }
-
- public static void clean(long lifespan) {
- final Set keys = resources.keySet();
- for (Iterator i = keys.iterator(); i.hasNext(); ) {
- final String key = (String) i.next();
- final GanttDiagramURIData data = resources.get(key);
- if (data.hasExpired(lifespan)) {
- i.remove();
- }
- }
- }
-
- public static int size() {
- return resources.size();
- }
-
- /**
- *
- * @author Diego Pino Garcia
- *
- */
- private static class GanttDiagramURIData {
-
- private static final long EXPIRE_TIME = Timer.ONE_HOUR;
-
- private long timestamp;
-
- private List URIs = new ArrayList();
-
- public GanttDiagramURIData(List URIs) {
- this.timestamp = currentTime();
- this.URIs.addAll(URIs);
- }
-
- public boolean hasExpired(long lifespan) {
- return ((timestamp + lifespan - currentTime()) <= 0);
- }
-
- private long currentTime() {
- return System.currentTimeMillis();
- }
-
- public List getURIs() {
- return Collections.unmodifiableList(URIs);
- }
-
- }
-
-}
diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/print/Print.java b/ganttzk/src/main/java/org/zkoss/ganttz/print/Print.java
deleted file mode 100644
index aa9004a14..000000000
--- a/ganttzk/src/main/java/org/zkoss/ganttz/print/Print.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * This file is part of NavalPlan
- *
- * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
- * Desenvolvemento Tecnolóxico de Galicia
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package org.zkoss.ganttz.print;
-
-import gantt.builder.ChartBuilder;
-import gantt.builder.DatasetBuilder;
-import gantt.data.ExtendedGanttCategoryDataset;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.jfree.chart.JFreeChart;
-import org.jfree.data.gantt.TaskSeries;
-import org.zkoss.ganttz.data.GanttDiagramGraph;
-import org.zkoss.ganttz.data.Task;
-import org.zkoss.ganttz.servlets.CallbackServlet;
-import org.zkoss.ganttz.servlets.handlers.GeneratePrintPageHandler;
-import org.zkoss.ganttz.servlets.handlers.JFreeChartHandler;
-import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
-import org.zkoss.zk.ui.Executions;
-
-public class Print {
-
- private static final int INTERVAL_LENGTH_IN_MINUTES = 300 * 24 * 30;
-
- private static final String DEFAULT_SERIES_NAME = "Scheduled";
-
- private static final long serialVersionUID = 1L;
-
- public static void print(GanttDiagramGraph diagramGraph) {
- try {
- printGanttHorizontalPagingDemo(diagramGraph);
- } catch (Exception e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- public static void printGanttHorizontalPagingDemo(GanttDiagramGraph diagramGraph)
- throws Exception {
- DatasetBuilder datasetBuilder = new DatasetBuilder();
-
- final List tasks = diagramGraph.getTasks();
- final Date begin = getSmallestBeginDate(tasks);
- final Date end = getBiggestFinishDate(tasks);
-
- // Create series
- List taskSeriesList = new ArrayList();
- final TaskSeries taskSeries = datasetBuilder.createTaskSeries(diagramGraph,
- DEFAULT_SERIES_NAME);
- taskSeriesList.add(taskSeries);
-
- // Create dataset and split it
- final ExtendedGanttCategoryDataset dataset = datasetBuilder
- .createDataset(taskSeriesList);
-
- List subdatasets = datasetBuilder
- .splitDatasetInIntervals(dataset, begin, end,
- INTERVAL_LENGTH_IN_MINUTES);
-
- // Show resulting printing page
- final List URIs = convertDatasetsToURIs(subdatasets);
- final String id = GanttDiagramURIStore.storeURIs(URIs);
- final String URL = generatePrintPage(id);
- showPage(URL);
- }
-
- private static void showPage(String URL) {
- Executions.getCurrent().sendRedirect(URL, "_blank");
- }
-
- private static String generatePrintPage(String id) {
- final GeneratePrintPageHandler handler = new GeneratePrintPageHandler(id);
- String URL = CallbackServlet.registerAndCreateURLFor(getCurrentRequest(), handler);
- URL = URL.replace("/navalplanner-webapp", "");
- return URL;
- }
-
- private static HttpServletRequest getCurrentRequest() {
- return (HttpServletRequest) Executions.getCurrent().getNativeRequest();
- }
-
- private static List convertDatasetsToURIs(List datasets) {
- List result = new ArrayList();
-
- for (ExtendedGanttCategoryDataset each : datasets) {
- final JFreeChartHandler handler = new JFreeChartHandler(
- createChart(each));
- final String uri = CallbackServlet.registerAndCreateURLFor(getCurrentRequest(),
- handler);
- result.add(uri);
- }
- return result;
- }
-
- private static JFreeChart createChart(ExtendedGanttCategoryDataset dataset) {
- final ChartBuilder chartBuilder = new ChartBuilder();
- return chartBuilder.createChart("Gantt Diagram",
- "Tasks", "Date", dataset, true, true, false, ZoomLevel.DETAIL_TWO);
- }
-
- private static Date getSmallestBeginDate(
- List tasks) {
- if (tasks.isEmpty())
- return Calendar.getInstance().getTime();
- return getSmallest(getStartDates(tasks));
- }
-
- private static Date getBiggestFinishDate(
- List tasks) {
- if (tasks.isEmpty())
- return Calendar.getInstance().getTime();
- return getBiggest(getEndDates(tasks));
- }
-
- private static List getStartDates(
- List tasks) {
- ArrayList result = new ArrayList();
- for (org.zkoss.ganttz.data.Task t : tasks) {
- result.add(t.getBeginDate());
- }
- return result;
- }
-
- private static List getEndDates(List tasks) {
- ArrayList result = new ArrayList();
- for (org.zkoss.ganttz.data.Task t : tasks) {
- result.add(t.getEndDate());
- }
- return result;
- }
-
- private static > T getSmallest(
- Collection elements) {
- return getSmallest(elements, new Comparator() {
-
- @Override
- public int compare(T o1, T o2) {
- return o1.compareTo(o2);
- }
- });
- }
-
- private static > T getBiggest(
- Collection elements) {
- return getSmallest(elements, new Comparator() {
-
- @Override
- public int compare(T o1, T o2) {
- return o2.compareTo(o1);
- }
- });
- }
-
- private static T getSmallest(Collection elements,
- Comparator comparator) {
- List withoutNulls = removeNulls(elements);
- if (withoutNulls.isEmpty())
- throw new IllegalArgumentException("at least one required");
- T result = null;
- for (T element : withoutNulls) {
- result = result == null ? element : (comparator.compare(result,
- element) < 0 ? result : element);
- }
- return result;
- }
-
- private static List removeNulls(Collection elements) {
- ArrayList result = new ArrayList();
- for (T e : elements) {
- if (e != null) {
- result.add(e);
- }
- }
- return result;
- }
-
-}
diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/servlets/handlers/GeneratePrintPageHandler.java b/ganttzk/src/main/java/org/zkoss/ganttz/servlets/handlers/GeneratePrintPageHandler.java
deleted file mode 100644
index f416a075b..000000000
--- a/ganttzk/src/main/java/org/zkoss/ganttz/servlets/handlers/GeneratePrintPageHandler.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * This file is part of NavalPlan
- *
- * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
- * Desenvolvemento Tecnolóxico de Galicia
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package org.zkoss.ganttz.servlets.handlers;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.zkoss.ganttz.print.GanttDiagramURIStore;
-import org.zkoss.ganttz.servlets.CallbackServlet.IServletRequestHandler;
-
-/**
- *
- * @author Diego Pino Garcia
- *
- */
-public class GeneratePrintPageHandler implements IServletRequestHandler {
-
- private static final String DEFAULT_TITLE = "Xestion-produccion";
-
- private String id;
-
- private String title = DEFAULT_TITLE;
-
- public GeneratePrintPageHandler(String id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- @Override
- public void handle(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- PrintWriter writer = response.getWriter();
- final String page = getPage();
- writer.write(page);
- writer.close();
- }
-
- private String getPage() {
- String result = "";
- result += page_template;
- result = result.replace("###TITLE###", getTitle());
- result = result.replace("###GANTT_DIAGRAM_IMAGES###", getDiagramImages());
- return result;
- }
-
- private String getDiagramImages() {
- String result = "";
- final List URIs = GanttDiagramURIStore.getURIsById(id);
- for(String URI: URIs) {
- result += image_template.replace("###URI###", URI);
- }
- return result;
- }
-
- private static final String page_template = new StringBuilder()
- .append("")
- .append("###TITLE###")
- .append("###GANTT_DIAGRAM_IMAGES###")
- .append("")
- .toString();
-
- private static final String image_template = new StringBuilder()
- .append("")
- .append("

")
- .append("
")
- .toString();
-
-}
diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/servlets/handlers/JFreeChartHandler.java b/ganttzk/src/main/java/org/zkoss/ganttz/servlets/handlers/JFreeChartHandler.java
deleted file mode 100644
index d25783107..000000000
--- a/ganttzk/src/main/java/org/zkoss/ganttz/servlets/handlers/JFreeChartHandler.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file is part of NavalPlan
- *
- * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
- * Desenvolvemento Tecnolóxico de Galicia
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package org.zkoss.ganttz.servlets.handlers;
-
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jfree.chart.ChartUtilities;
-import org.jfree.chart.JFreeChart;
-import org.zkoss.ganttz.servlets.CallbackServlet.IServletRequestHandler;
-
-/**
- *
- * @author Diego Pino Garcia
- *
- */
-public class JFreeChartHandler implements IServletRequestHandler {
-
- private JFreeChart chart;
-
- private static final int WIDTH = 800;
-
- private static final int HEIGHT = 600;
-
- public JFreeChartHandler(JFreeChart chart) {
- this.chart = chart;
- }
-
- @Override
- public void handle(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- toPNG(response, this.chart);
- }
-
- private void toPNG(HttpServletResponse response, JFreeChart chart) throws IOException {
- response.setContentType("image/png");
- ServletOutputStream writer = response.getOutputStream();
- writer.write(encodeAsPNG(chart));
- writer.close();
- }
-
- private static byte[] encodeAsPNG(JFreeChart chart) throws IOException {
- final BufferedImage chartImage = chart.createBufferedImage(WIDTH, HEIGHT);
- return ChartUtilities.encodeAsPNG(chartImage);
- }
-
-}
diff --git a/ganttzk/src/test/java/org/zkoss/ganttz/print/GanttDiagramURIStoreTest.java b/ganttzk/src/test/java/org/zkoss/ganttz/print/GanttDiagramURIStoreTest.java
deleted file mode 100644
index 95f97f480..000000000
--- a/ganttzk/src/test/java/org/zkoss/ganttz/print/GanttDiagramURIStoreTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of NavalPlan
- *
- * Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
- * Desenvolvemento Tecnolóxico de Galicia
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package org.zkoss.ganttz.print;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.List;
-
-import javax.management.timer.Timer;
-
-import org.junit.Test;
-
-public class GanttDiagramURIStoreTest {
-
- private String URI = "http://www.igalia.com";
-
- @Test
- public void testStoreURIs() {
- String id = GanttDiagramURIStore.storeURI(URI);
- List URIs = GanttDiagramURIStore.getURIsById(id);
- assertNotNull(URIs);
- String uri = URIs.get(0);
- assertEquals(uri, URI);
- }
-
- @Test
- public void testCleanAllResources() {
- GanttDiagramURIStore.storeURI(URI);
- GanttDiagramURIStore.clean(0);
- assertEquals(0, GanttDiagramURIStore.size());
- }
-
- @Test
- public void testDoNotCleanResourceInmediatelyAfterInsertingIt() {
- GanttDiagramURIStore.storeURI(URI);
- GanttDiagramURIStore.clean(Timer.ONE_MINUTE);
- assertEquals(1, GanttDiagramURIStore.size());
- }
-
-}