Esempio n. 1
0
 public static IssueChangeDto of(String issueKey, FieldDiffs diffs) {
   IssueChangeDto dto = newDto(issueKey);
   dto.setChangeType(IssueChangeDto.TYPE_FIELD_CHANGE);
   dto.setChangeData(diffs.toString());
   dto.setUserLogin(diffs.userLogin());
   return dto;
 }
Esempio n. 2
0
  private void writeChangelog(Issue issue, JsonWriter json) {
    json.name("changelog")
        .beginArray()
        .beginObject()
        .prop("creationDate", DateUtils.formatDateTime(issue.creationDate()))
        .prop("fCreationDate", formatDate(issue.creationDate()))
        .name("diffs")
        .beginArray()
        .value(i18n.message(UserSession.get().locale(), "created", null))
        .endArray()
        .endObject();

    IssueChangelog changelog = issueChangelogService.changelog(issue);
    for (FieldDiffs diffs : changelog.changes()) {
      String userLogin = diffs.userLogin();
      json.beginObject()
          .prop("userName", userLogin != null ? changelog.user(diffs).name() : null)
          .prop("creationDate", DateUtils.formatDateTime(diffs.creationDate()))
          .prop("fCreationDate", formatDate(diffs.creationDate()));
      json.name("diffs").beginArray();
      List<String> diffsFormatted = issueChangelogService.formatDiffs(diffs);
      for (String diff : diffsFormatted) {
        json.value(diff);
      }
      json.endArray();
      json.endObject();
    }
    json.endArray();
  }
Esempio n. 3
0
 public FieldDiffs toFieldDiffs() {
   return FieldDiffs.parse(changeData)
       .setUserLogin(userLogin)
       .setCreatedAt(createdAt)
       .setUpdatedAt(updatedAt)
       .setIssueKey(issueKey);
 }
 public IssueChangeNotification setIssue(DefaultIssue issue) {
   setFieldValue("key", issue.key());
   setFieldValue("reporter", issue.reporter());
   setFieldValue("assignee", issue.assignee());
   setFieldValue("message", issue.message());
   setFieldValue("componentKey", issue.componentKey());
   FieldDiffs currentChange = issue.currentChange();
   if (currentChange != null) {
     for (Map.Entry<String, FieldDiffs.Diff> entry : currentChange.diffs().entrySet()) {
       String type = entry.getKey();
       FieldDiffs.Diff diff = entry.getValue();
       setFieldValue("old." + type, neverEmptySerializableToString(diff.oldValue()));
       setFieldValue("new." + type, neverEmptySerializableToString(diff.newValue()));
     }
   }
   return this;
 }
Esempio n. 5
0
 public static FieldDiffs parse(@Nullable String s) {
   FieldDiffs diffs = new FieldDiffs();
   if (!Strings.isNullOrEmpty(s)) {
     Iterable<String> fields = FIELDS_SPLITTER.split(s);
     for (String field : fields) {
       String[] keyValues = field.split("=");
       if (keyValues.length == 2) {
         String[] values = keyValues[1].split("\\|");
         String oldValue = "";
         String newValue = "";
         if (values.length > 0) {
           oldValue = Strings.nullToEmpty(values[0]);
         }
         if (values.length > 1) {
           newValue = Strings.nullToEmpty(values[1]);
         }
         diffs.setDiff(keyValues[0], oldValue, newValue);
       }
     }
   }
   return diffs;
 }