/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.ui.conf.view;

import java.util.*;
import javax.servlet.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.servlet.RequestImpl;

public class ConfMemberView implements ContentJSP
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private int max_results;                      // the maximum number of results displayed
  private List role_list;                       // the list of possible roles
  private String conference_name;               // the current conference name
  private boolean simple = true;                // is this a simple listing or not?
  private RequestInput rinput = null;           // the RequestInput (during execution)
  private int field = -1;                       // search field indicator
  private int mode = -1;                        // search mode indicator
  private String term = "";                     // current search term
  private List results = null;                  // the search results
  private int offset = 0;                       // offset in list of results
  private int find_count = -1;                  // total count of things found

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  public ConfMemberView(int max_results, ConferenceContext conf)
  {
    this.max_results = max_results;
    this.conference_name = conf.getName();
    SecurityInfo sinf = conf.getSecurityInfo();
    this.role_list = sinf.getRoleList("Conference.UserLevels");

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface Content
   *--------------------------------------------------------------------------------
   */

  public boolean needFrame()
  {
    return true;

  } // end needFrame

  public int getMenuSelector()
  {
    return MENU_SELECTOR_COMMUNITY;

  } // end getMenuSelector

  public String getPageTitle(RequestOutput ro)
  {
    return "Membership in Conference " + conference_name;

  } // end getPageTitle

  public String getPageQID()
  {
    return null;

  } // end getPageQID

  /*--------------------------------------------------------------------------------
   * Implementations from interface ContentJSP
   *--------------------------------------------------------------------------------
   */

  public String getJSPName()
  {
    return "conf/membership.jsp";

  } // end getJSPName

  public void initialize(RequestInput req)
  {
    rinput = req;

  } // end initialize

  public void terminate(RequestInput req)
  {
    rinput = null;

  } // end terminate

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  public final int getMaxResults()
  {
    return max_results;

  } // end getMaxResults

  public final List getRoleList()
  {
    return role_list;

  } // end getRoleList

  public final String getConferenceName()
  {
    return conference_name;

  } // end getConferenceName

  public final boolean getSimple()
  {
    return simple;

  } // end getSimple

  public final void setSimple(boolean b)
  {
    simple = b;

  } // end setSimple

  public final int getField()
  {
    return field;

  } // end getField

  public final void setField(int v)
  {
    field = v;

  } // end setField

  public final boolean testField(int v)
  {
    return (field==v);

  } // end testField

  public final int getMode()
  {
    return mode;

  } // end getMode

  public final void setMode(int v)
  {
    mode = v;

  } // end setMode

  public final boolean testMode(int v)
  {
    return (mode==v);

  } // end testMode

  public final String getTerm()
  {
    return term;

  } // end getTerm

  public final void setTerm(String v)
  {
    term = v;

  } // end setTerm

  public final List getResults()
  {
    return results;

  } // end getResults

  public final void setResults(List v)
  {
    results = v;

  } // end setResults

  public final int getOffset()
  {
    return offset;

  } // end getOffset

  public final void setOffset(int v)
  {
    offset = v;

  } // end setOffset

  public final int getFindCount()
  {
    return find_count;

  } // end getFindCount

  public final void setFindCount(int v)
  {
    find_count = v;

  } // end setFindCount

  /*--------------------------------------------------------------------------------
   * External static operations
   *--------------------------------------------------------------------------------
   */

  public static final ConfMemberView get(ServletRequest sreq) throws ServletException
  {
    Object obj = sreq.getAttribute(RequestImpl.REQUEST_CONTENT);
    if (obj==null)
      throw new ServletException("ConfMemberView.get: unable to get request content");
    if (obj instanceof ConfMemberView)
      return (ConfMemberView)obj;
    throw new ServletException("ConfMemberView.get: request content is not a ConfMemberView object");

  } // end get

} // end class ConfMemberView
