# HG changeset patch # User Sascha L. Teichmann # Date 1334935407 0 # Node ID f905c936ffff9ed97f63d2a33b94afc39cbaa560 # Parent e64e0d094843714fceaa2d3a50c545f9165e7c19 Added the XSL transformation to generate the fixings overview. flys-client/trunk@4286 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e64e0d094843 -r f905c936ffff flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Apr 20 11:02:26 2012 +0000 +++ b/flys-client/ChangeLog Fri Apr 20 15:23:27 2012 +0000 @@ -1,3 +1,18 @@ +2012-04-20 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/client/server/FixingsKMChartServiceImpl.java: + Use the XSL transform to render the overview. + + * src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java, + src/main/java/de/intevation/flys/client/client/services/FixingsOverviewServiceAsync.java: + Adjusted signature to pass locale, too. + + * src/main/java/de/intevation/flys/client/client/services/FixingsOverviewService.java: + Simplification. + + * src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl: New. Generates the + HTML table overview. + 2012-04-20 Sascha L. Teichmann * src/main/webapp/WEB-INF/web.xml: Fixed incorrect servlet mapping. diff -r e64e0d094843 -r f905c936ffff flys-client/src/main/java/de/intevation/flys/client/client/services/FixingsOverviewService.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/services/FixingsOverviewService.java Fri Apr 20 11:02:26 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/FixingsOverviewService.java Fri Apr 20 15:23:27 2012 +0000 @@ -9,6 +9,7 @@ public interface FixingsOverviewService extends RemoteService { String generateOverview( + String locale, String uuid, boolean checkboxes, String filter diff -r e64e0d094843 -r f905c936ffff flys-client/src/main/java/de/intevation/flys/client/client/services/FixingsOverviewServiceAsync.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/services/FixingsOverviewServiceAsync.java Fri Apr 20 11:02:26 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/FixingsOverviewServiceAsync.java Fri Apr 20 15:23:27 2012 +0000 @@ -5,6 +5,7 @@ public interface FixingsOverviewServiceAsync { void generateOverview( + String locale, String uuid, boolean checkboxes, String filter, diff -r e64e0d094843 -r f905c936ffff flys-client/src/main/java/de/intevation/flys/client/server/FixingsKMChartServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/FixingsKMChartServiceImpl.java Fri Apr 20 11:02:26 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FixingsKMChartServiceImpl.java Fri Apr 20 15:23:27 2012 +0000 @@ -58,15 +58,10 @@ return; } - HttpClient client; - - client = new HttpClientImpl(url, locale); - - resp.setHeader("Content-Type", guessMIMEType(filterDoc)); - InputStream in; try { + HttpClient client = new HttpClientImpl(url, locale); in = (InputStream)client.callService( url, // XXX: Why? The URL is passed by construction already. SERVICE_NAME, @@ -78,6 +73,8 @@ return; } + resp.setHeader("Content-Type", guessMIMEType(filterDoc)); + try { OutputStream out = resp.getOutputStream(); diff -r e64e0d094843 -r f905c936ffff flys-client/src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java Fri Apr 20 11:02:26 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java Fri Apr 20 15:23:27 2012 +0000 @@ -2,23 +2,83 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; +import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.artifacts.common.utils.XSLTransformer; + +import de.intevation.artifacts.httpclient.exceptions.ConnectionException; + +import de.intevation.artifacts.httpclient.http.HttpClient; +import de.intevation.artifacts.httpclient.http.HttpClientImpl; + import de.intevation.flys.client.client.services.FixingsOverviewService; import de.intevation.flys.client.shared.exceptions.ServerException; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.log4j.Logger; + +import org.w3c.dom.Document; + public class FixingsOverviewServiceImpl extends RemoteServiceServlet implements FixingsOverviewService { + private static final Logger log = + Logger.getLogger(FixingsOverviewServiceImpl.class); + + public static final String SERVICE_NAME = "fixings-overview"; + + public static final String XSL_TRANSFORM = + "/WEB-INF/stylesheets/fixoverview2html.xsl"; + @Override public String generateOverview( + String locale, String uuid, boolean checkboxes, String filter ) throws ServerException { - // TODO: Implement me! + log.info("FixingsOverviewServiceImpl.doGet"); + + if (filter == null || filter.length() == 0) { + log.warn("Missing 'filter' parameter."); + return ""; + } + + Document filterDoc = XMLUtils.jsonToXML(filter); + + if (filterDoc == null) { + log.warn("Creating filter document failed."); + return ""; + } + + InputStream transform = + getServletContext().getResourceAsStream(XSL_TRANSFORM); + + try { + String url = getServletContext().getInitParameter("server-url"); + HttpClient client = new HttpClientImpl(url, locale); + Document resultDoc = + client.callService(url, SERVICE_NAME, filterDoc); + XSLTransformer xformer = new XSLTransformer(); + xformer.addParameter("project-uuid", uuid); + xformer.addParameter( + "render-checkboxes", checkboxes ? "true()" : "false()"); + String result = xformer.transform(resultDoc, transform); + return result != null ? result : ""; + } + catch (ConnectionException ce) { + log.error(ce); + } + finally { + try { transform.close(); } + catch (IOException ioe) {} + } + return ""; } } diff -r e64e0d094843 -r f905c936ffff flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl Fri Apr 20 15:23:27 2012 +0000 @@ -0,0 +1,126 @@ + + + + + + de3f3307-3429-4ff9-8f43-3fb2fcf21b27 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + width: + + + + + %;float:left + + +
+
+
+
+ + + + + +
+ + background: + + green + blue + magenta + red + black + + ;width: + + + + % + ;float:left + + + km + + - + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + +