@Override
    public List<Vector> moduleSearch(String word) {
        List<Vector> modulesData = new ArrayList<>();
        List<Long> moduleIds = new ArrayList<>();
        word = word.toLowerCase();
        String compareTo;
        Query q = em.createQuery("SELECT m FROM Module m");
        for (Object o : q.getResultList()) {
            ModuleEntity m = (ModuleEntity) o;
            compareTo = m.getModuleTitle().toLowerCase();
            if (compareTo.contains(word) || word.equals("*")) {
                moduleIds.add(m.getId());
                continue;
            }
            compareTo = m.getModuleCode().toLowerCase();
            if (compareTo.contains(word)) {
                moduleIds.add(m.getId());
            }
        }
        for (Long moduleId : moduleIds) {
            moduleEntity = em.find(ModuleEntity.class, moduleId);
            Vector modInfo = new Vector();
            modInfo.add(moduleEntity.getId());
            modInfo.add(moduleEntity.getModuleTitle());
            modInfo.add(moduleEntity.getModuleCode());
            modInfo.add(moduleEntity.getTime());
            modInfo.add(moduleEntity.getVenue());
            modInfo.add(moduleEntity.getSynopsis().getContent());
            modInfo.add(moduleEntity.getLecturer().getTitle() + " " + moduleEntity.getLecturer().getName());
            List<Long> tutorialIds = new ArrayList<>();
            List<String> tuts = new ArrayList<>();
            for (TutorialEntity t : moduleEntity.getTutorials()) {
                tutorialIds.add(t.getId());
                tuts.add("Group " + t.getGroupNumber() + ": "
                        + t.getTime() + " at " + t.getVenue() + " by " + t.getTutor().getName());
            }
            modInfo.add(tutorialIds);
            List<Long> studentIds = new ArrayList();
            for (StudentEntity s : moduleEntity.getStudents()) {
                studentIds.add(s.getId());
            }
            modInfo.add(studentIds);
            modInfo.add(tuts);
            modulesData.add(modInfo);
        }
        return modulesData;
    }