public static Group findOrCreate(String name) { Group it = Group.find("name", name).first(); if (it == null) { it = new Group(name); } return it; }
public static List<Group> getAllGroups() { List<Group> groups = new ArrayList<Group>(); List<Map<String, Object>> rows = null; rows = getJdbcTemplate().queryForList(GET_ALL_GROUPS); if (rows != null) { for (Map row : rows) { String name = (String) row.get(UserRowMapper.USER_FULL_NAME_COLUMN); if (StringUtils.isNotBlank(name)) { Group group = new Group(); group.name = name; groups.add(group); } } } return groups; }
public static void update(Long idGroup, List<SqlRow> gpms) { Group group = Group.findById(idGroup); if (group == null) return; Ebean.beginTransaction(); try { deleteForGroup(idGroup); Integer i = 1; for (SqlRow man : gpms) { Profile prof = Profile.lastProfileByGpmId(man.getLong("gpm")); if (prof == null) continue; CacheClassifier cc = new CacheClassifier( group, i++, prof.gpm.idGpm, prof.name, prof.image, (prof.gender == null) ? null : prof.gender.value, (prof.relationshipStatus == null) ? null : prof.relationshipStatus.status, prof.nFollowers); if (cc.name == null || cc.name.isEmpty()) cc.name = Profile.getLastNotEmptyField(prof.gpm.id, "name"); cc.save(); } Ebean.commitTransaction(); } finally { Ebean.endTransaction(); } }
public List<Group> getGroups() { List<Group> allGroups = Group.findAll(); List<Group> answer = new ArrayList<Group>(); for (Group g : allGroups) { for (User u : g.members) { if (u.equals(this)) { answer.add(g); break; } } } return answer; }
public static void group(Long id) { Group group = id == null ? null : (Group) Group.findById(id); User user = user(); render(group, user); }
private static void fillDatabase() { Teacher teacher = new Teacher(); teacher.setFirstName("Ivan"); teacher.setLastName("Ivanov"); teacherDao.save(teacher); Teacher teacher2 = new Teacher(); teacher2.setFirstName("Petr"); teacher2.setLastName("Petrov"); teacherDao.save(teacher2); Group group = new Group(); group.setCreated(new Date()); group.setCurator(teacher); group.setName("1"); groupDao.save(group); Student student = new Student(); student.setBirthday(new Date()); student.setFirstName("stud1"); student.setLastName("stud1"); Group group1 = (Group) groupDao.list("1").toArray()[0]; student.setGroup(group1); studentDao.save(student); Student student2 = new Student(); student2.setBirthday(new Date()); student2.setFirstName("stud2"); student2.setLastName("stud2"); student2.setGroup(group1); studentDao.save(student2); Student student3 = new Student(); student3.setBirthday(new Date()); student3.setFirstName("stud3"); student3.setLastName("stud3"); student3.setGroup(group1); studentDao.save(student3); Lection lection = new Lection(); lection.setName("Math"); lectionDao.save(lection); Lection lection1 = new Lection(); lection1.setName("Phisics"); lectionDao.save(lection1); Lection lection2 = (Lection) lectionDao.list("Math").toArray()[0]; Teacher teacher3 = (Teacher) teacherDao.list("Ivan").toArray()[0]; GroupLection groupLection = new GroupLection(); groupLection.setDate(new Date()); groupLection.setGroup(group1); groupLection.setLection(lection2); groupLection.setTeacher(teacher3); groupLectionDao.save(groupLection); LossStudent lossStudent = new LossStudent(); lossStudent.setDate(new Date()); lossStudent.setGroup(group1); lossStudent.setLection(lection2); lossStudent.setStudent(student3); lossStudent.setReason("sleeping"); lossStudentDao.save(lossStudent); }
public static List<CacheClassifier> findByGroup(Long id) { return find.where().eq("group", Group.findById(id)).orderBy("position").findList(); }