public TurboIssue(String repoId, Issue issue) { this.id = issue.getNumber(); this.title = issue.getTitle() == null ? "" : issue.getTitle(); this.creator = issue.getUser().getLogin(); this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt()); this.isPullRequest = isPullRequest(issue); this.description = issue.getBody() == null ? "" : issue.getBody(); this.updatedAt = issue.getUpdatedAt() != null ? Utility.dateToLocalDateTime(issue.getUpdatedAt()) : this.createdAt; this.commentCount = issue.getComments(); this.isOpen = issue.getState().equals(STATE_OPEN); this.assignee = issue.getAssignee() == null ? Optional.empty() : Optional.of(issue.getAssignee().getLogin()); this.labels = issue.getLabels().stream().map(Label::getName).collect(Collectors.toList()); this.milestone = issue.getMilestone() == null ? Optional.empty() : Optional.of(issue.getMilestone().getNumber()); this.metadata = IssueMetadata.empty(); this.repoId = repoId; this.markedReadAt = Optional.empty(); }
/** * Create issue map for issue * * @param issue * @param newIssue * @return map */ protected Map<Object, Object> createIssueMap(Issue issue, boolean newIssue) { Map<Object, Object> params = new HashMap<Object, Object>(); if (issue != null) { params.put(FIELD_BODY, issue.getBody()); params.put(FIELD_TITLE, issue.getTitle()); User assignee = issue.getAssignee(); if (assignee != null) params.put(FILTER_ASSIGNEE, assignee.getName()); Milestone milestone = issue.getMilestone(); if (milestone != null) { int number = milestone.getNumber(); if (number > 0) params.put(FILTER_MILESTONE, Integer.toString(number)); else { if (!newIssue) params.put(FILTER_MILESTONE, null); } } List<Label> labels = issue.getLabels(); if (labels != null) { List<String> labelNames = new ArrayList<String>(labels.size()); for (Label label : labels) labelNames.add(label.getName()); params.put(FILTER_LABELS, labelNames); } } return params; }