public String validate() { email = email.toLowerCase(); if (Student.authenticate(email, password) == null) { return "Invalid user or password"; } return null; }
public static void createAd(@Valid Ad ad, File photo) throws IOException { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // get current date time with Date() Date date = new Date(); ad.createDate = dateFormat.format(date); ad.student = Student.findById(1l); // ad.category=Category.findById(ad.category.id); File d = new File(Play.applicationPath.getAbsolutePath() + "/public/img/ads"); // if(d.exists()){ String suffix = FilenameUtils.getExtension(photo.getName()); File o = File.createTempFile("ad-", "." + suffix, d); InputStream input = new FileInputStream(photo); OutputStream output = new FileOutputStream(o); ad.image = o.getName(); ad.save(); try { IOUtils.copy(input, output); } finally { IOUtils.closeQuietly(output); IOUtils.closeQuietly(input); } Ads.index(1, ad.category.id.toString()); }
@Check("login") public static void index() { User curUser = User.find("byName", Secure.Security.connected()).first(); if (curUser.type == UserType.ADMINISTRATOR) { redirect("/admin/crud"); } else if (curUser.type == UserType.STUDENT) { Student.index(); } else { Teacher.index(); } }
public String validate() { if (email.length() == 0 | password.length() == 0 | name.length() == 0 | lastName.length() == 0 | studies.length() == 0) { return "Please fill in all required forms"; } Language lang = Language.Nederlands; if (language.equals("EN")) { lang = Language.English; } Student s = new Student(email, name, lastName, password, lang, studies); s.save(); return null; }
private static void testDatabase() { Student student = (Student) studentDao.list("stud1").toArray()[0]; System.out.println("last name: " + student.getLastName()); System.out.println("group name: " + student.getGroup().getName()); for (Student student1 : student.getGroup().getStudentList()) { System.out.println("students in group: " + student1.getFirstName()); } System.out.println("curator last name: " + student.getGroup().getCurator().getLastName()); for (GroupLection groupLection : student.getGroup().getCurator().getGroupLectionList()) { System.out.println("group lection time: " + groupLection.getDate()); } LossStudent lossStudent = (LossStudent) lossStudentDao.list().toArray()[0]; System.out.println( lossStudent.getDate() + " " + lossStudent.getStudent().getLastName() + " " + lossStudent.getLection().getName()); }
public Student createStudent( String name, String lastname, String studentid, Semester semester, Department department) { Student e = new Student(); // id is automatically set e.setName(name); e.setLastname(lastname); e.setStudentid(studentid); e.setSemester(semester); e.setDepartment(department); tx.begin(); em.persist(e); tx.commit(); return e; }
public static void reports(String value, int report) { List<Student> students = Student.findAll(); List<Result> results = null; if (report != 0) { switch (report) { case 1: results = StudentResults.generalAveragePerQuarter(Integer.parseInt(value)); renderArgs.put("userSelected", Integer.parseInt(value)); break; case 2: results = StudentResults.subjectGradesPerQuarter(value); renderArgs.put("subjectSelected", value); break; case 3: results = StudentResults.yearQuarterGeneralAverage(value); renderArgs.put("yearquarterSelected", value); break; } renderArgs.put("reportSelected", report); } else { renderArgs.put("reportSelected", 0); } render(students, results); }
/** * Returns true if the specified solution has the same student, number of courses preferred and * recommended courses list, as this solution. * * @param other solution to compare against * @return true if these solutions are equivalent, false otherwise */ public boolean sameSolution(StudentSolution other) { if (other == null) return false; return student.equals(other.student) && numCoursesPreferred == other.numCoursesPreferred && recommendedCourses.equals(other.recommendedCourses); }
public void changeYear() { for (Student st : this.students) { st.changeYear(); } }
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); }