Kontakt

Fakturační údaje

IČ: 87189224, BÚ: 1958653063/0800

Contact info in QR code

Musico

Informace

  • Webová aplikace vytvořená pomocí technologií EJB a JSF, s úmyslem nasazení na Glassfish serveru.
  • Psaná jako semestrální práce pro předmět X33EJA.
  • Účelem bylo osvojit si:
    • Návrh doménového modelu a jeho implementaci (alespoň jedna vazba M:N)
    • Použití JPA pro persistenci
    • Transakce
    • Použití EJB (stateless i statefull)
    • Lokalizaci do více jazyků
    • Autorizaci uživatelů, rozdělení do rolí a zabezpečení přístupu k business vrstvě
    • Webové rozhrání (servlety, jsp, nebo web framework)

Zdrojové kódy

 1: package cz.cvut.x33eja.macosond.business.music;
 2: 
 3: import cz.cvut.x33eja.macosond.persistence.entity.Band;
 4: import cz.cvut.x33eja.macosond.persistence.entity.Event;
 5: import cz.cvut.x33eja.macosond.persistence.entity.Genre;
 6: import java.util.Collection;
 7: import java.util.Date;
 8: import javax.annotation.security.PermitAll;
 9: import javax.annotation.security.RolesAllowed;
10: import javax.ejb.Stateless;
11: import javax.persistence.EntityManager;
12: import javax.persistence.PersistenceContext;
13: import javax.persistence.TemporalType;
14: 
15: /**
16:  *
17:  * @author Ondrej Macoszek <macosond@fel.cvut.cz>
18:  */
19: @Stateless
20: public class EventBean implements EventLocal
21: {
22:         @PersistenceContext(unitName="Musico-PU")
23:         private EntityManager em;
24: 
25:         @RolesAllowed({"member","admin"})
26:         public void add(Event event)
27:         {
28:                 em.persist(event);
29:         }
30: 
31:         @RolesAllowed({"member","admin"})
32:         public void edit(Event event)
33:         {
34:                 event = em.merge(event);
35:                 em.persist(event);
36:         }
37: 
38:         @RolesAllowed({"member","admin"})
39:         public void delete(Event event)
40:         {
41:                 event = em.merge(event);
42:                 em.remove(event);
43:         }
44: 
45:         @PermitAll
46:         public Event get(Event event)
47:         {
48:                 return em.find(Event.class, event.getEventID());
49:         }
50: 
51:         @PermitAll
52:         public Event get(Integer EventID)
53:         {
54:                 return em.find(Event.class, EventID);
55:         }
56: 
57:         @PermitAll
58:         public Collection<Event> getAll()
59:         {
60:                 return em.createNamedQuery("Event.list").getResultList();
61:         }
62: 
63:         @PermitAll
64:         public Collection<Event> getByGenre(Genre genre)
65:         {
66:                 genre = em.find(Genre.class, genre.getGenreID());
67:                 return genre.getEvents();
68:         }
69: 
70:         @PermitAll
71:         public Collection<Event> getByDateInterval(Date start, Date end)
72:         {
73:                 return em.createNamedQuery("Event.byDateInterval")
74:                         .setParameter("start", start, TemporalType.DATE)
75:                         .setParameter("end", end, TemporalType.DATE)
76:                         .getResultList();
77:         }
78: 
79:         @PermitAll
80:         public Collection<Event> getByBand(Band band)
81:         {
82:                 band = em.find(Band.class, band.getBandID());
83:                 return band.getEvents();
84:         }
85: 
86:         @PermitAll
87:         public Collection<Event> getByPlace(String place)
88:         {
89:                 return em.createNamedQuery("Event.byPlace")
90:                         .setParameter("place", place)
91:                         .getResultList();
92:         }
93: }
94: