# HG changeset patch # User Tim Englich # Date 1253863729 0 # Node ID bba8fd97e549ae93ddde91543ff670353e781fce # Parent d93ea867406b564cc9cfc65958882fc5fe93a6f4 Export and Diagrammoptions integrated into GUI gnv/trunk@133 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d93ea867406b -r bba8fd97e549 gnv/Changelog --- a/gnv/Changelog Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/Changelog Fri Sep 25 07:28:49 2009 +0000 @@ -1,3 +1,33 @@ +2009-09-25 Tim Englich + + * src/main/java/de/intevation/gnv/action/DoOutputAction.java Edited: + Some Refactoring work done. + Logging Integrated. Extract Method for setting Responseheader Informations. + + * src/main/java/de/intevation/gnv/action/DoExportAction.java Added: + Action for performing the Exports eg. CSV and Chart + * src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Added: + Action for do the Bussinesslogic for storing the Diagrammoptions that were + changed by the User. + * src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Edited, + * src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Edited: + Added Accessmethod for the Diagrammoptions. + + * src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Added: + Bean for the Representation of Diagrammoptions + + * src/main/resources/applicationMessages.properties Edited: + Added som GUI Lables. + + * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Edited, + src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp Add, + src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Add, + src/main/webapp/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp Add: + Added the GUI for the Statistics and Diagramoptions and tge Export. + + * src/main/webapp/WEB-INF/config/struts-config.xml Edited: + Added Actions for Performing Exports and Changing Diagramoptions. + 2009-09-24 Tim Englich * src/main/webapp/scripts/gnviewer.js Edited: Removed unused Methods from File. diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Fri Sep 25 07:28:49 2009 +0000 @@ -0,0 +1,71 @@ +/** + * + */ +package de.intevation.gnv.action; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.w3c.dom.Node; + +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.util.XMLUtils; +import de.intevation.gnv.util.XSLTransformer; + +/** + * @author Tim Englich + * + */ +public class ChangeOptionsAction extends ArtifactDatabaseActionBase { + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(ChangeOptionsAction.class); + /** + * Constructor + */ + public ChangeOptionsAction() { + super(); + } + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws Exception { + log.debug("NextArtifactStepAction.execute"); + SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); + + + ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); + + Node currentUI = artifactDescription.getCurrentUI(); + XSLTransformer transformer = new XSLTransformer(); + String ui = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "dynamic"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); + + request.setAttribute("ui", ui); + + 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()){ + }else{ + request.setAttribute("diagramm", true); + } + return super.execute(mapping, form, request, response); + } + + + +} diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Fri Sep 25 07:28:49 2009 +0000 @@ -0,0 +1,48 @@ +/** + * + */ +package de.intevation.gnv.action; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +/** + * @author Tim Englich + * + */ +public class DoExportAction extends DoOutputAction { + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(DoExportAction.class); + + /** + * Constructor + */ + public DoExportAction() { + super(); + } + + @Override + protected void setHeaders(String target, String mimeType, + HttpServletResponse response, HttpServletRequest request) { + log.debug("DoExportAction.setHeaders"); + super.setHeaders(target, mimeType, response, request); + String fileName = "GNVEXPORT_"+System.currentTimeMillis()+"."; + + if (target.equalsIgnoreCase("chart")){ + fileName = fileName + mimeType.substring(mimeType.indexOf("/")+1); + }else if (target.equalsIgnoreCase("CSV")){ + fileName = fileName +"csv"; + }else{ + fileName = fileName +"txt"; + } + log.debug("FileName for Export: "+fileName); + response.setHeader("Content-Disposition","attachment;filename="+fileName); + } + + +} diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Fri Sep 25 07:28:49 2009 +0000 @@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -30,6 +31,10 @@ public class DoOutputAction extends ArtifactDatabaseActionBase { /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(DoOutputAction.class); + /** * Constructor */ public DoOutputAction() { @@ -44,10 +49,14 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + log.debug("DoOutputAction.execute"); String target = request.getParameter("target"); String mimeType = request.getParameter("mimetype"); - // TODO Check if ist is propper; + log.debug("Target: "+target); + log.debug("MimeType: "+mimeType); + + // TODO Check if is propper; SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact(); @@ -66,7 +75,8 @@ ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); - response.setContentType(mimeType); + this.setHeaders(target, mimeType, response, request); + OutputStream outputStream = response.getOutputStream(); adc.doOutput(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), outputStream, target, mimeType, ips); @@ -76,5 +86,9 @@ return super.execute(mapping, form, request, response); } + protected void setHeaders(String target, String mimeType, HttpServletResponse response, HttpServletRequest request){ + response.setHeader("Content-Type", mimeType); + } + } diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java --- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Fri Sep 25 07:28:49 2009 +0000 @@ -15,11 +15,15 @@ public class DefaultSessionModel implements SessionModel{ + + private Collection artifactFactories = null; private ArtifactObject selectedArtifactFactory = null; private ArtifactObject currentArtifact =null; + + private DiagrammOptions diagrammOptions= null; /** @@ -88,5 +92,13 @@ this.currentArtifact = artifact; } + public DiagrammOptions getDiagrammOptions() { + if (diagrammOptions == null){ + diagrammOptions = new DiagrammOptions(); + } + return diagrammOptions; + } + + } diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Fri Sep 25 07:28:49 2009 +0000 @@ -0,0 +1,55 @@ +/** + * + */ +package de.intevation.gnv.action.sessionmodel; +/** + * @author Tim Englich + * + */ +public class DiagrammOptions { + + + public enum mode{ + Standard, + User_Specific + } + + private mode modus = mode.Standard; + + private int width = 500; + /** + * Constructor + */ + public DiagrammOptions() { + super(); + } + + /** + * @return + */ + public mode getModus() { + return modus; + } + + /** + * @param modus + */ + public void setModus(mode modus) { + this.modus = modus; + } + + /** + * @return + */ + public int getWidth() { + return width; + } + + /** + * @param width + */ + public void setWidth(int width) { + this.width = width; + } + +} \ No newline at end of file diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java --- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Fri Sep 25 07:28:49 2009 +0000 @@ -24,5 +24,7 @@ ArtifactObject getCurrentArtifact(); void setCurrentArtifact(ArtifactObject artifact); + + DiagrammOptions getDiagrammOptions(); } diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/resources/applicationMessages.properties --- a/gnv/src/main/resources/applicationMessages.properties Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/src/main/resources/applicationMessages.properties Fri Sep 25 07:28:49 2009 +0000 @@ -111,6 +111,7 @@ # attachedOutputOptions +gnviewer.output.options.diagramm.alt=Diagramm gnviewer.output.options.save.title=Diagramm speichern gnviewer.output.options.export.title=Daten exportieren gnviewer.diagram.options.ajax.success=Die Werte wurden erfolgreich gesetzt. diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/webapp/WEB-INF/config/struts-config.xml --- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml Fri Sep 25 07:28:49 2009 +0000 @@ -34,6 +34,19 @@ scope="request" validate="false"> + + + + + diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp Fri Sep 25 07:28:49 2009 +0000 @@ -0,0 +1,4 @@ +
+ + +
\ No newline at end of file diff -r d93ea867406b -r bba8fd97e549 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 Thu Sep 24 12:43:46 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Fri Sep 25 07:28:49 2009 +0000 @@ -1,11 +1,28 @@ +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> <%Object diagramm = request.getAttribute("diagramm"); 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 target = "chart"; // TODO: get from SessionModel - %> + String mimeTypeCSV = "text/plain";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request). +%>
- Chart + <bean:message key="gnviewer.output.options.diagramm.alt"/> +
+
+ "> + + + <%if (supportCSV) { %> + "> + + + <%}%> +
+ <%}%> \ No newline at end of file diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Fri Sep 25 07:28:49 2009 +0000 @@ -0,0 +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"%> +<% + DiagrammOptions diagrammOptions = SessionModelFactory.getInstance().getSessionModel(request).getDiagrammOptions(); + boolean isStandard = diagrammOptions.getModus() == DiagrammOptions.mode.Standard; +%> + +
+
+ + + +
+ onblur="document.forms.outputOptionsForm.submit()" type="radio"> + +
+ onblur="document.forms.outputOptionsForm.submit()" type="radio"> + + + +
+ +
+
+
\ No newline at end of file diff -r d93ea867406b -r bba8fd97e549 gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp Fri Sep 25 07:28:49 2009 +0000 @@ -0,0 +1,10 @@ +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +
+
+ + + +
+
+
+
\ No newline at end of file