package org.flymine.web;

/*
 * Copyright (C) 2002-2003 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;

import org.flymine.objectstore.query.QueryClass;

/**
 * Implementation of <strong>Action</strong> that processes
 * QueryClass selection form.
 *
 * @author Richard Smith
 * @author Mark Woodbridge
 */

public class QueryClassSelectAction extends Action
{
    /**
     * Process the specified HTTP request, and create the corresponding HTTP
     * response (or forward to another web component that will create it).
     * Return an <code>ActionForward</code> instance describing where and how
     * control should be forwarded, or <code>null</code> if the response has
     * already been completed.
     *
     * @param mapping The ActionMapping used to select this instance
     * @param form The optional ActionForm bean for this request (if any)
     * @param request The HTTP request we are processing
     * @param response The HTTP response we are creating
     * @return an ActionForward object defining where control goes next
     *
     * @exception Exception if the application business logic throws
     *  an exception
     */
    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws Exception {

        // Extract attributes we will need
        MessageResources messages = getResources(request);
        HttpSession session = request.getSession();

        QueryClassSelectForm queryClassSelectForm = (QueryClassSelectForm) form;

        String className = queryClassSelectForm.getClassName();

        if (className != null) {
            QueryClass qc = new QueryClass(Class.forName(className));
            session.setAttribute("queryClass", qc);
        }

        return (mapping.findForward("buildquery"));
    }
}


@@ -317,16 +317,65 @@
  *%0A */%0A%0A
+import java.util.Map;%0Aimport java.util.HashMap;%0A%0A
 import j
@@ -401,24 +401,24 @@
 ttpSession;%0A
-
 import javax
@@ -526,25 +526,40 @@
 truts.action
-.
+s.LookupDispatch
 Action;%0Aimpo
@@ -695,56 +695,8 @@
 ing;
-%0Aimport org.apache.struts.util.MessageResources;
 %0A%0Aim
@@ -941,16 +941,30 @@
 extends 
+LookupDispatch
 Action%0A%7B
@@ -1780,15 +1780,14 @@
 ard 
-execute
+select
 (Act
@@ -2055,67 +2055,8 @@
 eed%0A
-        MessageResources messages = getResources(request);%0A
     
@@ -2417,16 +2417,16 @@
      %7D%0A%0A
-
         
@@ -2474,12 +2474,1457 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Process the specified HTTP request, and create the corresponding HTTP%0A     * response (or forward to another web component that will create it).%0A     * Return an %3Ccode%3EActionForward%3C/code%3E instance describing where and how%0A     * control should be forwarded, or %3Ccode%3Enull%3C/code%3E if the response has%0A     * already been completed.%0A     *%0A     * @param mapping The ActionMapping used to select this instance%0A     * @param form The optional ActionForm bean for this request (if any)%0A     * @param request The HTTP request we are processing%0A     * @param response The HTTP response we are creating%0A     * @return an ActionForward object defining where control goes next%0A     *%0A     * @exception Exception if the application business logic throws%0A     *  an exception%0A     */%0A    public ActionForward browse(ActionMapping mapping,%0A                                 ActionForm form,%0A                                 HttpServletRequest request,%0A                                 HttpServletResponse response)%0A        throws Exception %7B%0A%0A        return mapping.findForward(%22tree%22);%0A    %7D%0A%0A    /**%0A     * Distributes the actions to the necessary methods, by providing a Map from action to%0A     * the name of a method.%0A     *%0A     * @return a Map%0A     */%0A    protected Map getKeyMethodMap() %7B%0A        Map map = new HashMap();%0A        map.put(%22button.select%22, %22select%22);%0A        map.put(%22button.browse%22, %22browse%22);%0A        return map;%0A    %7D
 %0A%7D%0A%0A

Add an action to allow class selection from a tree