Exemple #1
0
  EventDTO eventToDTO(Event event) {
    EventDTO eventDTO =
        new EventDTO(
            event.getId(),
            event.getName(),
            event.getDescription(),
            event.getStartDate(),
            event.getFinishDate());
    eventDTO.setOpenForEnroll(event.isOpenForEnroll());
    eventDTO.setOpenForPresence(event.isOpenForPresence());
    eventDTO.setPassword(event.getPassword());

    return eventDTO;
  }
Exemple #2
0
 public List<ManagerDTO> getUnrolledManagersInEvents(Long id) throws EntityDoesNotExistsException {
   try {
     Event event = em.find(Event.class, id);
     if (event == null) {
       throw new EntityDoesNotExistsException("There is no event with that id.");
     }
     // nao sei se este código está correcto??
     List<Manager> managers =
         (List<Manager>)
             em.createNamedQuery("getAllEventManagers")
                 .setParameter("eventId", event.getId())
                 .getResultList();
     // -----------------------------------------------------------------------------------------
     List<Manager> enrolled = em.find(Event.class, id).getManagers();
     managers.removeAll(enrolled);
     return managersToDTOs(managers);
   } catch (EntityDoesNotExistsException e) {
     throw e;
   } catch (Exception e) {
     throw new EJBException(e.getMessage());
   }
 }