# HG changeset patch # User Tim Englich # Date 1252936563 0 # Node ID 65ff6fcfee0caba0148cbd0895dd818e55c7617b # Parent fe6a64545552ba396d699fdec4d3b73bfd614f36 Some Basic Stuff for WebProjects gnv/trunk@84 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fe6a64545552 -r 65ff6fcfee0c gnv/Changelog --- a/gnv/Changelog Mon Sep 14 13:46:25 2009 +0000 +++ b/gnv/Changelog Mon Sep 14 13:56:03 2009 +0000 @@ -1,3 +1,27 @@ +2009-09-14 Tim Englich + + * src/main/webapp/WEB-INF/config/struts-config.xml: + Added two ActionMappings: + One for showing all FIS (ArtifactFactories) in an View. + The other for selceting one ArtifactFactory an visualizing the First Step of an Artifact. + * src/main/webapp/WEB-INF/jsp/index.jsp Edited: + Added an Combobox for selecting an FIS + * src/main/webapp/WEB-INF/web.xml: + Added the Servletmapping for the Struts Framework + * src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Added, + src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java Added, + src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Edited: + Some ActionHandler added for Handling the different Requests of the GNV. + FetchArtifactFactoriesAction: Will provides the Controllerlogic for Queriing all Reachable ArtifactFactories. + SelectArtifactFactoryAction will select one Specific ArtifactFactory and will create + an Instance in the ArtifactDatabase. + + * src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Added,: + src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java Added, + src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Added: + Interface and Defaultimplementation of an Model which can store the Session-Specific Informations. + e.g. Reachable ArtifactFactories and the current Artifact which should be used. + 2009-09-14 Tim Englich * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Edited: diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java --- a/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Mon Sep 14 13:46:25 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Mon Sep 14 13:56:03 2009 +0000 @@ -3,8 +3,6 @@ */ package de.intevation.gnv.action; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -20,6 +18,7 @@ */ public class ArtifactDatabaseActionBase extends Action { + protected final static String SUCCSESS_FORWARD_ID = "success"; /** * the logger, used to log exceptions and additonaly information */ @@ -39,19 +38,8 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - log.debug("ArtifactDatabaseActionBase.execute 1"); - return super.execute(mapping, form, request, response); + log.debug("ArtifactDatabaseActionBase.execute"); + ActionForward lForward = mapping.findForward(SUCCSESS_FORWARD_ID); + return lForward; } - - /** - * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.ServletRequest, javax.servlet.ServletResponse) - */ - @Override - public ActionForward execute(ActionMapping mapping, ActionForm form, - ServletRequest request, ServletResponse response) throws Exception { - log.debug("ArtifactDatabaseActionBase.execute 2"); - return super.execute(mapping, form, request, response); - } - - } diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java Mon Sep 14 13:56:03 2009 +0000 @@ -0,0 +1,53 @@ +/** + * + */ +package de.intevation.gnv.action; + +import java.util.Collection; + +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 de.intevation.gnv.action.sessionmodel.SessionModel; +import de.intevation.gnv.action.sessionmodel.SessionModelFactory; +import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; +import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; + +/** + * @author Tim Englich + * + */ +public class FetchArtifactFactoriesAction extends ArtifactDatabaseActionBase{ + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(FetchArtifactFactoriesAction.class); + + public FetchArtifactFactoriesAction() { + super(); + } + + /** + * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws Exception { + log.debug("ArtifactDatabaseActionBase.execute"); + + Collection artifactFactories = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient().getArtifactFactories(); + SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + sm.setArtifacteFactories(artifactFactories); + + + ActionForward lForward = mapping.findForward(SUCCSESS_FORWARD_ID); + return lForward; + } + +} diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java Mon Sep 14 13:56:03 2009 +0000 @@ -0,0 +1,61 @@ +/** + * + */ +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 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.ArtifactObject; + +/** + * @author Tim Englich + * + */ +public class SelectArtifactFactoryAction extends ArtifactDatabaseActionBase { + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(SelectArtifactFactoryAction.class); + + /** + * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws Exception { + log.debug("SelectArtifactFactoryAction.execute"); + String selectedArtifactFactoryID = request.getParameter("artifactFactory"); + log.debug("Selected ArtifactFactory ==> "+selectedArtifactFactoryID); + + SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + sm.selectArtifactFactory(selectedArtifactFactoryID); + + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient(); + ArtifactObject artifact = adc.createNewArtifact(sm.getSelectedArtifactFactory()); + sm.setCurrentArtifact(artifact); + + // TODO Initiales Describe Abrufen + + + // return succsess + return super.execute(mapping, form, request, response); + } + + /** + * Constructor + */ + public SelectArtifactFactoryAction() { + } + +} diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Mon Sep 14 13:56:03 2009 +0000 @@ -0,0 +1,92 @@ +/** + * + */ +package de.intevation.gnv.action.sessionmodel; + +import java.util.Collection; +import java.util.Iterator; + +import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; + +/** + * @author Tim Englich + * + */ +public class DefaultSessionModel implements SessionModel{ + + + private Collection artifactFactories = null; + + private ArtifactObject selectedArtifactFactory = null; + + private ArtifactObject currentArtifact =null; + + + /** + * Constructor + */ + public DefaultSessionModel() { + super(); + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#selectArtifactFactory(java.lang.String) + */ + public void selectArtifactFactory(String artiFactFactoryId) { + Collection artifactObjects = this.getArtifactFactories(); + if (artifactObjects != null){ + Iterator unselect = artifactObjects.iterator(); + this.selectedArtifactFactory = null; + while (unselect.hasNext()){ + unselect.next().setSelected(false); + } + Iterator it = artifactObjects.iterator(); + while (it.hasNext()){ + ArtifactObject obj = it.next(); + if(obj.getId().equals(artiFactFactoryId)){ + obj.setSelected(true); + this.selectedArtifactFactory = obj; + break; + } + } + } + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#setArtifacteFactories(java.util.Collection) + */ + public void setArtifacteFactories( + Collection artifactFactories) { + this.artifactFactories = artifactFactories; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#getAttributeFactories() + */ + public Collection getArtifactFactories() { + return this.artifactFactories; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#getSelectedArtifactFactory() + */ + public ArtifactObject getSelectedArtifactFactory() { + return this.selectedArtifactFactory; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#getCurrentArtifact() + */ + public ArtifactObject getCurrentArtifact() { + return this.currentArtifact; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#setCurrentArtifact(de.intevation.gnv.artifactdatabase.objects.ArtifactObject) + */ + public void setCurrentArtifact(ArtifactObject artifact) { + this.currentArtifact = artifact; + } + + +} diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Mon Sep 14 13:56:03 2009 +0000 @@ -0,0 +1,28 @@ +/** + * + */ +package de.intevation.gnv.action.sessionmodel; + +import java.util.Collection; + +import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; + +/** + * @author Tim Englich + * + */ +public interface SessionModel { + + Collection getArtifactFactories(); + + void setArtifacteFactories(Collection artifactFactories); + + void selectArtifactFactory(String artiFactFactoryId); + + ArtifactObject getSelectedArtifactFactory(); + + ArtifactObject getCurrentArtifact(); + + void setCurrentArtifact(ArtifactObject artifact); + +} diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModelFactory.java Mon Sep 14 13:56:03 2009 +0000 @@ -0,0 +1,68 @@ +/** + * + */ +package de.intevation.gnv.action.sessionmodel; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; + +import de.intevation.gnv.artifactdatabase.client.DefaultArtifactDatabaseClient; + +/** + * @author Tim Englich + * + */ +public class SessionModelFactory { + + public final static String SESSION_MODEL_ID = "de.intevation.gnv.action.sessionmodel.SessionModel.ID"; + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(SessionModelFactory.class); + + + /** + * The singleton Instance of this Factory. + */ + private static SessionModelFactory instance = null; + + /** + * Constructor + */ + private SessionModelFactory() { + super(); + } + + /** + * This Method provides an singleton Instance of this Class. + * @return an singleton Instance of this Class + */ + public static SessionModelFactory getInstance(){ + if (instance == null){ + instance = new SessionModelFactory(); + } + return instance; + } + + + /** + * Getting the ArtifactDatabaseClient + * @return the ArtifactDatabaseClient + */ + public SessionModel getSessionModel(HttpServletRequest request){ + synchronized (this.getClass()) { + SessionModel sm = null; + if (request.getSession().getAttribute(SESSION_MODEL_ID)!= null){ + sm = (SessionModel)request.getSession().getAttribute(SESSION_MODEL_ID); + ; + }else{ + sm = new DefaultSessionModel(); + request.getSession().setAttribute(SESSION_MODEL_ID, sm); + } + + return sm; + } + } + +} diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/webapp/WEB-INF/config/struts-config.xml --- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml Mon Sep 14 13:46:25 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml Mon Sep 14 13:56:03 2009 +0000 @@ -4,13 +4,22 @@ "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"> - - - - - General Forward - + + + + + diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/webapp/WEB-INF/jsp/index.jsp --- a/gnv/src/main/webapp/WEB-INF/jsp/index.jsp Mon Sep 14 13:46:25 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/index.jsp Mon Sep 14 13:56:03 2009 +0000 @@ -1,5 +1,29 @@ - + +<%@page import="java.util.Collection"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.ArtifactObject"%> +<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%> +<%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> +<%@page import="java.util.Iterator"%> -

Hello World!

+
+ + +
diff -r fe6a64545552 -r 65ff6fcfee0c gnv/src/main/webapp/WEB-INF/web.xml --- a/gnv/src/main/webapp/WEB-INF/web.xml Mon Sep 14 13:46:25 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/web.xml Mon Sep 14 13:56:03 2009 +0000 @@ -4,4 +4,19 @@ Archetype Created Web Application + + action + de.intevation.gnv.servlet.GNVActionServlet + + config + + /WEB-INF/config/struts-config.xml + + 1 + + + + action + *.do +