Exemple #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();
    }
  }
Exemple #2
0
  /**
   * This persists a Comment in this Android App. It does no checking to make sure that the comment
   * has not been added before. It assumes that the given issueKey must belong to an {@link Issue}
   * that has already been persisted in this Android App via {@link
   * IssuePersister#addCreatedIssue(Issue)}.
   *
   * @param issueKey The issue that this comment will be persisted against.
   * @param comment The comment to be saved.
   */
  public void addCreatedComment(String issueKey, Comment comment) {
    SQLiteDatabase db = issuePersisterDatabase.getWritableDatabase();

    String issueID = getIssueId(db, issueKey);
    if (issueID != null) {
      saveComment(db, issueID, comment);
    } else {
      Log.e(
          TAG,
          "We could not find the issue for the key '"
              + issueKey
              + "' in the JMC Database. Regretfully ignoring the comment made on the issue.");
    }
    db.close();
  }
Exemple #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();
 }