public static PullRequest toPullRequest(JsonObject pullRequest) { JsonObject head = (JsonObject) pullRequest.get("head"); String url = pullRequest.getString("url"); int prNumber = pullRequest.getInteger("number"); PullRequest openPullRequest = new PullRequest(); openPullRequest.setRef(head.getString("ref")); openPullRequest.setSha(head.getString("sha")); openPullRequest.setNumber(prNumber); openPullRequest.setUrl(url); return openPullRequest; }
public static StashTask extractTask(JsonObject jsonTask) { long taskId = getLong(jsonTask, "id"); String taskText = (String)jsonTask.get("text"); String taskState = (String)jsonTask.get("state"); boolean deletable = true; JsonObject objPermission = (JsonObject)jsonTask.get("permittedOperations"); if (objPermission != null) { deletable = (boolean)objPermission.get("deletable"); } return new StashTask(taskId, taskText, taskState, deletable); }
public static PullRequest toPullRequest(JsonObject pullRequest) { JsonObject head = (JsonObject) pullRequest.get("head"); String url = pullRequest.getString("url"); int prNumber = pullRequest.getInteger("number"); PullRequest openPullRequest = new PullRequest(); openPullRequest.setRef(head.getString("ref")); openPullRequest.setSha(head.getString("sha")); openPullRequest.setNumber(prNumber); openPullRequest.setUrl(url); return openPullRequest; }
/** * Parses GitHub JsonObject in accordance to the API (https://developer.github.com/v3/issues/) */ static Improvement toImprovement(JsonObject issue) { BigDecimal id = (BigDecimal) issue.get("number"); String issueUrl = (String) issue.get("html_url"); String title = (String) issue.get("title"); boolean isPullRequest = issue.get("pull_request") != null; Collection<String> labels = extractLabels(issue); return new DefaultImprovement(id.longValue(), title, issueUrl, labels, isPullRequest); }
/** * Parses GitHub JsonObject in accordance to the API (https://developer.github.com/v3/issues/) */ static Improvement toImprovement(JsonObject issue) { BigDecimal id = (BigDecimal) issue.get("number"); String issueUrl = (String) issue.get("html_url"); String title = (String) issue.get("title"); boolean isPullRequest = issue.get("pull_request") != null; Collection<String> labels = extractLabels(issue); return new DefaultImprovement(id.longValue(), title, issueUrl, labels, isPullRequest); }
/** * Parses GitHub JsonObject in accordance to the API (https://developer.github.com/v3/issues/) */ static Improvement toImprovement(JsonObject issue) { BigDecimal id = (BigDecimal) issue.get("number"); String issueUrl = (String) issue.get("html_url"); String title = (String) issue.get("title"); boolean isPullRequest = issue.get("pull_request") != null; Collection<String> labels = extractLabels(issue); return new DefaultImprovement(id.longValue(), title, issueUrl, labels, isPullRequest); }
private Queue<Long> dropTicketsAboveMaxInPage(Queue<Long> tickets, List<JsonObject> page) { if (page.isEmpty()) { return tickets; } BigDecimal highestId = (BigDecimal) page.get(0).get("number"); while (!tickets.isEmpty() && tickets.peek() > highestId.longValue()) { tickets.poll(); } return tickets; }
private Queue<Long> dropTicketsAboveMaxInPage(Queue<Long> tickets, List<JsonObject> page) { if (page.isEmpty()) { return tickets; } BigDecimal highestId = (BigDecimal) page.get(0).get("number"); while (!tickets.isEmpty() && tickets.peek() > highestId.longValue()) { tickets.poll(); } return tickets; }
private Queue<Long> dropTicketsAboveMaxInPage(Queue<Long> tickets, List<JsonObject> page) { if (page.isEmpty()) { return tickets; } BigDecimal highestId = (BigDecimal) page.get(0).get("number"); while (!tickets.isEmpty() && tickets.peek() > highestId.longValue()) { tickets.poll(); } return tickets; }
public static long getNextPageStart(JsonObject jsonObject) { if (jsonObject.get("nextPageStart") != null) { return getLong(jsonObject,"nextPageStart"); } return 0; }
public static StashComment extractComment(JsonObject jsonComment) { JsonObject jsonAnchor = (JsonObject)jsonComment.get("anchor"); if (jsonAnchor == null) { throw new StashReportExtractionException("JSON Comment does not contain any \"anchor\" tag" + " to describe comment \"line\" and \"path\""); } String path = (String)jsonAnchor.get("path"); // can be null if comment is attached to the global file Long line = getLong(jsonAnchor, "line"); return extractComment(jsonComment, path, line); }
@Override public ProjectContributor apply(JsonObject contributor) { String url = (String) contributor.get("url"); JsonObject user; try { user = objectFetcher.getPage(url); } catch (Exception e) { throw new RuntimeException("Error occurred while fetching contributor using " + url + "!", e); } return GitHubAllContributorsJson.toContributor(contributor, user); } }
@Override public ProjectContributor apply(JsonObject contributor) { String url = (String) contributor.get("url"); JsonObject user; try { user = objectFetcher.getPage(url); } catch (Exception e) { throw new RuntimeException("Error occurred while fetching contributor using " + url + "!", e); } return GitHubAllContributorsJson.toContributor(contributor, user); } }
private static StashComment buildCommentFromJSON(JsonObject jsonLineComment, StashDiff diff) { long lineCommentId = getLong(jsonLineComment, "id"); String lineCommentMessage = (String)jsonLineComment.get("text"); long lineCommentVersion = getLong(jsonLineComment, VERSION); JsonObject objAuthor = (JsonObject)jsonLineComment.get(AUTHOR); if (objAuthor == null) { return null; } StashUser author = extractUser(objAuthor); return new StashComment(lineCommentId, lineCommentMessage, diff.getPath(), diff.getDestination(), author, lineCommentVersion); }
public static StashCommentReport extractComments(JsonObject jsonComments) { StashCommentReport result = new StashCommentReport(); JsonArray jsonValues = (JsonArray)jsonComments.get("values"); if (jsonValues != null) { for (Object obj : jsonValues.toArray()) { JsonObject jsonComment = (JsonObject)obj; StashComment comment = extractComment(jsonComment); result.add(comment); } } return result; }