Skip to content

Commit 88026f1

Browse files
committed
api: Include milestones when export
1 parent 3c501e6 commit 88026f1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/controllers/MigrationApp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public static Result exportIssues(String owner, String projectName){
210210
return ok(exportData);
211211
}
212212

213-
private static ObjectNode composeMilestoneJson(Milestone m) {
213+
public static ObjectNode composeMilestoneJson(Milestone m) {
214214
ObjectNode node = Json.newObject();
215215
node.put("id", m.id);
216216
node.put("title", m.title);
@@ -381,6 +381,7 @@ public static List<ObjectNode> composePlainCommentsJson(AbstractPosting posting,
381381
List<ObjectNode> comments = new ArrayList<>();
382382
for (Comment comment : posting.getComments()) {
383383
ObjectNode commentNode = Json.newObject();
384+
commentNode.put("id", comment.id);
384385
commentNode.put("type", comment.asResource().getType().toString());
385386
commentNode.put("authorId", comment.authorLoginId);
386387
commentNode.put("authorName", comment.authorName);

app/controllers/api/ProjectApi.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.fasterxml.jackson.databind.JsonNode;
1010
import com.fasterxml.jackson.databind.node.ObjectNode;
11+
import controllers.MigrationApp;
12+
import controllers.annotation.AnonymousCheck;
1113
import controllers.annotation.IsAllowed;
1214
import models.*;
1315
import models.enumeration.Operation;
@@ -41,6 +43,8 @@ public static Result exports(String owner, String projectName) {
4143
json.put("milestoneCount", project.milestones.size());
4244
json.put("issues", composePosts(project, Issue.finder));
4345
json.put("posts", composePosts(project, Posting.finder));
46+
json.put("milestones", toJson(project.milestones.stream()
47+
.map(MigrationApp::composeMilestoneJson).collect(Collectors.toList())));
4448
return ok(json);
4549
}
4650

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

5559
private static ObjectNode getResult(AbstractPosting posting) {
5660
ObjectNode json = Json.newObject();
61+
json.put("id", posting.getNumber());
5762
json.put("title", posting.title);
5863
json.put("type", posting.asResource().getType().toString());
5964
json.put("author", posting.authorLoginId);
@@ -63,6 +68,8 @@ private static ObjectNode getResult(AbstractPosting posting) {
6368

6469
if(posting.asResource().getType() == ResourceType.ISSUE_POST){
6570
Optional.ofNullable(((Issue)posting).assignee).ifPresent(assignee -> json.put("assignee", assignee.user.loginId));
71+
Optional.ofNullable(((Issue)posting).milestone).ifPresent(milestone -> json.put("milestone", milestone.title));
72+
Optional.ofNullable(((Issue)posting).milestone).ifPresent(milestone -> json.put("milestoneId", milestone.id));
6673
}
6774
List<Attachment> attachments = Attachment.findByContainer(posting.asResource());
6875
if(attachments.size() > 0) {

0 commit comments

Comments
 (0)