public List<EventDTO> getAllEventsOfManager(Long id) { Manager man = em.find(Manager.class, id); if (man != null) { List<Event> events = new ArrayList<>(); events = man.getEvents(); return eventsToDTOs(events); } return null; }
public List<EventDTO> getManagerEvents(Long managerId) throws EntityDoesNotExistsException { try { Manager manager = em.find(Manager.class, managerId); if (manager == null) { throw new EntityDoesNotExistsException("Manager does not exists."); } return eventsToDTOs(manager.getEvents()); } catch (EntityDoesNotExistsException e) { throw e; } catch (Exception e) { throw new EJBException(e.getMessage()); } }