コード例 #1
0
  public List<Course> getCoursesTakingFull() {
    List<Course> courses = new ArrayList<Course>();
    List<Course> taking = this.getCoursesTaking("");

    for (Course course_ : taking) {
      course_ = getCourse(course_.getKey());

      courses.add(course_);
    }

    return courses;
  }
コード例 #2
0
  private List<Course> processCourses(Cursor c) {
    List<Course> courses = new ArrayList<Course>();

    try {
      if (c.moveToFirst()) {
        do {
          Course course = new Course(c.getString(c.getColumnIndex("key")));
          course.setTitle(c.getString(c.getColumnIndex("title")));

          courses.add(course);
        } while (c.moveToNext());
      }
    } catch (Exception e) {
      Log.d("DataProvider", "Error processing courses: " + e.getMessage());
    }

    c.close();

    return courses;
  }
コード例 #3
0
  private boolean doClashesOccur(String id) {
    // we want to take this course
    Course course = getCourse(id);

    boolean ok = true;

    List<Course> taking = getCoursesTakingFull();

    for (Course course_ : taking) {
      // different semester
      if (course.isFirstSemester() && course_.isSecondSemester()) continue;

      // check for events clashes
      for (Event event1 : course.getEvents()) {
        for (Event event2 : course_.getEvents()) {
          if (event1.getStartInt() == event2.getStartInt()) {
            ok = false;
          }
        }
      }
    }

    return ok;
  }
コード例 #4
0
  public Course getCourse(String id) {
    Cursor cursor = dbadapter.getCourse(id);

    Course course = new Course(cursor.getString(cursor.getColumnIndex("key")));

    course.setTitle(cursor.getString(cursor.getColumnIndex("title")));
    course.setLevel(cursor.getString(cursor.getColumnIndex("level")));
    course.setSCQFLevel(cursor.getString(cursor.getColumnIndex("scqf_level")));
    course.setAcronym(cursor.getString(cursor.getColumnIndex("acronym")));
    course.setNormalYear(cursor.getString(cursor.getColumnIndex("normal_year")));
    course.setVisitorsOnly(cursor.getString(cursor.getColumnIndex("visitors_only")));
    course.setBlocks(cursor.getString(cursor.getColumnIndex("blocks")));
    course.setCO(cursor.getString(cursor.getColumnIndex("co")));
    course.setSY(cursor.getString(cursor.getColumnIndex("sy")));
    course.setFirstMeet(cursor.getString(cursor.getColumnIndex("first_meet")));
    course.setLocation(cursor.getString(cursor.getColumnIndex("location")));
    course.setSpecialArrangements(cursor.getString(cursor.getColumnIndex("special_arrangements")));

    course.setEvents(
        cursor.getString(cursor.getColumnIndex("start")),
        cursor.getString(cursor.getColumnIndex("end")),
        cursor.getString(cursor.getColumnIndex("alts")),
        cursor.getString(cursor.getColumnIndex("sites")));

    course.setOptions(cursor.getString(cursor.getColumnIndex("options")));

    Cursor cursor_ = dbadapter.getCollege(cursor.getString(cursor.getColumnIndex("college")));

    if (cursor_.getCount() > 0)
      course.setCollege(
          new College(
              cursor_.getString(cursor_.getColumnIndex("key")),
              cursor_.getString(cursor_.getColumnIndex("name"))));

    cursor_.close();
    cursor_ = dbadapter.getSchool(cursor.getString(cursor.getColumnIndex("school")));

    if (cursor_.getCount() > 0)
      course.setSchool(
          new School(
              cursor_.getString(cursor_.getColumnIndex("key")),
              cursor_.getString(cursor_.getColumnIndex("name"))));

    cursor_.close();
    cursor_ = dbadapter.getSubjectArea(cursor.getString(cursor.getColumnIndex("subject_area")));

    if (cursor_.getCount() > 0)
      course.setSubjectArea(
          new SubjectArea(
              cursor_.getString(cursor_.getColumnIndex("key")),
              cursor_.getString(cursor_.getColumnIndex("name"))));

    cursor_.close();

    cursor.close();

    return course;
  }