Mercurial > dive4elements > gnv-client
view gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java @ 401:002a4d38c16d
Added a link to jump back to the fis selection.
gnv/trunk@568 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 18 Jan 2010 16:21:54 +0000 |
parents | a8b1875dcd93 |
children | 15ac78a91d1b |
line wrap: on
line source
/** * */ 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 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.artifactdatabase.objects.ArtifactObject; import de.intevation.gnv.util.XMLUtils; import de.intevation.gnv.util.XSLTransformer; /** * @author Tim Englich <tim.englich@intevation.de> * */ 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); try { SessionModel sm = SessionModelFactory.getInstance() .getSessionModel(request); Collection<ArtifactObject> artifactFactories = sm .getArtifactFactories(); // Removes the Artifactspecific Attributes from the SessionModel- sm.resetModel(); if (artifactFactories == null || artifactFactories.isEmpty()) { new FetchArtifactFactoriesAction().execute(mapping, form, request, response); } sm.selectArtifactFactory(selectedArtifactFactoryID); ArtifactObject af = sm.getSelectedArtifactFactory(); ; ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory .getInstance() .getArtifactDatabaseClient(getLocale(request)); ArtifactObject artifact = adc.createNewArtifact(af); sm.setCurrentArtifact(artifact); ArtifactDescription artifactdescription = adc .getCurrentStepDescription(af, artifact,true); String fisUrl = response.encodeURL( mapping.findForward("selectfis").getPath()); XSLTransformer transformer = new XSLTransformer(); transformer.addParameter("selectfis", fisUrl); Node dynamicUINode = new XMLUtils().getNodeXPath( artifactdescription.getCurrentUI(), "art:dynamic" ); if (dynamicUINode != null){ String ui = transformer.transform( dynamicUINode, "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui.xsl")); request.setAttribute("ui", ui); } Node staticUINode = new XMLUtils().getNodeXPath( artifactdescription.getCurrentUI(), "art:static" ); if (staticUINode != null) { String staticUI = transformer.transform( staticUINode, "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); request.setAttribute("staticui", staticUI); } // return succsess return super.execute(mapping, form, request, response); } catch (Exception e) { log.error(e, e); request.setAttribute( CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e .getMessage()); return super.getExceptionForward(mapping); } } /** * Constructor */ public SelectArtifactFactoryAction() { } }