Example #1
0
  /**
   * @param examId
   * @return
   */
  public Resources getExamResources(Exam exam) {
    Resources resources = new Resources();

    String query = "SELECT * FROM " + HLPResources.TABLE_NAME;
    query +=
        " LEFT JOIN "
            + HLPRelations.TABLE_NAME
            + "  ON ("
            + HLPResources.TABLE_NAME
            + "."
            + HLPResources.COL_ID
            + " = "
            + HLPRelations.COL_RES_ID
            + ")";
    query += " WHERE " + HLPRelations.COL_EXAM_ID + " = " + exam.getId();
    query += " AND " + HLPRelations.COL_SRCTABLE + " = '" + HLPExams.TABLE_NAME + "';";

    Log.i(DBsettings.LOG_TAG_TASKS, query);

    Cursor cursor = this.hlpExams.openCon().rawQuery(query, null);
    if (cursor != null) {
      resources.cursorToResourceList(cursor);
    } else {
      Log.w(DBsettings.LOG_TAG_EXAMS, "Cursor is NULL!!");
    }

    this.hlpExams.closeCon();

    return resources;
  }
Example #2
0
  /**
   * @param examId
   * @param date
   * @return
   */
  public boolean setExamDate(Exam exam, Date date) {
    boolean worked = false;

    Relation relation = this.dblRelations.getRelationByExamWithDateSet(exam);
    if (relation != null) {
      this.dblDates.deleteDate(relation.getDateId());
      this.dblRelations.deleteRelation(relation);
    }

    long dateId = this.dblDates.addDate(date);
    long relId =
        this.dblRelations.addRelation(
            new Relation(0, HLPExams.TABLE_NAME, 0, exam.getId(), 0, dateId, 0));

    if (dateId != -1 && relId != -1) worked = true;

    return worked;
  }
Example #3
0
  /**
   * @param exam
   * @return
   */
  public int updateExam(Exam exam) {
    ContentValues values = new ContentValues();

    if (!exam.getTitle().isEmpty()) {
      values.put(HLPExams.COL_TITLE, exam.getTitle());
    }

    if (!exam.getComment().isEmpty()) {
      values.put(HLPExams.COL_COMMENT, exam.getComment());
    }

    if (exam.getLecture_id() > 0) {
      values.put(HLPExams.COL_LECTURE_ID, exam.getLecture_id());
    }

    int ret =
        this.hlpExams.openCon().update(HLPExams.TABLE_NAME, values, "_id = " + exam.getId(), null);

    Log.i(DBsettings.LOG_TAG_EXAMS, "Update res.: " + ret);

    return ret;
  }
Example #4
0
 /**
  * @param exam
  * @return
  */
 public int deleteExam(Exam exam) {
   return this.deleteExam(exam.getId());
 }