Mercurial > dive4elements > gnv-client
changeset 171:7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/ChangeLog Fri Oct 09 07:54:48 2009 +0000 @@ -1,3 +1,8 @@ +2009-10-09 Tim Englich <tim.englich@intevation.de> + + * src/main/java/de/intevation/gnv/**/*.java Edited: + Code Formatting and Cleanup. + 2009-10-09 Tim Englich <tim.englich@intevation.de> * src/test/ressources/queries.properties Edited:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/APP.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/APP.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,7 +7,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class APP {
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Fri Oct 09 07:54:48 2009 +0000 @@ -38,7 +38,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public abstract class GNVArtifactBase extends DefaultArtifact { /** @@ -49,23 +49,24 @@ * The UID of this Class */ private static final long serialVersionUID = -8907096744400741458L; - + /** * The Identifier for the Replacement of the Artifactname */ public static final String XPATH_IDENTIFIER_REPLACE = "IDENTIFIER"; - + /** * The XPATH to the XML-Fragment that should be used for the Configuration */ - public static final String XPATH_ARTIFACT_CONFIGURATION= "/artifact-database/artifacts/artifact[@name='"+XPATH_IDENTIFIER_REPLACE+"']"; - - + public static final String XPATH_ARTIFACT_CONFIGURATION = "/artifact-database/artifacts/artifact[@name='" + + XPATH_IDENTIFIER_REPLACE + + "']"; + /** * The current Transition */ protected Transition current = null; - + /** * The Transitions that can be used */ @@ -75,18 +76,19 @@ * The Name of the Artifact */ protected String name = null; - + private ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); - + /** * Constructor */ public GNVArtifactBase() { super(); } - + /** - * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext) + * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, + * de.intevation.artifacts.CallContext) */ @Override public Document advance(Document target, CallContext context) { @@ -94,188 +96,221 @@ String uuid = Config.getStringXPath(target, "action/uuid/@value"); Document result = XMLUtils.newDocument(); try { - if (this.current != null){ + if (this.current != null) { String transitionName = this.readTransitionName(target); - log.debug("Transitionsname: "+transitionName); - if (this.current.isTransitionReachable(transitionName)){ + log.debug("Transitionsname: " + transitionName); + if (this.current.isTransitionReachable(transitionName)) { // 1. Prüfung ob Transition valide ist - if (this.current.validate()){ - + if (this.current.validate()) { + try { - Transition nextStep = this.transitions.get(transitionName); + Transition nextStep = this.transitions + .get(transitionName); // 2.Ergebnisse Berechnen - this.current.advance(uuid,context.getMeta()); + this.current.advance(uuid, context.getMeta()); // 3. Ergebnisse übergeben - nextStep.setDescibeData(this.current.getDescibeData()); - nextStep.putInputData(this.current.getInputData(),uuid); + nextStep.setDescibeData(this.current + .getDescibeData()); + nextStep.putInputData(this.current.getInputData(), + uuid); // 4. Umschalten auf neue Transistion this.current = nextStep; - result = new ArtifactXMLUtilities().createSuccessReport("Advance success", XMLUtils.newDocument()); + result = new ArtifactXMLUtilities() + .createSuccessReport("Advance success", + XMLUtils.newDocument()); } catch (TransitionException e) { - log.error(e,e); - result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); + log.error(e, e); + result = new ArtifactXMLUtilities() + .createExceptionReport(e + .getLocalizedMessage(), XMLUtils + .newDocument()); } - - }else{ - String msg = "Advance nicht möglich, da die Bedingungen für den Übergang " + - "in den neuen Zustand noch nicht gegeben ist."; + + } else { + String msg = "Advance nicht möglich, da die Bedingungen für den Übergang " + + "in den neuen Zustand noch nicht gegeben ist."; log.error(msg); - result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities() + .createExceptionReport(msg, XMLUtils + .newDocument()); } - - }else{ + + } else { String msg = "Transitionsübergang wird nicht unterstützt."; log.error(msg); - result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport( + msg, XMLUtils.newDocument()); } - }else{ + } else { String msg = "Kein Transitionsschritt aktiviert."; log.error(msg); - result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport(msg, + XMLUtils.newDocument()); } } catch (Exception e) { - log.error(e,e); - result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); + log.error(e, e); + result = new ArtifactXMLUtilities().createExceptionReport(e + .getLocalizedMessage(), XMLUtils.newDocument()); } return result; } protected String readTransitionName(Document document) { - String returnValue = Config.getStringXPath(document, "action/target/@name"); + String returnValue = Config.getStringXPath(document, + "action/target/@name"); return returnValue; } - protected Node getConfigurationFragment(Document document){ + protected Node getConfigurationFragment(Document document) { log.debug("GNVArtifactBase.getConfigurationFragment"); - String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(XPATH_IDENTIFIER_REPLACE, this.name); + String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll( + XPATH_IDENTIFIER_REPLACE, this.name); log.debug(xpathQuery); - return Config.getNodeXPath(document,xpathQuery); + return Config.getNodeXPath(document, xpathQuery); } - + /** - * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, de.intevation.artifacts.CallContext) + * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, + * de.intevation.artifacts.CallContext) */ @Override public Document feed(Document target, CallContext context) { log.debug("GNVArtifactBase.feed"); Document result = XMLUtils.newDocument(); try { - if (this.current != null){ - String uuid = Config.getStringXPath(target, "action/uuid/@value"); - this.current.putInputData(this.parseInputData(target, "/action/data/input"),uuid); - result = new ArtifactXMLUtilities().createSuccessReport("Feed success", XMLUtils.newDocument()); - }else{ + if (this.current != null) { + String uuid = Config.getStringXPath(target, + "action/uuid/@value"); + this.current.putInputData(this.parseInputData(target, + "/action/data/input"), uuid); + result = new ArtifactXMLUtilities().createSuccessReport( + "Feed success", XMLUtils.newDocument()); + } else { String msg = "No Transition instantiated"; log.warn(msg); - result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport(msg, + XMLUtils.newDocument()); } } catch (TransitionException e) { - log.error(e,e); - result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); + log.error(e, e); + result = new ArtifactXMLUtilities().createExceptionReport(e + .getLocalizedMessage(), XMLUtils.newDocument()); } return result; } - + /** - * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, java.lang.Object) + * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, + * java.lang.Object) */ @Override public void setup(String identifier, ArtifactFactory factory, Object context) { log.debug("GNVArtifactBase.setup"); super.setup(identifier, factory, context); - + Object localContext = context; - if (context instanceof CallContext){ - localContext = ((CallContext)context).globalContext(); - + if (context instanceof CallContext) { + localContext = ((CallContext) context).globalContext(); + } - - if (localContext instanceof GNVArtifactContext){ - GNVArtifactContext gnvContext = (GNVArtifactContext)localContext; + + if (localContext instanceof GNVArtifactContext) { + GNVArtifactContext gnvContext = (GNVArtifactContext) localContext; Document doc = gnvContext.getConfig(); Node artifactNode = this.getConfigurationFragment(doc); - NodeList transitionList = Config.getNodeSetXPath(artifactNode, "transitions/transition"); - this.transitions = new HashMap<String, Transition>(transitionList.getLength()); - for (int i = 0 ; i < transitionList.getLength(); i++){ - Transition tmpTransition = TransitionFactory.getInstance().createTransition(transitionList.item(i)); - if (tmpTransition != null){ + NodeList transitionList = Config.getNodeSetXPath(artifactNode, + "transitions/transition"); + this.transitions = new HashMap<String, Transition>(transitionList + .getLength()); + for (int i = 0; i < transitionList.getLength(); i++) { + Transition tmpTransition = TransitionFactory.getInstance() + .createTransition(transitionList.item(i)); + if (tmpTransition != null) { this.transitions.put(tmpTransition.getID(), tmpTransition); - if (this.current == null){ + if (this.current == null) { this.current = tmpTransition; } } } - + } } - - - protected Document createDescibeOutput(CallMeta callMeta){ + + protected Document createDescibeOutput(CallMeta callMeta) { log.debug("GNVArtifactBase.createDescibeOutput"); Document document = XMLUtils.newDocument(); - Element rootNode = this.createRootNode(document); + Element rootNode = this.createRootNode(document); this.createHeader(rootNode, document, "describe"); this.createOutputs(rootNode, document); this.createCurrentState(rootNode, document); this.createReachableStates(rootNode, document); this.createModel(rootNode, document); - this.createUserInterface(rootNode, document,callMeta); + this.createUserInterface(rootNode, document, callMeta); return document; } - - protected Element createRootNode(Document document){ - Element rootNode = xmlUtilities.createArtifactElement(document,"result"); + + protected Element createRootNode(Document document) { + Element rootNode = xmlUtilities.createArtifactElement(document, + "result"); document.appendChild(rootNode); return rootNode; } - - protected void createHeader(Element parent, Document document, String documentType){ - Element typeNode = xmlUtilities.createArtifactElement(document,"type"); + + protected void createHeader(Element parent, Document document, + String documentType) { + Element typeNode = xmlUtilities.createArtifactElement(document, "type"); typeNode.setAttribute("name", documentType); parent.appendChild(typeNode); - - Element uuidNode = xmlUtilities.createArtifactElement(document,"uuid"); + + Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid"); uuidNode.setAttribute("value", super.identifier); parent.appendChild(uuidNode); - - Element hashNode = xmlUtilities.createArtifactElement(document,"hash"); + + Element hashNode = xmlUtilities.createArtifactElement(document, "hash"); hashNode.setAttribute("value", this.hash()); parent.appendChild(hashNode); } - protected void createReachableStates(Element parent,Document document){ - Element stateNode = xmlUtilities.createArtifactElement(document,"reachable-states"); - if (this.current != null){ - Iterator<String> states = this.current.reachableTransitions().iterator(); - while(states.hasNext()){ + protected void createReachableStates(Element parent, Document document) { + Element stateNode = xmlUtilities.createArtifactElement(document, + "reachable-states"); + if (this.current != null) { + Iterator<String> states = this.current.reachableTransitions() + .iterator(); + while (states.hasNext()) { String value = states.next(); - Element currentNode = xmlUtilities.createArtifactElement(document,"state"); + Element currentNode = xmlUtilities.createArtifactElement( + document, "state"); currentNode.setAttribute("name", value); - log.debug("Reachable State: "+value); - currentNode.setAttribute("description", transitions.get(value).getDescription()); + log.debug("Reachable State: " + value); + currentNode.setAttribute("description", transitions.get(value) + .getDescription()); stateNode.appendChild(currentNode); } } parent.appendChild(stateNode); } - - protected void createCurrentState(Element parent, Document document){ - Element stateNode = xmlUtilities.createArtifactElement(document,"state"); + + protected void createCurrentState(Element parent, Document document) { + Element stateNode = xmlUtilities.createArtifactElement(document, + "state"); stateNode.setAttribute("name", this.current.getID()); stateNode.setAttribute("description", this.current.getDescription()); parent.appendChild(stateNode); } - - - protected void createModel(Element parent, Document document){ - Element modelNode = xmlUtilities.createArtifactElement(document,"model"); - if (this.current != null){ - Collection<InputValue> inputValues = this.current.getRequiredInputValues(); - if (inputValues != null){ + + protected void createModel(Element parent, Document document) { + Element modelNode = xmlUtilities.createArtifactElement(document, + "model"); + if (this.current != null) { + Collection<InputValue> inputValues = this.current + .getRequiredInputValues(); + if (inputValues != null) { Iterator<InputValue> it = inputValues.iterator(); - while(it.hasNext()){ + while (it.hasNext()) { InputValue inputValue = it.next(); - Element inputNode = xmlUtilities.createArtifactElement(document,"input"); + Element inputNode = xmlUtilities.createArtifactElement( + document, "input"); inputNode.setAttribute("name", inputValue.getName()); inputNode.setAttribute("type", inputValue.getType()); modelNode.appendChild(inputNode); @@ -284,86 +319,101 @@ } parent.appendChild(modelNode); } - - protected void createUserInterface(Element parent, Document document, CallMeta callMeta){ - Element uiNode = xmlUtilities.createArtifactElement(document,"ui"); - - if (this.current != null){ - this.current.describe(document, uiNode,callMeta); + + protected void createUserInterface(Element parent, Document document, + CallMeta callMeta) { + Element uiNode = xmlUtilities.createArtifactElement(document, "ui"); + + if (this.current != null) { + this.current.describe(document, uiNode, callMeta); } - + parent.appendChild(uiNode); } - - protected void createOutputs(Element parent, Document document){ + + protected void createOutputs(Element parent, Document document) { log.debug("GNVArtifactBase.createOutputs"); - Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs"); - if (this.current instanceof OutputTransition){ - Collection<OutputMode> outputModes = ((OutputTransition)this.current).getOutputModes(); - if (outputModes != null){ + Element outputsNode = xmlUtilities.createArtifactElement(document, + "outputs"); + if (this.current instanceof OutputTransition) { + Collection<OutputMode> outputModes = ((OutputTransition) this.current) + .getOutputModes(); + if (outputModes != null) { Iterator<OutputMode> it = outputModes.iterator(); - while(it.hasNext()){ + while (it.hasNext()) { OutputMode outputMode = it.next(); - log.debug("Write Outputnode for "+ outputMode.toString()); - Element outputModeNode = xmlUtilities.createArtifactElement(document,"output"); + log.debug("Write Outputnode for " + outputMode.toString()); + Element outputModeNode = xmlUtilities + .createArtifactElement(document, "output"); outputModeNode.setAttribute("name", outputMode.getName()); - outputModeNode.setAttribute("description", outputMode.getDescription()); - outputModeNode.setAttribute("mime-type", outputMode.getMimeType()); + outputModeNode.setAttribute("description", outputMode + .getDescription()); + outputModeNode.setAttribute("mime-type", outputMode + .getMimeType()); outputsNode.appendChild(outputModeNode); - - Collection<InputValue> inputParameters = outputMode.getInputParameters(); - if (inputParameters != null){ - Element inputParametersNode = xmlUtilities.createArtifactElement(document,"parameter"); + + Collection<InputValue> inputParameters = outputMode + .getInputParameters(); + if (inputParameters != null) { + Element inputParametersNode = xmlUtilities + .createArtifactElement(document, "parameter"); outputModeNode.appendChild(inputParametersNode); Iterator<InputValue> it2 = inputParameters.iterator(); - while (it2.hasNext()){ + while (it2.hasNext()) { InputValue inputValue = it2.next(); - Element inputParameterNode = xmlUtilities.createArtifactElement(document,"parameter"); + Element inputParameterNode = xmlUtilities + .createArtifactElement(document, + "parameter"); inputParametersNode.appendChild(inputParameterNode); - inputParameterNode.setAttribute("name", inputValue.getName()); - inputParameterNode.setAttribute("type", inputValue.getType()); - inputParameterNode.setAttribute("value", inputValue.getDefaultValue()); + inputParameterNode.setAttribute("name", inputValue + .getName()); + inputParameterNode.setAttribute("type", inputValue + .getType()); + inputParameterNode.setAttribute("value", inputValue + .getDefaultValue()); } } } - }else{ + } else { log.warn("No Outputmodes given."); } } parent.appendChild(outputsNode); } - - protected Collection<InputData> parseInputData(Document document, String xPath){ + protected Collection<InputData> parseInputData(Document document, + String xPath) { log.debug("GNVArtifactBase.parseInputData"); - HashMap<String,InputData> returnValue = null; - + HashMap<String, InputData> returnValue = null; + log.debug(new ArtifactXMLUtilities().writeDocument2String(document)); - - NodeList inputElemets = (NodeList)XMLUtils.xpath(document, xPath,XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);//Config.getNodeSetXPath(document, ""); - if(inputElemets != null){ - returnValue = new HashMap<String,InputData>(inputElemets.getLength()); - for (int i = 0; i < inputElemets.getLength(); i++){ + + NodeList inputElemets = (NodeList) XMLUtils.xpath(document, xPath, + XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE);// Config.getNodeSetXPath(document, + // ""); + if (inputElemets != null) { + returnValue = new HashMap<String, InputData>(inputElemets + .getLength()); + for (int i = 0; i < inputElemets.getLength(); i++) { Node inputDataNode = inputElemets.item(i); - String name = Config.getStringXPath(inputDataNode,"@name"); - String value = Config.getStringXPath(inputDataNode,"@value"); - - if (returnValue.containsKey(name)){ + String name = Config.getStringXPath(inputDataNode, "@name"); + String value = Config.getStringXPath(inputDataNode, "@value"); + + if (returnValue.containsKey(name)) { InputData inputData = returnValue.get(name); inputData.concartValue(value); log.debug(inputData.toString()); returnValue.put(name, inputData); - }else{ - InputData inputData = new DefaultInputData(name,value); - - returnValue.put(name,inputData); + } else { + InputData inputData = new DefaultInputData(name, value); + + returnValue.put(name, inputData); } } } return returnValue.values(); } - /** * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, * java.io.OutputStream, de.intevation.artifacts.CallContext) @@ -388,9 +438,8 @@ } } - - protected String readOutputType(Document document){ - String value = Config.getStringXPath(document,"action/out/@name"); + 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/cache/CacheFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/cache/CacheFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -10,7 +10,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class CacheFactory { @@ -18,10 +18,9 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(CacheFactory.class); - + private final static String CACHENAME = "artifactdata"; - /** * The singleton Instance of this Factory. */ @@ -41,31 +40,35 @@ /** * This Method provides an singleton Instance of this Class. + * * @return an singleton Instance of this Class */ - public static CacheFactory getInstance(){ - if (instance == null){ + public static CacheFactory getInstance() { + if (instance == null) { instance = new CacheFactory(); } return instance; } - - + /** * Getting the ConnectionPool + * * @return the ConnectionPool */ - public Cache getCache(){ + public Cache getCache() { return this.cacheManager.getCache(CACHENAME); } /** - * Initializes the ConnectionPool. - * Should only be called once on system startup - * @param properties the Properties for the Individual Configuration of the ConnectionPool + * Initializes the ConnectionPool. Should only be called once on system + * startup + * + * @param properties + * the Properties for the Individual Configuration of the + * ConnectionPool */ - public void initializeCache(String configurationFileName){ - if (cacheManager == null){ + public void initializeCache(String configurationFileName) { + if (cacheManager == null) { cacheManager = new CacheManager(configurationFileName); cacheManager.addCache(CACHENAME); } @@ -73,9 +76,10 @@ /** * Checks if the ConnectionPool has already been initialized. + * * @return true if the ConnectionPool is initialized. */ - public boolean isInitialized(){ + public boolean isInitialized() { return this.cacheManager != null; }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContext.java Fri Oct 09 07:54:48 2009 +0000 @@ -8,22 +8,21 @@ import de.intevation.artifactdatabase.DefaultArtifactContext; - /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class GNVArtifactContext extends DefaultArtifactContext{ +public class GNVArtifactContext extends DefaultArtifactContext { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(GNVArtifactContext.class); - - public GNVArtifactContext(){ + + public GNVArtifactContext() { super(); log.debug("GNVArtifactContext.Constructor"); } - + public GNVArtifactContext(Document config) { super(config); log.debug("GNVArtifactContext.Constructor(config)");
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -21,20 +21,20 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class GNVArtifactContextFactory implements ArtifactContextFactory { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(GNVArtifactContext.class); - - public static final String XPATH_GEOBACKEND_CONFIGURATION= "artifact-database/geo-backend/backend-configuration"; - - public static final String XPATH_GEOBACKEND_QUERYCONFIGURATION= "artifact-database/geo-backend/query-configuration"; - + + public static final String XPATH_GEOBACKEND_CONFIGURATION = "artifact-database/geo-backend/backend-configuration"; + + public static final String XPATH_GEOBACKEND_QUERYCONFIGURATION = "artifact-database/geo-backend/query-configuration"; + private final static String CACHECONFIGNODEPATH = "/artifact-database/ehcache/configuration"; - + /** * Constructor */ @@ -51,30 +51,32 @@ try { log.debug("GNVArtifactContextFactory.createArtifactContext"); log.info("Initialisation of the Geo-BackendConnectionPool"); - String backendConfigurationFile = Config.getStringXPath(config, XPATH_GEOBACKEND_CONFIGURATION); + String backendConfigurationFile = Config.getStringXPath(config, + XPATH_GEOBACKEND_CONFIGURATION); Properties properties = getProperties(backendConfigurationFile); ConnectionPoolFactory cpf = ConnectionPoolFactory.getInstance(); cpf.initializeConnectionPool(properties); - + log.info("Initialisation of the QueryContainer"); - String queryConfigurationFile = Config.getStringXPath(config, XPATH_GEOBACKEND_QUERYCONFIGURATION); + String queryConfigurationFile = Config.getStringXPath(config, + XPATH_GEOBACKEND_QUERYCONFIGURATION); Properties queryProperties = getProperties(queryConfigurationFile); QueryContainerFactory qcf = QueryContainerFactory.getInstance(); qcf.initializeQueryContainer(queryProperties); - - + log.info("Initialisation of the Cache"); - String cacheConfigurationFile = Config.getStringXPath(config, CACHECONFIGNODEPATH); + String cacheConfigurationFile = Config.getStringXPath(config, + CACHECONFIGNODEPATH); CacheFactory cf = CacheFactory.getInstance(); cf.initializeCache(cacheConfigurationFile); - + returnValue = new GNVArtifactContext(config); } catch (FileNotFoundException e) { - log.error(e,e); + log.error(e, e); } catch (IOException e) { - log.error(e,e); - } catch (QueryContainerException e){ - log.error(e,e); + log.error(e, e); + } catch (QueryContainerException e) { + log.error(e, e); } return returnValue; } @@ -86,7 +88,8 @@ * @throws IOException */ private Properties getProperties(String filePath) - throws FileNotFoundException, IOException { + throws FileNotFoundException, + IOException { InputStream inputStream = new FileInputStream(filePath); Properties properties = new Properties(); properties.load(inputStream);
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -36,10 +36,10 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class FISArtifact extends DefaultArtifact { - + /** * the logger, used to log exceptions and additonaly information */ @@ -48,112 +48,135 @@ * The UID of this Class */ private static final long serialVersionUID = 2874044542701727083L; - + /** * The Identifier for the Replacement of the Artifactname */ public static final String XPATH_IDENTIFIER_REPLACE = "IDENTIFIER"; - + /** * The XPATH to the XML-Fragment that should be used for the Configuration */ - public static final String XPATH_ARTIFACT_CONFIGURATION= "/artifact-database/artifacts/artifact[@name='"+XPATH_IDENTIFIER_REPLACE+"']"; - + public static final String XPATH_ARTIFACT_CONFIGURATION = "/artifact-database/artifacts/artifact[@name='" + + XPATH_IDENTIFIER_REPLACE + + "']"; + /** * The Name of the Artifact */ private String name = null; - + private Map<String, Product> products = null; - + private Artifact productArtifact = null; - + private Product current = null; - + private ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); - - + /** - * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext) + * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, + * de.intevation.artifacts.CallContext) */ @Override public Document advance(Document target, CallContext context) { - + Document result = null; - if (this.productArtifact == null){ - if (this.current != null){ - - String uuid = Config.getStringXPath(target, "action/uuid/@value"); - String hash = Config.getStringXPath(target, "action/hash/@value"); - this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context); - Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash)); - log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument)); - Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context)); - log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument)); - this.productArtifact.feed(feedDocument, context); - String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name"); - Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName)); - log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument)); - result = this.productArtifact.advance(advanceDocument, context); - }else{ + if (this.productArtifact == null) { + if (this.current != null) { + + String uuid = Config.getStringXPath(target, + "action/uuid/@value"); + String hash = Config.getStringXPath(target, + "action/hash/@value"); + this.productArtifact = this.current.getArtifactFactory() + .createArtifact(uuid, context); + Document feedDocument = xmlUtilities.reInitDocument(this + .createFeedProductArtifactDocument(uuid, hash)); + log.debug("Feed ==> " + + this.xmlUtilities + .writeDocument2String(feedDocument)); + Document descibeDocument = xmlUtilities + .reInitDocument(this.productArtifact.describe(context)); + log.debug("Descibe ==> " + + this.xmlUtilities + .writeDocument2String(descibeDocument)); + this.productArtifact.feed(feedDocument, context); + String targetName = Config.getStringXPath(descibeDocument, + "result/reachable-states/state/@name"); + Document advanceDocument = xmlUtilities.reInitDocument(this + .createAdvanceProductArtifactDocument(uuid, hash, + targetName)); + log.debug("Advance ==> " + + this.xmlUtilities + .writeDocument2String(advanceDocument)); + result = this.productArtifact.advance(advanceDocument, context); + } else { String msg = "Artifact is not configured properly. Call feed first."; log.error(msg); - result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport(msg, + XMLUtils.newDocument()); } - }else{ + } else { result = this.productArtifact.advance(target, context); } return result; } - private Document createAdvanceProductArtifactDocument(String uuid, String hash, String targetName){ + + private Document createAdvanceProductArtifactDocument(String uuid, + String hash, + String targetName) { Document document = XMLUtils.newDocument(); - Element rootNode = xmlUtilities.createArtifactElement(document, "action"); - + Element rootNode = xmlUtilities.createArtifactElement(document, + "action"); + Element typeNode = xmlUtilities.createArtifactElement(document, "type"); typeNode.setAttribute("name", "advanve"); rootNode.appendChild(typeNode); - + Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid"); uuidNode.setAttribute("value", uuid); rootNode.appendChild(uuidNode); - + Element hashNode = xmlUtilities.createArtifactElement(document, "hash"); hashNode.setAttribute("value", hash); rootNode.appendChild(hashNode); - Element targetNode = xmlUtilities.createArtifactElement(document, "target"); + Element targetNode = xmlUtilities.createArtifactElement(document, + "target"); targetNode.setAttribute("name", targetName); rootNode.appendChild(targetNode); - + document.appendChild(rootNode); return document; } - - private Document createFeedProductArtifactDocument(String uuid, String hash){ + + private Document createFeedProductArtifactDocument(String uuid, String hash) { Document document = XMLUtils.newDocument(); - Element rootNode = xmlUtilities.createArtifactElement(document, "action"); - + Element rootNode = xmlUtilities.createArtifactElement(document, + "action"); + Element typeNode = xmlUtilities.createArtifactElement(document, "type"); typeNode.setAttribute("name", "feed"); rootNode.appendChild(typeNode); - + Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid"); uuidNode.setAttribute("value", uuid); rootNode.appendChild(uuidNode); - + Element hashNode = xmlUtilities.createArtifactElement(document, "hash"); hashNode.setAttribute("value", hash); rootNode.appendChild(hashNode); - + Element dataNode = xmlUtilities.createArtifactElement(document, "data"); rootNode.appendChild(dataNode); - - + Collection<InputData> parameter = this.current.getParameter(); - if (parameter != null){ + if (parameter != null) { Iterator<InputData> parameterIt = parameter.iterator(); - while(parameterIt.hasNext()){ + while (parameterIt.hasNext()) { InputData inputData = parameterIt.next(); - Element inputNode = xmlUtilities.createArtifactElement(document, "input"); + Element inputNode = xmlUtilities.createArtifactElement( + document, "input"); inputNode.setAttribute("name", inputData.getName()); inputNode.setAttribute("value", inputData.getValue()); dataNode.appendChild(inputNode); @@ -161,7 +184,7 @@ } document.appendChild(rootNode); return document; - + } /** @@ -169,14 +192,16 @@ */ @Override public Document describe(CallContext context) { - if (this.productArtifact == null){ + if (this.productArtifact == null) { return this.createDescibeOutput(context.getMeta()); - }else{ + } else { Document document = this.productArtifact.describe(context); document = new ArtifactXMLUtilities().reInitDocument(document); - Node staticNode = Config.getNodeXPath(document, "/result/ui/static"); - if (staticNode != null){ - Node staticUI = this.createSelectBox(document, context.getMeta()); + Node staticNode = Config + .getNodeXPath(document, "/result/ui/static"); + if (staticNode != null) { + Node staticUI = this.createSelectBox(document, context + .getMeta()); staticNode.insertBefore(staticUI, staticNode.getFirstChild()); } return document; @@ -184,24 +209,29 @@ } /** - * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, java.lang.Object) + * @see de.intevation.artifactdatabase.DefaultArtifact#feed(org.w3c.dom.Document, + * java.lang.Object) */ @Override public Document feed(Document target, CallContext context) { log.debug("FISArtifact.feed"); Document result = null; - if (this.productArtifact == null){ - String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value"); - log.debug("Looking for ProductArtifact "+productName); + if (this.productArtifact == null) { + String productName = Config.getStringXPath(target, + "action/data/input[@name='product']/@value"); + log.debug("Looking for ProductArtifact " + productName); if (this.products.containsKey(productName)) { this.current = this.products.get(productName); - result = new ArtifactXMLUtilities().createSuccessReport("Feed success New ProductArtifact created", XMLUtils.newDocument()); - }else{ - String msg = "Product does not exists for "+productName; + result = new ArtifactXMLUtilities().createSuccessReport( + "Feed success New ProductArtifact created", XMLUtils + .newDocument()); + } else { + String msg = "Product does not exists for " + productName; log.error(msg); - result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport(msg, + XMLUtils.newDocument()); } - }else{ + } else { log.debug("Feed a Productartifact"); result = this.productArtifact.feed(target, context); } @@ -209,12 +239,14 @@ } /** - * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, java.lang.Object) + * @see de.intevation.artifactdatabase.DefaultArtifact#out(org.w3c.dom.Document, + * java.lang.Object) */ @Override - public void out(Document format, OutputStream outputStream, CallContext context) throws IOException { - if (this.productArtifact != null){ - this.productArtifact.out(format,outputStream, context); + public void out(Document format, OutputStream outputStream, + CallContext context) throws IOException { + if (this.productArtifact != null) { + this.productArtifact.out(format, outputStream, context); } } @@ -225,52 +257,64 @@ super(); } - /** - * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, de.intevation.artifacts.ArtifactFactory, java.lang.Object) - */ + /** + * @see de.intevation.artifactdatabase.DefaultArtifact#setup(java.lang.String, + * de.intevation.artifacts.ArtifactFactory, java.lang.Object) + */ @Override public void setup(String identifier, ArtifactFactory factory, Object context) { log.debug("FISArtifact.setup"); this.name = factory.getName(); - super.setup(identifier,factory, context); - if (context instanceof GNVArtifactContext){ - GNVArtifactContext gnvContext = (GNVArtifactContext)context; + super.setup(identifier, factory, context); + if (context instanceof GNVArtifactContext) { + GNVArtifactContext gnvContext = (GNVArtifactContext) context; Document doc = gnvContext.getConfig(); Node artifactNode = this.getConfigurationFragment(doc); - - NodeList products = Config.getNodeSetXPath(artifactNode,"products/product"); - if (products != null){ - this.products = new HashMap<String, Product>(products.getLength()); - for (int i = 0; i < products.getLength(); i++){ - Node productNode = products.item(i); - String productName = Config.getStringXPath(productNode, "@name"); - NodeList parameterNodes = Config.getNodeSetXPath(productNode, "parameters/parameter"); - Collection<InputData> parameter = null; - if (parameterNodes != null){ - parameter = new ArrayList<InputData>(parameterNodes.getLength()); - for (int j = 0; j < parameterNodes.getLength(); j++){ - Node parameterNode = parameterNodes.item(j); - String name = Config.getStringXPath(parameterNode, "@name"); - String value = Config.getStringXPath(parameterNode, "@value"); - parameter.add(new DefaultInputData(name, value)); - } - } - Node artifactFactoryNode = Config.getNodeXPath(productNode, "artifact-factory"); - ArtifactFactory artifactFactory =new ArtifactFactoryUtilities().createArtitfactFactor(doc, artifactFactoryNode); - this.products.put(productName, new DefaultProduct(productName, parameter,artifactFactory)); - } - } + + NodeList products = Config.getNodeSetXPath(artifactNode, + "products/product"); + if (products != null) { + this.products = new HashMap<String, Product>(products + .getLength()); + for (int i = 0; i < products.getLength(); i++) { + Node productNode = products.item(i); + String productName = Config.getStringXPath(productNode, + "@name"); + NodeList parameterNodes = Config.getNodeSetXPath( + productNode, "parameters/parameter"); + Collection<InputData> parameter = null; + if (parameterNodes != null) { + parameter = new ArrayList<InputData>(parameterNodes + .getLength()); + for (int j = 0; j < parameterNodes.getLength(); j++) { + Node parameterNode = parameterNodes.item(j); + String name = Config.getStringXPath(parameterNode, + "@name"); + String value = Config.getStringXPath(parameterNode, + "@value"); + parameter.add(new DefaultInputData(name, value)); + } + } + Node artifactFactoryNode = Config.getNodeXPath(productNode, + "artifact-factory"); + ArtifactFactory artifactFactory = new ArtifactFactoryUtilities() + .createArtitfactFactor(doc, artifactFactoryNode); + this.products.put(productName, new DefaultProduct( + productName, parameter, artifactFactory)); + } + } } } - - protected Node getConfigurationFragment(Document document){ + + protected Node getConfigurationFragment(Document document) { log.debug("GNVArtifactBase.getConfigurationFragment"); - String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll(XPATH_IDENTIFIER_REPLACE, this.name); + String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll( + XPATH_IDENTIFIER_REPLACE, this.name); log.debug(xpathQuery); - return Config.getNodeXPath(document,xpathQuery); + return Config.getNodeXPath(document, xpathQuery); } - - protected Document createDescibeOutput(CallMeta callMeta){ + + protected Document createDescibeOutput(CallMeta callMeta) { log.debug("GNVArtifactBase.createDescibeOutput"); Document document = XMLUtils.newDocument(); Element rootNode = this.createRootNode(document); @@ -280,38 +324,42 @@ this.createReachableStates(rootNode, document); this.createModel(rootNode, document); this.createUserInterface(rootNode, document, callMeta); - + return document; } - - protected Element createRootNode(Document document){ - Element rootNode = xmlUtilities.createArtifactElement(document,"result"); + + protected Element createRootNode(Document document) { + Element rootNode = xmlUtilities.createArtifactElement(document, + "result"); document.appendChild(rootNode); return rootNode; } - - protected void createHeader(Element parent, Document document, String documentType){ - Element typeNode = xmlUtilities.createArtifactElement(document,"type"); + + protected void createHeader(Element parent, Document document, + String documentType) { + Element typeNode = xmlUtilities.createArtifactElement(document, "type"); typeNode.setAttribute("name", documentType); parent.appendChild(typeNode); - - Element uuidNode = xmlUtilities.createArtifactElement(document,"uuid"); + + Element uuidNode = xmlUtilities.createArtifactElement(document, "uuid"); uuidNode.setAttribute("value", super.identifier); parent.appendChild(uuidNode); - - Element hashNode = xmlUtilities.createArtifactElement(document,"hash"); + + Element hashNode = xmlUtilities.createArtifactElement(document, "hash"); hashNode.setAttribute("value", this.hash()); parent.appendChild(hashNode); - } - protected void createReachableStates(Element parent,Document document){ - Element stateNode = xmlUtilities.createArtifactElement(document,"reachable-states"); - if (this.products != null){ + + protected void createReachableStates(Element parent, Document document) { + Element stateNode = xmlUtilities.createArtifactElement(document, + "reachable-states"); + if (this.products != null) { Iterator<Product> products = this.products.values().iterator(); - while(products.hasNext()){ + while (products.hasNext()) { Product product = products.next(); - Element currentNode = xmlUtilities.createArtifactElement(document,"state"); + Element currentNode = xmlUtilities.createArtifactElement( + document, "state"); currentNode.setAttribute("name", product.getName()); currentNode.setAttribute("description", product.getName()); stateNode.appendChild(currentNode); @@ -319,83 +367,97 @@ } parent.appendChild(stateNode); } - - protected void createCurrentState(Element parent, Document document){ - Element stateNode = xmlUtilities.createArtifactElement(document,"state"); + + protected void createCurrentState(Element parent, Document document) { + Element stateNode = xmlUtilities.createArtifactElement(document, + "state"); stateNode.setAttribute("name", "choose-product"); - stateNode.setAttribute("description", "Initialer Stand Auswahl des products"); + stateNode.setAttribute("description", + "Initialer Stand Auswahl des products"); parent.appendChild(stateNode); } - - - protected void createModel(Element parent, Document document){ - Element modelNode = xmlUtilities.createArtifactElement(document,"model"); - - Element inputNode = xmlUtilities.createArtifactElement(document,"input"); + + protected void createModel(Element parent, Document document) { + Element modelNode = xmlUtilities.createArtifactElement(document, + "model"); + + Element inputNode = xmlUtilities.createArtifactElement(document, + "input"); inputNode.setAttribute("name", "product"); inputNode.setAttribute("type", "String"); modelNode.appendChild(inputNode); - + parent.appendChild(modelNode); } - - protected void createUserInterface(Element parent, Document document, CallMeta callMeta){ - Element uiNode = xmlUtilities.createArtifactElement(document,"ui"); + + protected void createUserInterface(Element parent, Document document, + CallMeta callMeta) { + Element uiNode = xmlUtilities.createArtifactElement(document, "ui"); ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); - Node dynamic = xmlUtilities.createArtifactElement(document, "dynamic"); + Node dynamic = xmlUtilities.createArtifactElement(document, "dynamic"); uiNode.appendChild(dynamic); - if (this.products != null && !this.products.isEmpty()){ - Element selectNode = createSelectBox(document,callMeta); - + if (this.products != null && !this.products.isEmpty()) { + Element selectNode = createSelectBox(document, callMeta); + dynamic.appendChild(selectNode); } - + parent.appendChild(uiNode); } + /** * @param document * @param xmlUtilities * @return */ private Element createSelectBox(Document document, CallMeta callMeta) { - + ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); String selectboxName = "product"; Iterator<Product> it = this.products.values().iterator(); - Element selectNode = xmlUtilities.createXFormElement(document,"select1"); + Element selectNode = xmlUtilities.createXFormElement(document, + "select1"); selectNode.setAttribute("ref", selectboxName); - - + Element lableNode = xmlUtilities.createXFormElement(document, "label"); - lableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), selectboxName, selectboxName)); + lableNode.setTextContent(RessourceFactory.getInstance().getRessource( + callMeta.getLanguages(), selectboxName, selectboxName)); selectNode.appendChild(lableNode); - Element choiceNode = xmlUtilities.createXFormElement(document, "choices"); + Element choiceNode = xmlUtilities.createXFormElement(document, + "choices"); selectNode.appendChild(choiceNode); - while (it.hasNext()){ + while (it.hasNext()) { Product p = it.next(); - Element itemNode = xmlUtilities.createXFormElement(document, "item"); - - if (this.current != null && this.current.getName().equals(p.getName())){ + Element itemNode = xmlUtilities + .createXFormElement(document, "item"); + + if (this.current != null + && this.current.getName().equals(p.getName())) { itemNode.setAttribute("selected", "true"); } - - Element choiceLableNode = xmlUtilities.createXFormElement(document, "label"); - choiceLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), p.getName(), p.getName())); + + Element choiceLableNode = xmlUtilities.createXFormElement(document, + "label"); + choiceLableNode.setTextContent(RessourceFactory.getInstance() + .getRessource(callMeta.getLanguages(), p.getName(), + p.getName())); itemNode.appendChild(choiceLableNode); - - Element choicValueNode = xmlUtilities.createXFormElement(document, "value"); + + Element choicValueNode = xmlUtilities.createXFormElement(document, + "value"); choicValueNode.setTextContent(p.getName()); itemNode.appendChild(choicValueNode); - + choiceNode.appendChild(itemNode); - + } return selectNode; } - - protected void createOutputs(Element parent, Document document){ + + protected void createOutputs(Element parent, Document document) { log.debug("GNVArtifactBase.createOutputs"); - Element outputsNode = xmlUtilities.createArtifactElement(document,"outputs"); + Element outputsNode = xmlUtilities.createArtifactElement(document, + "outputs"); parent.appendChild(outputsNode); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/product/DefaultProduct.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/product/DefaultProduct.java Fri Oct 09 07:54:48 2009 +0000 @@ -10,24 +10,25 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultProduct implements Product { private String name = null; - + private Collection<InputData> parameter = null; - + private ArtifactFactory artifactFactory = null; - /** * Constructor + * * @param name * @param parameter * @param artifactFactory */ - public DefaultProduct(String name, Collection<InputData> parameter, ArtifactFactory artifactFactory) { + public DefaultProduct(String name, Collection<InputData> parameter, + ArtifactFactory artifactFactory) { super(); this.name = name; this.parameter = parameter;
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/product/Product.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/product/Product.java Fri Oct 09 07:54:48 2009 +0000 @@ -11,11 +11,13 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface Product extends Serializable{ +public interface Product extends Serializable { public String getName(); + public Collection<InputData> getParameter(); + public ArtifactFactory getArtifactFactory(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/RessourceFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/RessourceFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -12,7 +12,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class RessourceFactory { @@ -20,17 +20,17 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(RessourceFactory.class); - + /** * The singleton Instance of this Factory. */ private static RessourceFactory instance = null; private static String RESSOURCE_BASE_ID = "artifact.ressource.dir"; - + private static String ressourceName = "artifactMessages"; - private static String DEFAULT_DIR = "lang"; - + private static String DEFAULT_DIR = "lang"; + private String ressourceDir = null; /** @@ -43,39 +43,40 @@ /** * This Method provides an singleton Instance of this Class. + * * @return an singleton Instance of this Class */ - public static synchronized RessourceFactory getInstance(){ - if (instance == null){ + public static synchronized RessourceFactory getInstance() { + if (instance == null) { instance = new RessourceFactory(); } return instance; } - + /** * Deliveres the translated Value for an Key to an given Language - * @param locale The choosen locale - * @param key the key - * @param defaultValue the Value that should be returned. + * + * @param locale + * The choosen locale + * @param key + * the key + * @param defaultValue + * the Value that should be returned. * @return the translated Value */ - public String getRessource( - PreferredLocale [] preferredLocales, - String key, - String defaultValue - ) { + public String getRessource(PreferredLocale[] preferredLocales, String key, + String defaultValue) { if (key == null || preferredLocales.length == 0) { return defaultValue; } try { - ResourceBundle rb = ResourceBundle.getBundle( - ressourceDir + "/" + ressourceName, - preferredLocales[0].getLocale()); + ResourceBundle rb = ResourceBundle.getBundle(ressourceDir + "/" + + ressourceName, + preferredLocales[0].getLocale()); return rb.getString(key); - } - catch (MissingResourceException mre) { + } catch (MissingResourceException mre) { log.warn(mre.getLocalizedMessage()); return defaultValue; }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -17,6 +17,7 @@ import java.awt.Color; import java.awt.Font; +import java.awt.Transparency; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; @@ -59,332 +60,356 @@ */ public class ChartFactory { - /** - * Default Logging instance - */ - private static Logger sLogger = Logger.getLogger(ChartFactory.class); - private static boolean sDebug = sLogger.isDebugEnabled(); - + /** + * Default Logging instance + */ + private static Logger sLogger = Logger.getLogger(ChartFactory.class); + private static boolean sDebug = sLogger.isDebugEnabled(); - public synchronized void createSimpleTimeSeriesChart(ChartLabels pLabels, ChartStyle pStyle, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, OutputStream outputStream, Collection<Result> resultSet) throws IOException, TechnicalChartException { - if (sDebug) - sLogger.debug("createSimpleTimeSeriesChart()"); - int lLowerLevel = Integer.MIN_VALUE; - int lUpperLevel = Integer.MAX_VALUE; - if (pStyle.isUseUpperDataLevel() - && pStyle.getUpperLevel() < Integer.MAX_VALUE) { - lUpperLevel = pStyle.getUpperLevel(); - } - if (pStyle.isUseLowerDataLevel() - && pStyle.getLowerLevel() > Integer.MIN_VALUE) { - lLowerLevel = pStyle.getLowerLevel(); - } - if (sDebug) - sLogger.debug(" vor createDataset()"); - XYDataset lSet = this.createDataset(resultSet, lUpperLevel, - lLowerLevel,parameters,measurements); - if (sDebug) - sLogger.debug(" nach createDataset()"); - final Color[] color = {Color.black, Color.red, Color.green, Color.blue}; - DateAxis domain = new DateAxis(pLabels.getDomainAxisLabel()); + public synchronized void createSimpleTimeSeriesChart( + ChartLabels pLabels, + ChartStyle pStyle, + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements, + OutputStream outputStream, + Collection<Result> resultSet) + throws IOException, + TechnicalChartException { + if (sDebug) + sLogger.debug("createSimpleTimeSeriesChart()"); + int lLowerLevel = Integer.MIN_VALUE; + int lUpperLevel = Integer.MAX_VALUE; + if (pStyle.isUseUpperDataLevel() + && pStyle.getUpperLevel() < Integer.MAX_VALUE) { + lUpperLevel = pStyle.getUpperLevel(); + } + if (pStyle.isUseLowerDataLevel() + && pStyle.getLowerLevel() > Integer.MIN_VALUE) { + lLowerLevel = pStyle.getLowerLevel(); + } + if (sDebug) + sLogger.debug(" vor createDataset()"); + XYDataset lSet = this.createDataset(resultSet, lUpperLevel, + lLowerLevel, parameters, measurements); + if (sDebug) + sLogger.debug(" nach createDataset()"); + final Color[] color = { Color.black, Color.red, Color.green, Color.blue }; + DateAxis domain = new DateAxis(pLabels.getDomainAxisLabel()); NumberAxis axis; StandardXYItemRenderer renderer = new StandardXYItemRenderer(); - XYPlot plot = new XYPlot(); - //Global settings - - plot.setOrientation(PlotOrientation.VERTICAL); - plot.setBackgroundPaint(Color.lightGray); - plot.setDomainGridlinePaint(Color.white); - plot.setRangeGridlinePaint(Color.white); - plot.setAxisOffset(new RectangleInsets(5.0,5.0,5.0,5.0)); - //plot.getRangeAxis().setFixedDimension(10.0); - plot.setDomainAxis(domain); - plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); - if (parameters.size() == 1) { - KeyValueDescibeData parameter = parameters.iterator().next(); - axis = new NumberAxis(parameter.getValue()); - if(parameter.getValue().contains("richtung")){ - NumberAxis axis1 = new NumberAxis( - ((String) parameter.getValue()));//,new Range(0.0,360.0)); - axis1.setTickUnit(new NumberTickUnit(30.0)); - axis1.setUpperBound(360.0); - axis1.setLowerBound(0.0); - //axis1.setDisplayRange(0.0,360.0); - plot.setRangeAxis( axis1); - }else{ - axis.setFixedDimension(10.0); - axis.setAutoRangeIncludesZero(false); - plot.setRangeAxis(axis); - } - axis.configure(); - plot.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT); - plot.setRenderer(renderer); - plot.setDataset(lSet); - } else { - // Individual settings for different parameters - for (int i = 0; i < lSet.getSeriesCount(); i++) { - - plot.setDataset(i, getDataset((TimeSeriesCollection) lSet, i)); - Color mColor=color[i % color.length]; // zyklische Farbvergabe - mColor = color[0]; - // if ( pParameterId.length==1){ - - if(((String) lSet.getSeriesKey(i)).contains("richtung")){ - NumberAxis axis1 = new NumberAxis(((String) lSet.getSeriesKey(i)));//,new Range(0.0,360.0)); - axis1.setTickUnit(new NumberTickUnit(30.0)); - //axis1.setDisplayRange(0.0,360.0); - axis1.setLabelPaint(mColor); - axis1.setTickLabelPaint(mColor); - axis1.setUpperBound(360.0); - axis1.setLowerBound(0.0); - plot.setRangeAxis(i, axis1); - - - } - else { - axis = new NumberAxis((String) lSet.getSeriesKey(i)); - axis.setFixedDimension(10.0); - axis.setAutoRangeIncludesZero(false); - axis.setLabelPaint(mColor); - axis.setTickLabelPaint(mColor); - plot.setRangeAxis(i, axis); - axis.configure(); - } - if (i % 2 != 0) - plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT); - else - plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT); - plot.mapDatasetToRangeAxis(i, i); - // } - renderer = new StandardXYItemRenderer(); - renderer.setSeriesPaint(i, mColor); - // renderer.setSeriesStroke(i,stroke[j]); - plot.setRenderer(i, renderer); - } - } - JFreeChart chart = new JFreeChart( - pLabels.getTitle(), - new Font ("SansSerif",Font.BOLD,24), - plot,true); - - - setStyle(chart, pStyle); - configureRenderingOptions(chart); - if (sDebug) - sLogger.debug(" vor encodeChart()"); - - encodeChart(chart, pStyle, outputStream); - } - private static XYDataset getDataset(TimeSeriesCollection T, int pIndex){ //throws TechnicalChartException{ - //if (T.getSeriesCount() < pIndex) throw TechnicalChartException(); - TimeSeriesCollection TSC = new TimeSeriesCollection(); - TSC.addSeries(T.getSeries(pIndex)); - return (XYDataset) TSC; - } - - private void configureRenderingOptions(JFreeChart pJfreechart) { - org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart - .getPlot()).getRenderer(); - if (xyitemrenderer instanceof XYLineAndShapeRenderer) { - XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; - xylineandshaperenderer.setBaseShapesVisible(true); - xylineandshaperenderer.setBaseShapesFilled(true); - } - } - - private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) { - if (sDebug) - sLogger.debug("setStyle()"); - pJfreechart.setBackgroundPaint(pStyle.getCanvasColor()); - XYPlot xyplot = (XYPlot) pJfreechart.getPlot(); - xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor()); - xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor()); - xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor()); - - Insets lOffsets = pStyle.getAxisOffset(); - RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper, - lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight); - xyplot.setAxisOffset(lRectangleInsets); - xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible()); - xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible()); - - } - - - private TimeSeries createTimeSeries(String pTimeSeriesName, Collection<Result> resultSet, - int lUpperCut, int lLowerCut,int pStart,int pEnd, Date dStart, Date dEnd) throws TechnicalChartException{ - if (sDebug) - sLogger.debug("createTimeSeries()"); - Result lRow0, lRow1; - - Date lDate=null, lDate0=null; - - TimeSeries lTimeseries = new TimeSeries(pTimeSeriesName, - org.jfree.data.time.Minute.class); - try { - long maxGap=0, lDateDiff=0; - double lValue=0; - + XYPlot plot = new XYPlot(); + // Global settings - int i = 0; - Iterator<Result> resultIterator = resultSet.iterator(); - while (resultIterator.hasNext()){ - Result lRow = resultIterator.next(); - if (i >= pStart+1 && i <= pEnd){ - if (i == pStart+1){ - lRow0 = lRow;// - - // Handle Gaps > 0.5% timeserieslength, i.e do not draw here - // +TODO mache maxGap variabel über diagram options - maxGap = (dEnd.getTime() - dStart.getTime()) / 200; // 0,5 prozent der Länge - if (maxGap < 3600000) maxGap=3600010; - if (maxGap <(dEnd.getTime() - dStart.getTime())/(pEnd-pStart)) - maxGap = (dEnd.getTime() - dStart.getTime())/(pEnd-pStart) + 1000; - - if (sDebug) - sLogger.debug("MaxGap : "+maxGap/1000+" Länge : "+(dEnd.getTime() - dStart.getTime())/1000+ - "Intervall "+(dEnd.getTime() - dStart.getTime())/(pEnd-pStart)/1000); - lDate = lRow0.getDate("XORDINATE"); - lDate0 = lDate; - lValue = lRow0.getDouble("YORDINATE"); - if (lValue > lLowerCut && lValue < lUpperCut){ - //lTimeseries.addOrUpdate(new Minute(lDate), lValue); - lTimeseries.add(new Minute(lDate), lValue); - } - } - //for (int i = pStart+1; i <= pEnd; i++) { - lRow1 =lRow; - lDate = lRow1.getDate("XORDINATE"); - lValue = lRow1.getDouble("YORDINATE"); - lDateDiff = lDate.getTime() - lDate0.getTime(); - if (lDateDiff > maxGap) { - // add 1 minute in millisecs to left hand side Date - // and insert Dummy to break line - lDate0.setTime((lDate0.getTime() + 60000)); - lTimeseries.addOrUpdate(new Minute(lDate0), null); - lTimeseries.addOrUpdate(new Minute(lDate), lValue); - //lTimeseries.add(new Minute(lDate0), null); - } else if (lDateDiff == 0) { - if (sDebug) - sLogger.debug("Datediff: "+lDateDiff+" bei index : "+i+" Datum : "+lDate+" "+lDate0); - } - else if (lValue > lLowerCut && lValue < lUpperCut) { - lTimeseries.addOrUpdate(new Minute(lDate), lValue); - //lTimeseries.add(new Minute(lDate), lValue); - } - lRow0 = lRow1; - lDate0 = lDate; - }else if (i > pEnd){ - return lTimeseries; - } - i++; + plot.setOrientation(PlotOrientation.VERTICAL); + plot.setBackgroundPaint(Color.lightGray); + plot.setDomainGridlinePaint(Color.white); + plot.setRangeGridlinePaint(Color.white); + plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); + // plot.getRangeAxis().setFixedDimension(10.0); + plot.setDomainAxis(domain); + plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); + if (parameters.size() == 1) { + KeyValueDescibeData parameter = parameters.iterator().next(); + axis = new NumberAxis(parameter.getValue()); + if (parameter.getValue().contains("richtung")) { + NumberAxis axis1 = new NumberAxis((parameter + .getValue()));// ,new Range(0.0,360.0)); + axis1.setTickUnit(new NumberTickUnit(30.0)); + axis1.setUpperBound(360.0); + axis1.setLowerBound(0.0); + // axis1.setDisplayRange(0.0,360.0); + plot.setRangeAxis(axis1); + } else { + axis.setFixedDimension(10.0); + axis.setAutoRangeIncludesZero(false); + plot.setRangeAxis(axis); } - - - } catch (OutOfMemoryError e) { - sLogger.error(e.getMessage(), e); - return lTimeseries; - - } catch (Exception e) { //TechnicalChartException - sLogger.error(e.getMessage(), e); - } - finally { - } - - return lTimeseries; - } + axis.configure(); + plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); + plot.setRenderer(renderer); + plot.setDataset(lSet); + } else { + // Individual settings for different parameters + for (int i = 0; i < lSet.getSeriesCount(); i++) { - private XYDataset createDataset(Collection<Result> resultSet, - int lUpperCut, int lLowerCut,Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements) throws TechnicalChartException { - - TimeSeriesCollection lTimeSeriesCollection = new TimeSeriesCollection(); - try{ - Date dStart = null, dEnd= null; - String break1, break2, break3; - int mStart = 0; - int mEnd = 0; - - - Iterator<Result> resultIterator = resultSet.iterator(); - if (resultIterator.hasNext()){ - Result row = resultIterator.next(); - - break1 = row.getString("GROUP1"); // 2 - break2 = row.getString("GROUP2"); //3 - break3 = row.getString("GROUP3"); // 4 - dStart = row.getDate("XORDINATE"); - int i = 1; - while (resultIterator.hasNext()) { - row = resultIterator.next(); - if (!break1.equals(row.getString("GROUP1")) - || !break2 .equals(row.getString("GROUP2")) - || !break3.equals(row.getString("GROUP3"))){ - String mTimeSeriesName = findValueTitle(parameters,break1)+" "+ - findValueTitle(measurements,break2)+"m"; - - lTimeSeriesCollection.addSeries(createTimeSeries(mTimeSeriesName, - resultSet, lUpperCut, lLowerCut, mStart, mEnd, dStart, dEnd)); - mStart = i; - dStart = row.getDate("XORDINATE"); - break1 = row.getString("GROUP1"); - break2 = row.getString("GROUP2"); //3 - break3 = row.getString("GROUP3"); // 4 - - } - mEnd = i; - dEnd = row.getDate("XORDINATE"); - i = i + 1; - } - - String mTimeSeriesName = findValueTitle(parameters,break1)+" "+ - findValueTitle(measurements,break2)+"m"; - lTimeSeriesCollection.addSeries(createTimeSeries(mTimeSeriesName, - resultSet, lUpperCut, lLowerCut, mStart, mEnd, dStart, dEnd)); - } - } - catch (Exception e){ - sLogger.error(e.getMessage(), e); - } - finally{ - } - return lTimeSeriesCollection; - } + plot.setDataset(i, getDataset((TimeSeriesCollection) lSet, i)); + Color mColor = color[i % color.length]; // zyklische Farbvergabe + mColor = color[0]; + // if ( pParameterId.length==1){ - - - private void encodeChart(JFreeChart pChart, ChartStyle pStyle, OutputStream outputStream) - throws IOException { - if (sDebug) - sLogger.debug("encodeChart()"); - KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter(); - lEncoder.setEncodingAlpha(true); + if (((String) lSet.getSeriesKey(i)).contains("richtung")) { + NumberAxis axis1 = new NumberAxis(((String) lSet + .getSeriesKey(i)));// ,new Range(0.0,360.0)); + axis1.setTickUnit(new NumberTickUnit(30.0)); + // axis1.setDisplayRange(0.0,360.0); + axis1.setLabelPaint(mColor); + axis1.setTickLabelPaint(mColor); + axis1.setUpperBound(360.0); + axis1.setLowerBound(0.0); + plot.setRangeAxis(i, axis1); - int lWidth = (int) pStyle.getChartSize().getWidth(); - int lHeight = (int) pStyle.getChartSize().getHeight(); + } else { + axis = new NumberAxis((String) lSet.getSeriesKey(i)); + axis.setFixedDimension(10.0); + axis.setAutoRangeIncludesZero(false); + axis.setLabelPaint(mColor); + axis.setTickLabelPaint(mColor); + plot.setRangeAxis(i, axis); + axis.configure(); + } + if (i % 2 != 0) + plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT); + else + plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT); + plot.mapDatasetToRangeAxis(i, i); + // } + renderer = new StandardXYItemRenderer(); + renderer.setSeriesPaint(i, mColor); + // renderer.setSeriesStroke(i,stroke[j]); + plot.setRenderer(i, renderer); + } + } + JFreeChart chart = new JFreeChart(pLabels.getTitle(), new Font( + "SansSerif", Font.BOLD, 24), plot, true); - BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight, - BufferedImage.BITMASK, null); - - lEncoder.encode(lImage, outputStream); - -} + setStyle(chart, pStyle); + configureRenderingOptions(chart); + if (sDebug) + sLogger.debug(" vor encodeChart()"); - private String findValueTitle(Collection<KeyValueDescibeData> values, String pMmtId){ - int id = 0; - try { + encodeChart(chart, pStyle, outputStream); + } + + private static XYDataset getDataset(TimeSeriesCollection T, int pIndex) { // throws + // TechnicalChartException{ + // if (T.getSeriesCount() < pIndex) throw TechnicalChartException(); + TimeSeriesCollection TSC = new TimeSeriesCollection(); + TSC.addSeries(T.getSeries(pIndex)); + return TSC; + } + + private void configureRenderingOptions(JFreeChart pJfreechart) { + org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart + .getPlot()).getRenderer(); + if (xyitemrenderer instanceof XYLineAndShapeRenderer) { + XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; + xylineandshaperenderer.setBaseShapesVisible(true); + xylineandshaperenderer.setBaseShapesFilled(true); + } + } + + private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) { + if (sDebug) + sLogger.debug("setStyle()"); + pJfreechart.setBackgroundPaint(pStyle.getCanvasColor()); + XYPlot xyplot = (XYPlot) pJfreechart.getPlot(); + xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor()); + xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor()); + xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor()); + + Insets lOffsets = pStyle.getAxisOffset(); + RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper, + lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight); + xyplot.setAxisOffset(lRectangleInsets); + xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible()); + xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible()); + + } + + private TimeSeries createTimeSeries(String pTimeSeriesName, + Collection<Result> resultSet, + int lUpperCut, int lLowerCut, + int pStart, int pEnd, Date dStart, + Date dEnd) + throws TechnicalChartException { + if (sDebug) + sLogger.debug("createTimeSeries()"); + Result lRow0, lRow1; + + Date lDate = null, lDate0 = null; + + TimeSeries lTimeseries = new TimeSeries(pTimeSeriesName, + org.jfree.data.time.Minute.class); + try { + long maxGap = 0, lDateDiff = 0; + double lValue = 0; + + int i = 0; + Iterator<Result> resultIterator = resultSet.iterator(); + while (resultIterator.hasNext()) { + Result lRow = resultIterator.next(); + if (i >= pStart + 1 && i <= pEnd) { + if (i == pStart + 1) { + lRow0 = lRow;// + + // Handle Gaps > 0.5% timeserieslength, i.e do not draw + // here + // +TODO mache maxGap variabel über diagram options + maxGap = (dEnd.getTime() - dStart.getTime()) / 200; // 0,5 + // prozent + // der + // Länge + if (maxGap < 3600000) + maxGap = 3600010; + if (maxGap < (dEnd.getTime() - dStart.getTime()) + / (pEnd - pStart)) + maxGap = (dEnd.getTime() - dStart.getTime()) + / (pEnd - pStart) + 1000; + + if (sDebug) + sLogger.debug("MaxGap : " + maxGap / 1000 + + " Länge : " + + (dEnd.getTime() - dStart.getTime()) + / 1000 + "Intervall " + + (dEnd.getTime() - dStart.getTime()) + / (pEnd - pStart) / 1000); + lDate = lRow0.getDate("XORDINATE"); + lDate0 = lDate; + lValue = lRow0.getDouble("YORDINATE"); + if (lValue > lLowerCut && lValue < lUpperCut) { + // lTimeseries.addOrUpdate(new Minute(lDate), + // lValue); + lTimeseries.add(new Minute(lDate), lValue); + } + } + // for (int i = pStart+1; i <= pEnd; i++) { + lRow1 = lRow; + lDate = lRow1.getDate("XORDINATE"); + lValue = lRow1.getDouble("YORDINATE"); + lDateDiff = lDate.getTime() - lDate0.getTime(); + if (lDateDiff > maxGap) { + // add 1 minute in millisecs to left hand side Date + // and insert Dummy to break line + lDate0.setTime((lDate0.getTime() + 60000)); + lTimeseries.addOrUpdate(new Minute(lDate0), null); + lTimeseries.addOrUpdate(new Minute(lDate), lValue); + // lTimeseries.add(new Minute(lDate0), null); + } else if (lDateDiff == 0) { + if (sDebug) + sLogger.debug("Datediff: " + lDateDiff + + " bei index : " + i + " Datum : " + + lDate + " " + lDate0); + } else if (lValue > lLowerCut && lValue < lUpperCut) { + lTimeseries.addOrUpdate(new Minute(lDate), lValue); + // lTimeseries.add(new Minute(lDate), lValue); + } + lRow0 = lRow1; + lDate0 = lDate; + } else if (i > pEnd) { + return lTimeseries; + } + i++; + } + + } catch (OutOfMemoryError e) { + sLogger.error(e.getMessage(), e); + return lTimeseries; + + } catch (Exception e) { // TechnicalChartException + sLogger.error(e.getMessage(), e); + } finally { + } + + return lTimeseries; + } + + private XYDataset createDataset(Collection<Result> resultSet, + int lUpperCut, int lLowerCut, + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements) + throws TechnicalChartException { + + TimeSeriesCollection lTimeSeriesCollection = new TimeSeriesCollection(); + try { + Date dStart = null, dEnd = null; + String break1, break2, break3; + int mStart = 0; + int mEnd = 0; + + Iterator<Result> resultIterator = resultSet.iterator(); + if (resultIterator.hasNext()) { + Result row = resultIterator.next(); + + break1 = row.getString("GROUP1"); // 2 + break2 = row.getString("GROUP2"); // 3 + break3 = row.getString("GROUP3"); // 4 + dStart = row.getDate("XORDINATE"); + int i = 1; + while (resultIterator.hasNext()) { + row = resultIterator.next(); + if (!break1.equals(row.getString("GROUP1")) + || !break2.equals(row.getString("GROUP2")) + || !break3.equals(row.getString("GROUP3"))) { + String mTimeSeriesName = findValueTitle(parameters, + break1) + + " " + + findValueTitle(measurements, + break2) + "m"; + + lTimeSeriesCollection.addSeries(createTimeSeries( + mTimeSeriesName, resultSet, lUpperCut, + lLowerCut, mStart, mEnd, dStart, dEnd)); + mStart = i; + dStart = row.getDate("XORDINATE"); + break1 = row.getString("GROUP1"); + break2 = row.getString("GROUP2"); // 3 + break3 = row.getString("GROUP3"); // 4 + + } + mEnd = i; + dEnd = row.getDate("XORDINATE"); + i = i + 1; + } + + String mTimeSeriesName = findValueTitle(parameters, break1) + + " " + + findValueTitle(measurements, break2) + + "m"; + lTimeSeriesCollection.addSeries(createTimeSeries( + mTimeSeriesName, resultSet, lUpperCut, lLowerCut, + mStart, mEnd, dStart, dEnd)); + } + } catch (Exception e) { + sLogger.error(e.getMessage(), e); + } finally { + } + return lTimeSeriesCollection; + } + + private void encodeChart(JFreeChart pChart, ChartStyle pStyle, + OutputStream outputStream) throws IOException { + if (sDebug) + sLogger.debug("encodeChart()"); + KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter(); + lEncoder.setEncodingAlpha(true); + + int lWidth = (int) pStyle.getChartSize().getWidth(); + int lHeight = (int) pStyle.getChartSize().getHeight(); + + BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight, + Transparency.BITMASK, null); + + lEncoder.encode(lImage, outputStream); + + } + + private String findValueTitle(Collection<KeyValueDescibeData> values, + String pMmtId) { + int id = 0; + try { id = Integer.parseInt(pMmtId); } catch (NumberFormatException e) { - sLogger.warn(e,e); + sLogger.warn(e, e); return pMmtId; } - + Iterator<KeyValueDescibeData> it = values.iterator(); - while(it.hasNext()){ - KeyValueDescibeData data = it.next(); - if (id ==Integer.parseInt(data.getKey())){ - return data.getValue(); - } - } - return ""; + while (it.hasNext()) { + KeyValueDescibeData data = it.next(); + if (id == Integer.parseInt(data.getKey())) { + return data.getValue(); + } + } + return ""; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartLabels.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartLabels.java Fri Oct 09 07:54:48 2009 +0000 @@ -13,9 +13,8 @@ package de.intevation.gnv.chart; /** - * @author drewnak - * @author Tim Englich <tim.englich@intevation.de> - * Changes and codecleanup + * @author drewnak + * @author Tim Englich <tim.englich@intevation.de> Changes and codecleanup */ public class ChartLabels { /** @@ -29,6 +28,7 @@ /** * Constructor + * * @param title * @param domainAxisLabel */ @@ -44,7 +44,6 @@ return this.title; } - /** * @return the timeAxisLabel */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartStyle.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/ChartStyle.java Fri Oct 09 07:54:48 2009 +0000 @@ -44,9 +44,11 @@ * @param pRangeCrosshairVisible * @param pAxisOffset */ - public ChartStyle(Color pCanvasColor, Color pPlotBackgroundColor, Color pDomainGridlineColor, - Color pRangeGridlineColor, boolean pDomainCrosshairVisible, boolean pRangeCrosshairVisible, - Insets pAxisOffset, Dimension pChartSize) { + public ChartStyle(Color pCanvasColor, Color pPlotBackgroundColor, + Color pDomainGridlineColor, Color pRangeGridlineColor, + boolean pDomainCrosshairVisible, + boolean pRangeCrosshairVisible, Insets pAxisOffset, + Dimension pChartSize) { super(); mCanvasColor = pCanvasColor; mPlotBackgroundColor = pPlotBackgroundColor; @@ -130,7 +132,6 @@ mOverrideDefaultChartWidth = pOverrideDefaultChartWidth; } - public void setNewChartWidth(int pNewChartWidth) { mChartSize.setSize(pNewChartWidth, mChartSize.getHeight()); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -28,85 +28,89 @@ /** * * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class HorizontalProfileChartFactory extends VerticalProfileChartFactory { - /** - * Default Logging instance - */ - private static Logger sLogger = Logger.getLogger(HorizontalProfileChartFactory.class); - private static boolean sDebug = sLogger.isDebugEnabled(); - - - public HorizontalProfileChartFactory(){ - super(); - super.plotOrientation = PlotOrientation.VERTICAL; - } + /** + * Default Logging instance + */ + private static Logger sLogger = Logger + .getLogger(HorizontalProfileChartFactory.class); + private static boolean sDebug = sLogger.isDebugEnabled(); - - /** - * - * @param seriesName - * @param resultSet - * @param lUpperCut - * @param lLowerCut - * @param pStart - * @param pEnd - * @return - * @throws TechnicalChartException - */ - @Override - protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet, - int lUpperCut, int lLowerCut,int pStart,int pEnd) throws TechnicalChartException{ - if (sDebug) - sLogger.debug("createXYSeries()"); - XYSeries series = new XYSeries(seriesName); - try { - double xValue=0; - double yValue=0; - double xStartCoord = 0; - double yStartCoord = 0; - int i = 0; - Iterator<Result> resultIterator = resultSet.iterator(); - while (resultIterator.hasNext()){ + public HorizontalProfileChartFactory() { + super(); + super.plotOrientation = PlotOrientation.VERTICAL; + } + + /** + * + * @param seriesName + * @param resultSet + * @param lUpperCut + * @param lLowerCut + * @param pStart + * @param pEnd + * @return + * @throws TechnicalChartException + */ + @Override + protected XYSeries createXYSeries(String seriesName, + Collection<Result> resultSet, + int lUpperCut, int lLowerCut, int pStart, + int pEnd) throws TechnicalChartException { + if (sDebug) + sLogger.debug("createXYSeries()"); + XYSeries series = new XYSeries(seriesName); + try { + double xValue = 0; + double yValue = 0; + double xStartCoord = 0; + double yStartCoord = 0; + int i = 0; + Iterator<Result> resultIterator = resultSet.iterator(); + while (resultIterator.hasNext()) { Result lRow = resultIterator.next(); - if (i >= pStart && i <= pEnd ){ - if (xStartCoord == 0 && yStartCoord == 0){ + if (i >= pStart && i <= pEnd) { + if (xStartCoord == 0 && yStartCoord == 0) { xStartCoord = lRow.getDouble("XORDINATE_XCOORD"); yStartCoord = lRow.getDouble("XORDINATE_YCOORD"); } - - double currentXCoord = lRow.getDouble("XORDINATE_XCOORD");; + + double currentXCoord = lRow.getDouble("XORDINATE_XCOORD"); + ; double currentYCoord = lRow.getDouble("XORDINATE_YCOORD"); - - xValue = this.calculateDistance(xStartCoord, yStartCoord, currentXCoord, currentYCoord); - - yValue = lRow.getDouble("YORDINATE"); - series.add(xValue, yValue); - sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue); - - }else if (i > pEnd){ + + xValue = this.calculateDistance(xStartCoord, yStartCoord, + currentXCoord, currentYCoord); + + yValue = lRow.getDouble("YORDINATE"); + series.add(xValue, yValue); + sLogger.debug(seriesName + " Added Value " + xValue + " / " + + yValue); + + } else if (i > pEnd) { return series; } i++; } - } catch (OutOfMemoryError e) { - sLogger.error(e.getMessage(), e); - return series; - - } catch (Exception e) { //TechnicalChartException - sLogger.error(e.getMessage(), e); - } - finally { - } - - return series; - } - - private double calculateDistance(double xStartCoord, double yStartCoord, double currentXCoord, double currentYCoord){ - double dx = xStartCoord - currentXCoord; - double dy = yStartCoord - currentYCoord; - return Math.sqrt((dx*dx)+(dy*dy)); - } + } catch (OutOfMemoryError e) { + sLogger.error(e.getMessage(), e); + return series; + + } catch (Exception e) { // TechnicalChartException + sLogger.error(e.getMessage(), e); + } finally { + } + + return series; + } + + private double calculateDistance(double xStartCoord, double yStartCoord, + double currentXCoord, double currentYCoord) { + double dx = xStartCoord - currentXCoord; + double dy = yStartCoord - currentYCoord; + return Math.sqrt((dx * dx) + (dy * dy)); + } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/Insets.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/Insets.java Fri Oct 09 07:54:48 2009 +0000 @@ -17,6 +17,7 @@ public double mLower; public double mLeft; public double mRight; + /** * @param pUpper * @param pLower
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -17,6 +17,7 @@ import java.awt.Color; import java.awt.Font; +import java.awt.Transparency; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; @@ -45,281 +46,293 @@ /** * * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class VerticalProfileChartFactory { - /** - * Default Logging instance - */ - private static Logger sLogger = Logger.getLogger(VerticalProfileChartFactory.class); - private static boolean sDebug = sLogger.isDebugEnabled(); - protected PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; + /** + * Default Logging instance + */ + private static Logger sLogger = Logger + .getLogger(VerticalProfileChartFactory.class); + private static boolean sDebug = sLogger.isDebugEnabled(); + protected PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; - public synchronized void createProfileChart(ChartLabels pLabels, ChartStyle pStyle, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, OutputStream outputStream, Collection<Result> resultSet) throws IOException, TechnicalChartException { - if (sDebug) - sLogger.debug("createSimpleTimeSeriesChart()"); - int lLowerLevel = Integer.MIN_VALUE; - int lUpperLevel = Integer.MAX_VALUE; - if (pStyle.isUseUpperDataLevel() - && pStyle.getUpperLevel() < Integer.MAX_VALUE) { - lUpperLevel = pStyle.getUpperLevel(); - } - if (pStyle.isUseLowerDataLevel() - && pStyle.getLowerLevel() > Integer.MIN_VALUE) { - lLowerLevel = pStyle.getLowerLevel(); - } - if (sDebug) - sLogger.debug(" vor createDataset()"); - XYDataset lSet = this.createDataset(resultSet, lUpperLevel, - lLowerLevel,parameters,measurements); - if (sDebug) - sLogger.debug(" nach createDataset()"); - final Color[] color = {Color.black, Color.red, Color.green, Color.blue}; - NumberAxis domain = new NumberAxis(pLabels.getDomainAxisLabel()); + public synchronized void createProfileChart( + ChartLabels pLabels, + ChartStyle pStyle, + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements, + OutputStream outputStream, + Collection<Result> resultSet) + throws IOException, + TechnicalChartException { + if (sDebug) + sLogger.debug("createSimpleTimeSeriesChart()"); + int lLowerLevel = Integer.MIN_VALUE; + int lUpperLevel = Integer.MAX_VALUE; + if (pStyle.isUseUpperDataLevel() + && pStyle.getUpperLevel() < Integer.MAX_VALUE) { + lUpperLevel = pStyle.getUpperLevel(); + } + if (pStyle.isUseLowerDataLevel() + && pStyle.getLowerLevel() > Integer.MIN_VALUE) { + lLowerLevel = pStyle.getLowerLevel(); + } + if (sDebug) + sLogger.debug(" vor createDataset()"); + XYDataset lSet = this.createDataset(resultSet, lUpperLevel, + lLowerLevel, parameters, measurements); + if (sDebug) + sLogger.debug(" nach createDataset()"); + final Color[] color = { Color.black, Color.red, Color.green, Color.blue }; + NumberAxis domain = new NumberAxis(pLabels.getDomainAxisLabel()); NumberAxis axis; StandardXYItemRenderer renderer = new StandardXYItemRenderer(); - XYPlot plot = new XYPlot(); - //Global settings - - plot.setOrientation(plotOrientation); - plot.setBackgroundPaint(Color.lightGray); - plot.setDomainGridlinePaint(Color.white); - plot.setRangeGridlinePaint(Color.white); - plot.setAxisOffset(new RectangleInsets(5.0,5.0,5.0,5.0)); - //plot.getRangeAxis().setFixedDimension(10.0); - plot.setDomainAxis(domain); - plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); - if (parameters.size() == 1) { - KeyValueDescibeData parameter = parameters.iterator().next(); - axis = new NumberAxis(parameter.getValue()); - if(parameter.getValue().contains("richtung")){ - NumberAxis axis1 = new NumberAxis( - ((String) parameter.getValue()));//,new Range(0.0,360.0)); - axis1.setTickUnit(new NumberTickUnit(30.0)); - axis1.setUpperBound(360.0); - axis1.setLowerBound(0.0); - //axis1.setDisplayRange(0.0,360.0); - plot.setRangeAxis( axis1); - }else{ - axis.setFixedDimension(10.0); - axis.setAutoRangeIncludesZero(false); - plot.setRangeAxis(axis); - } - axis.configure(); - plot.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT); - plot.setRenderer(renderer); - plot.setDataset(lSet); - } else { - // Individual settings for different parameters - for (int i = 0; i < lSet.getSeriesCount(); i++) { + XYPlot plot = new XYPlot(); + // Global settings - plot.setDataset(i, getDataset((XYSeriesCollection) lSet, i)); - Color mColor=color[i % color.length]; // zyklische Farbvergabe - mColor = color[0]; - // if ( pParameterId.length==1){ - - if(((String) lSet.getSeriesKey(i)).contains("richtung")){ - NumberAxis axis1 = new NumberAxis(((String) lSet.getSeriesKey(i)));//,new Range(0.0,360.0)); - axis1.setTickUnit(new NumberTickUnit(30.0)); - //axis1.setDisplayRange(0.0,360.0); - axis1.setLabelPaint(mColor); - axis1.setTickLabelPaint(mColor); - axis1.setUpperBound(360.0); - axis1.setLowerBound(0.0); - plot.setRangeAxis(i, axis1); - - - } - else { - axis = new NumberAxis((String) lSet.getSeriesKey(i)); - axis.setFixedDimension(10.0); - axis.setAutoRangeIncludesZero(false); - axis.setLabelPaint(mColor); - axis.setTickLabelPaint(mColor); - plot.setRangeAxis(i, axis); - axis.configure(); - } - if (i % 2 != 0) - plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT); - else - plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT); - plot.mapDatasetToRangeAxis(i, i); - // } - renderer = new StandardXYItemRenderer(); - renderer.setSeriesPaint(i, mColor); - // renderer.setSeriesStroke(i,stroke[j]); - plot.setRenderer(i, renderer); - } - } - JFreeChart chart = new JFreeChart( - pLabels.getTitle(), - new Font ("SansSerif",Font.BOLD,24), - plot,true); - + plot.setOrientation(plotOrientation); + plot.setBackgroundPaint(Color.lightGray); + plot.setDomainGridlinePaint(Color.white); + plot.setRangeGridlinePaint(Color.white); + plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); + // plot.getRangeAxis().setFixedDimension(10.0); + plot.setDomainAxis(domain); + plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); + if (parameters.size() == 1) { + KeyValueDescibeData parameter = parameters.iterator().next(); + axis = new NumberAxis(parameter.getValue()); + if (parameter.getValue().contains("richtung")) { + NumberAxis axis1 = new NumberAxis((parameter + .getValue()));// ,new Range(0.0,360.0)); + axis1.setTickUnit(new NumberTickUnit(30.0)); + axis1.setUpperBound(360.0); + axis1.setLowerBound(0.0); + // axis1.setDisplayRange(0.0,360.0); + plot.setRangeAxis(axis1); + } else { + axis.setFixedDimension(10.0); + axis.setAutoRangeIncludesZero(false); + plot.setRangeAxis(axis); + } + axis.configure(); + plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); + plot.setRenderer(renderer); + plot.setDataset(lSet); + } else { + // Individual settings for different parameters + for (int i = 0; i < lSet.getSeriesCount(); i++) { - setStyle(chart, pStyle); - configureRenderingOptions(chart); - if (sDebug) - sLogger.debug(" vor encodeChart()"); - - encodeChart(chart, pStyle, outputStream); - } - private static XYDataset getDataset(XYSeriesCollection T, int pIndex){ //throws TechnicalChartException{ - //if (T.getSeriesCount() < pIndex) throw TechnicalChartException(); - XYSeriesCollection XYSC = new XYSeriesCollection(); - XYSC.addSeries(T.getSeries(pIndex)); - return (XYDataset) XYSC; - } - - private void configureRenderingOptions(JFreeChart pJfreechart) { - org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart - .getPlot()).getRenderer(); - if (xyitemrenderer instanceof XYLineAndShapeRenderer) { - XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; - xylineandshaperenderer.setBaseShapesVisible(true); - xylineandshaperenderer.setBaseShapesFilled(true); - } - } + plot.setDataset(i, getDataset((XYSeriesCollection) lSet, i)); + Color mColor = color[i % color.length]; // zyklische Farbvergabe + mColor = color[0]; + // if ( pParameterId.length==1){ - private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) { - if (sDebug) - sLogger.debug("setStyle()"); - pJfreechart.setBackgroundPaint(pStyle.getCanvasColor()); - XYPlot xyplot = (XYPlot) pJfreechart.getPlot(); - xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor()); - xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor()); - xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor()); - - Insets lOffsets = pStyle.getAxisOffset(); - RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper, - lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight); - xyplot.setAxisOffset(lRectangleInsets); - xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible()); - xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible()); + if (((String) lSet.getSeriesKey(i)).contains("richtung")) { + NumberAxis axis1 = new NumberAxis(((String) lSet + .getSeriesKey(i)));// ,new Range(0.0,360.0)); + axis1.setTickUnit(new NumberTickUnit(30.0)); + // axis1.setDisplayRange(0.0,360.0); + axis1.setLabelPaint(mColor); + axis1.setTickLabelPaint(mColor); + axis1.setUpperBound(360.0); + axis1.setLowerBound(0.0); + plot.setRangeAxis(i, axis1); - } - - - protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet, - int lUpperCut, int lLowerCut,int pStart,int pEnd) throws TechnicalChartException{ - if (sDebug) - sLogger.debug("createXYSeries()"); - XYSeries series = new XYSeries(seriesName); - try { - double xValue=0; - double yValue=0; - int i = 0; - Iterator<Result> resultIterator = resultSet.iterator(); - while (resultIterator.hasNext()){ + } else { + axis = new NumberAxis((String) lSet.getSeriesKey(i)); + axis.setFixedDimension(10.0); + axis.setAutoRangeIncludesZero(false); + axis.setLabelPaint(mColor); + axis.setTickLabelPaint(mColor); + plot.setRangeAxis(i, axis); + axis.configure(); + } + if (i % 2 != 0) + plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT); + else + plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT); + plot.mapDatasetToRangeAxis(i, i); + // } + renderer = new StandardXYItemRenderer(); + renderer.setSeriesPaint(i, mColor); + // renderer.setSeriesStroke(i,stroke[j]); + plot.setRenderer(i, renderer); + } + } + JFreeChart chart = new JFreeChart(pLabels.getTitle(), new Font( + "SansSerif", Font.BOLD, 24), plot, true); + + setStyle(chart, pStyle); + configureRenderingOptions(chart); + if (sDebug) + sLogger.debug(" vor encodeChart()"); + + encodeChart(chart, pStyle, outputStream); + } + + private static XYDataset getDataset(XYSeriesCollection T, int pIndex) { // throws + // TechnicalChartException{ + // if (T.getSeriesCount() < pIndex) throw TechnicalChartException(); + XYSeriesCollection XYSC = new XYSeriesCollection(); + XYSC.addSeries(T.getSeries(pIndex)); + return XYSC; + } + + private void configureRenderingOptions(JFreeChart pJfreechart) { + org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = ((XYPlot) pJfreechart + .getPlot()).getRenderer(); + if (xyitemrenderer instanceof XYLineAndShapeRenderer) { + XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; + xylineandshaperenderer.setBaseShapesVisible(true); + xylineandshaperenderer.setBaseShapesFilled(true); + } + } + + private void setStyle(JFreeChart pJfreechart, ChartStyle pStyle) { + if (sDebug) + sLogger.debug("setStyle()"); + pJfreechart.setBackgroundPaint(pStyle.getCanvasColor()); + XYPlot xyplot = (XYPlot) pJfreechart.getPlot(); + xyplot.setBackgroundPaint(pStyle.getPlotBackgroundColor()); + xyplot.setDomainGridlinePaint(pStyle.getDomainGridlineColor()); + xyplot.setRangeGridlinePaint(pStyle.getRangeGridlineColor()); + + Insets lOffsets = pStyle.getAxisOffset(); + RectangleInsets lRectangleInsets = new RectangleInsets(lOffsets.mUpper, + lOffsets.mLeft, lOffsets.mLower, lOffsets.mRight); + xyplot.setAxisOffset(lRectangleInsets); + xyplot.setDomainCrosshairVisible(pStyle.isDomainCrosshairVisible()); + xyplot.setRangeCrosshairVisible(pStyle.isRangeCrosshairVisible()); + + } + + protected XYSeries createXYSeries(String seriesName, + Collection<Result> resultSet, + int lUpperCut, int lLowerCut, int pStart, + int pEnd) throws TechnicalChartException { + if (sDebug) + sLogger.debug("createXYSeries()"); + XYSeries series = new XYSeries(seriesName); + try { + double xValue = 0; + double yValue = 0; + int i = 0; + Iterator<Result> resultIterator = resultSet.iterator(); + while (resultIterator.hasNext()) { Result lRow = resultIterator.next(); - if (i >= pStart && i <= pEnd ){ - xValue = lRow.getDouble("XORDINATE"); - yValue = lRow.getDouble("YORDINATE"); - series.add(xValue, yValue); - sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue); - - }else if (i > pEnd){ + if (i >= pStart && i <= pEnd) { + xValue = lRow.getDouble("XORDINATE"); + yValue = lRow.getDouble("YORDINATE"); + series.add(xValue, yValue); + sLogger.debug(seriesName + " Added Value " + xValue + " / " + + yValue); + + } else if (i > pEnd) { return series; } i++; } - } catch (OutOfMemoryError e) { - sLogger.error(e.getMessage(), e); - return series; - - } catch (Exception e) { //TechnicalChartException - sLogger.error(e.getMessage(), e); - } - finally { - } - - return series; - } - - private XYDataset createDataset(Collection<Result> resultSet, - int lUpperCut, int lLowerCut,Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements) throws TechnicalChartException { - - XYSeriesCollection xyDataset = new XYSeriesCollection(); + } catch (OutOfMemoryError e) { + sLogger.error(e.getMessage(), e); + return series; - try{ - String break1, break2, break3; - int mStart = 0; - int mEnd = 0; - - - Iterator<Result> resultIterator = resultSet.iterator(); - if (resultIterator.hasNext()){ - // Row row = new Row(sArrayStrLine); - Result row = resultIterator.next(); - - break1 = row.getString("GROUP1"); // 2 - break2 = row.getString("GROUP2"); //3 - break3 = row.getString("GROUP3"); // 4 - int i = 1; - while (resultIterator.hasNext()) { - row = resultIterator.next(); - if (!break1.equals(row.getString("GROUP1")) - || !break2 .equals(row.getString("GROUP2")) - || !break3.equals(row.getString("GROUP3"))){ - String seriesName = findValueTitle(parameters,break1)+" "+ - findValueTitle(measurements,break2); - sLogger.debug("Neuer Datensatz "+seriesName+ "von Datensätzen "+mStart+" / "+mEnd); - xyDataset.addSeries(createXYSeries(seriesName, - resultSet, lUpperCut, lLowerCut, mStart, mEnd)); - mStart = i; - - break1 = row.getString("GROUP1"); - break2 = row.getString("GROUP2"); //3 - break3 = row.getString("GROUP3"); // 4 - - } - mEnd = i; - //mEnd ++; - i = i + 1; - } - - String seriesName = findValueTitle(parameters,break1)+" "+ - findValueTitle(measurements,break2); - sLogger.debug("Neuer Datensatz "+seriesName+ "von Datensätzen "+mStart+" / "+mEnd); - xyDataset.addSeries(createXYSeries(seriesName, - resultSet, lUpperCut, lLowerCut, mStart, mEnd)); - } - } - catch (Exception e){ - sLogger.error(e.getMessage(), e); - } - finally{ - } - return xyDataset; - } + } catch (Exception e) { // TechnicalChartException + sLogger.error(e.getMessage(), e); + } finally { + } - - - private void encodeChart(JFreeChart pChart, ChartStyle pStyle, OutputStream outputStream) - throws IOException { - if (sDebug) - sLogger.debug("encodeChart()"); - KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter(); - lEncoder.setEncodingAlpha(true); - - int lWidth = (int) pStyle.getChartSize().getWidth(); - int lHeight = (int) pStyle.getChartSize().getHeight(); + return series; + } - BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight, - BufferedImage.BITMASK, null); - - lEncoder.encode(lImage, outputStream); - -} + private XYDataset createDataset(Collection<Result> resultSet, + int lUpperCut, int lLowerCut, + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements) + throws TechnicalChartException { - private String findValueTitle(Collection<KeyValueDescibeData> values, String id){ - if (values != null){ + XYSeriesCollection xyDataset = new XYSeriesCollection(); + + try { + String break1, break2, break3; + int mStart = 0; + int mEnd = 0; + + Iterator<Result> resultIterator = resultSet.iterator(); + if (resultIterator.hasNext()) { + // Row row = new Row(sArrayStrLine); + Result row = resultIterator.next(); + + break1 = row.getString("GROUP1"); // 2 + break2 = row.getString("GROUP2"); // 3 + break3 = row.getString("GROUP3"); // 4 + int i = 1; + while (resultIterator.hasNext()) { + row = resultIterator.next(); + if (!break1.equals(row.getString("GROUP1")) + || !break2.equals(row.getString("GROUP2")) + || !break3.equals(row.getString("GROUP3"))) { + String seriesName = findValueTitle(parameters, break1) + + " " + + findValueTitle(measurements, + break2); + sLogger.debug("Neuer Datensatz " + seriesName + + "von Datensätzen " + mStart + " / " + + mEnd); + xyDataset.addSeries(createXYSeries(seriesName, + resultSet, lUpperCut, lLowerCut, mStart, mEnd)); + mStart = i; + + break1 = row.getString("GROUP1"); + break2 = row.getString("GROUP2"); // 3 + break3 = row.getString("GROUP3"); // 4 + + } + mEnd = i; + // mEnd ++; + i = i + 1; + } + + String seriesName = findValueTitle(parameters, break1) + " " + + findValueTitle(measurements, break2); + sLogger.debug("Neuer Datensatz " + seriesName + + "von Datensätzen " + mStart + " / " + mEnd); + xyDataset.addSeries(createXYSeries(seriesName, resultSet, + lUpperCut, lLowerCut, mStart, mEnd)); + } + } catch (Exception e) { + sLogger.error(e.getMessage(), e); + } finally { + } + return xyDataset; + } + + private void encodeChart(JFreeChart pChart, ChartStyle pStyle, + OutputStream outputStream) throws IOException { + if (sDebug) + sLogger.debug("encodeChart()"); + KeypointPNGEncoderAdapter lEncoder = new KeypointPNGEncoderAdapter(); + lEncoder.setEncodingAlpha(true); + + int lWidth = (int) pStyle.getChartSize().getWidth(); + int lHeight = (int) pStyle.getChartSize().getHeight(); + + BufferedImage lImage = pChart.createBufferedImage(lWidth, lHeight, + Transparency.BITMASK, null); + + lEncoder.encode(lImage, outputStream); + + } + + private String findValueTitle(Collection<KeyValueDescibeData> values, + String id) { + if (values != null) { Iterator<KeyValueDescibeData> it = values.iterator(); - while(it.hasNext()){ + while (it.hasNext()) { KeyValueDescibeData data = it.next(); - if (id.equals(data.getKey())){ - return data.getValue(); + if (id.equals(data.getKey())) { + return data.getValue(); } } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/exception/TechnicalChartException.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/exception/TechnicalChartException.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.chart.exception; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class TechnicalChartException extends Exception { @@ -21,6 +22,7 @@ /** * Constructor + * * @param message */ public TechnicalChartException(String message) { @@ -29,6 +31,7 @@ /** * Constructor + * * @param cause */ public TechnicalChartException(Throwable cause) { @@ -37,6 +40,7 @@ /** * Constructor + * * @param message * @param cause */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -12,23 +12,24 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class HorizontalProfileArtifact extends GNVArtifactBase { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(HorizontalProfileArtifact.class); + private static Logger log = Logger + .getLogger(HorizontalProfileArtifact.class); /** * */ private static final long serialVersionUID = -721831166719594662L; - + /** * Constructor */ - public HorizontalProfileArtifact(){ + public HorizontalProfileArtifact() { super(); log.debug("HorizontalProfileArtifact.Constructor"); this.name = "horizontalProfile"; @@ -44,11 +45,12 @@ } /** - * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, de.intevation.artifacts.ArtifactFactory, java.lang.Object) + * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, + * de.intevation.artifacts.ArtifactFactory, java.lang.Object) */ @Override public void setup(String identifier, ArtifactFactory factory, Object context) { log.debug("HorizontalProfileArtifact.setup"); - super.setup(identifier,factory,context); + super.setup(identifier, factory, context); } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileInstantaneousPointArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileInstantaneousPointArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,25 +7,27 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class HorizontalProfileInstantaneousPointArtifact extends HorizontalProfileArtifact { +public class HorizontalProfileInstantaneousPointArtifact extends + HorizontalProfileArtifact { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(HorizontalProfileInstantaneousPointArtifact.class); - + private static Logger log = Logger + .getLogger(HorizontalProfileInstantaneousPointArtifact.class); + /** * The UID of this Class. */ - private static final long serialVersionUID = -6700816287500004553L; - + private static final long serialVersionUID = -6700816287500004553L; + /** * Constructor */ - public HorizontalProfileInstantaneousPointArtifact(){ + public HorizontalProfileInstantaneousPointArtifact() { super(); log.debug("HorizontalProfileInstantaneousPointArtifact.Constructor"); - super.name = super.name+ "InstantaneousPoint"; + super.name = super.name + "InstantaneousPoint"; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileMeshArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileMeshArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,26 +7,26 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class HorizontalProfileMeshArtifact extends HorizontalProfileArtifact { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(HorizontalProfileMeshArtifact.class); - - + private static Logger log = Logger + .getLogger(HorizontalProfileMeshArtifact.class); + /** * The UID of this class */ private static final long serialVersionUID = -8291547966693867205L; - + /** * Constructor */ - public HorizontalProfileMeshArtifact(){ + public HorizontalProfileMeshArtifact() { super(); log.debug("VerticalProfileMeshArtifact.Constructor"); - super.name = super.name+ "Mesh"; + super.name = super.name + "Mesh"; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -12,24 +12,23 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class VerticalProfileArtifact extends GNVArtifactBase { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(VerticalProfileArtifact.class); - - + /** * The UID of this class */ private static final long serialVersionUID = -8291547966693867205L; - + /** * Constructor */ - public VerticalProfileArtifact(){ + public VerticalProfileArtifact() { super(); log.debug("VerticalProfileArtifact.Constructor"); this.name = "verticalProfile"; @@ -45,11 +44,12 @@ } /** - * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, de.intevation.artifacts.ArtifactFactory, java.lang.Object) + * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, + * de.intevation.artifacts.ArtifactFactory, java.lang.Object) */ @Override public void setup(String identifier, ArtifactFactory factory, Object context) { log.debug("VerticalProfileArtifact.setup"); - super.setup(identifier,factory,context); + super.setup(identifier, factory, context); } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileInstantaneousPointArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileInstantaneousPointArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,26 +7,27 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class VerticalProfileInstantaneousPointArtifact extends VerticalProfileArtifact { +public class VerticalProfileInstantaneousPointArtifact extends + VerticalProfileArtifact { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(VerticalProfileInstantaneousPointArtifact.class); - - + private static Logger log = Logger + .getLogger(VerticalProfileInstantaneousPointArtifact.class); + /** * The UID of this class */ private static final long serialVersionUID = -8291547966693867205L; - + /** * Constructor */ - public VerticalProfileInstantaneousPointArtifact(){ + public VerticalProfileInstantaneousPointArtifact() { super(); log.debug("VerticalProfileInstantaneousPointArtifact.Constructor"); - super.name = super.name+ "InstantaneousPoint"; + super.name = super.name + "InstantaneousPoint"; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileMeshArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/vertical/VerticalProfileMeshArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,26 +7,26 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class VerticalProfileMeshArtifact extends VerticalProfileArtifact { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(VerticalProfileMeshArtifact.class); - - + private static Logger log = Logger + .getLogger(VerticalProfileMeshArtifact.class); + /** * The UID of this class */ private static final long serialVersionUID = -8291547966693867205L; - + /** * Constructor */ - public VerticalProfileMeshArtifact(){ + public VerticalProfileMeshArtifact() { super(); log.debug("VerticalProfileMeshArtifact.Constructor"); - super.name = super.name+ "Mesh"; + super.name = super.name + "Mesh"; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java Fri Oct 09 07:54:48 2009 +0000 @@ -9,7 +9,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class HorizontalProfileStatistics extends TimeseriesStatistics { @@ -19,7 +19,7 @@ public HorizontalProfileStatistics() { super(); } - + @Override protected double calculateXOrdinateValue(Result row) throws SQLException { return row.getDouble("XORDINATE_XCOORD");
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/Statistic.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/Statistic.java Fri Oct 09 07:54:48 2009 +0000 @@ -22,7 +22,7 @@ * <ol> * <li></li> * </ol> - * + * * @author blume * @version 1.0 * @serial 1.0
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/Statistics.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/Statistics.java Fri Oct 09 07:54:48 2009 +0000 @@ -25,7 +25,7 @@ * <ol> * <li>Providng a marker interface for statistics.</li> * </ol> - * + * * @author blume * @version 1.0 * @serial 1.0 @@ -39,6 +39,8 @@ * @return * @throws StatisticsException */ - public Collection<Statistic> calculateStatistics(Collection<Result> resultSet) throws StatisticsException; + public Collection<Statistic> calculateStatistics( + Collection<Result> resultSet) + throws StatisticsException; }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java Fri Oct 09 07:54:48 2009 +0000 @@ -27,14 +27,12 @@ import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.statistics.exception.StatisticsException; - - /** * The class <code>TimeseriesStatistics</code> fulfills the following purposes: * <ol> * <li></li> * </ol> - * + * * @author blume * @author Tim Englich <tim.englich@intevation.de> * @version 1.0 @@ -52,73 +50,71 @@ private Collection<Statistic> statistics = null; - public TimeseriesStatistics(){ + public TimeseriesStatistics() { super(); } - + /** * @see de.intevation.gnv.statistics.Statistics#calculateStatistics(java.util.Collection) */ - public Collection<Statistic> calculateStatistics(Collection<Result> resultSet) throws StatisticsException { + public Collection<Statistic> calculateStatistics( + Collection<Result> resultSet) + throws StatisticsException { DescriptiveStatistics lStatistics = null; SimpleRegression lRegression = null; statistics = new ArrayList<Statistic>(); String break1, break2; int lSeries = 1; - try{ - + try { + Iterator<Result> resultIterator = resultSet.iterator(); - if (resultIterator.hasNext()){ + if (resultIterator.hasNext()) { Result row = resultIterator.next(); break1 = row.getString("GROUP1"); break2 = row.getString("GROUP2"); - lRegression = new SimpleRegression(); - lStatistics = DescriptiveStatistics.newInstance(); - while (resultIterator.hasNext()) { - - if (!break1.equals(row.getString("GROUP1")) + lRegression = new SimpleRegression(); + lStatistics = DescriptiveStatistics.newInstance(); + while (resultIterator.hasNext()) { + + if (!break1.equals(row.getString("GROUP1")) || !break2.equals(row.getString("GROUP2"))) { - addStatisticsValues(lStatistics, lRegression, lSeries); - - lStatistics.clear(); - lRegression.clear(); - - lStatistics.addValue(row.getDouble("YORDINATE")); - Double x = this.calculateXOrdinateValue(row); - lRegression.addData(x ,row.getDouble("YORDINATE")); - - break1 = row.getString("GROUP1"); - break2 = row.getString("GROUP2"); - row = resultIterator.next(); - lSeries ++; + addStatisticsValues(lStatistics, lRegression, lSeries); + + lStatistics.clear(); + lRegression.clear(); + + lStatistics.addValue(row.getDouble("YORDINATE")); + Double x = this.calculateXOrdinateValue(row); + lRegression.addData(x, row.getDouble("YORDINATE")); + + break1 = row.getString("GROUP1"); + break2 = row.getString("GROUP2"); + row = resultIterator.next(); + lSeries++; + } else { + + lStatistics.addValue(row.getDouble("YORDINATE")); + Double x = this.calculateXOrdinateValue(row); + lRegression.addData(x, row.getDouble("YORDINATE")); + row = resultIterator.next(); + } + } - else{ - - lStatistics.addValue(row.getDouble("YORDINATE")); - Double x = this.calculateXOrdinateValue(row); - lRegression.addData(x,row.getDouble("YORDINATE")); - row = resultIterator.next(); - } - + addStatisticsValues(lStatistics, lRegression, lSeries); + lStatistics.clear(); + lRegression.clear(); } - addStatisticsValues(lStatistics, lRegression,lSeries); - lStatistics.clear(); - lRegression.clear(); - } - } - catch (Exception e){ + } catch (Exception e) { log.error(e.getMessage(), e); } - + return statistics; } - - - protected double calculateXOrdinateValue(Result row) throws SQLException{ - return new Double( (row.getDate("XORDINATE")).getTime()/1000/3600) ; + + protected double calculateXOrdinateValue(Result row) throws SQLException { + return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600); } - - + /** * @param lStatistics * @param lRegression @@ -126,20 +122,43 @@ * @param lSeries */ private void addStatisticsValues(DescriptiveStatistics lStatistics, - SimpleRegression lRegression, int lSeries) { - statistics.add(new Statistic("gnviewer.statistics.series",(double)lSeries)); - statistics.add(new Statistic("gnviewer.statistics.descriptive.arithmeticMean", lStatistics.getMean())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.kurtosis", lStatistics.getKurtosis())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.max", lStatistics.getMax())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.min", lStatistics.getMin())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.n", lStatistics.getN())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.90", lStatistics.getPercentile(90))); - statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.75", lStatistics.getPercentile(75))); - statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.50", lStatistics.getPercentile(50))); - statistics.add(new Statistic("gnviewer.statistics.descriptive.percentile.10", lStatistics.getPercentile(10))); - statistics.add(new Statistic("gnviewer.statistics.descriptive.deviation", lStatistics.getStandardDeviation())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.variance", lStatistics.getVariance())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.intercept", lRegression.getIntercept())); - statistics.add(new Statistic("gnviewer.statistics.descriptive.slope", lRegression.getSlope())); - } + SimpleRegression lRegression, int lSeries) { + statistics.add(new Statistic("gnviewer.statistics.series", + lSeries)); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.arithmeticMean", lStatistics + .getMean())); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.kurtosis", lStatistics + .getKurtosis())); + statistics.add(new Statistic("gnviewer.statistics.descriptive.max", + lStatistics.getMax())); + statistics.add(new Statistic("gnviewer.statistics.descriptive.min", + lStatistics.getMin())); + statistics.add(new Statistic("gnviewer.statistics.descriptive.n", + lStatistics.getN())); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.percentile.90", lStatistics + .getPercentile(90))); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.percentile.75", lStatistics + .getPercentile(75))); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.percentile.50", lStatistics + .getPercentile(50))); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.percentile.10", lStatistics + .getPercentile(10))); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.deviation", lStatistics + .getStandardDeviation())); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.variance", lStatistics + .getVariance())); + statistics.add(new Statistic( + "gnviewer.statistics.descriptive.intercept", lRegression + .getIntercept())); + statistics.add(new Statistic("gnviewer.statistics.descriptive.slope", + lRegression.getSlope())); + } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/VerticalProfileStatistics.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/VerticalProfileStatistics.java Fri Oct 09 07:54:48 2009 +0000 @@ -9,7 +9,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class VerticalProfileStatistics extends TimeseriesStatistics { @@ -24,6 +24,5 @@ protected double calculateXOrdinateValue(Result row) throws SQLException { return row.getDouble("XORDINATE"); } - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/exception/StatisticsException.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/exception/StatisticsException.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.statistics.exception; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class StatisticsException extends Exception { @@ -21,6 +22,7 @@ /** * Constructor + * * @param arg0 */ public StatisticsException(String arg0) { @@ -29,6 +31,7 @@ /** * Constructor + * * @param arg0 */ public StatisticsException(Throwable arg0) { @@ -37,6 +40,7 @@ /** * Constructor + * * @param arg0 * @param arg1 */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -12,24 +12,23 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class TimeSeriesArtifact extends GNVArtifactBase { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(TimeSeriesArtifact.class); - - + /** * The UID of this class */ private static final long serialVersionUID = -8291547966693867205L; - + /** * Constructor */ - public TimeSeriesArtifact(){ + public TimeSeriesArtifact() { super(); log.debug("TimeSeriesArtifact.Constructor"); this.name = "timeSeries"; @@ -45,11 +44,12 @@ } /** - * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, de.intevation.artifacts.ArtifactFactory, java.lang.Object) + * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, + * de.intevation.artifacts.ArtifactFactory, java.lang.Object) */ @Override public void setup(String identifier, ArtifactFactory factory, Object context) { log.debug("TimeSeriesArtifact.setup"); - super.setup(identifier,factory,context); + super.setup(identifier, factory, context); } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesMeshArtifact.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/timeseries/TimeSeriesMeshArtifact.java Fri Oct 09 07:54:48 2009 +0000 @@ -1,4 +1,5 @@ package de.intevation.gnv.timeseries; + public class TimeSeriesMeshArtifact extends TimeSeriesArtifact { /** @@ -12,7 +13,7 @@ */ public TimeSeriesMeshArtifact() { super(); - super.name = super.name+ "Mesh"; + super.name = super.name + "Mesh"; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputData.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,23 +2,24 @@ * */ package de.intevation.gnv.transition; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultInputData implements InputData { - /** * */ private static final long serialVersionUID = 4308041648698108066L; private String name = null; private String value = null; + /** * Constructor */ - public DefaultInputData(String name , String value ) { + public DefaultInputData(String name, String value) { this.name = name; this.value = value; } @@ -42,14 +43,14 @@ */ @Override public String toString() { - return this.name + "==> "+ this.value; + return this.name + "==> " + this.value; } /** * @see de.intevation.gnv.transition.InputData#concartValue(java.lang.String) */ public void concartValue(String value) { - this.value = this.value +" , "+value; + this.value = this.value + " , " + value; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultInputValue.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.transition; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultInputValue implements InputValue { @@ -17,17 +18,19 @@ private boolean multiselect = false; private int usedInQueries = 1; private String defaultValue = "N/N"; - - - public DefaultInputValue(String name, String type, String defaultValue, boolean multiselect){ - this(name, type, multiselect, 1); - this.defaultValue = defaultValue; - + + public DefaultInputValue(String name, String type, String defaultValue, + boolean multiselect) { + this(name, type, multiselect, 1); + this.defaultValue = defaultValue; + } + /** * Constructor */ - public DefaultInputValue(String name, String type, boolean multiselect, int usedInQueries){ + public DefaultInputValue(String name, String type, boolean multiselect, + int usedInQueries) { this.name = name; this.type = type; this.multiselect = multiselect; @@ -53,7 +56,8 @@ */ @Override public String toString() { - return "InputValue "+this.name+" ==> "+this.type+ "==> multiselect: "+this.multiselect; + return "InputValue " + this.name + " ==> " + this.type + + "==> multiselect: " + this.multiselect; } /** @@ -68,7 +72,7 @@ } public String getDefaultValue() { - return this.defaultValue; + return this.defaultValue; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultOutputMode.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,7 +7,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultOutputMode implements OutputMode { @@ -19,21 +19,23 @@ private String description = null; private String mimeType = null; private Collection<InputValue> inputParameters = null; - + /** * Constructor + * * @param name * @param description * @param mimeType */ - public DefaultOutputMode(String name, String description, String mimeType, Collection<InputValue> inputParameters) { + public DefaultOutputMode(String name, String description, String mimeType, + Collection<InputValue> inputParameters) { super(); this.name = name; this.description = description; this.mimeType = mimeType; this.inputParameters = inputParameters; } - + /** * @see de.intevation.gnv.transition.OutputMode#getDescription() */ @@ -60,7 +62,8 @@ */ @Override public String toString() { - return "Name: "+this.name+" ; Description: "+this.description+" ; Mime-Type: "+this.mimeType; + return "Name: " + this.name + " ; Description: " + this.description + + " ; Mime-Type: " + this.mimeType; } /**
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/DefaultTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -3,10 +3,9 @@ */ package de.intevation.gnv.transition; - /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultTransition extends TransitionBase { @@ -16,7 +15,6 @@ public DefaultTransition() { } - /** * @see de.intevation.gnv.transition.Transition#validate() */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputData.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,11 +7,13 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface InputData extends Serializable{ +public interface InputData extends Serializable { public String getName(); + public String getValue(); + public void concartValue(String value); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/InputValue.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,14 +7,18 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface InputValue extends Serializable{ - +public interface InputValue extends Serializable { + public String getName(); + public String getType(); + public String getDefaultValue(); + public boolean isMultiselect(); + public int usedInQueries(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/MinMaxTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/MinMaxTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -14,44 +14,46 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class MinMaxTransition extends TransitionBase { - + /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(MinMaxTransition.class); - + /** * Constructor */ public MinMaxTransition() { super(); } - + /** - * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, java.lang.String) + * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, + * java.lang.String) */ @Override protected void purifyResult(Collection<Result> result, String uuid) { log.debug("MinMaxTransition.purifyResult"); - if (this.descibeData == null){ + if (this.descibeData == null) { this.descibeData = new ArrayList<Object>(); } - if (result != null && result.size() == 1){ - + if (result != null && result.size() == 1) { + Object[] names = this.inputValueNames.toArray(); - String minName = names[names.length-2].toString(); - String maxName = names[names.length-1].toString(); + String minName = names[names.length - 2].toString(); + String maxName = names[names.length - 1].toString(); Result value = result.iterator().next(); - DescribeData describeData = new DefaultMinMaxDescribeData(minName, maxName,value.getObject("MIN"), value.getObject("MAX")); + DescribeData describeData = new DefaultMinMaxDescribeData(minName, + maxName, value.getObject("MIN"), value.getObject("MAX")); log.debug(describeData.toString()); this.descibeData.add(describeData); - }else{ + } else { log.warn("Result cannot be handled as MinMax Resultset"); } - + } /**
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputMode.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputMode.java Fri Oct 09 07:54:48 2009 +0000 @@ -8,15 +8,15 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface OutputMode extends Serializable{ - +public interface OutputMode extends Serializable { + public String getName(); - + public String getDescription(); - + public String getMimeType(); - + public Collection<InputValue> getInputParameters(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -25,7 +25,7 @@ */ public void out(String outputMode, Collection<InputData> inputData, OutputStream outputStream, String uuid, CallMeta callMeta) - throws TransitionException; + throws TransitionException; /** * Delivers the provided OutputModes of an Transition
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/OutputTransitionBase.java Fri Oct 09 07:54:48 2009 +0000 @@ -21,28 +21,26 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public abstract class OutputTransitionBase extends TransitionBase implements - OutputTransition { - - + OutputTransition { + /** * The UID of this Class */ private static final long serialVersionUID = -1718732895737303823L; - + /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(OutputTransitionBase.class); - - + /** * The different Outputmodes which are provided by an OutputTransition */ protected Collection<OutputMode> outputModes = null; - + /** * Constructor */ @@ -57,6 +55,7 @@ log.debug("OutputTransitionBase.getOutputModes"); return this.outputModes; } + /** * @see de.intevation.gnv.transition.Transition#validate() */ @@ -72,55 +71,69 @@ public void setup(Node configuration) { log.debug("OutputTransitionBase.setup"); super.setup(configuration); - NodeList outputModeList = Config.getNodeSetXPath(configuration, "outputsModes/outputsMode"); - if (outputModeList != null){ - log.debug(outputModeList.getLength()+ " were found."); - this.outputModes = new ArrayList<OutputMode>(outputModeList.getLength()); - for (int i = 0; i < outputModeList.getLength(); i++){ + NodeList outputModeList = Config.getNodeSetXPath(configuration, + "outputsModes/outputsMode"); + if (outputModeList != null) { + log.debug(outputModeList.getLength() + " were found."); + this.outputModes = new ArrayList<OutputMode>(outputModeList + .getLength()); + for (int i = 0; i < outputModeList.getLength(); i++) { Node currentNode = outputModeList.item(i); - String name = Config.getStringXPath(currentNode, "@name"); - String description = Config.getStringXPath(currentNode, "@description"); - String mimeType = Config.getStringXPath(currentNode, "@mime-type"); - - NodeList inputValuesList = Config.getNodeSetXPath(currentNode, "parameters/inputvalue"); + String name = Config.getStringXPath(currentNode, "@name"); + String description = Config.getStringXPath(currentNode, + "@description"); + String mimeType = Config.getStringXPath(currentNode, + "@mime-type"); + + NodeList inputValuesList = Config.getNodeSetXPath(currentNode, + "parameters/inputvalue"); Collection<InputValue> inputParameters = null; - if (inputValuesList != null){ - inputParameters = new ArrayList<InputValue>(inputValuesList.getLength()); - for (int j = 0 ; j < inputValuesList.getLength(); j++){ + if (inputValuesList != null) { + inputParameters = new ArrayList<InputValue>(inputValuesList + .getLength()); + for (int j = 0; j < inputValuesList.getLength(); j++) { Node currentInputValuesNode = inputValuesList.item(j); - String inputValueName = Config.getStringXPath(currentInputValuesNode, "@name"); - String inputValueType = Config.getStringXPath(currentInputValuesNode, "@type"); - String defaultValue = Config.getStringXPath(currentInputValuesNode, "@value"); + String inputValueName = Config.getStringXPath( + currentInputValuesNode, "@name"); + String inputValueType = Config.getStringXPath( + currentInputValuesNode, "@type"); + String defaultValue = Config.getStringXPath( + currentInputValuesNode, "@value"); boolean isMultiselect = false; - InputValue inputValue = new DefaultInputValue(inputValueName, inputValueType, defaultValue, isMultiselect); + InputValue inputValue = new DefaultInputValue( + inputValueName, inputValueType, defaultValue, + isMultiselect); inputParameters.add(inputValue); } } - - OutputMode outputMode = new DefaultOutputMode(name, description, mimeType,inputParameters); + + OutputMode outputMode = new DefaultOutputMode(name, + description, mimeType, inputParameters); log.debug(outputMode.toString()); this.outputModes.add(outputMode); - + } } } - + /** * @see de.intevation.gnv.transition.TransitionBase#advance() */ @Override - public void advance(String uuid, CallMeta callMeta) throws TransitionException { + public void advance(String uuid, CallMeta callMeta) + throws TransitionException { log.debug("OutputTransitionBase.advance"); - if (this.getChartResult(uuid) == null){ + if (this.getChartResult(uuid) == null) { super.advance(uuid, callMeta); } } /** - * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, java.util.Collection, java.io.OutputStream) + * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String, + * java.util.Collection, java.io.OutputStream) */ public void out(String outputMode, Collection<InputData> inputData, - OutputStream outputStream) throws TransitionException { + OutputStream outputStream) throws TransitionException { } /** @@ -128,26 +141,27 @@ */ protected Collection<Result> getChartResult(String uuid) { log.debug("OutputTransitionBase.getChartResult"); - if (CacheFactory.getInstance().isInitialized()){ - String key = uuid+super.getID(); - log.debug("Hash for Queryelements: "+key); + if (CacheFactory.getInstance().isInitialized()) { + String key = uuid + super.getID(); + log.debug("Hash for Queryelements: " + key); Element value = CacheFactory.getInstance().getCache().get(key); - if (value != null){ - return (Collection<Result>)(value.getObjectValue()); + if (value != null) { + return (Collection<Result>) (value.getObjectValue()); } } return null; } - + /** - * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, java.lang.String) + * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, + * java.lang.String) */ @Override protected void purifyResult(Collection<Result> result, String uuid) { log.debug("OutputTransitionBase.purifyResult"); - if (CacheFactory.getInstance().isInitialized()){ - String key = uuid+super.getID(); - log.debug("Hash for Queryelements: "+key); + if (CacheFactory.getInstance().isInitialized()) { + String key = uuid + super.getID(); + log.debug("Hash for Queryelements: " + key); CacheFactory.getInstance().getCache().put(new Element(key, result)); } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/SingleInputTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/SingleInputTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -13,7 +13,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class SingleInputTransition extends TransitionBase { @@ -21,7 +21,7 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(SingleInputTransition.class); - + /** * */ @@ -41,24 +41,25 @@ } /** - * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, java.lang.String) + * @see de.intevation.gnv.transition.TransitionBase#purifyResult(java.util.Collection, + * java.lang.String) */ @Override protected void purifyResult(Collection<Result> result, String uuid) { log.debug("SingleInputTransition.purifyResult"); - if (this.descibeData == null){ + if (this.descibeData == null) { this.descibeData = new ArrayList<Object>(); } String value = null; - if (result != null && result.size() == 1){ + if (result != null && result.size() == 1) { Result tmpItem = result.iterator().next(); value = tmpItem.getObject("MAX").toString(); - }else{ + } else { value = ""; } - - this.descibeData.add(new DefaultSingleValueDescribeData(this.dataName, value)); + + this.descibeData.add(new DefaultSingleValueDescribeData(this.dataName, + value)); } - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/Transition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/Transition.java Fri Oct 09 07:54:48 2009 +0000 @@ -14,40 +14,40 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface Transition extends Serializable{ - +public interface Transition extends Serializable { + public void setup(Node configuration); - + public Collection<String> reachableTransitions(); - + public boolean isTransitionReachable(String transitionID); - + public String getID(); - + public String getDescription(); - + public boolean validate(); - + public void describe(Document document, Node rootNode, CallMeta callMeta); - + public void setParent(Transition transition); - + public Transition getParent(); - + public Collection<InputValue> getRequiredInputValues(); - - public void putInputData(Collection<InputData> inputData, String uuid) throws TransitionException; - + + public void putInputData(Collection<InputData> inputData, String uuid) + throws TransitionException; + public Collection<InputData> getInputData() throws TransitionException; - - public void advance(String uuid, CallMeta callMeta) throws TransitionException; - - + + public void advance(String uuid, CallMeta callMeta) + throws TransitionException; + public Collection<Object> getDescibeData(); - + public void setDescibeData(Collection<Object> descibeData); - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java Fri Oct 09 07:54:48 2009 +0000 @@ -41,10 +41,10 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public abstract class TransitionBase implements Transition { - + /** * The UID of this Class */ @@ -54,29 +54,29 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(GNVArtifactBase.class); - + private String id = null; - + private String description = null; - + protected String dataName = null; - + protected boolean dataMultiSelect = false; protected String queryID = null; - + private Collection<String> reachableTransitions = null; - + protected Collection<String> inputValueNames = null; - - private Map<String,InputValue> inputValues = null; - + + private Map<String, InputValue> inputValues = null; + private Transition parent = null; - - protected Map<String,InputData> inputData = null; - + + protected Map<String, InputData> inputData = null; + protected Collection<Object> descibeData = null; - + /** * Constructor */ @@ -90,14 +90,14 @@ public String getID() { return this.id; } - + /** * @see de.intevation.gnv.transition.Transition#getDescription() */ public String getDescription() { return this.description; } - + /** * @see de.intevation.gnv.transition.Transition#reachableTransitions() */ @@ -117,53 +117,60 @@ */ public void setup(Node configuration) { log.debug("TransitionBase.setup"); - this.id = Config.getStringXPath(configuration,"@id"); - this.description = Config.getStringXPath(configuration,"@description"); - - log.info("Transition-ID = "+ this.id); - NodeList nodes = Config.getNodeSetXPath(configuration,"reachableTransitions/transition"); + this.id = Config.getStringXPath(configuration, "@id"); + this.description = Config.getStringXPath(configuration, "@description"); + + log.info("Transition-ID = " + this.id); + NodeList nodes = Config.getNodeSetXPath(configuration, + "reachableTransitions/transition"); this.reachableTransitions = new ArrayList<String>(nodes.getLength()); - for (int i = 0 ; i < nodes.getLength(); i++){ + for (int i = 0; i < nodes.getLength(); i++) { String reachableTransition = nodes.item(i).getTextContent(); - log.info("ReachableTransition ==> "+ reachableTransition); + log.info("ReachableTransition ==> " + reachableTransition); this.reachableTransitions.add(reachableTransition); - + } - - NodeList inputValuesNodes = Config.getNodeSetXPath(configuration,"inputvalues/inputvalue"); - this.inputValues = new HashMap<String,InputValue>(inputValuesNodes.getLength()); - this.inputValueNames = new ArrayList<String>(inputValuesNodes.getLength()); - for (int i = 0 ; i < inputValuesNodes.getLength(); i++){ + + NodeList inputValuesNodes = Config.getNodeSetXPath(configuration, + "inputvalues/inputvalue"); + this.inputValues = new HashMap<String, InputValue>(inputValuesNodes + .getLength()); + this.inputValueNames = new ArrayList<String>(inputValuesNodes + .getLength()); + for (int i = 0; i < inputValuesNodes.getLength(); i++) { Node inputValueNode = inputValuesNodes.item(i); - String usedinQueryValue = Config.getStringXPath(inputValueNode,"@usedinquery"); + String usedinQueryValue = Config.getStringXPath(inputValueNode, + "@usedinquery"); int usedinQuery = 1; - if (usedinQueryValue != null){ + if (usedinQueryValue != null) { try { usedinQuery = Integer.parseInt(usedinQueryValue); } catch (NumberFormatException e) { - log.warn("Used in Query Value cannot be transformed into a Number"); + log + .warn("Used in Query Value cannot be transformed into a Number"); } } - InputValue inputValue = new DefaultInputValue( - Config.getStringXPath(inputValueNode,"@name"), - Config.getStringXPath(inputValueNode,"@type"), - Boolean.parseBoolean(Config.getStringXPath(inputValueNode,"@multiselect")), - usedinQuery); + InputValue inputValue = new DefaultInputValue(Config + .getStringXPath(inputValueNode, "@name"), Config + .getStringXPath(inputValueNode, "@type"), Boolean + .parseBoolean(Config.getStringXPath(inputValueNode, + "@multiselect")), usedinQuery); log.debug(inputValue.toString()); - this.inputValues.put(inputValue.getName(),inputValue); + this.inputValues.put(inputValue.getName(), inputValue); this.inputValueNames.add(inputValue.getName()); } - - this.queryID = Config.getStringXPath(configuration,"queryID"); - log.info("QueryID ==> "+ this.queryID); - - this.dataName = Config.getStringXPath(configuration,"dataname"); - - String dataMultiSelectValue = Config.getStringXPath(configuration,"data-multiselect"); - if (dataMultiSelectValue != null){ - this.dataMultiSelect = Boolean.parseBoolean(dataMultiSelectValue); + + this.queryID = Config.getStringXPath(configuration, "queryID"); + log.info("QueryID ==> " + this.queryID); + + this.dataName = Config.getStringXPath(configuration, "dataname"); + + String dataMultiSelectValue = Config.getStringXPath(configuration, + "data-multiselect"); + if (dataMultiSelectValue != null) { + this.dataMultiSelect = Boolean.parseBoolean(dataMultiSelectValue); } - + } /** @@ -183,97 +190,104 @@ /** * @see de.intevation.gnv.transition.Transition#putInputData(java.util.Collection) */ - public void putInputData(Collection<InputData> inputData, String uuid) throws TransitionException { + public void putInputData(Collection<InputData> inputData, String uuid) + throws TransitionException { log.debug("TransitionBase.putInputData"); - if (inputData != null){ + if (inputData != null) { Iterator<InputData> it = inputData.iterator(); InputValidator iv = new InputValidator(); - while(it.hasNext()){ + while (it.hasNext()) { InputData tmpItem = it.next(); InputValue inputValue = this.inputValues.get(tmpItem.getName()); - if (inputValue != null){ - if (this.inputData == null){ - this.inputData = new HashMap<String,InputData>(inputData.size()); + if (inputValue != null) { + if (this.inputData == null) { + this.inputData = new HashMap<String, InputData>( + inputData.size()); } - boolean valid = iv.isInputValid(tmpItem.getValue(), inputValue.getType()); - if (valid){ + boolean valid = iv.isInputValid(tmpItem.getValue(), + inputValue.getType()); + if (valid) { this.setSelection(tmpItem); - this.inputData.put(tmpItem.getName(),tmpItem); - }else{ - String errMsg = "Wrong input for "+tmpItem.getValue()+"is not an "+inputValue.getType()+" Value."; + this.inputData.put(tmpItem.getName(), tmpItem); + } else { + String errMsg = "Wrong input for " + tmpItem.getValue() + + "is not an " + inputValue.getType() + + " Value."; log.warn(errMsg); throw new TransitionException(errMsg); } - - }else{ - String errMsg = "No Inputvalue given for Inputdata "+ tmpItem.getName(); - log.warn(errMsg+ "Value will be ignored"); - + + } else { + String errMsg = "No Inputvalue given for Inputdata " + + tmpItem.getName(); + log.warn(errMsg + "Value will be ignored"); + } } - }else{ + } else { log.warn("No Inputdata given"); } } - - private void setSelection(InputData inputData){ + + private void setSelection(InputData inputData) { log.debug("TransitionBase.setSelection"); - + Object o = this.getDescribeData(inputData.getName()); - if(o != null){ - if (o instanceof Collection<?>){ - Collection<KeyValueDescibeData> values = (Collection<KeyValueDescibeData>)o; - + if (o != null) { + if (o instanceof Collection<?>) { + Collection<KeyValueDescibeData> values = (Collection<KeyValueDescibeData>) o; + String value = inputData.getValue(); String[] selectedValues = value.split(","); - Set<String> selectedItems = new HashSet<String>(selectedValues.length); - for (int i = 0; i < selectedValues.length; i++){ + Set<String> selectedItems = new HashSet<String>( + selectedValues.length); + for (int i = 0; i < selectedValues.length; i++) { selectedItems.add(selectedValues[i].trim()); } // Selektion umsetzen Iterator<KeyValueDescibeData> it = values.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { KeyValueDescibeData data = it.next(); - String key = ""+data.getKey(); + String key = "" + data.getKey(); boolean selected = selectedItems.contains(key); data.setSelected(selected); } - }else if (o instanceof MinMaxDescribeData){ - MinMaxDescribeData data = (MinMaxDescribeData)o; - if (inputData.getName().equals(data.getMinName())){ + } else if (o instanceof MinMaxDescribeData) { + MinMaxDescribeData data = (MinMaxDescribeData) o; + if (inputData.getName().equals(data.getMinName())) { // TODO: müssen die werte geparst werden? data.setMinValue(inputData.getValue()); } - if (inputData.getName().equals(data.getMaxName())){ + if (inputData.getName().equals(data.getMaxName())) { // TODO: müssen die werte geparst werden? data.setMaxValue(inputData.getValue()); } } } } - - private Object getDescribeData(String name){ + + private Object getDescribeData(String name) { log.debug("TransitionBase.getDescribeData"); - if (this.descibeData != null){ + if (this.descibeData != null) { Iterator<Object> it = this.descibeData.iterator(); - while (it.hasNext()){ + while (it.hasNext()) { Object o = it.next(); - if (o instanceof NamedCollection<?>){ - if (name.equals(((NamedCollection<?>)o).getName())){ + if (o instanceof NamedCollection<?>) { + if (name.equals(((NamedCollection<?>) o).getName())) { return o; } - }else if (o instanceof MinMaxDescribeData){ - if (name.equals(((MinMaxDescribeData)o).getMinName())){ + } else if (o instanceof MinMaxDescribeData) { + if (name.equals(((MinMaxDescribeData) o).getMinName())) { return o; } - if (name.equals(((MinMaxDescribeData)o).getMaxName())){ + if (name.equals(((MinMaxDescribeData) o).getMaxName())) { return o; } } } } return null; - + } /** @@ -283,9 +297,9 @@ log.debug("TransitionBase.isTransitionReachable"); boolean returnValue = false; Iterator<String> transitions = reachableTransitions.iterator(); - while (transitions.hasNext()){ - if(transitions.next().equals(transitionID)){ - log.debug("Transition "+transitionID+" wird unterstützt."); + while (transitions.hasNext()) { + if (transitions.next().equals(transitionID)) { + log.debug("Transition " + transitionID + " wird unterstützt."); returnValue = true; break; } @@ -294,83 +308,93 @@ } /** - * @see de.intevation.gnv.transition.Transition#advance(java.lang.String, de.intevation.artifacts.CallMeta) + * @see de.intevation.gnv.transition.Transition#advance(java.lang.String, + * de.intevation.artifacts.CallMeta) */ - public void advance(String uuid, CallMeta callMeta) throws TransitionException { + public void advance(String uuid, CallMeta callMeta) + throws TransitionException { log.debug("TransitionBase.advance"); try { List<String> list = new ArrayList<String>(); - - + Iterator<String> it = this.inputValueNames.iterator(); int i = 0; - while (it.hasNext()){ + while (it.hasNext()) { String value = it.next(); InputData data = this.inputData.get(value); - if (data != null && this.inputValues.containsKey(data.getName())){ - int size = this.inputValues.get(data.getName()).usedInQueries(); - String type = this.inputValues.get(data.getName()).getType(); + if (data != null + && this.inputValues.containsKey(data.getName())) { + int size = this.inputValues.get(data.getName()) + .usedInQueries(); + String type = this.inputValues.get(data.getName()) + .getType(); String requestValue = data.getValue(); - if (type.equalsIgnoreCase("string")){ - requestValue = this.prepareInputData4DBQuery(requestValue); - }else if (type.equalsIgnoreCase("date")){ - requestValue = this.prepareInputData4DateDBQuery(requestValue); + if (type.equalsIgnoreCase("string")) { + requestValue = this + .prepareInputData4DBQuery(requestValue); + } else if (type.equalsIgnoreCase("date")) { + requestValue = this + .prepareInputData4DateDBQuery(requestValue); } - for (int j = 0; j < size; j++){ + for (int j = 0; j < size; j++) { list.add(requestValue); } } } String[] filterValues = list.toArray(new String[0]); - Collection<Result> result = null; + Collection<Result> result = null; try { - if (this.queryID != null){ - QueryExecutor queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor(); - result = queryExecutor.executeQuery(this.queryID, filterValues); + if (this.queryID != null) { + QueryExecutor queryExecutor = QueryExecutorFactory + .getInstance().getQueryExecutor(); + result = queryExecutor.executeQuery(this.queryID, + filterValues); } this.purifyResult(result, uuid); } catch (RuntimeException e) { - log.error(e,e); + log.error(e, e); } } catch (QueryException e) { - log.error(e,e); + log.error(e, e); throw new TransitionException(e); } } - - private String prepareInputData4DateDBQuery(String value){ + + private String prepareInputData4DateDBQuery(String value) { log.debug("TransitionBase.prepareInputData4DateDBQuery"); - if (value != null){ + if (value != null) { String[] values = value.split(","); String newValue = ""; - for (int i = 0; i < values.length; i++){ - if (newValue.length() > 0){ - newValue= newValue + " , "; + for (int i = 0; i < values.length; i++) { + if (newValue.length() > 0) { + newValue = newValue + " , "; } - // TODO JUST HACK FIND A BETTER RESOLUTION - newValue = newValue + "to_date('"+values[i].trim()+"', 'YYYY.MM.DD HH24:MI:SS')"; + // TODO JUST HACK FIND A BETTER RESOLUTION + newValue = newValue + "to_date('" + values[i].trim() + + "', 'YYYY.MM.DD HH24:MI:SS')"; } return newValue; } - - return value; + + return value; } - private String prepareInputData4DBQuery(String value){ + + private String prepareInputData4DBQuery(String value) { log.debug("TransitionBase.prepareInputData4DBQuery"); - if (value != null){ + if (value != null) { String[] values = value.split(","); String newValue = ""; - for (int i = 0; i < values.length; i++){ - if (newValue.length() > 0){ - newValue= newValue + " , "; + for (int i = 0; i < values.length; i++) { + if (newValue.length() > 0) { + newValue = newValue + " , "; } - newValue = newValue + "'"+values[i].trim()+"'"; + newValue = newValue + "'" + values[i].trim() + "'"; } return newValue; } - - return value; - + + return value; + } /** @@ -378,151 +402,177 @@ */ protected void purifyResult(Collection<Result> result, String uuid) { log.debug("TransitionBase.purifyResult"); - if (this.descibeData == null){ + if (this.descibeData == null) { this.descibeData = new ArrayList<Object>(); } - Iterator<Result> rit = result.iterator(); - NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>(this.dataName,result.size()); + Iterator<Result> rit = result.iterator(); + NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>( + this.dataName, result.size()); keyValueDescibeData.setMultiSelect(this.dataMultiSelect); - while(rit.hasNext()){ + while (rit.hasNext()) { Result resultValue = rit.next(); - keyValueDescibeData.add(new DefaultKeyValueDescribeData(resultValue.getString("KEY"), resultValue.getString("VALUE"))); + keyValueDescibeData.add(new DefaultKeyValueDescribeData(resultValue + .getString("KEY"), resultValue.getString("VALUE"))); } this.descibeData.add(keyValueDescibeData); } - + /** - * @see de.intevation.gnv.transition.Transition#describe(org.w3c.dom.Document, org.w3c.dom.Node, de.intevation.artifacts.CallMeta) + * @see de.intevation.gnv.transition.Transition#describe(org.w3c.dom.Document, + * org.w3c.dom.Node, de.intevation.artifacts.CallMeta) */ public void describe(Document document, Node rootNode, CallMeta callMeta) { log.debug("TransitionBase.describe"); - if(this.descibeData != null){ + if (this.descibeData != null) { ArtifactXMLUtilities xmlutilities = new ArtifactXMLUtilities(); Iterator<Object> it = this.descibeData.iterator(); - Node staticNode = xmlutilities.createArtifactElement(document, "static"); - Node dynamic = xmlutilities.createArtifactElement(document, "dynamic"); + Node staticNode = xmlutilities.createArtifactElement(document, + "static"); + Node dynamic = xmlutilities.createArtifactElement(document, + "dynamic"); rootNode.appendChild(staticNode); rootNode.appendChild(dynamic); - while (it.hasNext()){ - + while (it.hasNext()) { + Object o = it.next(); - if (o instanceof Collection<?>){ - String name = null; - boolean multiselect = false; - if (o instanceof NamedCollection<?>){ - NamedCollection<?> nc = ((NamedCollection<?>)o); - name = nc.getName(); - multiselect = nc.isMultiSelect(); - }else{ - Object[] names = this.inputValueNames.toArray(); - name = names[names.length-1].toString(); - } - - - Element selectNode = xmlutilities.createXFormElement(document,multiselect ? "select" : "select1"); - selectNode.setAttribute("ref", name); - - Element lableNode = xmlutilities.createXFormElement(document, "label"); - lableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), name, name)); - Element choiceNode = xmlutilities.createXFormElement(document, "choices"); - - Collection<KeyValueDescibeData> values = (Collection<KeyValueDescibeData>)o; - Iterator<KeyValueDescibeData> resultIt = values.iterator(); - while (resultIt.hasNext()){ - KeyValueDescibeData result = resultIt.next(); - Element itemNode = xmlutilities.createXFormElement(document, "item"); - - if (result.isSelected()){ - itemNode.setAttribute("selected", "true"); - } - - - Element choiceLableNode = xmlutilities.createXFormElement(document, "label"); - choiceLableNode.setTextContent(result.getValue()); - itemNode.appendChild(choiceLableNode); - - Element choicValueNode = xmlutilities.createXFormElement(document, "value"); - choicValueNode.setTextContent(""+result.getKey()); - itemNode.appendChild(choicValueNode); - choiceNode.appendChild(itemNode); - } - selectNode.appendChild(lableNode); - selectNode.appendChild(choiceNode); - - if (!it.hasNext()){ - dynamic.appendChild(selectNode); - }else{ - staticNode.appendChild(selectNode); + if (o instanceof Collection<?>) { + String name = null; + boolean multiselect = false; + if (o instanceof NamedCollection<?>) { + NamedCollection<?> nc = ((NamedCollection<?>) o); + name = nc.getName(); + multiselect = nc.isMultiSelect(); + } else { + Object[] names = this.inputValueNames.toArray(); + name = names[names.length - 1].toString(); + } + + Element selectNode = xmlutilities.createXFormElement( + document, multiselect ? "select" : "select1"); + selectNode.setAttribute("ref", name); + + Element lableNode = xmlutilities.createXFormElement( + document, "label"); + lableNode.setTextContent(RessourceFactory.getInstance() + .getRessource(callMeta.getLanguages(), name, name)); + Element choiceNode = xmlutilities.createXFormElement( + document, "choices"); + + Collection<KeyValueDescibeData> values = (Collection<KeyValueDescibeData>) o; + Iterator<KeyValueDescibeData> resultIt = values.iterator(); + while (resultIt.hasNext()) { + KeyValueDescibeData result = resultIt.next(); + Element itemNode = xmlutilities.createXFormElement( + document, "item"); + + if (result.isSelected()) { + itemNode.setAttribute("selected", "true"); } - - }else if (o instanceof MinMaxDescribeData){ - MinMaxDescribeData descibeData = (MinMaxDescribeData)o; - Object min = descibeData.getMinValue(); - Object max = descibeData.getMaxValue(); - if (min instanceof GregorianCalendar){ - Date d = ((GregorianCalendar)min).getTime(); - min = DateUtils.getPatternedDateAmer(d); - } - - if (max instanceof GregorianCalendar){ - Date d = ((GregorianCalendar)max).getTime(); - max = DateUtils.getPatternedDateAmer(d); - } - - Element inputMinNode = xmlutilities.createXFormElement(document, "input"); - inputMinNode.setAttribute("ref", "minvalue"); - Element inputMinLableNode = xmlutilities.createXFormElement(document, "label"); - inputMinLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), "minvalue", "minvalue")); - inputMinNode.appendChild(inputMinLableNode); - - Element inputMinValueNode = xmlutilities.createXFormElement(document, "value"); - inputMinValueNode.setTextContent(min.toString()); - inputMinNode.appendChild(inputMinValueNode); - - Element inputMaxNode = xmlutilities.createXFormElement(document, "input"); - inputMaxNode.setAttribute("ref", "maxvalue"); - Element inputMaxLableNode = xmlutilities.createXFormElement(document, "label"); - inputMaxLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), "maxvalue", "maxvalue")); - inputMaxNode.appendChild(inputMaxLableNode); - - Element inputMaxValueNode = xmlutilities.createXFormElement(document, "value"); - inputMaxValueNode.setTextContent(max.toString()); - inputMaxNode.appendChild(inputMaxValueNode); - - - if (!it.hasNext()){ - dynamic.appendChild(inputMinNode); - dynamic.appendChild(inputMaxNode); - }else{ - staticNode.appendChild(inputMinNode); - staticNode.appendChild(inputMaxNode); - } - }else if (o instanceof SingleValueDescribeData){ - - SingleValueDescribeData svdb = (SingleValueDescribeData)o; - - Element inputNode = xmlutilities.createXFormElement(document, "input"); - inputNode.setAttribute("ref", svdb.getName()); - - Element inputLableNode = xmlutilities.createXFormElement(document, "label"); - inputLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), svdb.getName(), svdb.getName())); - inputNode.appendChild(inputLableNode); - - Element inputValueNode = xmlutilities.createXFormElement(document, "value"); - inputValueNode.setTextContent(svdb.getValue()); - inputNode.appendChild(inputValueNode); - - - if (!it.hasNext()){ - dynamic.appendChild(inputNode); - }else{ - staticNode.appendChild(inputNode); - } + + Element choiceLableNode = xmlutilities + .createXFormElement(document, "label"); + choiceLableNode.setTextContent(result.getValue()); + itemNode.appendChild(choiceLableNode); + + Element choicValueNode = xmlutilities + .createXFormElement(document, "value"); + choicValueNode.setTextContent("" + result.getKey()); + itemNode.appendChild(choicValueNode); + choiceNode.appendChild(itemNode); } - + selectNode.appendChild(lableNode); + selectNode.appendChild(choiceNode); + + if (!it.hasNext()) { + dynamic.appendChild(selectNode); + } else { + staticNode.appendChild(selectNode); + } + + } else if (o instanceof MinMaxDescribeData) { + MinMaxDescribeData descibeData = (MinMaxDescribeData) o; + Object min = descibeData.getMinValue(); + Object max = descibeData.getMaxValue(); + if (min instanceof GregorianCalendar) { + Date d = ((GregorianCalendar) min).getTime(); + min = DateUtils.getPatternedDateAmer(d); + } + + if (max instanceof GregorianCalendar) { + Date d = ((GregorianCalendar) max).getTime(); + max = DateUtils.getPatternedDateAmer(d); + } + + Element inputMinNode = xmlutilities.createXFormElement( + document, "input"); + inputMinNode.setAttribute("ref", "minvalue"); + Element inputMinLableNode = xmlutilities + .createXFormElement(document, "label"); + inputMinLableNode.setTextContent(RessourceFactory + .getInstance().getRessource( + callMeta.getLanguages(), "minvalue", + "minvalue")); + inputMinNode.appendChild(inputMinLableNode); + + Element inputMinValueNode = xmlutilities + .createXFormElement(document, "value"); + inputMinValueNode.setTextContent(min.toString()); + inputMinNode.appendChild(inputMinValueNode); + + Element inputMaxNode = xmlutilities.createXFormElement( + document, "input"); + inputMaxNode.setAttribute("ref", "maxvalue"); + Element inputMaxLableNode = xmlutilities + .createXFormElement(document, "label"); + inputMaxLableNode.setTextContent(RessourceFactory + .getInstance().getRessource( + callMeta.getLanguages(), "maxvalue", + "maxvalue")); + inputMaxNode.appendChild(inputMaxLableNode); + + Element inputMaxValueNode = xmlutilities + .createXFormElement(document, "value"); + inputMaxValueNode.setTextContent(max.toString()); + inputMaxNode.appendChild(inputMaxValueNode); + + if (!it.hasNext()) { + dynamic.appendChild(inputMinNode); + dynamic.appendChild(inputMaxNode); + } else { + staticNode.appendChild(inputMinNode); + staticNode.appendChild(inputMaxNode); + } + } else if (o instanceof SingleValueDescribeData) { + + SingleValueDescribeData svdb = (SingleValueDescribeData) o; + + Element inputNode = xmlutilities.createXFormElement( + document, "input"); + inputNode.setAttribute("ref", svdb.getName()); + + Element inputLableNode = xmlutilities.createXFormElement( + document, "label"); + inputLableNode.setTextContent(RessourceFactory + .getInstance().getRessource( + callMeta.getLanguages(), svdb.getName(), + svdb.getName())); + inputNode.appendChild(inputLableNode); + + Element inputValueNode = xmlutilities.createXFormElement( + document, "value"); + inputValueNode.setTextContent(svdb.getValue()); + inputNode.appendChild(inputValueNode); + + if (!it.hasNext()) { + dynamic.appendChild(inputNode); + } else { + staticNode.appendChild(inputNode); + } } + } } + } /** * @see de.intevation.gnv.transition.Transition#getDescibeData() @@ -536,13 +586,13 @@ */ public void setDescibeData(Collection<Object> descibeData) { this.descibeData = descibeData; - + } /** * @see de.intevation.gnv.transition.Transition#getInputData() */ public Collection<InputData> getInputData() throws TransitionException { - return this.inputData != null ? this.inputData.values() : null; + return this.inputData != null ? this.inputData.values() : null; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -11,7 +11,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class TransitionFactory { @@ -19,36 +19,37 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(GNVArtifactBase.class); - + private static TransitionFactory instance = null; + /** * Constructor */ public TransitionFactory() { super(); } - - public static TransitionFactory getInstance(){ - if (instance == null){ + + public static TransitionFactory getInstance() { + if (instance == null) { instance = new TransitionFactory(); } return instance; } - - - public Transition createTransition(Node configuration){ + + public Transition createTransition(Node configuration) { log.debug("TransitionFactory.createTransition"); Transition transition = null; try { - String classname = Config.getStringXPath(configuration, "@transition"); - transition = (Transition)(Class.forName(classname).newInstance()); + String classname = Config.getStringXPath(configuration, + "@transition"); + transition = (Transition) (Class.forName(classname).newInstance()); transition.setup(configuration); } catch (InstantiationException e) { - log.error(e,e); + log.error(e, e); } catch (IllegalAccessException e) { - log.error(e,e); + log.error(e, e); } catch (ClassNotFoundException e) { - log.error(e,e); + log.error(e, e); } return transition; }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DefaultKeyValueDescribeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DefaultKeyValueDescribeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.transition.describedata; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultKeyValueDescribeData implements KeyValueDescibeData { @@ -14,11 +15,11 @@ private static final long serialVersionUID = -924469415242703108L; private String key; - + private String value = null; - + private boolean selected = false; - + public DefaultKeyValueDescribeData(String key, String value) { super(); this.key = key; @@ -29,7 +30,7 @@ * @see de.intevation.gnv.transition.describedata.KeyValueDescibeData#getKey() */ public String getKey() { - return this.key; + return this.key; } /**
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DefaultMinMaxDescribeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DefaultMinMaxDescribeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.transition.describedata; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultMinMaxDescribeData implements MinMaxDescribeData { @@ -14,16 +15,18 @@ private static final long serialVersionUID = -2917176219029052295L; private Object minValue = null; - + private Object maxValue = null; - + private String minName = null; - + private String maxName = null; + /** * Constructor */ - public DefaultMinMaxDescribeData(String minName, String maxName, Object minValue, Object maxValue) { + public DefaultMinMaxDescribeData(String minName, String maxName, + Object minValue, Object maxValue) { super(); this.minName = minName; this.maxName = maxName; @@ -50,7 +53,8 @@ */ @Override public String toString() { - return "MIN: "+this.minValue.toString()+" ; MAX: "+this.maxValue.toString(); + return "MIN: " + this.minValue.toString() + " ; MAX: " + + this.maxValue.toString(); } /** @@ -80,6 +84,5 @@ public void setMinValue(Object minValue) { this.minValue = minValue; } - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DefaultSingleValueDescribeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DefaultSingleValueDescribeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,24 +2,25 @@ * */ package de.intevation.gnv.transition.describedata; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class DefaultSingleValueDescribeData implements SingleValueDescribeData { - /** * */ private static final long serialVersionUID = 3580176842483316917L; private String name = null; - + private String value = null; - + /** * Constructor + * * @param name * @param value */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DescribeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/DescribeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,9 +7,10 @@ /** * Markerinterface + * * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public interface DescribeData extends Serializable{ +public interface DescribeData extends Serializable { }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/KeyValueDescibeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/KeyValueDescibeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,16 +7,16 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface KeyValueDescibeData extends Serializable { - + public String getKey(); - + public String getValue(); - + public boolean isSelected(); - + public void setSelected(boolean selected); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/MinMaxDescribeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/MinMaxDescribeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,19 +2,23 @@ * */ package de.intevation.gnv.transition.describedata; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface MinMaxDescribeData extends DescribeData { - + public Object getMinValue(); + public Object getMaxValue(); - + public void setMinValue(Object minValue); + public void setMaxValue(Object maxValue); - + public String getMinName(); + public String getMaxName(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/NamedArrayList.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/NamedArrayList.java Fri Oct 09 07:54:48 2009 +0000 @@ -8,17 +8,19 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class NamedArrayList<E> extends ArrayList<E> implements NamedCollection<E> { +public class NamedArrayList<E> extends ArrayList<E> implements + NamedCollection<E> { /** * */ private static final long serialVersionUID = 8172229594749676354L; private String name = null; - + private boolean multiSelect = false; + /** * Constructor */ @@ -28,6 +30,7 @@ /** * Constructor + * * @param initialCapacity */ public NamedArrayList(String name, int initialCapacity) { @@ -37,6 +40,7 @@ /** * Constructor + * * @param c */ public NamedArrayList(String name, Collection<E> c) { @@ -50,6 +54,7 @@ public String getName() { return this.name; } + /** * @see de.intevation.gnv.transition.describedata.NamedCollection#isMultiSelect() */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/NamedCollection.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/NamedCollection.java Fri Oct 09 07:54:48 2009 +0000 @@ -7,13 +7,13 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface NamedCollection<E> extends Collection<E> { public String getName(); - + public boolean isMultiSelect(); - + public void setMultiSelect(boolean multiSelect); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/SingleValueDescribeData.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/describedata/SingleValueDescribeData.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,13 +2,14 @@ * */ package de.intevation.gnv.transition.describedata; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public interface SingleValueDescribeData extends DescribeData { public String getName(); - + public String getValue(); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/exception/TransitionException.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/exception/TransitionException.java Fri Oct 09 07:54:48 2009 +0000 @@ -2,9 +2,10 @@ * */ package de.intevation.gnv.transition.exception; + /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class TransitionException extends Exception { @@ -22,6 +23,7 @@ /** * Constructor + * * @param message */ public TransitionException(String message) { @@ -30,6 +32,7 @@ /** * Constructor + * * @param cause */ public TransitionException(Throwable cause) { @@ -38,6 +41,7 @@ /** * Constructor + * * @param message * @param cause */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -18,9 +18,10 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class HorizontalProfileOutputTransition extends TimeSeriesOutputTransition { +public class HorizontalProfileOutputTransition extends + TimeSeriesOutputTransition { /** * The UID of this class */ @@ -35,17 +36,21 @@ } /** - * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createChart(java.io.OutputStream, java.util.Collection, java.util.Collection, java.lang.String, de.intevation.gnv.chart.ChartStyle, de.intevation.gnv.chart.ChartLabels) + * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createChart(java.io.OutputStream, + * java.util.Collection, java.util.Collection, java.lang.String, + * de.intevation.gnv.chart.ChartStyle, + * de.intevation.gnv.chart.ChartLabels) */ @Override protected void createChart(OutputStream outputStream, - Collection<KeyValueDescibeData> parameters, - Collection<KeyValueDescibeData> measurements, - ChartStyle chartStyle, ChartLabels chartLables,String uuid) throws IOException, TechnicalChartException { + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements, + ChartStyle chartStyle, ChartLabels chartLables, + String uuid) throws IOException, + TechnicalChartException { HorizontalProfileChartFactory chartFactory = new HorizontalProfileChartFactory(); - chartFactory.createProfileChart(chartLables, chartStyle, - parameters, measurements, - outputStream, this.getChartResult(uuid)); + chartFactory.createProfileChart(chartLables, chartStyle, parameters, + measurements, outputStream, this.getChartResult(uuid)); } /** @@ -53,8 +58,7 @@ */ @Override protected Statistics getStatisticsGenerator() { - return new HorizontalProfileStatistics(); + return new HorizontalProfileStatistics(); } - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/NorthSouthEastWestTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/NorthSouthEastWestTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -18,7 +18,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class NorthSouthEastWestTransition extends TransitionBase { @@ -39,25 +39,32 @@ public boolean validate() { return true; } - + /** - * @see de.intevation.gnv.transition.TransitionBase#advance(java.lang.String, de.intevation.artifacts.CallMeta) + * @see de.intevation.gnv.transition.TransitionBase#advance(java.lang.String, + * de.intevation.artifacts.CallMeta) */ @Override - public void advance(String uuid,CallMeta callMeta) throws TransitionException { - if (this.descibeData == null){ + public void advance(String uuid, CallMeta callMeta) + throws TransitionException { + if (this.descibeData == null) { this.descibeData = new ArrayList<Object>(); } - NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>(this.dataName,2); + NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>( + this.dataName, 2); keyValueDescibeData.setMultiSelect(super.dataMultiSelect); - keyValueDescibeData.add(new DefaultKeyValueDescribeData("IPOSITION", RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), "iposition", "iposition"))); - keyValueDescibeData.add(new DefaultKeyValueDescribeData("JPOSITION", RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), "jposition", "jposition"))); + keyValueDescibeData.add(new DefaultKeyValueDescribeData("IPOSITION", + RessourceFactory.getInstance().getRessource( + callMeta.getLanguages(), "iposition", "iposition"))); + keyValueDescibeData.add(new DefaultKeyValueDescribeData("JPOSITION", + RessourceFactory.getInstance().getRessource( + callMeta.getLanguages(), "jposition", "jposition"))); this.descibeData.add(keyValueDescibeData); } @Override protected void purifyResult(Collection<Result> result, String uuid) { - + } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/vertical/VerticalProfileOutputTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/vertical/VerticalProfileOutputTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -18,7 +18,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class VerticalProfileOutputTransition extends TimeSeriesOutputTransition { /** @@ -34,19 +34,22 @@ super.domainLable = "Tiefe"; } - /** - * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createChart(java.io.OutputStream, java.util.Collection, java.util.Collection, java.lang.String, de.intevation.gnv.chart.ChartStyle, de.intevation.gnv.chart.ChartLabels) + * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createChart(java.io.OutputStream, + * java.util.Collection, java.util.Collection, java.lang.String, + * de.intevation.gnv.chart.ChartStyle, + * de.intevation.gnv.chart.ChartLabels) */ @Override protected void createChart(OutputStream outputStream, - Collection<KeyValueDescibeData> parameters, - Collection<KeyValueDescibeData> measurements, - ChartStyle chartStyle, ChartLabels chartLables,String uuid) throws IOException, TechnicalChartException { + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements, + ChartStyle chartStyle, ChartLabels chartLables, + String uuid) throws IOException, + TechnicalChartException { VerticalProfileChartFactory chartFactory = new VerticalProfileChartFactory(); - chartFactory.createProfileChart(chartLables, chartStyle, - parameters, measurements, - outputStream, this.getChartResult(uuid)); + chartFactory.createProfileChart(chartLables, chartStyle, parameters, + measurements, outputStream, this.getChartResult(uuid)); } /** @@ -54,8 +57,7 @@ */ @Override protected Statistics getStatisticsGenerator() { - return new VerticalProfileStatistics(); + return new VerticalProfileStatistics(); } - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java Fri Oct 09 07:54:48 2009 +0000 @@ -62,7 +62,7 @@ .getLogger(TimeSeriesOutputTransition.class); protected String domainLable = "Zeit [UTC]"; - + protected String featureValuesName = "featureid"; protected String parameterValuesName = "parameterid"; protected String measuremenValueName = "measurementid"; @@ -77,6 +77,7 @@ /** * @see de.intevation.gnv.transition.Transition#validate() */ + @Override public boolean validate() { return true; } @@ -129,11 +130,11 @@ if (chartResult != null) { CSVWriter writer = new CSVWriter(new OutputStreamWriter( outputStream, "ISO-8859-1"), ','); // USE THIS - // ENCODING - // BECAUSE OF - // PROBLEMS WITH - // EXCEL AND - // UTF-8 + // ENCODING + // BECAUSE OF + // PROBLEMS WITH + // EXCEL AND + // UTF-8 Iterator<Result> it = chartResult.iterator(); while (it.hasNext()) { Result result = it.next(); @@ -276,16 +277,19 @@ @Override public void setup(Node configuration) { super.setup(configuration); - String featureNameValue = Config.getStringXPath(configuration, "value-names/value-name[@name='feature']/@value"); - if (featureNameValue != null){ + String featureNameValue = Config.getStringXPath(configuration, + "value-names/value-name[@name='feature']/@value"); + if (featureNameValue != null) { this.featureValuesName = featureNameValue; } - String parameterNameValue = Config.getStringXPath(configuration, "value-names/value-name[@name='parameter']/@value"); - if (parameterNameValue != null){ + String parameterNameValue = Config.getStringXPath(configuration, + "value-names/value-name[@name='parameter']/@value"); + if (parameterNameValue != null) { this.parameterValuesName = parameterNameValue; } - String measurementNameValue = Config.getStringXPath(configuration, "value-names/value-name[@name='measurement']/@value"); - if (measurementNameValue != null){ + String measurementNameValue = Config.getStringXPath(configuration, + "value-names/value-name[@name='measurement']/@value"); + if (measurementNameValue != null) { this.measuremenValueName = measurementNameValue; } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactFactoryUtilities.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactFactoryUtilities.java Fri Oct 09 07:54:48 2009 +0000 @@ -9,47 +9,46 @@ import de.intevation.artifacts.ArtifactFactory; - /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class ArtifactFactoryUtilities { /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(ArtifactFactoryUtilities.class); + private static Logger log = Logger + .getLogger(ArtifactFactoryUtilities.class); + /** * Constructor */ public ArtifactFactoryUtilities() { } - public ArtifactFactory createArtitfactFactor(Document config, Node artifactFactoryNode){ - String className =artifactFactoryNode.getTextContent(); + public ArtifactFactory createArtitfactFactor(Document config, + Node artifactFactoryNode) { + String className = artifactFactoryNode.getTextContent(); ArtifactFactory factory = null; try { Class clazz = Class.forName(className); - factory = (ArtifactFactory)clazz.newInstance(); - } - catch (ClassNotFoundException cnfe) { + factory = (ArtifactFactory) clazz.newInstance(); + } catch (ClassNotFoundException cnfe) { log.error(cnfe.getLocalizedMessage(), cnfe); - } - catch (InstantiationException ie) { + } catch (InstantiationException ie) { log.error(ie.getLocalizedMessage(), ie); - } - catch (ClassCastException cce) { + } catch (ClassCastException cce) { log.error(cce.getLocalizedMessage(), cce); - } - catch (IllegalAccessException iae) { + } catch (IllegalAccessException iae) { log.error(iae.getLocalizedMessage(), iae); } if (factory != null) { factory.setup(config, artifactFactoryNode); - log.info("Registering '" + factory.getName() + "' as artifact factory."); + log.info("Registering '" + factory.getName() + + "' as artifact factory."); } return factory; }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java Fri Oct 09 07:54:48 2009 +0000 @@ -31,9 +31,9 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ -public class ArtifactXMLUtilities implements Serializable{ +public class ArtifactXMLUtilities implements Serializable { /** * */ @@ -42,93 +42,97 @@ /** * the logger, used to log exceptions and additonaly information */ - private static Logger log = Logger.getLogger(TimeSeriesOutputTransition.class); - + private static Logger log = Logger + .getLogger(TimeSeriesOutputTransition.class); + public static final String XFORM_URL = "http://www.w3.org/2002/xforms"; public static final String XFORM_PREFIX = "xform"; - + /** * Constructor */ public ArtifactXMLUtilities() { } - + /** * @param document * @return */ public Element createArtifactElement(Document document, String name) { - Element node = document.createElementNS(ArtifactNamespaceContext.NAMESPACE_URI, name); + Element node = document.createElementNS( + ArtifactNamespaceContext.NAMESPACE_URI, name); node.setPrefix(ArtifactNamespaceContext.NAMESPACE_PREFIX); return node; } - - public String writeDocument2String(Document document){ + + public String writeDocument2String(Document document) { try { - TransformerFactory transformerFactory = TransformerFactory.newInstance(); + TransformerFactory transformerFactory = TransformerFactory + .newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(document); StringWriter sw = new StringWriter(); - StreamResult result = new StreamResult(sw); + StreamResult result = new StreamResult(sw); transformer.transform(source, result); return sw.getBuffer().toString(); } catch (TransformerConfigurationException e) { - log.error(e,e); + log.error(e, e); } catch (TransformerFactoryConfigurationError e) { - log.error(e,e); + log.error(e, e); } catch (TransformerException e) { - log.error(e,e); + log.error(e, e); } return null; } - - - - public Document readDocument(InputStream inputStream){ + public Document readDocument(InputStream inputStream) { Document returnValue = null; try { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory + .newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); - returnValue = docBuilder.parse (inputStream); + returnValue = docBuilder.parse(inputStream); } catch (ParserConfigurationException e) { - log.error(e,e); + log.error(e, e); } catch (SAXException e) { - log.error(e,e); + log.error(e, e); } catch (IOException e) { - log.error(e,e); + log.error(e, e); } return returnValue; } - - public Document reInitDocument(Document document){ + + public Document reInitDocument(Document document) { try { - byte[] barray = this.writeDocument2String(document).getBytes("UTF-8"); - InputStream inputStream = new ByteArrayInputStream(barray); + byte[] barray = this.writeDocument2String(document).getBytes( + "UTF-8"); + InputStream inputStream = new ByteArrayInputStream(barray); return this.readDocument(inputStream); } catch (UnsupportedEncodingException e) { - log.error(e,e); + log.error(e, e); } return document; } - + public Element createXFormElement(Document document, String name) { Element node = document.createElementNS(XFORM_URL, name); node.setPrefix(XFORM_PREFIX); return node; } - - public Document createExceptionReport(String message, Document document){ + + public Document createExceptionReport(String message, Document document) { log.debug("ArtifactXMLUtilities.createExceptionReport"); - Element exceptionReportNode = this.createArtifactElement(document, "exceptionreport"); + Element exceptionReportNode = this.createArtifactElement(document, + "exceptionreport"); document.appendChild(exceptionReportNode); - Element exceptionNode = this.createArtifactElement(document, "exception"); + Element exceptionNode = this.createArtifactElement(document, + "exception"); exceptionNode.setTextContent(message); exceptionReportNode.appendChild(exceptionNode); return document; } - - public Document createSuccessReport(String message, Document document){ + + public Document createSuccessReport(String message, Document document) { log.debug("ArtifactXMLUtilities.creatSuccessReport"); Element reportNode = this.createArtifactElement(document, "result"); document.appendChild(reportNode); @@ -137,6 +141,5 @@ reportNode.appendChild(successNode); return document; } - }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Fri Oct 09 07:54:48 2009 +0000 @@ -10,7 +10,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class InputValidator { /** @@ -24,36 +24,46 @@ public InputValidator() { super(); } - - public boolean isInputValid(String input, String type){ - log.debug("InputValidator.isInputValid " + input+ " "+type); + + public boolean isInputValid(String input, String type) { + log.debug("InputValidator.isInputValid " + input + " " + type); boolean returnValue = false; String[] values = input.split(","); - for (int i = 0; i < values.length; i++){ + for (int i = 0; i < values.length; i++) { boolean valid; - if ("Integer".equalsIgnoreCase(type)){ + if ("Integer".equalsIgnoreCase(type)) { valid = GenericValidator.isInt(values[i].trim()); - }else if ("Double".equalsIgnoreCase(type)){ - valid = GenericValidator.isDouble(values[i].trim()); - }else if ("String".equalsIgnoreCase(type)){ - valid = GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: VALIDATE REGEXP - }else if ("Date".equalsIgnoreCase(type)){ - valid = GenericValidator.isDate(values[i].trim(), DateUtils.DATE_PATTERN, true); - }else if ("Point".equalsIgnoreCase(type)){ - valid = GenericValidator.matchRegexp(values[i], "[0-9]"); // TODO: FIXME: VALIDATE REGEXP - }else if ("AttributeName".equalsIgnoreCase(type)){ - valid = org.apache.commons.validator.GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: VALIDATE REGEXP - }else{ + } else if ("Double".equalsIgnoreCase(type)) { + valid = GenericValidator.isDouble(values[i].trim()); + } else if ("String".equalsIgnoreCase(type)) { + valid = GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: + // FIXME: + // VALIDATE + // REGEXP + } else if ("Date".equalsIgnoreCase(type)) { + valid = GenericValidator.isDate(values[i].trim(), + DateUtils.DATE_PATTERN, true); + } else if ("Point".equalsIgnoreCase(type)) { + valid = GenericValidator.matchRegexp(values[i], "[0-9]"); // TODO: + // FIXME: + // VALIDATE + // REGEXP + } else if ("AttributeName".equalsIgnoreCase(type)) { + valid = org.apache.commons.validator.GenericValidator + .matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: + // VALIDATE + // REGEXP + } else { valid = false; } - if (!valid){ - returnValue = false; + if (!valid) { + returnValue = false; break; - }else{ + } else { returnValue = true; } } - log.debug("Is valid? "+returnValue); + log.debug("Is valid? " + returnValue); return returnValue; }
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/GNVArtifactsTestCase.java Fri Oct 09 07:54:48 2009 +0000 @@ -34,7 +34,7 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class GNVArtifactsTestCase extends TestCase { @@ -42,17 +42,19 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = null; - + static { BasicConfigurator.configure(); log = Logger.getLogger(GNVArtifactContext.class); } - + private String configurationDir = "src/test/ressources/"; - + private FactoryBootstrap bootstrap = null; + /** * Constructor + * * @param name */ public GNVArtifactsTestCase(String name) { @@ -65,68 +67,92 @@ protected void setUp() throws Exception { log.debug("GNVArtifactsTestCase.setUp"); super.setUp(); - log.info(Config.CONFIG_DIR + " ==> "+configurationDir); + log.info(Config.CONFIG_DIR + " ==> " + configurationDir); System.setProperty(Config.CONFIG_DIR, configurationDir); log.info("Bootstrap wird initialisiert."); bootstrap = new FactoryBootstrap(); bootstrap.boot(); } - - public void testTimeSeriesArtifact(){ + + public void testTimeSeriesArtifact() { try { log.debug("GNVArtifactsTestCase.testTimeSeriesArtifact"); - String artefactName = "fis_marnet"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); + String artefactName = "fis_marnet"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); assertNotNull(artifactFactory); log.debug("TimeSeries-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); assertNotNull(artifact); log.debug("TimeSeries-Artifact is available"); - + CallContext cc = createCallContext(); - + // Erster Schritt - - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries/timeseries_step_01_feed.xml", - "src/test/ressources/timeseries/timeseries_step_01_advance.xml"); - + + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries/timeseries_step_01_feed.xml", + "src/test/ressources/timeseries/timeseries_step_01_advance.xml"); + // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries/timeseries_step_02_feed.xml", - "src/test/ressources/timeseries/timeseries_step_02_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries/timeseries_step_02_feed.xml", + "src/test/ressources/timeseries/timeseries_step_02_advance.xml"); + // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries/timeseries_step_03_feed.xml", - "src/test/ressources/timeseries/timeseries_step_03_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries/timeseries_step_03_feed.xml", + "src/test/ressources/timeseries/timeseries_step_03_advance.xml"); + // Vierter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries/timeseries_step_04_feed.xml", - "src/test/ressources/timeseries/timeseries_step_04_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries/timeseries_step_04_feed.xml", + "src/test/ressources/timeseries/timeseries_step_04_advance.xml"); + Document outputData; // Fünfter Schritt outputData = artifact.describe(cc); 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"), cc); - artifact.out(this.readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"),fos, cc); - } catch (Exception e){ - log.error(e,e); + try { + fos = new FileOutputStream( + "src/test/results/timeseriesdiagramm" + + System.currentTimeMillis() + ".png"); + artifact + .feed( + this + .readDocument("src/test/ressources/timeseries/timeseries_step_05_feed.xml"), + cc); + artifact + .out( + this + .readDocument("src/test/ressources/timeseries/timeseries_step_05_out.xml"), + fos, cc); + } catch (Exception e) { + log.error(e, e); fail(); - }finally{ + } finally { try { fos.flush(); fos.close(); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } } } catch (Exception e) { - log.error(e,e); + log.error(e, e); fail(); } } @@ -135,8 +161,10 @@ * @return */ private CallContext createCallContext() { - CallMeta callMeta = new DefaultCallMeta(new PreferredLocale[]{new DefaultPreferredLocale("de_DE", 1.0f)}); - CallContext cc = new TestCallContext(bootstrap.getContext(),callMeta); + CallMeta callMeta = new DefaultCallMeta( + new PreferredLocale[] { new DefaultPreferredLocale("de_DE", + 1.0f) }); + CallContext cc = new TestCallContext(bootstrap.getContext(), callMeta); return cc; } @@ -145,7 +173,9 @@ * @param cc * @throws Exception */ - private void doNextStep(Artifact artifact, CallContext cc, String feedDocument, String advanceDocument) throws Exception { + private void doNextStep(Artifact artifact, CallContext cc, + String feedDocument, String advanceDocument) + throws Exception { Document outputData = artifact.describe(cc); this.writeDocument2Log(outputData); outputData = artifact.feed(this.readDocument(feedDocument), cc); @@ -153,138 +183,111 @@ outputData = artifact.advance(this.readDocument(advanceDocument), cc); this.writeDocument2Log(outputData); this.check4ExceptionReport(outputData); - - + } - - public void testTimeSeriesMeshArtifact(){ + + public void testTimeSeriesMeshArtifact() { try { log.debug("GNVArtifactsTestCase.testTimeSeriesMeshArtifact"); - String artefactName = "fis_modeldata"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); + String artefactName = "fis_modeldata"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); assertNotNull(artifactFactory); log.debug("TimeSeriesMesh-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); assertNotNull(artifact); log.debug("TimeSeriesMesh-Artifact is available"); - - + CallContext cc = createCallContext(); - + // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries_mesh/timeseries_step_01_feed.xml", - "src/test/ressources/timeseries_mesh/timeseries_step_01_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries_mesh/timeseries_step_01_feed.xml", + "src/test/ressources/timeseries_mesh/timeseries_step_01_advance.xml"); + // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries_mesh/timeseries_step_02_feed.xml", - "src/test/ressources/timeseries_mesh/timeseries_step_02_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries_mesh/timeseries_step_02_feed.xml", + "src/test/ressources/timeseries_mesh/timeseries_step_02_advance.xml"); + // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries_mesh/timeseries_step_03_feed.xml", - "src/test/ressources/timeseries_mesh/timeseries_step_03_advance.xml"); - - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries_mesh/timeseries_step_03_feed.xml", + "src/test/ressources/timeseries_mesh/timeseries_step_03_advance.xml"); + // Vierter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries_mesh/timeseries_step_04_feed.xml", - "src/test/ressources/timeseries_mesh/timeseries_step_04_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries_mesh/timeseries_step_04_feed.xml", + "src/test/ressources/timeseries_mesh/timeseries_step_04_advance.xml"); + // Fünfter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries_mesh/timeseries_step_05_feed.xml", - "src/test/ressources/timeseries_mesh/timeseries_step_05_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries_mesh/timeseries_step_05_feed.xml", + "src/test/ressources/timeseries_mesh/timeseries_step_05_advance.xml"); + // Sechster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/timeseries_mesh/timeseries_step_06_feed.xml", - "src/test/ressources/timeseries_mesh/timeseries_step_06_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/timeseries_mesh/timeseries_step_06_feed.xml", + "src/test/ressources/timeseries_mesh/timeseries_step_06_advance.xml"); + // Siebter Schritt Document outputData = artifact.describe(cc); FileOutputStream fos = null; FileOutputStream fos2 = null; FileOutputStream fos3 = null; - try{ - fos = new FileOutputStream("src/test/results/timeseries_mesh"+System.currentTimeMillis()+".png"); - fos2 = new FileOutputStream("src/test/results/timeseries_mesh"+System.currentTimeMillis()+".xml"); - fos3 = new FileOutputStream("src/test/results/timeseries_mesh"+System.currentTimeMillis()+".csv"); - artifact.feed(this.readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_feed.xml"), cc); - artifact.out(this.readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_statistics.xml"),fos2, cc); - artifact.out(this.readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_chart.xml"),fos, cc); - artifact.out(this.readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_csv.xml"),fos3, cc); - } catch (Exception e){ - log.error(e,e); + try { + fos = new FileOutputStream("src/test/results/timeseries_mesh" + + System.currentTimeMillis() + + ".png"); + fos2 = new FileOutputStream("src/test/results/timeseries_mesh" + + System.currentTimeMillis() + + ".xml"); + fos3 = new FileOutputStream("src/test/results/timeseries_mesh" + + System.currentTimeMillis() + + ".csv"); + artifact + .feed( + this + .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_feed.xml"), + cc); + artifact + .out( + this + .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_statistics.xml"), + fos2, cc); + artifact + .out( + this + .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_chart.xml"), + fos, cc); + artifact + .out( + this + .readDocument("src/test/ressources/timeseries_mesh/timeseries_step_07_out_csv.xml"), + fos3, cc); + } catch (Exception e) { + log.error(e, e); fail(); - }finally{ - try { - fos.flush(); - fos.close(); - fos2.flush(); - fos2.close(); - fos3.flush(); - fos3.close(); - } catch (Exception e) { - log.error(e,e); - } - } - } catch (Exception e) { - log.error(e,e); - fail(); - } - } - - public void testVerticalProfileArtifact(){ - try { - log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); - String artefactName = "fis_marnet"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); - assertNotNull(artifactFactory); - log.debug("VerticalProfile-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); - assertNotNull(artifact); - log.debug("VerticalProfile-Artifact is available"); - - - CallContext cc = createCallContext(); - - // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile/verticalprofile_step_01_feed.xml", - "src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"); - - - // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile/verticalprofile_step_02_feed.xml", - "src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"); - - - // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile/verticalprofile_step_03_feed.xml", - "src/test/ressources/verticalprofile/verticalprofile_step_03_advance.xml"); - - - // Vierter Schritt - Document outputData = artifact.describe(cc); - FileOutputStream fos = null; - FileOutputStream fos2 = null; - FileOutputStream fos3 = null; - try{ - fos = new FileOutputStream("src/test/results/verticalprofile"+System.currentTimeMillis()+".png"); - fos2 = new FileOutputStream("src/test/results/verticalprofile"+System.currentTimeMillis()+".xml"); - fos3 = new FileOutputStream("src/test/results/verticalprofile"+System.currentTimeMillis()+".csv"); - artifact.feed(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_feed.xml"), cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_statistics.xml"),fos2, cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_chart.xml"),fos, cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_csv.xml"),fos3, cc); - } catch (Exception e){ - log.error(e,e); - fail(); - }finally{ + } finally { try { fos.flush(); fos.close(); @@ -293,136 +296,93 @@ fos3.flush(); fos3.close(); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } } } catch (Exception e) { - log.error(e,e); + log.error(e, e); fail(); } } - - public void testVerticalProfileMeshArtifact(){ + + public void testVerticalProfileArtifact() { try { log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); - String artefactName = "fis_modeldata"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); + String artefactName = "fis_marnet"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); assertNotNull(artifactFactory); log.debug("VerticalProfile-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); assertNotNull(artifact); log.debug("VerticalProfile-Artifact is available"); - - + CallContext cc = createCallContext(); - + // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_01_feed.xml", - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_01_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile/verticalprofile_step_01_feed.xml", + "src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"); + // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_02_feed.xml", - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_02_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile/verticalprofile_step_02_feed.xml", + "src/test/ressources/verticalprofile/verticalprofile_step_02_advance.xml"); + // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_03_feed.xml", - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_03_advance.xml"); - - // Vierter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_04_feed.xml", - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_04_advance.xml"); - - // Fünfter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_05_feed.xml", - "src/test/ressources/verticalprofile_mesh/verticalprofile_step_05_advance.xml"); - - // Sechster Schritt - Document outputData = artifact.describe(cc); - FileOutputStream fos = null; - FileOutputStream fos2 = null; - FileOutputStream fos3 = null; - try{ - fos = new FileOutputStream("src/test/results/verticalprofile_mesh"+System.currentTimeMillis()+".png"); - fos2 = new FileOutputStream("src/test/results/verticalprofile_mesh"+System.currentTimeMillis()+".xml"); - fos3 = new FileOutputStream("src/test/results/verticalprofile_mesh"+System.currentTimeMillis()+".csv"); - artifact.feed(this.readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_feed.xml"), cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_statistics.xml"),fos2, cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_chart.xml"),fos, cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_csv.xml"),fos3, cc); - } catch (Exception e){ - log.error(e,e); - fail(); - }finally{ - try { - fos.flush(); - fos.close(); - fos2.flush(); - fos2.close(); - fos3.flush(); - fos3.close(); - } catch (Exception e) { - log.error(e,e); - } - } - } catch (Exception e) { - log.error(e,e); - fail(); - } - } - - - - public void testVerticalProfileInstantaneousPointArtifact(){ - try { - log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); - String artefactName = "fis_bsh_ctd"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); - assertNotNull(artifactFactory); - log.debug("VerticalProfile-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); - assertNotNull(artifact); - log.debug("VerticalProfile-Artifact is available"); - - - CallContext cc = createCallContext(); - - // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_feed.xml", - "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_advance.xml"); - - // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_feed.xml", - "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_advance.xml"); - - // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_feed.xml", - "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile/verticalprofile_step_03_feed.xml", + "src/test/ressources/verticalprofile/verticalprofile_step_03_advance.xml"); + // Vierter Schritt Document outputData = artifact.describe(cc); FileOutputStream fos = null; FileOutputStream fos2 = null; FileOutputStream fos3 = null; - try{ - fos = new FileOutputStream("src/test/results/verticalprofile_instantaneouspoint"+System.currentTimeMillis()+".png"); - fos2 = new FileOutputStream("src/test/results/verticalprofile_instantaneouspoint"+System.currentTimeMillis()+".xml"); - fos3 = new FileOutputStream("src/test/results/verticalprofile_instantaneouspoint"+System.currentTimeMillis()+".csv"); - artifact.feed(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_feed.xml"), cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_statistics.xml"),fos2, cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_chart.xml"),fos, cc); - artifact.out(this.readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_csv.xml"),fos3, cc); - } catch (Exception e){ - log.error(e,e); + try { + fos = new FileOutputStream("src/test/results/verticalprofile" + + System.currentTimeMillis() + + ".png"); + fos2 = new FileOutputStream("src/test/results/verticalprofile" + + System.currentTimeMillis() + + ".xml"); + fos3 = new FileOutputStream("src/test/results/verticalprofile" + + System.currentTimeMillis() + + ".csv"); + artifact + .feed( + this + .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_feed.xml"), + cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_statistics.xml"), + fos2, cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_chart.xml"), + fos, cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile/verticalprofile_step_04_out_csv.xml"), + fos3, cc); + } catch (Exception e) { + log.error(e, e); fail(); - }finally{ + } finally { try { fos.flush(); fos.close(); @@ -431,74 +391,109 @@ fos3.flush(); fos3.close(); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } } } catch (Exception e) { - log.error(e,e); + log.error(e, e); fail(); } } - - public void testHorizontalProfileInstantaneousPointArtifact(){ + + public void testVerticalProfileMeshArtifact() { try { - log.debug("GNVArtifactsTestCase.testHorizontalProfileInstantaneousPointArtifact"); - String artefactName = "fis_delphin"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); + log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); + String artefactName = "fis_modeldata"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); assertNotNull(artifactFactory); log.debug("VerticalProfile-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); assertNotNull(artifact); log.debug("VerticalProfile-Artifact is available"); - - + CallContext cc = createCallContext(); - + // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_00_feed.xml", - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_00_advance.xml"); - - - // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_01_feed.xml", - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_01_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_01_feed.xml", + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_01_advance.xml"); + // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_02_feed.xml", - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_02_advance.xml"); + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_02_feed.xml", + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_02_advance.xml"); + // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_03_feed.xml", - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_03_advance.xml"); + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_03_feed.xml", + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_03_advance.xml"); + // Vierter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_04_feed.xml", - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_04_advance.xml"); - // Fünfter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_05_feed.xml", - "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_05_advance.xml"); - - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_04_feed.xml", + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_04_advance.xml"); + + // Fünfter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_05_feed.xml", + "src/test/ressources/verticalprofile_mesh/verticalprofile_step_05_advance.xml"); + + // Sechster Schritt Document outputData = artifact.describe(cc); FileOutputStream fos = null; FileOutputStream fos2 = null; FileOutputStream fos3 = null; - try{ - fos = new FileOutputStream("src/test/results/horizontalprofile_instantaneouspoint"+System.currentTimeMillis()+".png"); - fos2 = new FileOutputStream("src/test/results/horizontalprofile_instantaneouspoint"+System.currentTimeMillis()+".xml"); - fos3 = new FileOutputStream("src/test/results/horizontalprofile_instantaneouspoint"+System.currentTimeMillis()+".csv"); - artifact.feed(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_feed.xml"), cc); - //artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_statistics.xml"),fos2, cc); - artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_chart.xml"),fos, cc); -// artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_csv.xml"),fos3, cc); - } catch (Exception e){ - log.error(e,e); + try { + fos = new FileOutputStream( + "src/test/results/verticalprofile_mesh" + + System.currentTimeMillis() + ".png"); + fos2 = new FileOutputStream( + "src/test/results/verticalprofile_mesh" + + System.currentTimeMillis() + ".xml"); + fos3 = new FileOutputStream( + "src/test/results/verticalprofile_mesh" + + System.currentTimeMillis() + ".csv"); + artifact + .feed( + this + .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_feed.xml"), + cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_statistics.xml"), + fos2, cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_chart.xml"), + fos, cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile_mesh/verticalprofile_step_06_out_csv.xml"), + fos3, cc); + } catch (Exception e) { + log.error(e, e); fail(); - }finally{ + } finally { try { fos.flush(); fos.close(); @@ -507,79 +502,93 @@ fos3.flush(); fos3.close(); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } } } catch (Exception e) { - log.error(e,e); + log.error(e, e); fail(); } } - - public void testHorizontalProfileMeshPointArtifact(){ + + public void testVerticalProfileInstantaneousPointArtifact() { try { - log.debug("GNVArtifactsTestCase.testHorizontalProfileInstantaneousPointArtifact"); - String artefactName = "fis_modeldata"; - ArtifactFactory artifactFactory = this.getArtifactFactory(artefactName); + log.debug("GNVArtifactsTestCase.testVerticalProfileArtifact"); + String artefactName = "fis_bsh_ctd"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); assertNotNull(artifactFactory); log.debug("VerticalProfile-ArtifactFactory is available"); - Artifact artifact = artifactFactory.createArtifact(""+System.currentTimeMillis(),bootstrap.getContext()); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); assertNotNull(artifact); log.debug("VerticalProfile-Artifact is available"); - - + CallContext cc = createCallContext(); - - - + // Erster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_01_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_01_advance.xml"); - + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_feed.xml", + "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_01_advance.xml"); + // Zweiter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_02_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_02_advance.xml"); + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_feed.xml", + "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_02_advance.xml"); + // Dritter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_03_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_03_advance.xml"); + this + .doNextStep( + artifact, + cc, + "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_feed.xml", + "src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_03_advance.xml"); + // Vierter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_04_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_04_advance.xml"); - // Fünfter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_05_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_05_advance.xml"); - - // Sechster Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_06_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_06_advance.xml"); - - // Siebter Schritt - this.doNextStep(artifact, cc, - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_07_feed.xml", - "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_07_advance.xml"); - Document outputData = artifact.describe(cc); FileOutputStream fos = null; FileOutputStream fos2 = null; FileOutputStream fos3 = null; - try{ - fos = new FileOutputStream("src/test/results/horizontalProfile_mesh"+System.currentTimeMillis()+".png"); - fos2 = new FileOutputStream("src/test/results/horizontalProfile_mesh"+System.currentTimeMillis()+".xml"); - fos3 = new FileOutputStream("src/test/results/horizontalProfile_mesh"+System.currentTimeMillis()+".csv"); - artifact.feed(this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_feed.xml"), cc); - artifact.out(this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_statistics.xml"),fos2, cc); - artifact.out(this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_chart.xml"),fos, cc); -// artifact.out(this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_csv.xml"),fos3, cc); - } catch (Exception e){ - log.error(e,e); + try { + fos = new FileOutputStream( + "src/test/results/verticalprofile_instantaneouspoint" + + System.currentTimeMillis() + ".png"); + fos2 = new FileOutputStream( + "src/test/results/verticalprofile_instantaneouspoint" + + System.currentTimeMillis() + ".xml"); + fos3 = new FileOutputStream( + "src/test/results/verticalprofile_instantaneouspoint" + + System.currentTimeMillis() + ".csv"); + artifact + .feed( + this + .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_feed.xml"), + cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_statistics.xml"), + fos2, cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_chart.xml"), + fos, cc); + artifact + .out( + this + .readDocument("src/test/ressources/verticalprofile_instantaneouspoint/verticalprofile_step_04_out_csv.xml"), + fos3, cc); + } catch (Exception e) { + log.error(e, e); fail(); - }finally{ + } finally { try { fos.flush(); fos.close(); @@ -588,74 +597,304 @@ fos3.flush(); fos3.close(); } catch (Exception e) { - log.error(e,e); + log.error(e, e); } } } catch (Exception e) { - log.error(e,e); + log.error(e, e); fail(); } } - - protected void createFile(byte[] content, String fileName){ + + public void testHorizontalProfileInstantaneousPointArtifact() { + try { + log + .debug("GNVArtifactsTestCase.testHorizontalProfileInstantaneousPointArtifact"); + String artefactName = "fis_delphin"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); + assertNotNull(artifactFactory); + log.debug("VerticalProfile-ArtifactFactory is available"); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); + assertNotNull(artifact); + log.debug("VerticalProfile-Artifact is available"); + + CallContext cc = createCallContext(); + + // Erster Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_00_feed.xml", + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_00_advance.xml"); + + // Erster Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_01_feed.xml", + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_01_advance.xml"); + + // Zweiter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_02_feed.xml", + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_02_advance.xml"); + // Dritter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_03_feed.xml", + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_03_advance.xml"); + // Vierter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_04_feed.xml", + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_04_advance.xml"); + // Fünfter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_05_feed.xml", + "src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_05_advance.xml"); + + Document outputData = artifact.describe(cc); + FileOutputStream fos = null; + FileOutputStream fos2 = null; + FileOutputStream fos3 = null; + try { + fos = new FileOutputStream( + "src/test/results/horizontalprofile_instantaneouspoint" + + System.currentTimeMillis() + ".png"); + fos2 = new FileOutputStream( + "src/test/results/horizontalprofile_instantaneouspoint" + + System.currentTimeMillis() + ".xml"); + fos3 = new FileOutputStream( + "src/test/results/horizontalprofile_instantaneouspoint" + + System.currentTimeMillis() + ".csv"); + artifact + .feed( + this + .readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_feed.xml"), + cc); + // artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_statistics.xml"),fos2, + // cc); + artifact + .out( + this + .readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_chart.xml"), + fos, cc); + // artifact.out(this.readDocument("src/test/ressources/horizontalProfile_instantaneouspoint/horizontalprofile_step_06_out_csv.xml"),fos3, + // cc); + } catch (Exception e) { + log.error(e, e); + fail(); + } finally { + try { + fos.flush(); + fos.close(); + fos2.flush(); + fos2.close(); + fos3.flush(); + fos3.close(); + } catch (Exception e) { + log.error(e, e); + } + } + } catch (Exception e) { + log.error(e, e); + fail(); + } + } + + public void testHorizontalProfileMeshPointArtifact() { + try { + log + .debug("GNVArtifactsTestCase.testHorizontalProfileInstantaneousPointArtifact"); + String artefactName = "fis_modeldata"; + ArtifactFactory artifactFactory = this + .getArtifactFactory(artefactName); + assertNotNull(artifactFactory); + log.debug("VerticalProfile-ArtifactFactory is available"); + Artifact artifact = artifactFactory.createArtifact( + "" + System.currentTimeMillis(), bootstrap.getContext()); + assertNotNull(artifact); + log.debug("VerticalProfile-Artifact is available"); + + CallContext cc = createCallContext(); + + // Erster Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_01_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_01_advance.xml"); + + // Zweiter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_02_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_02_advance.xml"); + // Dritter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_03_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_03_advance.xml"); + // Vierter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_04_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_04_advance.xml"); + // Fünfter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_05_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_05_advance.xml"); + + // Sechster Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_06_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_06_advance.xml"); + + // Siebter Schritt + this + .doNextStep( + artifact, + cc, + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_07_feed.xml", + "src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_07_advance.xml"); + + Document outputData = artifact.describe(cc); + FileOutputStream fos = null; + FileOutputStream fos2 = null; + FileOutputStream fos3 = null; + try { + fos = new FileOutputStream( + "src/test/results/horizontalProfile_mesh" + + System.currentTimeMillis() + ".png"); + fos2 = new FileOutputStream( + "src/test/results/horizontalProfile_mesh" + + System.currentTimeMillis() + ".xml"); + fos3 = new FileOutputStream( + "src/test/results/horizontalProfile_mesh" + + System.currentTimeMillis() + ".csv"); + artifact + .feed( + this + .readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_feed.xml"), + cc); + artifact + .out( + this + .readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_statistics.xml"), + fos2, cc); + artifact + .out( + this + .readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_chart.xml"), + fos, cc); + // artifact.out(this.readDocument("src/test/ressources/horizontalProfile_mesh/horizontalprofile_step_08_out_csv.xml"),fos3, + // cc); + } catch (Exception e) { + log.error(e, e); + fail(); + } finally { + try { + fos.flush(); + fos.close(); + fos2.flush(); + fos2.close(); + fos3.flush(); + fos3.close(); + } catch (Exception e) { + log.error(e, e); + } + } + } catch (Exception e) { + log.error(e, e); + fail(); + } + } + + protected void createFile(byte[] content, String fileName) { try { FileOutputStream fos = new FileOutputStream(new File(fileName)); ByteArrayInputStream bis = new ByteArrayInputStream(content); byte[] buf = new byte[4096]; - while (bis.read(buf) > 0){ - fos.write(buf); + while (bis.read(buf) > 0) { + fos.write(buf); } fos.flush(); fos.close(); } catch (FileNotFoundException e) { - log.error(e,e); + log.error(e, e); } catch (IOException e) { - log.error(e,e); + log.error(e, e); } } - /** * @param artefactName */ - private ArtifactFactory getArtifactFactory(String artefactName){ + private ArtifactFactory getArtifactFactory(String artefactName) { log.debug("GNVArtifactsTestCase.getArtifactFactory"); ArtifactFactory[] artifactFactories = bootstrap.getArtifactFactories(); - for (int i = 0; i < artifactFactories.length; i++){ - if (artifactFactories[i].getName().equals(artefactName)){ + for (int i = 0; i < artifactFactories.length; i++) { + if (artifactFactories[i].getName().equals(artefactName)) { log.debug("ArtifactFactory wurde gefunden."); return artifactFactories[i]; } } return null; } - - protected void writeDocument2Log(Document document){ + + protected void writeDocument2Log(Document document) { log.debug(new ArtifactXMLUtilities().writeDocument2String(document)); } - - - protected Document readDocument(String fileName){ + + protected Document readDocument(String fileName) { Document returnValue = null; try { - DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory + .newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); - returnValue = docBuilder.parse (new File(fileName)); + returnValue = docBuilder.parse(new File(fileName)); } catch (ParserConfigurationException e) { - log.error(e,e); + log.error(e, e); } catch (SAXException e) { - log.error(e,e); + log.error(e, e); } catch (IOException e) { - log.error(e,e); + log.error(e, e); } return returnValue; } - - private void check4ExceptionReport(Document document) throws Exception{ + private void check4ExceptionReport(Document document) throws Exception { document = new ArtifactXMLUtilities().reInitDocument(document); - String message = Config.getStringXPath(document,"/exceptionreport/exception"); - if (message != null){ + String message = Config.getStringXPath(document, + "/exceptionreport/exception"); + if (message != null) { throw new Exception(message); } }
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestCallContext.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/TestCallContext.java Fri Oct 09 07:54:48 2009 +0000 @@ -8,12 +8,13 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class TestCallContext implements CallContext { private Object globalContext = null; private CallMeta callMeta = null; + /** * Constructor */
--- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java Fri Oct 09 07:54:48 2009 +0000 @@ -10,20 +10,22 @@ /** * @author Tim Englich <tim.englich@intevation.de> - * + * */ public class RessourceFactoryTestCase extends TestCase { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = null; - + static { BasicConfigurator.configure(); log = Logger.getLogger(RessourceFactoryTestCase.class); } + /** * Constructor + * * @param name */ public RessourceFactoryTestCase(String name) { @@ -33,17 +35,24 @@ /** * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); -// System.setProperty("artifact.ressource.dir", -// "src/test/ressources/lang"); + // System.setProperty("artifact.ressource.dir", + // "src/test/ressources/lang"); } - - public void testRessurceFactoryTestCase(){ - ; - String value = RessourceFactory.getInstance().getRessource( new PreferredLocale[]{new DefaultPreferredLocale("de", 1.0f)}, "fis_modeldata", "N/N"); + + public void testRessurceFactoryTestCase() { + ; + String value = RessourceFactory.getInstance() + .getRessource( + new PreferredLocale[] { new DefaultPreferredLocale( + "de", 1.0f) }, "fis_modeldata", "N/N"); log.debug(value); - value = RessourceFactory.getInstance().getRessource( new PreferredLocale[]{new DefaultPreferredLocale("en", 1.0f)}, "fis_modeldata", "N/N"); + value = RessourceFactory.getInstance() + .getRessource( + new PreferredLocale[] { new DefaultPreferredLocale( + "en", 1.0f) }, "fis_modeldata", "N/N"); log.debug(value); }