예제 #1
0
 public JarvisLink(
     final Long id,
     final LinkType linkType,
     final LinkDirection linkDirection,
     final JarvisIssueType type,
     Direction direction) {
   //        this.id = id;
   this.id = String.format("%d-%s", id, linkDirection.getIssueId());
   this.linkType = linkType;
   this.linkDirection = linkDirection;
   this.type = type;
   this.direction = direction;
 }
예제 #2
0
  public JiraMetricIssue(final Issue issue) {
    Preconditions.checkNotNull(issue, "Issue cannot be null...");
    this.issueKey = issue.getKey();
    this.summary = issue.getSummary();
    this.description = issue.getDescription();
    this.issueId = Long.valueOf(issue.getId());
    if (issue.getStatus() != null) {
      this.status = issue.getStatus().getName();
    }
    if (issue.getProject() != null) {
      this.projectKey = issue.getProject().getKey();
    }
    if (issue.getReporter() != null) {
      this.reporterName = issue.getReporter().getName();
    }
    if (issue.getAssignee() != null) {
      this.assigneeName = issue.getAssignee().getName();
    }
    if (issue.getResolution() != null) {
      this.resolution = issue.getResolution().getName();
    }
    this.creationDate = issue.getCreatedDate() != null ? issue.getCreatedDate().getTime() : 0;
    this.updateDate = issue.getUpdatedDate() != null ? issue.getUpdatedDate().getTime() : 0;
    this.dueDate = issue.getDueDate() != null ? issue.getDueDate().getTime() : 0;
    if (issue.getPriority() != null) {
      this.priority =
          issue.getPriority().getId() != null ? Long.valueOf(issue.getPriority().getId()) : 0L;
    }
    if (issue.getTimeTracking() != null) {
      this.originalEstimateMinutes = issue.getTimeTracking().getOriginalEstimateSeconds() / 60;
      this.remainingEstimateMinutes = issue.getTimeTracking().getRemainingEstimateSeconds() / 60;
      this.timeSpentMinutes = issue.getTimeTracking().getTimeSpentSeconds() / 60;
    }
    if (issue.getIssueType() != null) {
      IssueType jiraIssueType = issue.getIssueType();
      this.type = new JarvisIssueType(Long.valueOf(jiraIssueType.getId()), jiraIssueType.getName());
      this.typeId = Long.valueOf(jiraIssueType.getId());
      this.typeName = jiraIssueType.getName();
    }
    if (issue.getChangeLog() != null) {
      final List<JiraIssueChangelog> changelogList = Lists.newArrayList();
      final ChangeLog changeLog = issue.getChangeLog();

      for (final ChangeLogEntry changeLogEntry : changeLog.getEntries()) {
        for (final ChangeLogItem changeLogItem : changeLogEntry.getItems()) {
          ChangeCompositeKey changeCompositeKey =
              new ChangeCompositeKey(
                  Long.valueOf(changeLogEntry.getId()), changeLogEntry.getCreated().getTime());
          String issueKey = issue.getKey();
          Long issueId = Long.valueOf(issue.getId());
          String author =
              changeLogEntry.getAuthor() != null
                  ? changeLogEntry.getAuthor().getDisplayName()
                  : "Unknown";

          JiraIssueChangelog jiraIssueChangelog =
              new JiraIssueChangelog(
                  changeCompositeKey,
                  issueKey,
                  issueId,
                  author,
                  changeLogItem.getFieldType(),
                  changeLogItem.getField(),
                  changeLogItem.getFromString(),
                  changeLogItem.getToString(),
                  changeLogItem.getFrom(),
                  changeLogItem.getTo());
          changelogList.add(jiraIssueChangelog);
        }
      }
      this.changelogList = changelogList;
    }

    try {
      for (final WorkLog workLog : issue.getWorkLogs()) {
        IssueWorkLog issueWorkLog = new IssueWorkLog(workLog);
        this.issueWorkLogs.add(issueWorkLog);
      }

      for (final RemoteLink remoteLink : issue.getRemoteLinks()) {
        IssueRemoteLink issueRemoteLink =
            new IssueRemoteLink(
                remoteLink.getTitle(),
                remoteLink.getRemoteUrl(),
                String.format("%s-%s", remoteLink.getId(), this.issueId),
                remoteLink.getUrl());
        remoteLinks.add(issueRemoteLink);
      }

      for (final Component component : issue.getComponents()) {
        this.components.add(component.getName());
      }

      this.labels.addAll(issue.getLabels());
    } catch (Exception e) {
      // ignore
      e.printStackTrace();
    }

    if (issue.getIssueLinks() != null) {
      List<JarvisLink> jarvisIssueLinks = Lists.newArrayList();
      for (final IssueLink issueLink : issue.getIssueLinks()) {
        LinkDirection linkDirection = new LinkDirection();
        Issue linkedIssue = issueLink.getInwardIssue();
        JarvisLink.Direction direction = JarvisLink.Direction.INWARD;

        if (linkedIssue == null) {
          linkedIssue = issueLink.getOutwardIssue();
          direction = JarvisLink.Direction.OUTWARD;
        }

        linkDirection.setIssueId(Long.valueOf(linkedIssue.getId()));
        linkDirection.setIssueKey(linkedIssue.getKey());

        IssueType linkedIssueType = linkedIssue.getIssueType();

        net.rcarz.jiraclient.LinkType jiraLinkType = issueLink.getType();

        if (linkedIssueType != null && linkedIssueType != null) {
          LinkType linkType =
              new LinkType(
                  Long.valueOf(jiraLinkType.getId()),
                  jiraLinkType.getName(),
                  jiraLinkType.getInward(),
                  jiraLinkType.getOutward());

          JarvisIssueType jarvisIssueType =
              new JarvisIssueType(Long.valueOf(linkedIssueType.getId()), linkedIssueType.getName());

          JarvisLink jarvisLink =
              new JarvisLink(
                  Long.valueOf(issueLink.getId()),
                  linkType,
                  linkDirection,
                  jarvisIssueType,
                  direction);

          jarvisIssueLinks.add(jarvisLink);
        }
      }
      this.issueLinks = jarvisIssueLinks;
    }
  }