kiurubeans
Class SpaceGroup

java.lang.Object
  |
  +--kiurubeans.KiuruHandler
        |
        +--kiurubeans.EntityHandler
              |
              +--kiurubeans.SpaceGroup
All Implemented Interfaces:
EnumType

public class SpaceGroup
extends EntityHandler

Encapsulation of SpaceGroup data entity.


Field Summary
static int ACCESSLEVEL_FULL
          all modify rights
static int ACCESSLEVEL_NONE
          no modify right
static int ACCESSLEVEL_NORMAL
          right to modify contents of the spacegroup, but no reserver's access levels
static int ADD_PERSON_CONFIRM
          Confirms adding reservers for this spacegroup
static int ADD_PERSONS
          Selects reservers for this spacegroup
static int ADD_SPACE_CONFIRM
          Confirms adding spaces for this spacegroup
static int ADD_SPACES
          Selects spaces for this spacegroup
static int DELETE_PERSONS
          Removes reservers from this spacegroup
static int DELETE_SPACES
          Removes spaces from this spacegroup
 
Fields inherited from class kiurubeans.EntityHandler
DELETE_RECORD, GET_RECORD, POST_RECORD, RESET_RECORD
 
Fields inherited from class kiurubeans.KiuruHandler
NO_ACTION
 
Constructor Summary
SpaceGroup()
          Dummy empty constructor
 
Method Summary
 void addPersons()
          Adds selectedPersons to the current spaceGroup.
 void addPersons(DB db)
          Adds selected persons into the current spaceGroup
 void addSpaces()
          Adds selected spaces to current spacegroup
 void addSpaces(DB db)
          Adds selectedSpaces to the current spaceGroup.
static void addToFavorites(Error error, User user, java.lang.String[] spaces)
          Adds given spaces to user's favorites
 void assignSpaceGroupFromDataBase()
          Assigns SpaceGroup's properties according to current SpaceGroupId
 void assignSpaceGroupFromDataBase(DB db)
          Assigns SpaceGroup's properties according to current SpaceGroupId using existing db connection.
static int checkModifyRight(DB db, User user, int spaceGroupId)
          Checks modify right for spaceGroup with given id. if spaceGroup does not exist or other error is encountered returns 0.
protected  void defaultAction()
          Performs action based on actionType (eg. addNew, modify, post, delete).
 void deletePersons()
          Deletes selected persons from current spacegroup
 void deleteRecord()
          Deletes current spacegroup + relations to spaces & persons
 void deleteSpaces()
          Deletes selected spaces from current spacegroup
protected  boolean doCheckModifyRight()
          Implementation of modify rights checking.
protected  void doClearActionState(javax.servlet.http.HttpServletRequest request)
          Default implementation of clearing action state.
protected  void doClearEmptyParameters(javax.servlet.http.HttpServletRequest request)
          Implementation of parameter clearing.
 java.lang.String getAccessRightLevelAsString()
          Returns required accessrightlevel for this spacegroup as string in user's own language.
 int getAccessRightLevelId()
          Getter for attribute accessRightLevelId.
 boolean getAddingNew()
          Returns true if entity is in a state of adding a new record.
 java.lang.String getDescription()
          Getter for attribute description.
protected  int getMaxState()
          Returns current max state value.
 int getModifyRight()
          Getter for attribute modifyRight.
 java.lang.String getName()
          Returns the name of the spaceGroup
 void getRecord()
          Retrieves record from database according to current Id field(s) value(s).
 java.lang.String[] getSelectedPersons()
          Getter for attribute selectedPersons.
 java.lang.String getSelectedPersons(int i)
          Returns the ith selected person
 java.lang.String[] getSelectedSpaces()
          Getter for attribute selectedSpaces.
 java.lang.String getSelectedSpaces(int i)
          Returns the ith selected space
 int getSpaceGroupId()
          Getter for attribute spaceGroupId.
static RS2 getSpaceGroupTypes()
          Returns all spacegrouptypes from database.
 int getType()
          Returns current spacegroup's type id.
 java.lang.String getTypeAsString()
          Returns current spacegroup's type as string.
 void postRecord()
          Saves record to database.
 void putSpaceGroupToDataBase()
          Saves current spacegroup object to database
 void putSpaceGroupToDataBase(DB db)
          Saves current spacegroup object to database
 void resetRecord()
          Clears field values.
 void setAccessRightLevelId(int i)
          Sets minimum accessRightLevel for reservation requests in this spacegroup Assumes accessrightlevelid is between 1..6
 void setDescription(java.lang.String desc)
          Setter for attribute description.
 void setName(java.lang.String name)
          Sets the name of the spaceGroup.
 void setSelectedPersons(int i, java.lang.String s)
          Sets the ith selected person
 void setSelectedPersons(java.lang.String[] s)
          Setter for attribute selectedPersons.
 void setSelectedSpaces(int i, java.lang.String s)
          Sets the ith selected space
 void setSelectedSpaces(java.lang.String[] s)
          Setter for attribute selectedSpaces.
 void setSpaceGroupId(int spaceGroupId)
          Setter for attribute spaceGroupId.
 void setSubmitAdd(java.lang.String s)
          Used with html forms.
 void setSubmitAddPersonConfirm(java.lang.String s)
          Used with html forms.
 void setSubmitAddPersons(java.lang.String s)
          Used with html forms.
 void setSubmitAddSpace(java.lang.String s)
          Used with html forms.
 void setSubmitAddSpaceConfirm(java.lang.String s)
          Used with html forms.
 void setSubmitDelete(java.lang.String s)
          Used with html forms.
 void setSubmitDeletePersons(java.lang.String s)
          Used with html forms.
 void setSubmitDeleteSpace(java.lang.String s)
          Used with html forms.
 void setSubmitModify(java.lang.String s)
          Used with html forms.
 void setSubmitPost(java.lang.String s)
          Used with html forms.
 void setType(int spaceGroupType)
          Setter for attribute spaceGroupType.
 void updateModifyRight()
          Returns true is user has right to modify contents of current spacegroup.
 
Methods inherited from class kiurubeans.EntityHandler
clearEmptyParameters, hasModifyRight
 
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

ACCESSLEVEL_NONE

public static final int ACCESSLEVEL_NONE
no modify right

See Also:
Constant Field Values

ACCESSLEVEL_NORMAL

public static final int ACCESSLEVEL_NORMAL
right to modify contents of the spacegroup, but no reserver's access levels

See Also:
Constant Field Values

ACCESSLEVEL_FULL

public static final int ACCESSLEVEL_FULL
all modify rights

See Also:
Constant Field Values

ADD_SPACES

public static final int ADD_SPACES
Selects spaces for this spacegroup

See Also:
Constant Field Values

ADD_PERSONS

public static final int ADD_PERSONS
Selects reservers for this spacegroup

See Also:
Constant Field Values

ADD_SPACE_CONFIRM

public static final int ADD_SPACE_CONFIRM
Confirms adding spaces for this spacegroup

See Also:
Constant Field Values

ADD_PERSON_CONFIRM

public static final int ADD_PERSON_CONFIRM
Confirms adding reservers for this spacegroup

See Also:
Constant Field Values

DELETE_SPACES

public static final int DELETE_SPACES
Removes spaces from this spacegroup

See Also:
Constant Field Values

DELETE_PERSONS

public static final int DELETE_PERSONS
Removes reservers from this spacegroup

See Also:
Constant Field Values
Constructor Detail

SpaceGroup

public SpaceGroup()
Dummy empty constructor

Method Detail

getMaxState

protected int getMaxState()
Returns current max state value. Inherited classes may override this to introduce new states.

Overrides:
getMaxState in class EntityHandler
Returns:
Current max state value.

getName

public java.lang.String getName()
Returns the name of the spaceGroup

Returns:
Name of the spaceGroup

setName

public void setName(java.lang.String name)
Sets the name of the spaceGroup.

Parameters:
name - Name of the spacegroup

getTypeAsString

public java.lang.String getTypeAsString()
Returns current spacegroup's type as string.

Returns:
current spacegroup's type as string

getType

public int getType()
Returns current spacegroup's type id.

Returns:
current spacegroup's type id.

setType

public void setType(int spaceGroupType)
Setter for attribute spaceGroupType.

Parameters:
spaceGroupType - new spacegroup type id.

getSpaceGroupId

public int getSpaceGroupId()
Getter for attribute spaceGroupId.

Returns:
spacegroup id.

setSpaceGroupId

public void setSpaceGroupId(int spaceGroupId)
Setter for attribute spaceGroupId. Use with caution, this should be persistent for an object. -1 indicates a new record.

Parameters:
spaceGroupId - new spacegroup id.

getDescription

public java.lang.String getDescription()
Getter for attribute description.

Returns:
spacegroup description

setDescription

public void setDescription(java.lang.String desc)
Setter for attribute description.

Parameters:
desc - new spacegroup description

getSelectedSpaces

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

Returns:
The spaces the user has selected for this spacegroup.

setSelectedSpaces

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

Parameters:
s - The spaces the user has selected for this spacegroup.

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

getSelectedPersons

public java.lang.String[] getSelectedPersons()
Getter for attribute selectedPersons.

Returns:
The reservers the user has selected for this spacegroup.

setSelectedPersons

public void setSelectedPersons(java.lang.String[] s)
Setter for attribute selectedPersons.

Parameters:
s - The reservers the user has selected for this spacegroup.

setSelectedPersons

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

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

getSelectedPersons

public java.lang.String getSelectedPersons(int i)
Returns the ith selected person

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

getAccessRightLevelAsString

public java.lang.String getAccessRightLevelAsString()
Returns required accessrightlevel for this spacegroup as string in user's own language. Accessrightlevel determines right to make reservation requests.

Returns:
accessrightlevel

getAccessRightLevelId

public int getAccessRightLevelId()
Getter for attribute accessRightLevelId.

Returns:
required accessrightlevel for this spacegroup

setAccessRightLevelId

public void setAccessRightLevelId(int i)
Sets minimum accessRightLevel for reservation requests in this spacegroup Assumes accessrightlevelid is between 1..6

Parameters:
i - Minimum accessRightLevel

setSubmitAdd

public void setSubmitAdd(java.lang.String s)
Used with html forms. Changes bean state to AddNew. 'this' should be initialized!

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitModify

public void setSubmitModify(java.lang.String s)
Used with html forms. Changes bean state to searchWithId, so 'this' can be modified. id property should be set before call to performAction

Parameters:
s - We are not interested in

setSubmitPost

public void setSubmitPost(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitDelete

public void setSubmitDelete(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitAddSpace

public void setSubmitAddSpace(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitAddSpaceConfirm

public void setSubmitAddSpaceConfirm(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitDeleteSpace

public void setSubmitDeleteSpace(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitAddPersons

public void setSubmitAddPersons(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitAddPersonConfirm

public void setSubmitAddPersonConfirm(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

setSubmitDeletePersons

public void setSubmitDeletePersons(java.lang.String s)
Used with html forms. Changes the internal state of the bean.

Parameters:
s - We are not interested in the content of the string, because it can vary.

getModifyRight

public int getModifyRight()
Getter for attribute modifyRight.

Returns:
current user's modify right state

defaultAction

protected void defaultAction()
                      throws java.lang.Exception
Performs action based on actionType (eg. addNew, modify, post, delete). Inherited classes may override this method to introduce custom actions.

Overrides:
defaultAction in class EntityHandler
Throws:
java.lang.Exception - If something went wrong during database operations.
See Also:
KiuruHandler.performAction()

getSpaceGroupTypes

public static RS2 getSpaceGroupTypes()
                              throws java.lang.Exception
Returns all spacegrouptypes from database.

Returns:
RS2 containing name and spacegroutypeid of all possible spacegrouptypes.
Throws:
java.lang.Exception - If something went wrong during database operations.

assignSpaceGroupFromDataBase

public void assignSpaceGroupFromDataBase()
                                  throws java.lang.Exception
Assigns SpaceGroup's properties according to current SpaceGroupId

Throws:
java.lang.Exception - If something went wrong during database operations.

assignSpaceGroupFromDataBase

public void assignSpaceGroupFromDataBase(DB db)
                                  throws java.lang.Exception
Assigns SpaceGroup's properties according to current SpaceGroupId using existing db connection.

Parameters:
db - open db connection.
Throws:
java.lang.Exception - If something went wrong during database operations.

putSpaceGroupToDataBase

public void putSpaceGroupToDataBase()
                             throws java.lang.Exception
Saves current spacegroup object to database

Throws:
java.lang.Exception - If something went wrong during database operations.

putSpaceGroupToDataBase

public void putSpaceGroupToDataBase(DB db)
                             throws java.lang.Exception
Saves current spacegroup object to database

Parameters:
db - open db connection
Throws:
java.lang.Exception - If something went wrong during database operations.

deleteRecord

public void deleteRecord()
Deletes current spacegroup + relations to spaces & persons

Specified by:
deleteRecord in class EntityHandler

deleteSpaces

public void deleteSpaces()
Deletes selected spaces from current spacegroup


deletePersons

public void deletePersons()
Deletes selected persons from current spacegroup


addSpaces

public void addSpaces()
               throws java.lang.Exception
Adds selected spaces to current spacegroup

Throws:
java.lang.Exception - If something went wrong during database operations.

addSpaces

public void addSpaces(DB db)
               throws java.lang.Exception
Adds selectedSpaces to the current spaceGroup.

Parameters:
db - Database connection
Throws:
java.lang.Exception - If something went wrong during database operations.

addPersons

public void addPersons()
                throws java.lang.Exception
Adds selectedPersons to the current spaceGroup. This method opens new DB.

Throws:
java.lang.Exception - If something went wrong during database operations.

addPersons

public void addPersons(DB db)
                throws java.lang.Exception
Adds selected persons into the current spaceGroup

Parameters:
db - Database connection
Throws:
java.lang.Exception - If something went wrong during database operations.

addToFavorites

public static void addToFavorites(Error error,
                                  User user,
                                  java.lang.String[] spaces)
                           throws java.lang.Exception
Adds given spaces to user's favorites

Parameters:
error - error where error messages are sent to
user - User whose favorite list spaces are added
spaces - array of spaces' id numbers as strings
Throws:
java.lang.Exception - If something went wrong during database operations.

updateModifyRight

public void updateModifyRight()
Returns true is user has right to modify contents of current spacegroup. (Administrators & persons with modifyRight) Note! User must be set for this method!


checkModifyRight

public static int checkModifyRight(DB db,
                                   User user,
                                   int spaceGroupId)
                            throws java.lang.Exception
Checks modify right for spaceGroup with given id. if spaceGroup does not exist or other error is encountered returns 0.

Parameters:
db - Database connection
user - User who wants to modify spaceGroup
spaceGroupId - SpaceGroupId of the to be modified spaceGroup
Returns:
true if user is allowed to modify spaceGroup
Throws:
java.lang.Exception - If something went wrong during database operations.

doCheckModifyRight

protected boolean doCheckModifyRight()
Implementation of modify rights checking. Notify that SpaceGroup has also additional modifyrights scheme. This method returns true only if user has full modifyright.

Specified by:
doCheckModifyRight in class EntityHandler
Returns:
true is user can modify entity.
See Also:
EntityHandler.hasModifyRight()

doClearEmptyParameters

protected void doClearEmptyParameters(javax.servlet.http.HttpServletRequest request)
Implementation of parameter clearing.

Specified by:
doClearEmptyParameters in class KiuruHandler
Parameters:
request - request-object from the JSP page.
See Also:
EntityHandler.clearEmptyParameters(HttpServletRequest)

getAddingNew

public boolean getAddingNew()
Returns true if entity is in a state of adding a new record. Implementation depends of a descendand class.

Specified by:
getAddingNew in class EntityHandler
Returns:
True if entity is in a state of adding a new record.

getRecord

public void getRecord()
               throws java.lang.Exception
Retrieves record from database according to current Id field(s) value(s).

Id field(s) are defined in descendant classes. Method implements also user rights check, eg. if user has no right to retrieve the record, empty object is returned instead.

Specified by:
getRecord in class EntityHandler
Throws:
java.lang.Exception - if there is a problem with DB connection

postRecord

public void postRecord()
                throws java.lang.Exception
Saves record to database.

If field values are not valid, sets Ok property to false.

Specified by:
postRecord in class EntityHandler
Throws:
java.lang.Exception - if there is a problem with DB connection

resetRecord

public void resetRecord()
Clears field values.

Result should be equivalent to constructing a new object. Nothing is saved to database.

Specified by:
resetRecord in class EntityHandler

doClearActionState

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

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