@DeclareRoles(value={"admin","user"}) @RolesAllowed(value="admin") public class EventEJB extends Object
| Constructor and Description |
|---|
EventEJB() |
| Modifier and Type | Method and Description |
|---|---|
void |
createEvent(es.uvigo.esei.dgss.lettab.domain.Event event)
Create an event and stores it in the database
|
List<es.uvigo.esei.dgss.lettab.domain.Event> |
findEvent(String text)
This method search events by title and description, and order them by
ascendant date and descendant participants
|
es.uvigo.esei.dgss.lettab.domain.Event |
findEventById(int id) |
String |
getCurrentUserLogin() |
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 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
|
public String getCurrentUserLogin()
@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)
participant - The user that is linked to an eventevent - Event assigned to a user@RolesAllowed(value="user") public void removeLinkEventToUser(es.uvigo.esei.dgss.lettab.domain.User participant, es.uvigo.esei.dgss.lettab.domain.Event event)
participant - The user that is linked to the eventevent - The event assigned to the user@RolesAllowed(value="user") public void createEvent(es.uvigo.esei.dgss.lettab.domain.Event event) throws IllegalArgumentException, javax.persistence.EntityExistsException, javax.persistence.PersistenceException
event - The event that we want to persistIllegalArgumentException - When the event we want to persist is nulljavax.persistence.PersistenceException - Happens when there is any error with the persistencejavax.persistence.EntityExistsException@PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> findEvent(String text) throws javax.persistence.EntityNotFoundException
text - The String that should match with the title or description of
the eventsjavax.persistence.EntityNotFoundException - if there aren't any event that matches with the text@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@RolesAllowed(value="user") @PermitAll public List<es.uvigo.esei.dgss.lettab.domain.Event> getEventsToAssist(String login) throws javax.persistence.EntityNotFoundException, 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 nullCopyright © 2016. All rights reserved.