public static void createSomeInstitutions(int numInstitutions) { for (int i = 0; i < numInstitutions; i++) { User.NameGenerator ng = new User.NameGenerator(); Institution in = new Institution("School of " + ng.getName(), ng.getName() + ", VA", "descriptionnnn"); in.save(); } }
public static void delete(Long id) { Institution institution = find.ref(id); if (institution == null) { return; } institution.retired = true; institution.save(); }
public static List<Institution> getAllInstitutionsForStudent(Long studentId) { String sql = "select * from institution " + "where id in " + "(select institution_id from student_in_institution " + "where student_id=" + studentId + ")"; List<Institution> allInstitutions = new ArrayList<Institution>(); List<SqlRow> rows = Ebean.createSqlQuery(sql).findList(); for (SqlRow row : rows) { allInstitutions.add(Institution.byId(row.getLong("id"))); } return allInstitutions; }
/** ****************************** CREATE / DELETE ****************************** */ public static Institution create(Institution institution) { institution.save(); return institution; }