kiurubeans
Class SpaceSearch

java.lang.Object
  |
  +--kiurubeans.KiuruHandler
        |
        +--kiurubeans.SearchHandler
              |
              +--kiurubeans.SpaceSearch
All Implemented Interfaces:
EnumType

public class SpaceSearch
extends SearchHandler

Implement space searching, ordering & filtering


Field Summary
static int ADD_RECORD
          Adds new space.
static int DELETE_SPACES
          Deletes selected spaces. clears search field
 
Fields inherited from class kiurubeans.SearchHandler
RESET_SEARCH, SUBMIT_SEARCH
 
Fields inherited from class kiurubeans.KiuruHandler
NO_ACTION
 
Constructor Summary
SpaceSearch()
          Constructs a new instance of SpaceSearch.
 
Method Summary
protected  void defaultAction()
          Performs action based on actionType.
protected  void doClearActionState(javax.servlet.http.HttpServletRequest request)
          Default implementation of clearing action state.
protected  void doClearEmptyParameters(javax.servlet.http.HttpServletRequest request)
          Ensures empty request parameters are clearer when entity is posted.
 java.lang.String getCode()
          Getter for attribute code.
static RS2 getFavoriteSpaces(int userId)
          Returns favorite spaces of user with given id, null if not exists.
static java.lang.String getFavoriteSpacesWithDelims(int userId, java.lang.String delim)
          Returns user's favorite space ids in a single delimited string, null if not exists
protected  int getMaxState()
          Returns current max state value.
 boolean getOfficialOnly()
          Getter for attribute officialOnly
static java.lang.String getOfficialSqlClause(java.lang.String spacealias, boolean officialOnly)
          Returns SQL clause for getting only official spaces.
static RS2 getPlainSpaceGroupSpaces(int spacegroupid)
          Returns all spaces (code, spaceid) of a given spacegroup
static RS2 getPlainSpaceGroupSpaces(java.lang.String[] spacegroupids, java.lang.String[] spaceids)
          Returns all spaces of given spacegroups + additional spaces in alphabethical order if no spacegroupids or spaceids are given, retuns NULL
 java.lang.String[] getSelectedSpaces()
          Getter for attribute selectedSpaces
 java.lang.String getSelectedSpaces(int i)
          Returns the ith selected space
static RS2 getSpaceCodes(java.lang.String[] spaceids)
          Returns space codes for spaces with given ids
static RS2 getSpaceGroupSpaceIds(int spacegroupid)
          Returns all spaceids of a given spacegroup
static RS2 getSpaceGroupSpaces(int spacegroupid)
          Returns all spaces (code, spaceid, spacetypename) of a given spacegroup
static RS2 getSpaceGroupSpaces(java.lang.String[] spacegroupids, java.lang.String[] spaceids)
          Returns all spaces of given spacegroups + additional spaces in alphabethical order if no spacegroupids or spaceids are given, retuns NULL
 RS2 getSpaces()
          Returns all spaces with code match.
static RS2 getSpacesCode(int spaceId)
          Gets code of given space.
 void resetSearch()
          Implementation for RESET_SEARCH
 void setCode(java.lang.String code)
          Setter for attribute code.
 void setOfficialOnly(boolean b)
          Setter for attribute officialOnly
 void setSelectedSpaces(int i, java.lang.String s)
          Sets the ith selected space
 void setSelectedSpaces(java.lang.String[] s)
          Setter for attribute selectedSpaces
 void setSubmitAdd(java.lang.String s)
          Sets bean state to ADD_RECORD.
 void setSubmitDelete(java.lang.String s)
          Sets bean state to DELETE_SPACES.
 void submitSearch()
          Implementation for SUBMIT_SEARCH
 
Methods inherited from class kiurubeans.SearchHandler
assignDefaultOrder, clearEmptyParameters, fieldIndexOf, getOrder, getOrderClause, getVisibleFields, getVisibleFields, setContinueSearch, setOrder, setSubmitSearch, setVisibleFields, setVisibleFields
 
Methods inherited from class kiurubeans.KiuruHandler
addError, addNotice, getEnumState, getError, getLangId, getOk, getUser, performAction, resetActionState, resetErrorState, setEnumState, setError, setOk, setUser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD_RECORD

public static final int ADD_RECORD
Adds new space. No action in bean.

See Also:
Constant Field Values

DELETE_SPACES

public static final int DELETE_SPACES
Deletes selected spaces. clears search field

See Also:
Constant Field Values
Constructor Detail

SpaceSearch

public SpaceSearch()
Constructs a new instance of SpaceSearch. Defines ordeding.

Method Detail

getMaxState

protected int getMaxState()
Returns current max state value. Inherited classes may override this when new states are introduced.

Overrides:
getMaxState in class SearchHandler
Returns:
max state value

getSelectedSpaces

public java.lang.String[] getSelectedSpaces()
Getter for attribute selectedSpaces

Returns:
spaces selected by user

setSelectedSpaces

public void setSelectedSpaces(java.lang.String[] s)
Setter for attribute selectedSpaces

Parameters:
s - spaces selected by user

setSelectedSpaces

public void setSelectedSpaces(int i,
                              java.lang.String s)
Sets the ith selected space

Parameters:
i - Which space is going to be set
s - The id of the selected space

getSelectedSpaces

public java.lang.String getSelectedSpaces(int i)
Returns the ith selected space

Parameters:
i - Which space is given
Returns:
The id of the selected space

getOfficialOnly

public boolean getOfficialOnly()
Getter for attribute officialOnly

Returns:
true if only official spaces are retrieved

setOfficialOnly

public void setOfficialOnly(boolean b)
Setter for attribute officialOnly

Parameters:
b - determines if only official spaces are retrieved

getOfficialSqlClause

public static java.lang.String getOfficialSqlClause(java.lang.String spacealias,
                                                    boolean officialOnly)
Returns SQL clause for getting only official spaces.

Parameters:
spacealias - space table alias used in sql
officialOnly - if true, only official spaces are returned
Returns:
" and "+condition for officials or emptystring

getCode

public java.lang.String getCode()
Getter for attribute code.

Returns:
user's query string

setCode

public void setCode(java.lang.String code)
Setter for attribute code.

Parameters:
code - user's query string

setSubmitDelete

public void setSubmitDelete(java.lang.String s)
Sets bean state to DELETE_SPACES. Usually called from a web form.

Parameters:
s - any nonempty string.
See Also:
DELETE_SPACES

setSubmitAdd

public void setSubmitAdd(java.lang.String s)
Sets bean state to ADD_RECORD. Usually called from a web form.

Parameters:
s - any nonempty string.
See Also:
ADD_RECORD

doClearEmptyParameters

protected void doClearEmptyParameters(javax.servlet.http.HttpServletRequest request)
Ensures empty request parameters are clearer when entity is posted.

If bean is used in a JSP, this should be called in the beginning of page. If form content is "" or null it is not sent via HTTP, so those fields must be cleared manually.

Overrides:
doClearEmptyParameters in class SearchHandler
Parameters:
request - HTTP request with parameters
See Also:
SearchHandler.clearEmptyParameters(HttpServletRequest)

getSpaceGroupSpaces

public static RS2 getSpaceGroupSpaces(int spacegroupid)
                               throws java.lang.Exception
Returns all spaces (code, spaceid, spacetypename) of a given spacegroup

Parameters:
spacegroupid - spacegroup where spaces should be located
Returns:
spaces of a given spacegroup
Throws:
java.lang.Exception - if problems with db connection

getPlainSpaceGroupSpaces

public static RS2 getPlainSpaceGroupSpaces(int spacegroupid)
                                    throws java.lang.Exception
Returns all spaces (code, spaceid) of a given spacegroup

Parameters:
spacegroupid - spacegroup where spaces should be located
Returns:
spaces of a given spacegroup
Throws:
java.lang.Exception - if problems with db connection

getSpaceGroupSpaceIds

public static RS2 getSpaceGroupSpaceIds(int spacegroupid)
                                 throws java.lang.Exception
Returns all spaceids of a given spacegroup

Parameters:
spacegroupid - spacegroup where spaces should be located
Returns:
spaces of a given spacegroup
Throws:
java.lang.Exception - if problems with db connection

getSpaceCodes

public static RS2 getSpaceCodes(java.lang.String[] spaceids)
                         throws java.lang.Exception
Returns space codes for spaces with given ids

Parameters:
spaceids - ids for spaces to be retrieved
Returns:
space codes
Throws:
java.lang.Exception - if problems with db connection

getSpaceGroupSpaces

public static RS2 getSpaceGroupSpaces(java.lang.String[] spacegroupids,
                                      java.lang.String[] spaceids)
                               throws java.lang.Exception
Returns all spaces of given spacegroups + additional spaces in alphabethical order if no spacegroupids or spaceids are given, retuns NULL

Parameters:
spacegroupids - input spacegroupids
spaceids - inputspaceids
Returns:
spaces in form (code, spaceid, spacetypename)
Throws:
java.lang.Exception - if problems with db connetions

getPlainSpaceGroupSpaces

public static RS2 getPlainSpaceGroupSpaces(java.lang.String[] spacegroupids,
                                           java.lang.String[] spaceids)
                                    throws java.lang.Exception
Returns all spaces of given spacegroups + additional spaces in alphabethical order if no spacegroupids or spaceids are given, retuns NULL

Parameters:
spacegroupids - input spacegroupids
spaceids - inputspaceids
Returns:
spaces in form (code, spaceid)
Throws:
java.lang.Exception - if problems with db connetions

getSpaces

public RS2 getSpaces()
              throws java.lang.Exception
Returns all spaces with code match. Note! This might be called automatically within performaction. Currently must be called manually.

Returns:
matched spaces (code,spaceid,spacetypename)
Throws:
java.lang.Exception - if problems with db connection

doClearActionState

protected void doClearActionState(javax.servlet.http.HttpServletRequest request)
Default implementation of clearing action state. Descendant classes may override this.

Overrides:
doClearActionState in class SearchHandler
Parameters:
request - The request-object of the JSP.
See Also:
SearchHandler.doClearActionState(HttpServletRequest)

defaultAction

protected void defaultAction()
                      throws java.lang.Exception
Performs action based on actionType. Called from performAction. Descendant classes should override this and call the same method in inherited class as default.

Overrides:
defaultAction in class SearchHandler
Throws:
java.lang.Exception - If something went wrong during actual executed action.
See Also:
KiuruHandler.performAction()

submitSearch

public void submitSearch()
Implementation for SUBMIT_SEARCH

Specified by:
submitSearch in class SearchHandler

resetSearch

public void resetSearch()
Implementation for RESET_SEARCH

Specified by:
resetSearch in class SearchHandler

getFavoriteSpaces

public static RS2 getFavoriteSpaces(int userId)
                             throws java.lang.Exception
Returns favorite spaces of user with given id, null if not exists.

Parameters:
userId - user whose favorites we are getting
Returns:
RS2 fields: code, spaceid, spacetypeid
Throws:
java.lang.Exception - if problems with db connection

getFavoriteSpacesWithDelims

public static java.lang.String getFavoriteSpacesWithDelims(int userId,
                                                           java.lang.String delim)
                                                    throws java.lang.Exception
Returns user's favorite space ids in a single delimited string, null if not exists

Parameters:
userId - user whose favorites we are getting
delim - string delimiter
Returns:
space ids in a single delimited string
Throws:
java.lang.Exception - if problems with db connection

getSpacesCode

public static RS2 getSpacesCode(int spaceId)
                         throws java.lang.Exception
Gets code of given space.

Parameters:
spaceId - Id of given space.
Returns:
RS2 containg code of space.
Throws:
java.lang.Exception - if problems with db connection