From 4faef69e314efdbe400fada9e2be1a32a3c8b518 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Thu, 9 Jan 2025 11:13:20 -0800 Subject: [PATCH] feat(ProjectMetadata): Add researchProjects field --- .../project/impl/ProjectMetadataImpl.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/wise/portal/domain/project/impl/ProjectMetadataImpl.java b/src/main/java/org/wise/portal/domain/project/impl/ProjectMetadataImpl.java index c094987c19..84dd36156d 100644 --- a/src/main/java/org/wise/portal/domain/project/impl/ProjectMetadataImpl.java +++ b/src/main/java/org/wise/portal/domain/project/impl/ProjectMetadataImpl.java @@ -125,7 +125,7 @@ public class ProjectMetadataImpl implements ProjectMetadata, Serializable { @Column(name = "tools", length = 32768, columnDefinition = "text") @Getter @Setter - private String tools; // text (blob) 2^15 + private String tools; // text (blob) 2^15 @Column(name = "lesson_plan", length = 5120000, columnDefinition = "mediumtext") @Getter @@ -200,6 +200,10 @@ public class ProjectMetadataImpl implements ProjectMetadata, Serializable { @Setter private String navMode; + @Getter + @Setter + private String researchProjects; + public ProjectMetadataImpl() { } @@ -236,6 +240,12 @@ public void populateFromJSON(JSONObject metadataJSON) { } setAuthors(authors.toString()); + JSONArray researchProjects = metadataJSON.optJSONArray("researchProjects"); + if (researchProjects == null) { + researchProjects = new JSONArray(); + } + setResearchProjects(researchProjects.toString()); + JSONArray parentProjects = metadataJSON.optJSONArray("parentProjects"); if (parentProjects == null) { parentProjects = new JSONArray(); @@ -372,7 +382,8 @@ public String getTechDetailsString() { if (techReqs != null && !techReqs.equals("") && !techReqs.equals("null")) { try { JSONObject techReqsJSON = new JSONObject(techReqs); - if (techReqsJSON.has("java") && (techReqsJSON.getString("java").equals("checked") || techReqsJSON.getString("java").equals("true"))) { + if (techReqsJSON.has("java") && (techReqsJSON.getString("java").equals("checked") + || techReqsJSON.getString("java").equals("true"))) { techReqsAndDetailsStringBuf.append("Java"); } @@ -383,14 +394,16 @@ public String getTechDetailsString() { techReqsAndDetailsStringBuf.append("Flash"); } - if (techReqsJSON.has("quickTime") && (techReqsJSON.getString("quickTime").equals("checked") || techReqsJSON.getString("quickTime").equals("true"))) { + if (techReqsJSON.has("quickTime") && (techReqsJSON.getString("quickTime").equals("checked") + || techReqsJSON.getString("quickTime").equals("true"))) { if (techReqsAndDetailsStringBuf.length() != 0) { techReqsAndDetailsStringBuf.append(", "); } techReqsAndDetailsStringBuf.append("QuickTime"); } - if (techReqsJSON.has("techDetails") && techReqsJSON.getString("techDetails") != null && !techReqsJSON.getString("techDetails").equals("")) { + if (techReqsJSON.has("techDetails") && techReqsJSON.getString("techDetails") != null + && !techReqsJSON.getString("techDetails").equals("")) { if (techReqsAndDetailsStringBuf.length() != 0) { techReqsAndDetailsStringBuf.append(", "); } @@ -458,6 +471,14 @@ public String toJSONString() { metadata.put("parentProjects", new JSONArray()); } + String researchProjectsString = metadata.getString("researchProjects"); + if (researchProjectsString != null && researchProjectsString != "null") { + JSONArray researchProjectsJSON = new JSONArray(researchProjectsString); + metadata.put("researchProjects", researchProjectsJSON); + } else { + metadata.put("researchProjects", new JSONArray()); + } + } catch (JSONException e) { e.printStackTrace(); }