# HG changeset patch # User Tim Englich # Date 1253888648 0 # Node ID 07e9c137a2f1bf5a1a1c9fa7b50c7a1ac94de404 # Parent bba8fd97e549ae93ddde91543ff670353e781fce Added dynamic Outputparameter Support and Outputparameter-manipulation gnv/trunk@134 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/Changelog --- a/gnv/Changelog Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/Changelog Fri Sep 25 14:24:08 2009 +0000 @@ -1,3 +1,45 @@ +2009-09-25 Tim Englich + + * src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java Edited, + src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java Edietd: + Integrated some Method for accessing and Setting OutputModes to an ArtifactDescription. + + * src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java Edited, + src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java Edited, + src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java Edited, + src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java Edited: + Adding some Beans and their InterfaceDescription for the Representation of OutputModes + supported by an Artifact + + * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Edited: + Fetsching the OutputMode-Informations from the Describedocument and put them into a Collection + of OutputModes. + + * src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Edited: + Restet SessionModel integrated. + + * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Edited: + Cast for ArtifactDescription removed. + + * src/main/java/de/intevation/gnv/action/DoOutputAction.java Edited, + src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Edited: + Dynamical read of OutputParameter for Outputgeneration + + * src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Edited:, + src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Edited: + Added some Method for retrieving Diagrammoptions and reset the SessionModel + + * src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Edited: + Dynamic Options Support Added + + * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Edited: + Dynamic Rendring of the Outputparameters of an ArtifactoutputType added. + Ath this Moment only The Outputparameter for Chart ist provided. + + * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Edited : + Integrated dynamic Setting of Diagramm-Parameter to the Link. + Also Read MimeType from the OPutputParameters of the Artifact. + 2009-09-25 Tim Englich * src/main/java/de/intevation/gnv/action/DoOutputAction.java Edited: diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Fri Sep 25 14:24:08 2009 +0000 @@ -3,6 +3,9 @@ */ package de.intevation.gnv.action; +import java.util.Collection; +import java.util.Iterator; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -12,11 +15,14 @@ import org.apache.struts.action.ActionMapping; import org.w3c.dom.Node; +import de.intevation.gnv.action.sessionmodel.DiagrammOptions; import de.intevation.gnv.action.sessionmodel.SessionModel; import de.intevation.gnv.action.sessionmodel.SessionModelFactory; import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; +import de.intevation.gnv.artifactdatabase.objects.OutputMode; +import de.intevation.gnv.artifactdatabase.objects.OutputParameter; import de.intevation.gnv.util.XMLUtils; import de.intevation.gnv.util.XSLTransformer; @@ -42,10 +48,26 @@ throws Exception { log.debug("NextArtifactStepAction.execute"); SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); + + String target = request.getParameter("target"); + OutputMode outputMode = sm.getOutputMode(target); + if (outputMode != null){ + + Collection op = outputMode.getOutputParameters(); + if (op != null){ + Iterator it = op.iterator(); + DiagrammOptions diagrammOptions = new DiagrammOptions(); + while (it.hasNext()){ + OutputParameter parameter = it.next(); + diagrammOptions.setValue(parameter.getName(), request.getParameter(parameter.getName())); + + } + sm.setDiagrammOptions(diagrammOptions); + } + } + + ArtifactDescription ad = sm.getArtifactDescription(); ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - - ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); Node currentUI = artifactDescription.getCurrentUI(); @@ -56,7 +78,6 @@ String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); request.setAttribute("staticui", staticUI); - request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty())); if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){ diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Fri Sep 25 14:24:08 2009 +0000 @@ -23,6 +23,8 @@ import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; import de.intevation.gnv.artifactdatabase.objects.InputParameter; +import de.intevation.gnv.artifactdatabase.objects.OutputMode; +import de.intevation.gnv.artifactdatabase.objects.OutputParameter; /** * @author Tim Englich @@ -59,30 +61,38 @@ // TODO Check if is propper; SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); - Collection inputParameter = ad.getInputParameter(); - Collection ips = null; - if (inputParameter != null){ - ips = new ArrayList(inputParameter.size()); - Iterator it = inputParameter.iterator(); - while (it.hasNext()){ - String name = it.next(); - String[] values = request.getParameterValues(name); - InputParameter ip = new DefaultInputParameter(name, values); - ips.add(ip); + OutputMode outputMode = sm.getOutputMode(target); + if (outputMode != null && outputMode.getMimeType().equals(mimeType)){ + Collection inputParameter =outputMode.getOutputParameters(); + Collection ips = null; + if (inputParameter != null){ + ips = new ArrayList(inputParameter.size()); + Iterator it = inputParameter.iterator(); + while (it.hasNext()){ + String name = it.next().getName(); + String[] values = request.getParameterValues(name); + InputParameter ip = new DefaultInputParameter(name, values); + ips.add(ip); + } } + + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); + + this.setHeaders(target, mimeType, response, request); + + OutputStream outputStream = response.getOutputStream(); + adc.doOutput(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), outputStream, target, mimeType, ips); + + outputStream.flush(); + outputStream.close(); + }else{ + if (outputMode == null){ + log.error("Outputmode wird nicht unterstützt."); + }else if (!outputMode.getMimeType().equals(mimeType)){ + log.error("MimeType "+mimeType+" wird nicht unterstützt."); + } + // TODO FIXME: Fehlerbehandlung } - - ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - - this.setHeaders(target, mimeType, response, request); - - OutputStream outputStream = response.getOutputStream(); - adc.doOutput(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), outputStream, target, mimeType, ips); - - outputStream.flush(); - outputStream.close(); - return super.execute(mapping, form, request, response); } diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Fri Sep 25 14:24:08 2009 +0000 @@ -52,7 +52,7 @@ throws Exception { log.debug("NextArtifactStepAction.execute"); SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); + ArtifactDescription ad = sm.getArtifactDescription(); Collection inputParameter = ad.getInputParameter(); Collection ips = null; if (inputParameter != null){ diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Fri Sep 25 14:24:08 2009 +0000 @@ -45,6 +45,8 @@ SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); Collection artifactFactories = sm.getArtifactFactories(); + // Löscht die Artifactspezifischen Attribute am Sessionmodel + sm.resetModel(); if (artifactFactories == null || artifactFactories.isEmpty()){ new FetchArtifactFactoriesAction().execute(mapping, form, request, response); diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java --- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Fri Sep 25 14:24:08 2009 +0000 @@ -6,7 +6,11 @@ import java.util.Collection; import java.util.Iterator; +import org.apache.log4j.Logger; + +import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; +import de.intevation.gnv.artifactdatabase.objects.OutputMode; /** * @author Tim Englich @@ -15,7 +19,15 @@ public class DefaultSessionModel implements SessionModel{ + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(DefaultSessionModel.class); + /** + * The UID of this Class. + */ + private static final long serialVersionUID = 3431484439985158311L; private Collection artifactFactories = null; @@ -91,14 +103,52 @@ public void setCurrentArtifact(ArtifactObject artifact) { this.currentArtifact = artifact; } - + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#getDiagrammOptions() + */ public DiagrammOptions getDiagrammOptions() { - if (diagrammOptions == null){ - diagrammOptions = new DiagrammOptions(); + return this.diagrammOptions; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#setDiagrammOptions(de.intevation.gnv.action.sessionmodel.DiagrammOptions) + */ + public void setDiagrammOptions(DiagrammOptions diagrammOptions) { + this.diagrammOptions = diagrammOptions; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#getArtifactDescription() + */ + public ArtifactDescription getArtifactDescription() { + if (this.currentArtifact != null){ + return (ArtifactDescription)this.currentArtifact; } - return diagrammOptions; + return null; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#getOutputMode(java.lang.String) + */ + public OutputMode getOutputMode(String name) { + ArtifactDescription ad = this.getArtifactDescription(); + if (ad != null){ + if (ad.getOutputModes() != null){ + return ad.getOutputModes().get(name); + } + } + return null; } - - + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#resetModel() + */ + public void resetModel() { + log.debug("DefaultSessionModel.resetModel"); + selectedArtifactFactory = null; + currentArtifact =null; + diagrammOptions= null; + + } } diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java --- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Fri Sep 25 14:24:08 2009 +0000 @@ -2,6 +2,10 @@ * */ package de.intevation.gnv.action.sessionmodel; + +import java.util.HashMap; +import java.util.Map; + /** * @author Tim Englich * @@ -9,14 +13,7 @@ public class DiagrammOptions { - public enum mode{ - Standard, - User_Specific - } - - private mode modus = mode.Standard; - - private int width = 500; + private Map values = new HashMap(); /** * Constructor */ @@ -24,32 +21,19 @@ super(); } + /** * @return */ - public mode getModus() { - return modus; - } - - /** - * @param modus - */ - public void setModus(mode modus) { - this.modus = modus; - } - - /** - * @return - */ - public int getWidth() { - return width; + public String getValue(String key) { + return this.values.get(key); } /** * @param width */ - public void setWidth(int width) { - this.width = width; + public void setValue(String key, String value) { + this.values.put(key, value); } } \ No newline at end of file diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java --- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Fri Sep 25 14:24:08 2009 +0000 @@ -3,15 +3,18 @@ */ package de.intevation.gnv.action.sessionmodel; +import java.io.Serializable; import java.util.Collection; +import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; +import de.intevation.gnv.artifactdatabase.objects.OutputMode; /** * @author Tim Englich * */ -public interface SessionModel { +public interface SessionModel extends Serializable{ Collection getArtifactFactories(); @@ -25,6 +28,14 @@ void setCurrentArtifact(ArtifactObject artifact); + void setDiagrammOptions(DiagrammOptions diagrammOptions); + DiagrammOptions getDiagrammOptions(); + + OutputMode getOutputMode(String name); + + ArtifactDescription getArtifactDescription(); + + void resetModel(); } diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Fri Sep 25 14:24:08 2009 +0000 @@ -8,7 +8,9 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import org.apache.log4j.Logger; import org.restlet.Client; @@ -28,7 +30,11 @@ import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory; import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; +import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode; +import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter; import de.intevation.gnv.artifactdatabase.objects.InputParameter; +import de.intevation.gnv.artifactdatabase.objects.OutputMode; +import de.intevation.gnv.artifactdatabase.objects.OutputParameter; import de.intevation.gnv.propertiesreader.PropertiesReader; import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; import de.intevation.gnv.util.XMLUtils; @@ -289,6 +295,32 @@ ArtifactDescription ad = (ArtifactDescription)artifact; Node uiNode = xmlUtils.getNodeXPath(document, "/result/ui"); Node outputNode = xmlUtils.getNodeXPath(document, "/result/outputs"); + + Map outputModes = null; + if (outputNode != null){ + NodeList outputModesNodes = xmlUtils.getNodeSetXPath(outputNode, "output"); + if (outputModesNodes != null){ + outputModes = new HashMap(outputModesNodes.getLength()); + for (int i = 0; i < outputModesNodes.getLength(); i++){ + Node outputModeNode = outputModesNodes.item(i); + String name = xmlUtils.getStringXPath(outputModeNode, "@name"); + String mimeType = xmlUtils.getStringXPath(outputModeNode, "@mime-type"); + + NodeList parameterNodes = xmlUtils.getNodeSetXPath(outputModeNode, "parameter/parameter"); + Collection parameter = null; + if (parameterNodes != null){ + parameter = new ArrayList(parameterNodes.getLength()); + for (int j = 0; j < parameterNodes.getLength(); j++){ + Node outputParameterNode = parameterNodes.item(j); + parameter.add(new DefaultOutputParameter(xmlUtils.getStringXPath(outputParameterNode,"@name"),xmlUtils.getStringXPath(outputParameterNode,"@value"),xmlUtils.getStringXPath(outputParameterNode,"@name"),xmlUtils.getStringXPath(outputParameterNode,"@type"))); + } + } + outputModes.put(name,new DefaultOutputMode(name, mimeType, parameter)); + } + + } + } + String currentState = xmlUtils.getStringXPath(document, "/result/state/@name"); NodeList statesList = xmlUtils.getNodeSetXPath(document, "/result/reachable-states/state/@name"); Collection reachableStates = new ArrayList(statesList.getLength()); @@ -307,6 +339,7 @@ ad.setInputParameter(inputParameter); } + ad.setOutputModes(outputModes); ad.setCurrentOut(outputNode); ad.setCurrentUI(uiNode); ad.setCurrentState(currentState); diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java Fri Sep 25 14:24:08 2009 +0000 @@ -4,6 +4,7 @@ package de.intevation.gnv.artifactdatabase.objects; import java.util.Collection; +import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -23,6 +24,7 @@ private Collection reachableStates; private Collection inputParameter; + private Map outputModes; private String currentState = null; /** @@ -146,4 +148,27 @@ this.inputParameter = inputParameter; } + /** + * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#getOutputModes() + */ + public Map getOutputModes() { + return this.outputModes; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#getOutputModesAsCollection() + */ + public Collection getOutputModesAsCollection() { + if (this.outputModes != null){ + return this.outputModes.values(); + } + return null; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#setOutputModes(java.util.Map) + */ + public void setOutputModes(Map outputModes) { + this.outputModes = outputModes; + } } diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java Fri Sep 25 14:24:08 2009 +0000 @@ -4,6 +4,7 @@ package de.intevation.gnv.artifactdatabase.objects; import java.util.Collection; +import java.util.Map; import org.w3c.dom.Node; @@ -52,6 +53,24 @@ */ public Collection getInputParameter(); + /** + * @param inputParameter + */ public void setInputParameter(Collection inputParameter); + + /** + * @return the reachableStates + */ + public Map getOutputModes(); + + /** + * @return the reachableStates + */ + public Collection getOutputModesAsCollection(); + + /** + * @param outputParameter + */ + public void setOutputModes(Map outputModes); } \ No newline at end of file diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java Fri Sep 25 14:24:08 2009 +0000 @@ -0,0 +1,51 @@ +/** + * + */ +package de.intevation.gnv.artifactdatabase.objects; + +import java.util.Collection; + +/** + * @author Tim Englich + * + */ +public class DefaultOutputMode implements OutputMode { + + + private String name = null; + + private String mimeType = null; + + private Collection outputParameter = null; + + public DefaultOutputMode(String name, String mimeType, + Collection outputParameter) { + super(); + this.name = name; + this.mimeType = mimeType; + this.outputParameter = outputParameter; + } + + + /** + * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getMimeType() + */ + public String getMimeType() { + return this.mimeType; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getName() + */ + public String getName() { + return this.name; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getOutputParameters() + */ + public Collection getOutputParameters() { + return this.outputParameter; + } + +} diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java Fri Sep 25 14:24:08 2009 +0000 @@ -0,0 +1,56 @@ +/** + * + */ +package de.intevation.gnv.artifactdatabase.objects; +/** + * @author Tim Englich + * + */ +public class DefaultOutputParameter implements OutputParameter { + + + private String name = null; + + private String value = null; + + private String description = null; + + private String type = null; + + /** + * Constructor + * @param name + * @param value + * @param description + */ + public DefaultOutputParameter(String name, String value, String description, String type) { + super(); + this.name = name; + this.value = value; + this.description = description; + this.type = type; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.OutputParameter#getName() + */ + public String getName() { + return this.name; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.OutputParameter#getValue() + */ + public String getValue() { + return this.value; + } + + public String getDescription() { + return this.description; + } + + public String getType() { + return this.type; + } + +} diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java Fri Sep 25 14:24:08 2009 +0000 @@ -0,0 +1,20 @@ +/** + * + */ +package de.intevation.gnv.artifactdatabase.objects; + +import java.util.Collection; + +/** + * @author Tim Englich + * + */ +public interface OutputMode { + + public String getName(); + + public String getMimeType(); + + public Collection getOutputParameters(); + +} diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java Fri Sep 25 14:24:08 2009 +0000 @@ -0,0 +1,17 @@ +/** + * + */ +package de.intevation.gnv.artifactdatabase.objects; +/** + * @author Tim Englich + * + */ +public interface OutputParameter { + + + String getName(); + String getValue(); + String getDescription(); + String getType(); + +} diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp --- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Fri Sep 25 14:24:08 2009 +0000 @@ -1,28 +1,49 @@ <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> +<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%> +<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%> +<%@page import="java.util.Collection"%> +<%@page import="java.util.Iterator"%> <%Object diagramm = request.getAttribute("diagramm"); +SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); if (diagramm != null){ - String target = "chart"; String targetCSV = "csv"; - boolean supportCSV = true; // TODO get from SessionModel - String mimeType = "image/png";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request). - String mimeTypeCSV = "text/plain";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request). + boolean supportChart = sm.getOutputMode(target) != null; + boolean supportCSV = sm.getOutputMode(targetCSV) != null; + String mimeType = null; + String parameterString = ""; + if (supportChart){ + mimeType = sm.getOutputMode(target).getMimeType(); + DiagrammOptions diagrammOptions = sm.getDiagrammOptions(); + Collection op = sm.getOutputMode(target).getOutputParameters(); + if (op != null){ + Iterator it = op.iterator(); + while (it.hasNext()){ + OutputParameter parameter = it.next(); + parameterString = parameterString +"&"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue()); + } + } + } + String mimeTypeCSV = null; + if (supportCSV){ + mimeTypeCSV = sm.getOutputMode(targetCSV).getMimeType(); + } %> - -
- <bean:message key="gnviewer.output.options.diagramm.alt"/> +
+ <bean:message key="gnviewer.output.options.diagramm.alt"/>
- "> + "> <%if (supportCSV) { %> - "> + "> <%}%>
+
- <%}%> \ No newline at end of file diff -r bba8fd97e549 -r 07e9c137a2f1 gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp --- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Fri Sep 25 07:28:49 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Fri Sep 25 14:24:08 2009 +0000 @@ -1,33 +1,33 @@ <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%> <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> -<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions.mode"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputMode"%> +<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%> +<%@page import="java.util.Collection"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%> +<%@page import="java.util.Iterator"%> <% - DiagrammOptions diagrammOptions = SessionModelFactory.getInstance().getSessionModel(request).getDiagrammOptions(); - boolean isStandard = diagrammOptions.getModus() == DiagrammOptions.mode.Standard; + SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + DiagrammOptions diagrammOptions = sm.getDiagrammOptions(); + boolean useDiagrammOptions = diagrammOptions != null; + String target = "chart"; + OutputMode outputMode = sm.getOutputMode(target); %> -
- onblur="document.forms.outputOptionsForm.submit()" type="radio"> - -
- onblur="document.forms.outputOptionsForm.submit()" type="radio"> - - - -
- + <%if (outputMode != null && outputMode.getOutputParameters() != null && !outputMode.getOutputParameters().isEmpty()){ + Iterator it = outputMode.getOutputParameters().iterator(); + while (it.hasNext()){ + OutputParameter om = it.next(); %> + <%=om.getDescription()%>:
+ <%}%> + + "/> + <%}%>
\ No newline at end of file