예제 #1
0
 public void formatAndSaveScoreById(String semesterName, String scoreStr, int accountId) {
   // 2012-07-10 basilwang delete the related scores of the seleced
   // semester value
   if (scoreStr == null) {
     return;
   }
   delete(accountId, semesterName);
   ScoreConfig scoreConfig = getScoreConfig();
   Pattern trPattern = Pattern.compile(scoreConfig.getTr());
   Matcher matcher;
   matcher = trPattern.matcher(scoreStr);
   Matcher tdMatcher = null;
   matcher.find();
   while (matcher.find()) {
     String tr = matcher.group();
     Pattern tdPattern = Pattern.compile(scoreConfig.getTd());
     tdMatcher = tdPattern.matcher(tr);
     Score score = new Score(semesterName);
     score.setMyid(accountId);
     List<ScoreConfigInTD> scoreConfigIntds = scoreConfig.getScoreConfigintds();
     for (ScoreConfigInTD scoreConfigIntd : scoreConfigIntds) {
       tdMatcher.find();
       if (scoreConfigIntd.getDbfield() == null) {
         continue;
       }
       score.setter(scoreConfigIntd.getDbfield(), tdMatcher.group(1));
     }
     save(score);
   }
 }
예제 #2
0
 public List<Score> getScores(String semesterName, int myid) {
   String sql = constructSQL();
   String[] bindArgs = {String.valueOf(myid), getSemesterId(semesterName)};
   Cursor result = daoHelper.query(sql, bindArgs);
   List<Score> list = new ArrayList<Score>();
   while (result.moveToNext()) {
     Score score = new Score();
     for (int i = 1; i < indexs.length; i++) {
       String value = result.getString(i);
       score.setter(indexs[i], value);
     }
     list.add(score);
   }
   daoHelper.closeDB();
   return list;
 }
예제 #3
0
  public void save(Score score) {

    String sql =
        "INSERT INTO Scores (coursename,coursecode,coursetype,coursebelongto,scorelevel,scorepoint,score,secondmajorflag,secondscore,thirdscore,department,memo,isthirdscore,myid,semesterid) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    Object[] bindArgs = {
      score.getCourseName(),
      score.getCourseCode(),
      score.getCourseType(),
      score.getCourseBelongTo(),
      score.getScoreLevel(),
      score.getScorePoint(),
      score.getScore(),
      score.getSecondMajorFlag(),
      score.getSecondScore(),
      score.getThirdScore(),
      score.getDepartment(),
      score.getMemo(),
      score.getIsthirdscore(),
      score.getMyid(),
      getSemesterId(score.getSemesterName())
    };
    daoHelper.insert(sql, bindArgs);
  }