kiurubeans
Class KiuruSpace

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

public class KiuruSpace
extends EntityHandler

Representation of Space db entity.


Field Summary
static int ADD_SPACEGROUP
          Selects spacegroups for this space
static int ADD_SPACEGROUP_CONFIRM
          Confirms adding spacegroups to this space
 
Fields inherited from class kiurubeans.EntityHandler
DELETE_RECORD, GET_RECORD, POST_RECORD, RESET_RECORD
 
Fields inherited from class kiurubeans.KiuruHandler
NO_ACTION
 
Constructor Summary
KiuruSpace()
          Default constructor
KiuruSpace(int id, Error e)
          Constructor for KiuruSpace.
 
Method Summary
 void addSpaceGroups()
          Adds current space to selected space groups.
 void assignSpaceFromDataBase()
          Gets the data for the space from the database according to the spaceId.
 void assignSpaceFromDataBase(DB db, int aid)
          Gets the data for the KiuruSpace from database using existing connection.
 void assignSpaceFromDataBase(int aid)
          Gets the data for the kiuruSpace from database.
static boolean checkReservationRequestRight(int spaceId, User user)
          Checks if given user has rights to make reservation requests to given space.
static boolean checkUserRights(int spaceID, User user)
          Checks if given user has rights to make reservations to given space.
protected  void defaultAction()
          Performs action based on actionType (eg. addNew, modify, post, delete).
 void deleteRecord()
          Deletes current space & relations to resource, spacegroup & event.
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.
 boolean equals(java.lang.Object o)
          Tells if current KiuruSpace object is equivalent with another object.
 boolean getAddingNew()
          Returns if entity is in a state of adding a new record.
 int getIntSize()
          Returns the size of the space as int number.
protected  int getMaxState()
          Returns current max state value.
 java.lang.String getName()
          Returns the of the space
 int getOrganisationId()
          Returns the organisation that "owns" this space.
 void getRecord()
          Retrieves record from database according to current Id field(s) value(s).
 java.lang.String getReservationMethod()
          Returns the name of the reservation method used for this space.
 java.util.ArrayList getReservationMethodList()
          Returns the list of available reservation methods for spaces.
 java.lang.String[] getSelectedSpaceGroups()
          Returns the selected spaceGroups.
 java.lang.String getSelectedSpaceGroups(int i)
          Returns the ith selected spaceGroup
 java.lang.String getSize()
          Returns the size of the space in String.
static KiuruSpace getSpaceFromDataBase(DB db, int aid)
          Creates a new kiuruSpace object and gets data from database for newly created kiuruSpace.
static KiuruSpace getSpaceFromDataBase(int aid)
          Creates a new kiuruSpace object and gets data from database for newly created kiuruSpace.
 int getSpaceId()
          Returns the spaceId of the current object.
static RS2 getSpaceTypes()
          Returns all spacegrouptypes from database.
 int getType()
          Returns the type of space.
 void postRecord()
          Saves record to database.
 void putSpaceToDataBase()
          Stores the data of the object into the database
 void resetRecord()
          Clears field values.
 void setName(java.lang.String name)
          Sets the name of the space
 void setOrganisationId(int i)
          Organisation that "owns" the space.
 void setReservationMethod(java.lang.String reservationMethod)
          Sets reservation method for this space.
 void setSelectedSpaceGroups(int i, java.lang.String s)
          Sets the ith selected spacegroup
 void setSelectedSpaceGroups(java.lang.String[] s)
          User wants to e.g. add this space into these spaceGroups
 void setSize(int size)
          Sets the size of the space.
 void setSize(java.lang.String size)
          Sets the size of the space.
 void setSpaceId(int id)
          Sets the id for the current space.
 void setSpaceId(java.lang.String id)
          Sets the spaceId for the current space.
 void setSubmitAdd(java.lang.String s)
          Used with html forms.
 void setSubmitAddSpaceGroup(java.lang.String s)
          Used with html forms.
 void setSubmitAddSpaceGroupConfirm(java.lang.String s)
          Used with html forms.
 void setSubmitDeleteRecord(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 spaceType)
          Sets the type of the space.
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD_SPACEGROUP

public static final int ADD_SPACEGROUP
Selects spacegroups for this space

See Also:
Constant Field Values

ADD_SPACEGROUP_CONFIRM

public static final int ADD_SPACEGROUP_CONFIRM
Confirms adding spacegroups to this space

See Also:
Constant Field Values
Constructor Detail

KiuruSpace

public KiuruSpace(int id,
                  Error e)
Constructor for KiuruSpace. Does not read anything from db.

Parameters:
id - The spaceId for the space
e - Error objects. Possible error messages are delivered here.

KiuruSpace

public KiuruSpace()
Default constructor

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 EntityHandler
Returns:
max state value

getAddingNew

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

Specified by:
getAddingNew in class EntityHandler
Returns:
true, if the space is in a state of adding a new record.

getReservationMethodList

public java.util.ArrayList getReservationMethodList()
Returns the list of available reservation methods for spaces. The list contains methods written in Finnish.

Returns:
Arraylist that contains available reservation methods for spaces.

getName

public java.lang.String getName()
Returns the of the space

Returns:
The name of the space.

setName

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

Parameters:
name - Name of the space

getIntSize

public int getIntSize()
Returns the size of the space as int number.

Returns:
The size of the space as int.

getSize

public java.lang.String getSize()
Returns the size of the space in String. String contains integer number.

Returns:
String that contains the size of the space. Size is integer number.

setSize

public void setSize(int size)
Sets the size of the space.

Parameters:
size - How many people are allowed to be in the space at the same time.

setSize

public void setSize(java.lang.String size)
Sets the size of the space. String must contain a non-negative integer number.

Parameters:
size - String that tells how many people are allowed to be in the space at the same time. String has to contain a non-negative integer number.

getReservationMethod

public java.lang.String getReservationMethod()
Returns the name of the reservation method used for this space.

Returns:
The reservation method used for this space

setReservationMethod

public void setReservationMethod(java.lang.String reservationMethod)
Sets reservation method for this space.

Parameters:
reservationMethod - How is reservations supervised. Not really needed if we use only Korppi

getSpaceId

public int getSpaceId()
Returns the spaceId of the current object.

Returns:
ID of space.

setSpaceId

public void setSpaceId(int id)
Sets the id for the current space. Use with caution, this should be persistent for an objecct. -1 indicates a new record.

Parameters:
id - New spaceId

setSpaceId

public void setSpaceId(java.lang.String id)
Sets the spaceId for the current space.

Parameters:
id - String containing the new space id. id must be an integer.

setOrganisationId

public void setOrganisationId(int i)
Organisation that "owns" the space.

Parameters:
i - Id of the organisation

getOrganisationId

public int getOrganisationId()
Returns the organisation that "owns" this space.

Returns:
OrganisationId of the organisation

getType

public int getType()
Returns the type of space.

Returns:
SpaceTypeId of the space.

setType

public void setType(int spaceType)
Sets the type of the space.

Parameters:
spaceType - spaceTypeId of the new type.

getSelectedSpaceGroups

public java.lang.String[] getSelectedSpaceGroups()
Returns the selected spaceGroups.

Returns:
The spaceGroups the user has selected for this space.

setSelectedSpaceGroups

public void setSelectedSpaceGroups(java.lang.String[] s)
User wants to e.g. add this space into these spaceGroups

Parameters:
s - The string array containing the ids of the spaceGroups the user has selected.

setSelectedSpaceGroups

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

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

getSelectedSpaceGroups

public java.lang.String getSelectedSpaceGroups(int i)
Returns the ith selected spaceGroup

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

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 be translated. The most important thing is that it exists.
See Also:
EntityHandler.RESET_RECORD

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 the content of the string, because it can be translated. The most important thing is that it exists.
See Also:
EntityHandler.GET_RECORD

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 be translated. The most important thing is that it exists.
See Also:
EntityHandler.POST_RECORD

setSubmitDeleteRecord

public void setSubmitDeleteRecord(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 be translated. The most important thing is that it exists.
See Also:
EntityHandler.DELETE_RECORD

setSubmitAddSpaceGroup

public void setSubmitAddSpaceGroup(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 be translated. The most important thing is that it exists.
See Also:
ADD_SPACEGROUP

setSubmitAddSpaceGroupConfirm

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

Parameters:
s - We are not interested in this, because it can be translated. The most important thing is that it exists.
See Also:
ADD_SPACEGROUP_CONFIRM

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

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 in the actual actions performed.
See Also:
KiuruHandler.performAction()

assignSpaceFromDataBase

public void assignSpaceFromDataBase()
                             throws java.lang.Exception
Gets the data for the space from the database according to the spaceId.

Throws:
java.lang.Exception - If database handling was not successful

assignSpaceFromDataBase

public void assignSpaceFromDataBase(DB db,
                                    int aid)
                             throws java.lang.Exception
Gets the data for the KiuruSpace from database using existing connection.

Parameters:
db - Database connection
aid - spaceId of the wanted space.
Throws:
java.lang.Exception - If something went wrong during the database query.

assignSpaceFromDataBase

public void assignSpaceFromDataBase(int aid)
                             throws java.lang.Exception
Gets the data for the kiuruSpace from database. Opens a new database connection.

Parameters:
aid - The spaceId of wanted space.
Throws:
java.lang.Exception - If something went wrong during database handling.

getSpaceFromDataBase

public static KiuruSpace getSpaceFromDataBase(int aid)
                                       throws java.lang.Exception
Creates a new kiuruSpace object and gets data from database for newly created kiuruSpace.

Parameters:
aid - spaceId of the wanted space.
Returns:
KiuruSpace object.
Throws:
java.lang.Exception - If something went wrong during database handling.

getSpaceFromDataBase

public static KiuruSpace getSpaceFromDataBase(DB db,
                                              int aid)
                                       throws java.lang.Exception
Creates a new kiuruSpace object and gets data from database for newly created kiuruSpace. Uses existing database connection.

Parameters:
db - Database connection.
aid - spaceId of the wanted space.
Returns:
KiuruSpace object.
Throws:
java.lang.Exception - If something went wrong during database handling.

putSpaceToDataBase

public void putSpaceToDataBase()
                        throws java.lang.Exception
Stores the data of the object into the database

Throws:
java.lang.Exception - Saving into the database was not ok.

deleteRecord

public void deleteRecord()
Deletes current space & relations to resource, spacegroup & event. NOTE! There may be other relations to Space! Deletion is NOT SAFE! It should be used with extreme caution. Does NOT check if there are active events for a particular space!

Specified by:
deleteRecord in class EntityHandler

addSpaceGroups

public void addSpaceGroups()
                    throws java.lang.Exception
Adds current space to selected space groups.

Throws:
java.lang.Exception - if there is a problem with db connection.

getSpaceTypes

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

Returns:
RS2 containing name and spacetypeid of the spacegrouptypes.
Throws:
java.lang.Exception - Database handling was not ok.

checkUserRights

public static boolean checkUserRights(int spaceID,
                                      User user)
                               throws java.lang.Exception
Checks if given user has rights to make reservations to given space.

Parameters:
spaceID - spaceId of the space where user wants to make reservations.
user - User who is making the reservation.
Returns:
True if user is allowed to make reservations to given space.
Throws:
java.lang.Exception - Database query was not ok.

checkReservationRequestRight

public static boolean checkReservationRequestRight(int spaceId,
                                                   User user)
                                            throws java.lang.Exception
Checks if given user has rights to make reservation requests to given space.

Parameters:
spaceId - spaceId of the space where user wants to make reservations.
user - User who is making the reservation request.
Returns:
True if user is allowed to make reservation requests to given space.
Throws:
java.lang.Exception - Database query was not ok.

equals

public boolean equals(java.lang.Object o)
Tells if current KiuruSpace object is equivalent with another object.

Overrides:
equals in class java.lang.Object
Parameters:
o - Object that we are comparing our KiuruSpace object with.
Returns:
True if objects are identical.

doCheckModifyRight

protected boolean doCheckModifyRight()
Implementation of modify rights checking. Currently unofficial (non-organisation-related) spaces may by modified by anybody. Other spaces may be modified by secretary.

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)

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

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)