Skip to content

Commit

Permalink
api: Include milestones when export
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Nov 20, 2016
1 parent 3c501e6 commit 88026f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/MigrationApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static Result exportIssues(String owner, String projectName){
return ok(exportData);
}

private static ObjectNode composeMilestoneJson(Milestone m) {
public static ObjectNode composeMilestoneJson(Milestone m) {
ObjectNode node = Json.newObject();
node.put("id", m.id);
node.put("title", m.title);
Expand Down Expand Up @@ -381,6 +381,7 @@ public static List<ObjectNode> composePlainCommentsJson(AbstractPosting posting,
List<ObjectNode> comments = new ArrayList<>();
for (Comment comment : posting.getComments()) {
ObjectNode commentNode = Json.newObject();
commentNode.put("id", comment.id);
commentNode.put("type", comment.asResource().getType().toString());
commentNode.put("authorId", comment.authorLoginId);
commentNode.put("authorName", comment.authorName);
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/api/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import controllers.MigrationApp;
import controllers.annotation.AnonymousCheck;
import controllers.annotation.IsAllowed;
import models.*;
import models.enumeration.Operation;
Expand Down Expand Up @@ -41,6 +43,8 @@ public static Result exports(String owner, String projectName) {
json.put("milestoneCount", project.milestones.size());
json.put("issues", composePosts(project, Issue.finder));
json.put("posts", composePosts(project, Posting.finder));
json.put("milestones", toJson(project.milestones.stream()
.map(MigrationApp::composeMilestoneJson).collect(Collectors.toList())));
return ok(json);
}

Expand All @@ -54,6 +58,7 @@ private static <T> JsonNode composePosts(Project project, Model.Finder<Long, T>

private static ObjectNode getResult(AbstractPosting posting) {
ObjectNode json = Json.newObject();
json.put("id", posting.getNumber());
json.put("title", posting.title);
json.put("type", posting.asResource().getType().toString());
json.put("author", posting.authorLoginId);
Expand All @@ -63,6 +68,8 @@ private static ObjectNode getResult(AbstractPosting posting) {

if(posting.asResource().getType() == ResourceType.ISSUE_POST){
Optional.ofNullable(((Issue)posting).assignee).ifPresent(assignee -> json.put("assignee", assignee.user.loginId));
Optional.ofNullable(((Issue)posting).milestone).ifPresent(milestone -> json.put("milestone", milestone.title));
Optional.ofNullable(((Issue)posting).milestone).ifPresent(milestone -> json.put("milestoneId", milestone.id));
}
List<Attachment> attachments = Attachment.findByContainer(posting.asResource());
if(attachments.size() > 0) {
Expand Down

0 comments on commit 88026f1

Please sign in to comment.