public int updateInstructor(Instructor instructor) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(NAME, instructor.getname()); values.put(DEPARTMENT, instructor.getdepartment()); values.put(C_ID, instructor.getcourse().getcid()); values.put(EMAIL, instructor.getemail()); values.put(WEBPAGE, instructor.getwebpage()); values.put(PHONE, instructor.getphone()); values.put(OFFICEHOURS, instructor.getoffice_hours()); values.put(NOTES, instructor.getnotes()); return db.update( TABLE_INSTRUCTOR, values, I_ID + "= ?", new String[] {String.valueOf(instructor.getiid())}); }
// Adding new Instructor public void addInstructor(Instructor instructor) { Log.d("entered addInstructor", "yes"); SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(NAME, instructor.getname()); values.put(DEPARTMENT, instructor.getdepartment()); if (instructor.getcourse() != null) values.put(C_ID, instructor.getcourse().getcid()); else values.put(C_ID, 0); values.put(EMAIL, instructor.getemail()); values.put(WEBPAGE, instructor.getwebpage()); values.put(PHONE, instructor.getphone()); values.put(OFFICEHOURS, instructor.getoffice_hours()); values.put(NOTES, instructor.getnotes()); Long success = db.insert(TABLE_INSTRUCTOR, null, values); Log.d("added instructor successfully", success.toString()); db.close(); }
public void deleteInstructor(Instructor instructor) { SQLiteDatabase db = this.getWritableDatabase(); db.delete(TABLE_INSTRUCTOR, I_ID + "=?", new String[] {String.valueOf(instructor.getiid())}); }
// Getting specific instructor public Instructor getInstructor(int iid) { Log.d("goes into getInstructor", "yes"); String selectQuery = "SELECT * FROM Instructor" + " WHERE iid = " + iid; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); cursor.moveToFirst(); Instructor instructor = new Instructor(); instructor.setiid(cursor.getInt(0)); Log.d("getting instructor name", cursor.getString(1)); instructor.setname(cursor.getString(1)); instructor.setdepartment(cursor.getString(2)); if (cursor.getInt(3) > 0) instructor.setcourse(getCourse(cursor.getInt(3))); else instructor.setcourse(null); instructor.setemail(cursor.getString(4)); instructor.setwebpage(cursor.getString(5)); instructor.setphone(cursor.getString(6)); instructor.setoffice_hours(cursor.getString(7)); instructor.setnotes(cursor.getString(8)); return instructor; }
public static void main(String[] args) { Student student = new Student(); student.setName("Jeff"); Address homeAddress = new Address(); homeAddress.setAddressType(AddressType.HOME); homeAddress.setAddressLine1("101 Fifth St."); homeAddress.setAddressLine2("Suite 3a"); homeAddress.setCity("St. Charles"); homeAddress.setState("MO"); homeAddress.setPostalCode("63303"); Set addresses = new HashSet(); addresses.add(homeAddress); student.setAddresses(addresses); Instructor instructor = new Instructor(); instructor.setFirstName("John"); instructor.setLastName("Smith"); instructor.setInstructorName(instructor.getFirstName(), instructor.getLastName()); Instructor instructor2 = new Instructor(); instructor2.setFirstName("Ron"); instructor2.setLastName("Regan"); instructor2.setInstructorName(instructor.getFirstName(), instructor.getLastName()); Course java = new Course(); java.setCourseName("CSP 443 Advanced Java"); java.setCreditHours(3.0f); java.setInstructor(instructor); Course cSharp = new Course(); cSharp.setCourseName("CSP 233 Beginning C#"); cSharp.setCreditHours(5.0f); java.setInstructor(instructor2); Course algebra = new Course(); algebra.setCourseName("Beginners Algebra"); algebra.setCreditHours(3.0f); algebra.setInstructor(instructor2); Course computer = new Course(); computer.setCourseName("Intro to Computer Science"); computer.setCreditHours(4.5f); computer.setInstructor(instructor); Rating rate = new Rating(); rate.setCourse(java, 8.5d); Rating rate2 = new Rating(); rate2.setCourse(cSharp, 9.0d); Rating rate3 = new Rating(); rate3.setCourse(algebra, 7.0); Rating rate4 = new Rating(); rate4.setCourse(computer, 8.0); Set courses = new HashSet(); courses.add(java); courses.add(cSharp); courses.add(computer); courses.add(algebra); student.setCourses(courses); Set instructors = new HashSet(); instructors.add(instructor); instructors.add(instructor2); instructor.setInstructors(instructors); Grade javaGrade = new Grade(student, java, 3.459f); Grade cSharpGrade = new Grade(student, cSharp, 3.975f); Grade algebraGrade = new Grade(student, algebra, 3.5f); Grade computerGrade = new Grade(student, computer, 3.0f); Session session = HibernateUtilities.getSessionFactory().openSession(); session.beginTransaction(); session.save(student); session.save(javaGrade); session.save(cSharpGrade); session.save(algebraGrade); session.save(computerGrade); session.getTransaction().commit(); session.close(); double result = GradebookBusinessLogic.calculateCumulativeGPA(student); System.out.println(student.getName() + " Cumulative Grade: " + result); System.out.println(instructor.getInstructorName() + ":" + rate4.getRate()); System.out.println(instructor2.getInstructorName() + ";" + rate3.getRate()); }
public String execute() { /////// Session // Bean///////////////////////////////////////////////////////////////////////////// SessionBean session = new SessionBean(); Users e = (Users) ActionContext.getContext().getSession().get("user"); if (e == null) { return ERROR; } if (e.getRole().equals("instructor")) { role = "instructor"; } else { role = "student"; } String email = e.getEmail(); l1 = session.getLecture(lectureID); this.description = l1.getLectureDescription(); this.title = l1.getLectureTitle(); media = l1.getMaterials(); List<Media> allQ = new ArrayList<Media>(); int j = 0; for (int i = 0; i < media.size(); i++) { j = 0; for (j = 0; j < allQ.size(); j++) { if (media.get(i).getPath().equals(allQ.get(j).getPath()) || media.get(i).getType().equals("empty")) { break; } } if (j == allQ.size()) { allQ.add(media.get(i)); } } media = allQ; downLoadFiles = new ArrayList<String>(); for (int i = 0; i < media.size(); i++) { if (media.get(i).getType().equals("mp4") || media.get(i).getType().equals(".mp4") || media.get(i).getType().equals("mpeg")) { videoPath = media.get(i).getPath(); } else { downLoadFiles.add(media.get(i).getPath()); } } videoPath = mediaLocation + videoPath; Comment = session.findCommentByLectureId(lectureID); int length = downLoadFiles.size(); if (length == 1) { } else { List<String> temp = new ArrayList<String>(); for (int i = 1; i < length; i++) { temp.add(downLoadFiles.get(i)); } downLoadFiles = temp; } if (role.equals("instructor")) { instructor = session.getInstructor(email); courses = session.findByInstructor(email); System.out.println(instructor.getFirstname() + " " + instructor.getLastname()); role = "instructor"; return "instructor"; } else { student = session.getStudent(email); courses = session.findByStudent(email); otherCourses = session.findOtherCoursesByStudent(email); System.out.println(student.getFirstname() + " " + student.getLastname()); role = "student"; return "student"; } }
public Option update(Instructor instructor, Option option, String messageOfOption) throws OptionFactoryException { return this.update(instructor.getId(), option.getId(), messageOfOption); }
public Option update(Instructor instructor, Option option, Integer reward) throws OptionFactoryException { return this.update(instructor.getId(), option.getId(), reward); }
public Option newInstance( Instructor instructor, Task task, String messageOfOption, Integer reward) throws OptionFactoryException { return this.newInstance(instructor.getId(), task.getId(), messageOfOption, reward); }