From bf5741b6251f97c742cd671a35cd960c7e93b830 Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Mon, 6 May 2024 18:20:00 -0400 Subject: [PATCH] fix(Unit Library): Fix tags returned in projects --- .../web/controllers/project/ProjectAPIController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/project/ProjectAPIController.java b/src/main/java/org/wise/portal/presentation/web/controllers/project/ProjectAPIController.java index 4a0b8bae9..e4a9c493f 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/project/ProjectAPIController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/project/ProjectAPIController.java @@ -18,6 +18,7 @@ import org.wise.portal.domain.project.Project; import org.wise.portal.domain.project.impl.ProjectImpl; import org.wise.portal.domain.user.User; +import org.wise.portal.domain.usertag.UserTag; import org.wise.portal.presentation.web.controllers.ControllerUtil; import org.wise.portal.service.portal.PortalService; import org.wise.portal.service.project.ProjectService; @@ -127,12 +128,20 @@ private JSONArray getProjectsWithTagsJSON(User user, List projectList) JSONArray projectsJSON = new JSONArray(); for (Project project : projectList) { JSONObject projectJSON = ControllerUtil.getProjectJSON(project); - projectJSON.put("tags", userTagsService.getTagsList(user, project)); + projectJSON.put("tags", convertTagsToJsonArray(userTagsService.getTagsList(user, project))); projectsJSON.put(projectJSON); } return projectsJSON; } + private JSONArray convertTagsToJsonArray(List tags) { + JSONArray tagsJSONArray = new JSONArray(); + for (UserTag tag : tags) { + tagsJSONArray.put(tag.toMap()); + } + return tagsJSONArray; + } + private JSONObject populateProjectMetadata(JSONObject projectLibraryGroup) throws JSONException { if (projectLibraryGroup.getString("type").equals("group")) { JSONArray children = projectLibraryGroup.getJSONArray("children");