@DeclareRoles(value={"admin","user"}) @RolesAllowed(value="admin") @PermitAll public class EventEJB extends Object
| Constructor and Description |
|---|
EventEJB() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelEvent(String userLogin,
int eventId)
This method is used to cancel a given event.
|
es.uvigo.esei.dgss.lettab.domain.Event |
createEvent(es.uvigo.esei.dgss.lettab.domain.Event event)
Create an event and stores it in the database
|
es.uvigo.esei.dgss.lettab.domain.Event |
findEventById(int id)
Receives the id of an event and return the event related with it.
|
List<es.uvigo.esei.dgss.lettab.domain.Event> |
findEvents(String text)
This method search events by title and description, and order them by
ascendant date and descendant participants
|
List<es.uvigo.esei.dgss.lettab.domain.Event> |
getEventsToAssist(String login)
This method search signed up user's events, and order them by ascendant
date and descendant participants
|
List<es.uvigo.esei.dgss.lettab.domain.Event> |
getFiveRandomEvents()
Get five random events using JPQL
|
List<es.uvigo.esei.dgss.lettab.domain.Event> |
getMyEvents(String login)
Gives a list with the events created by the user bound to the login
passed as a parameter.
|
List<es.uvigo.esei.dgss.lettab.domain.Event> |
getPopularEvents(int numEvents)
Get popular active events using JPQL and order them by date asc.
|
void |
linkEventToUser(es.uvigo.esei.dgss.lettab.domain.User participant,
es.uvigo.esei.dgss.lettab.domain.Event event)
Links an user to an event and increase the number of participants for
that event
|
void |
removeLinkEventToUser(es.uvigo.esei.dgss.lettab.domain.User participant,
es.uvigo.esei.dgss.lettab.domain.Event event)
Removes the relationship between an user who assist to an event
|
void |
updateEvent(es.uvigo.esei.dgss.lettab.domain.Event event,
String login)
Update an event
|
@PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> getFiveRandomEvents()
@PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> getPopularEvents(int numEvents)
numEvents - The number of events to look for@RolesAllowed(value="user") public void linkEventToUser(es.uvigo.esei.dgss.lettab.domain.User participant, es.uvigo.esei.dgss.lettab.domain.Event event) throws EventNotActiveException, NullPointerException
participant - The user that is linked to an eventevent - Event assigned to a userEventNotActiveException - thrown if the event were deleted by his ownerNullPointerException - Thrown if the passed event is a null object@RolesAllowed(value="user") public void removeLinkEventToUser(es.uvigo.esei.dgss.lettab.domain.User participant, es.uvigo.esei.dgss.lettab.domain.Event event) throws NullPointerException, EventNotActiveException, IllegalArgumentException
participant - The user that is linked to the eventevent - The event assigned to the userEventNotActiveException - thrown if the event is inactiveNullPointerException - Thrown if the user is a null parameterIllegalArgumentException - Thrown if the event/user is null or is a removed entity@RolesAllowed(value="user") public es.uvigo.esei.dgss.lettab.domain.Event createEvent(es.uvigo.esei.dgss.lettab.domain.Event event) throws IllegalArgumentException, javax.persistence.EntityExistsException
event - The event that we want to persistIllegalArgumentException - When the event we want to persist is nulljavax.persistence.EntityExistsException - Happens if the event is already persisted@PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> findEvents(String text) throws SearchNotFoundException
text - The String that should match with the title or description of
the eventsjavax.persistence.EntityNotFoundException - if there aren't any active event that matches with the textSearchNotFoundException@PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> getMyEvents(String login)
login - The String passed to retrieve the user@PermitAll public es.uvigo.esei.dgss.lettab.domain.Event findEventById(int id) throws javax.persistence.NoResultException
id - The id bound to the event looking forjavax.persistence.NoResultException - thrown if no result found@PermitAll public void updateEvent(es.uvigo.esei.dgss.lettab.domain.Event event, String login) throws IllegalArgumentException, javax.persistence.NoResultException, SecurityException, DateBeforeTodayException
event - the event updatelogin - the login of the userIllegalArgumentException - Happens when the event does not exist and the event date is
not futureSecurityException - Happens when the user is not the ownerDateBeforeTodayException - Thrown when the new date is before the actual datejavax.persistence.NoResultException - When the event cannot be found@PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> getEventsToAssist(String login) throws javax.persistence.NoResultException, IllegalArgumentException
login - The User of which we will obtain the signed up event's listjavax.persistence.EntityNotFoundException - if there aren't any event of which the user is signedIllegalArgumentException - if the user is nulljavax.persistence.NoResultException@PermitAll public void cancelEvent(String userLogin, int eventId) throws javax.persistence.NoResultException, SecurityException, IllegalArgumentException, UserNotActiveException, EventAlreadyCancelledException
userLogin - The user who wants to cancel the eventeventId - The event to canceljavax.persistence.NoResultException - Returns that when the user cannot be foundUserNotActiveException - If the user is not activeSecurityException - When the login is not the creator of the eventIllegalArgumentException - When the login is nullEventAlreadyCancelledException - When the event is already cancelledCopyright © 2017. All rights reserved.