Mercurial > dive4elements > gnv-client
changeset 73:504570de21fd
Refactoring Work depending on Infrastructurchanges in the Artifact-Module
gnv-artifacts/trunk@79 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 14 Sep 2009 10:32:38 +0000 |
parents | 1fece4da4f2f |
children | 3d73718aa1b8 |
files | gnv-artifacts/Changelog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesArtifact.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java gnv-artifacts/src/test/ressources/conf.xml gnv-artifacts/src/test/ressources/log4j.properties |
diffstat | 9 files changed, 96 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/Changelog Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/Changelog Mon Sep 14 10:32:38 2009 +0000 @@ -1,3 +1,13 @@ +2009-09-14 Tim Englich <tim.englich@intevation.de> + + * src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Edited, + src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Edited, + src/main/java/de/intevation/gnv/transition/OutputTransition.java Edited , + src/main/java/de/intevation/gnv/timeseries/TimeSeriesArtifact.java Edited, + src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Edited, + src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Edited: + Refactoring Work depending on Infrastructurchanges in the Artifact-Module + 2009-09-10 Tim Englich <tim.englich@intevation.de> * src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Edited,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Mon Sep 14 10:32:38 2009 +0000 @@ -3,6 +3,8 @@ */ package de.intevation.gnv.artifacts; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -23,6 +25,7 @@ import de.intevation.artifactdatabase.XMLUtils; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.ArtifactNamespaceContext; +import de.intevation.artifacts.CallContext; import de.intevation.gnv.artifacts.context.GNVArtifactContext; import de.intevation.gnv.transition.DefaultInputData; import de.intevation.gnv.transition.InputData; @@ -84,10 +87,10 @@ } /** - * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, java.lang.Object) + * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext) */ @Override - public Document advance(Document target, Object context) { + public Document advance(Document target, CallContext context) { Document result = XMLUtils.newDocument(); if (this.current != null){ String transitionName = this.readTransitionName(target); @@ -139,10 +142,10 @@ } /** - * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object) + * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, de.intevation.artifacts.CallContext) */ @Override - public Document feed(Document target, Object context) { + public Document feed(Document target, CallContext context) { Document result = XMLUtils.newDocument(); try { if (this.current != null){ @@ -314,19 +317,25 @@ /** * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, java.lang.Object) */ - public byte[] out(Document format, Object context) { + + + /** + * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, java.io.OutputStream, de.intevation.artifacts.CallContext) + */ + @Override + public void out(Document format, OutputStream outputStream, CallContext context) + throws IOException { log.debug("TGNVArtifactBase.out"); try { if (current != null && current instanceof OutputTransition){ - return ((OutputTransition)current).out(this.readOutputType(format)); + ((OutputTransition)current).out(this.readOutputType(format), outputStream); } } catch (TransitionException e) { log.error(e,e); } - return null; } - + protected String readOutputType(Document document){ String value = Config.getStringXPath(document,"action/out/@name"); return value;
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Mon Sep 14 10:32:38 2009 +0000 @@ -3,6 +3,8 @@ */ package de.intevation.gnv.artifacts.fis; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -20,6 +22,7 @@ import de.intevation.artifactdatabase.XMLUtils; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.CallContext; import de.intevation.gnv.artifacts.GNVArtifactBase; import de.intevation.gnv.artifacts.context.GNVArtifactContext; import de.intevation.gnv.artifacts.fis.product.DefaultProduct; @@ -72,10 +75,10 @@ /** - * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, java.lang.Object) + * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext) */ @Override - public Document advance(Document target, Object context) { + public Document advance(Document target, CallContext context) { if (this.productArtifact == null){ if (this.current != null){ String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: müssen wir für das subartifact eine veränderte uuid führen? @@ -162,7 +165,7 @@ * @see de.intevation.artifactdatabase.DefaultArtifact#describe(java.lang.Object) */ @Override - public Document describe(Object context) { + public Document describe(CallContext context) { if (this.productArtifact == null){ return this.createDescibeOutput(); }else{ @@ -174,7 +177,7 @@ * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object) */ @Override - public Document feed(Document target, Object context) { + public Document feed(Document target, CallContext context) { if (this.productArtifact == null){ String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value"); if (this.products.containsKey(productName)) { @@ -193,12 +196,10 @@ * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, java.lang.Object) */ @Override - public byte[] out(Document format, Object context) { - byte[] returnValue = null; + public void out(Document format, OutputStream outputStream, CallContext context) throws IOException { if (this.productArtifact != null){ - returnValue = this.productArtifact.out(format, context); + this.productArtifact.out(format,outputStream, context); } - return returnValue; } /**
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesArtifact.java Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesArtifact.java Mon Sep 14 10:32:38 2009 +0000 @@ -8,6 +8,7 @@ import org.w3c.dom.Node; import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.CallContext; import de.intevation.gnv.artifacts.GNVArtifactBase; import de.intevation.gnv.artifacts.context.GNVArtifactContext; @@ -40,7 +41,7 @@ * @see de.intevation.artifactdatabase.DefaultArtifact#describe(java.lang.Object) */ @Override - public Document describe(Object context) { + public Document describe(CallContext context) { log.debug("TimeSeriesArtifact.describe"); return super.createDescibeOutput(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Mon Sep 14 10:32:38 2009 +0000 @@ -3,6 +3,7 @@ */ package de.intevation.gnv.transition; +import java.io.OutputStream; import java.util.Collection; import de.intevation.gnv.transition.exception.TransitionException; @@ -19,7 +20,7 @@ * @return The Bytecode of the Result * @throws TransitionException */ - public byte[] out( String outputMode) throws TransitionException; + public void out( String outputMode, OutputStream outputStream) throws TransitionException; /** * Delivers the provided OutputModes of an Transition
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Mon Sep 14 10:32:38 2009 +0000 @@ -7,6 +7,7 @@ import java.awt.Dimension; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.Collection; import java.util.Iterator; @@ -46,14 +47,13 @@ return true; } - /** - * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String) - */ - public byte[] out(String outputMode) throws TransitionException { + /** + * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, java.io.OutputStream) + */ + public void out(String outputMode, OutputStream outputStream) throws TransitionException { log.debug("TimeSeriesOutputTransition"); try { this.advance(); // TODO nur neu holen wenn hash auf chartResult sich geändert hat - ByteArrayOutputStream os = new ByteArrayOutputStream(); ChartFactory chartFactory = new ChartFactory(); Collection<KeyValueDescibeData> parameters = this.getParameters(); @@ -66,8 +66,7 @@ ChartLabels chartLables = new ChartLabels(lDiagramTitle.toString(),domainLable , /*mSelectedParams[0].getTitle()*/ "Selected Params Title"); chartFactory.createSimpleTimeSeriesChart(chartLables, chartStyle, timeSeriesName, parameters, measurements, - os, this.chartResult); - return os.toByteArray(); + outputStream, this.chartResult); } catch (IOException e) { log.error(e,e); throw new TransitionException(e);
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Mon Sep 14 10:32:38 2009 +0000 @@ -78,39 +78,52 @@ log.debug("TimeSeries-Artifact is available"); // Erster Schritt - Document outputData = artifact.describe(bootstrap.getContext()); + Document outputData = artifact.describe(null); this.writeDocument2Log(outputData); - artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_01_feed.xml"), bootstrap.getContext()); - outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_01_advance.xml"), bootstrap.getContext()); + artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_01_feed.xml"), null); + outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_01_advance.xml"), null); this.writeDocument2Log(outputData); // Zweiter Schritt - outputData = artifact.describe(bootstrap.getContext()); + outputData = artifact.describe(null); this.writeDocument2Log(outputData); - artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_02_feed.xml"), bootstrap.getContext()); - outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_02_advance.xml"), bootstrap.getContext()); + artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_02_feed.xml"), null); + outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_02_advance.xml"), null); this.writeDocument2Log(outputData); // Dritter Schritt - outputData = artifact.describe(bootstrap.getContext()); + outputData = artifact.describe(null); this.writeDocument2Log(outputData); - artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_03_feed.xml"), bootstrap.getContext()); - outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_03_advance.xml"), bootstrap.getContext()); + artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_03_feed.xml"), null); + outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_03_advance.xml"), null); this.writeDocument2Log(outputData); // Vierter Schritt - outputData = artifact.describe(bootstrap.getContext()); + outputData = artifact.describe(null); this.writeDocument2Log(outputData); - artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_04_feed.xml"), bootstrap.getContext()); - outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_04_advance.xml"), bootstrap.getContext()); + artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_04_feed.xml"), null); + outputData = artifact.advance(this.readDocument("src/test/ressources/timeseries/timeseries_step_04_advance.xml"), null); this.writeDocument2Log(outputData); // Fünfter Schritt - outputData = artifact.describe(bootstrap.getContext()); - artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_feed.xml"), bootstrap.getContext()); - byte[] result = artifact.out(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"), bootstrap.getContext()); - this.createFile(result, "src/test/results/timeseriesdiagramm"+System.currentTimeMillis()+".png"); + outputData = artifact.describe(null); + FileOutputStream fos = null; + try{ + fos = new FileOutputStream("src/test/results/timeseriesdiagramm"+System.currentTimeMillis()+".png"); + artifact.feed(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_feed.xml"), null); + artifact.out(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"),fos, null); + } catch (Exception e){ + log.error(e,e); + fail(); + }finally{ + try { + fos.flush(); + fos.close(); + } catch (Exception e) { + log.error(e,e); + } + } } protected void createFile(byte[] content, String fileName){
--- a/gnv-artifacts/src/test/ressources/conf.xml Thu Sep 10 13:14:03 2009 +0000 +++ b/gnv-artifacts/src/test/ressources/conf.xml Mon Sep 14 10:32:38 2009 +0000 @@ -118,11 +118,18 @@ <backend-configuration>../geo-backend/src/test/ressources/ArcSDEConnectionPoolTestCase.properties</backend-configuration> <query-configuration>src/test/ressources/queries.properties</query-configuration> </geo-backend> + <rest-server> + <port>8181</port> + </rest-server> + <!-- garbage collection of outdated artifacts --> + <cleaner> + <sleep-time>60000</sleep-time> + </cleaner> <database> - <user></user> - <password></password> - <!-- <url>jdbc:h2:artifacts.db</url> --> - <!-- <driver>org.h2.Driver</driver> --> - <!-- <sql></sql> --> + <user>tim</user> + <password>test</password> + <!--url>jdbc:h2:src/test/ressources/artifacts.db</url> + <driver>org.h2.Driver</driver> + <sql></sql> --> </database> </artifact-database>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/test/ressources/log4j.properties Mon Sep 14 10:32:38 2009 +0000 @@ -0,0 +1,9 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=DEBUG, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n