Example #1
0
  public void updateUsingIssuesWithComments(IssuesWithComments issuesWithComments) {
    SQLiteDatabase db = issuePersisterDatabase.getWritableDatabase();
    if (db != null) {
      for (Issue issue : issuesWithComments.issues()) {
        String issueID = getIssueId(db, issue.getKey());
        if (issueID == null) {
          saveIssue(db, issue);
          issueID = getIssueId(db, issue.getKey());
          if (issueID == null) {
            Log.e(
                TAG,
                "Created an issue and it still did not exist after I created it. Aborting and reporting error.");
            // TODO Perform CONNECT-173 here
          }
        }

        if (issueID != null && issue.getComments() != null) {
          for (Comment comment : issue.getComments()) {
            if (!commentExists(db, comment)) saveComment(db, issueID, comment);
          }
        }
      }
      db.close();
    }
  }
Example #2
0
 private void saveIssue(SQLiteDatabase db, Issue issue) {
   ContentValues values = new ContentValues(7);
   values.put("key", issue.getKey());
   values.put("title", issue.getTitle());
   values.put("status", issue.getStatus());
   values.put("description", issue.getDescription());
   DateFormat dateFormat = new SimpleDateFormat(dateFormatString, Locale.US);
   values.put("dateUpdated", dateFormat.format(issue.getDateUpdated()));
   values.put("hasUpdates", Boolean.FALSE);
   values.put("isCrashReport", Boolean.TRUE);
   db.insert(IssuePersisterDatabase.ISSUES_TABLE_NAME, null, values);
 }
Example #3
0
 /**
  * This function adds an issue to persistent storage and also performs duplicate checking to make
  * sure that it does not overwrite anything.
  *
  * @param issue The issue that you wish to persist in this Android Application.
  */
 public void addCreatedIssue(Issue issue) {
   SQLiteDatabase db = issuePersisterDatabase.getWritableDatabase();
   if (issueKeyExists(db, issue.getKey())) {
     Log.i(
         TAG,
         "This issue has already been added to the local JMC Database before. Ignoring the addition of '"
             + issue.getKey()
             + "'.");
   } else {
     saveIssue(db, issue);
     List<Comment> issueComments = issue.getComments();
     if (issueComments != null) {
       String issueId = getIssueId(db, issue.getKey());
       for (Comment comment : issue.getComments()) {
         saveComment(db, issueId, comment);
       }
     }
   }
   if (db != null) db.close();
 }