kiurubeans
Class KiuruReservation

java.lang.Object
  |
  +--kiurubeans.KiuruReservation

public class KiuruReservation
extends java.lang.Object

This class encapsulates actual making of reservations and getting information about already made reservations.


Field Summary
static int REQUEST_STATE_CANCELLED
          Reservation was made and then cancelled
static int REQUEST_STATE_CONFIRMED
          Reservation is made and confirmed.
static int REQUEST_STATE_PROCESSING
          Reservation is being processed.
static int REQUEST_STATE_REMOVED
          Somebody removed reservation.
static int REQUEST_STATE_REQUEST
          Reservation request
 
Constructor Summary
KiuruReservation()
          Default constructor
 
Method Summary
static java.util.ArrayList acceptReservationRequests(java.lang.String[] reservations)
          Changes states of specified reservation requests into reservations
static void addPersonToReservation(int personID, int reservationID)
          Adds person as a contact person into a reservation
static boolean assignPersonsToReservation(int cPerson, int resMaker, java.lang.Integer[] reservations)
          Assigns persons to a reservation
static boolean checkUsersReservationRights(int reservationId, User user)
          Checks if given user has access to modify reservation (or anything administrial)
static int[] getEventAndEventGroupId(int reservationId)
          Returns EventID and EventGroupID of given reservation in int array.
static int[] getEventAndEventGroupId(java.lang.String reservationId)
          Returns EventID and EventGroupID of given reservation in int array.
static int getEventId(int reservationId)
          Returns eventid of given reservation
static int getEventId(java.lang.String reservationId)
          Returns eventid of given reservation
static int getReservationPerson(int reservationId)
          Returns contact person of given reservation
static int getReservationPerson(java.lang.String reservationId)
          Returns contact person of given reservation
static java.lang.String getReservationState(int eventId, int spaceId)
          Returns state for current reservation, or empty string if there is no reservation.
static boolean isReservationOk(int eventId)
          Determines if there is reservation for given event.
static boolean isReservationOk(int eventId, int spaceId)
          Determines if given event is reserved (+confirmed) at given space.
static boolean isReserved(int spaceId, int eventId)
          Checks if given space is reserved or free.
static java.lang.Integer[] makeReservation(int spaceId, java.lang.Integer[] eventIds, int organisationId, int payOrganisationId, int requestState, java.lang.String reservationInfo, User user)
          Makes reservations to given space for given event
static int makeReservation(int spaceId, int eventId, int organisationId, int requestState, java.lang.String reservationInfo, User user)
          Makes reservation to given space for given event
static int makeReservation(int spaceId, int eventId, int organisationId, java.lang.String reservationInfo, User user)
          Makes reservation to given space for given event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_STATE_REQUEST

public static final int REQUEST_STATE_REQUEST
Reservation request

See Also:
Constant Field Values

REQUEST_STATE_PROCESSING

public static final int REQUEST_STATE_PROCESSING
Reservation is being processed. Reserved for future use.

See Also:
Constant Field Values

REQUEST_STATE_CONFIRMED

public static final int REQUEST_STATE_CONFIRMED
Reservation is made and confirmed. This is the final state.

See Also:
Constant Field Values

REQUEST_STATE_CANCELLED

public static final int REQUEST_STATE_CANCELLED
Reservation was made and then cancelled

See Also:
Constant Field Values

REQUEST_STATE_REMOVED

public static final int REQUEST_STATE_REMOVED
Somebody removed reservation.

See Also:
Constant Field Values
Constructor Detail

KiuruReservation

public KiuruReservation()
Default constructor

Method Detail

assignPersonsToReservation

public static boolean assignPersonsToReservation(int cPerson,
                                                 int resMaker,
                                                 java.lang.Integer[] reservations)
Assigns persons to a reservation

Parameters:
cPerson - personID of the contact person for the reservation
resMaker - personID of the person who actually made the reservation
reservations - Array of Integers containing reservationIDs.
Returns:
true if no exceptions were thrown.

isReserved

public static boolean isReserved(int spaceId,
                                 int eventId)
                          throws java.lang.Exception
Checks if given space is reserved or free.

Parameters:
spaceId - Id of space
eventId - Time interval to be checked
Returns:
Returns false if given space is free during given event
Throws:
java.lang.Exception - If something went wrong in query

makeReservation

public static int makeReservation(int spaceId,
                                  int eventId,
                                  int organisationId,
                                  int requestState,
                                  java.lang.String reservationInfo,
                                  User user)
                           throws java.lang.Exception
Makes reservation to given space for given event

Parameters:
spaceId - Space that is going to be reserved.
eventId - Event that is going to be held.
organisationId - Organisation that is arranging the event.
requestState - If the reservation is final or proposition.
reservationInfo - Additional info
user - Who is making the reservation
Returns:
id of made reservation or -1 if reservation was not successful
Throws:
java.lang.Exception - If something went wrong in database update

makeReservation

public static int makeReservation(int spaceId,
                                  int eventId,
                                  int organisationId,
                                  java.lang.String reservationInfo,
                                  User user)
                           throws java.lang.Exception
Makes reservation to given space for given event

Parameters:
spaceId - Space that is going to be reserved.
eventId - Event that is going to be held.
organisationId - Organisation that is arranging the event.
reservationInfo - Additional info
user - Who is making the reservation
Returns:
id of made reservation or -1 if reservation was not successful
Throws:
java.lang.Exception - If something went wrong in database update

makeReservation

public static java.lang.Integer[] makeReservation(int spaceId,
                                                  java.lang.Integer[] eventIds,
                                                  int organisationId,
                                                  int payOrganisationId,
                                                  int requestState,
                                                  java.lang.String reservationInfo,
                                                  User user)
                                           throws java.lang.Exception
Makes reservations to given space for given event

Parameters:
spaceId - Space that is going to be reserved.
eventIds - Events that are going to be held.
organisationId - Organisation that is arranging the event.
reservationInfo - Additional info
user - Who is making the reservation
requestState - If the reservation is final or proposition.
payOrganisationId - Organisation that is paying the event.
Returns:
id of made reservation or -1 if reservation was not successful
Throws:
java.lang.Exception - If something went wrong in database update

addPersonToReservation

public static void addPersonToReservation(int personID,
                                          int reservationID)
                                   throws java.lang.Exception
Adds person as a contact person into a reservation

Parameters:
personID - Id of the contact person
reservationID - Id of the reservation
Throws:
java.lang.Exception - If something went wrong during database update

getReservationState

public static java.lang.String getReservationState(int eventId,
                                                   int spaceId)
Returns state for current reservation, or empty string if there is no reservation.

Parameters:
spaceId - Id of space where reservation is made to
eventId - Id of the event that deals with reservation
Returns:
RequestState as a String.

isReservationOk

public static boolean isReservationOk(int eventId,
                                      int spaceId)
Determines if given event is reserved (+confirmed) at given space. We use this method in order to avoid double reservations.

Parameters:
eventId - Id of event that is checked
spaceId - Id of space where event should occur.
Returns:
true if reservation is confirmed

isReservationOk

public static boolean isReservationOk(int eventId)
Determines if there is reservation for given event.

Parameters:
eventId - Id of given event
Returns:
true if reservation is made and confirmed

getReservationPerson

public static int getReservationPerson(java.lang.String reservationId)
                                throws java.lang.Exception
Returns contact person of given reservation

Parameters:
reservationId - Id of reservation as String
Returns:
PersonID of the contact person
Throws:
java.lang.Exception - If something went wrong in database query

getReservationPerson

public static int getReservationPerson(int reservationId)
                                throws java.lang.Exception
Returns contact person of given reservation

Parameters:
reservationId - ReservationId
Returns:
PersonID of contact person.
Throws:
java.lang.Exception - If something went wrong in database query

getEventId

public static int getEventId(java.lang.String reservationId)
Returns eventid of given reservation

Parameters:
reservationId - Id of the given reservation
Returns:
eventID

getEventId

public static int getEventId(int reservationId)
Returns eventid of given reservation

Parameters:
reservationId - Id of the given reservation
Returns:
eventId

getEventAndEventGroupId

public static int[] getEventAndEventGroupId(java.lang.String reservationId)
                                     throws java.lang.Exception
Returns EventID and EventGroupID of given reservation in int array.

Parameters:
reservationId - Id of reservation as String
Returns:
int array where array[0]=eventId and array[1]=eventGroupId
Throws:
java.lang.Exception - If something went wrong in database query

getEventAndEventGroupId

public static int[] getEventAndEventGroupId(int reservationId)
                                     throws java.lang.Exception
Returns EventID and EventGroupID of given reservation in int array.

Parameters:
reservationId - Id of reservation
Returns:
int array where array[0]=eventId and array[1]=eventGroupId
Throws:
java.lang.Exception - If something went wrong in database query

checkUsersReservationRights

public static boolean checkUsersReservationRights(int reservationId,
                                                  User user)
Checks if given user has access to modify reservation (or anything administrial)

Parameters:
reservationId - Id of reservation to be checked
user - User who tries to modify reservation
Returns:
true if user is allowed to modify reservation

acceptReservationRequests

public static java.util.ArrayList acceptReservationRequests(java.lang.String[] reservations)
Changes states of specified reservation requests into reservations

Parameters:
reservations - Array of Strings containing reservationIDs we are accepting.
Returns:
Returns reservation requests that couldn't be accepted. The main reason for this is the space is not free.