From 0c51c7eb5d578d2d57af7a60e208e04eaa36a056 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 23 Sep 2024 14:59:44 -0700 Subject: [PATCH 1/2] GRAD2-2934: task is completed. GRAD2-2934: task is completed. --- .../educ/api/gradstudent/service/DataConversionService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java index 4ed1793a..571f552b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java @@ -36,6 +36,7 @@ @Service public class DataConversionService { + public static final String NULL_VALUE = "NULL"; // NULL String => Nullify (set to NULL) private static final String CREATE_USER = "createUser"; private static final String CREATE_DATE = "createDate"; public static final String DEFAULT_CREATED_BY = "DATA_CONV"; @@ -296,7 +297,7 @@ private void handleStudentAchievements(String currentProgram, String newProgram, } private void resetAdultStartDate(String currentProgram, String newProgram, GraduationStudentRecordEntity targetObject) { - // Only when 1950 adult program is channged to another, reset adultStartDate to null + // Only when 1950 adult program is changed to another, reset adultStartDate to null if (!StringUtils.equalsIgnoreCase(currentProgram, newProgram) && "1950".equalsIgnoreCase(currentProgram)) { targetObject.setAdultStartDate(null); } @@ -350,7 +351,8 @@ private void populate(OngoingUpdateFieldDTO field, GraduationStudentRecordEntity private String getStringValue(Object value) { if (value == null) return null; - return (String) value; + String str = (String) value; + return NULL_VALUE.equalsIgnoreCase(str)? null : str; } private StudentOptionalProgramEntity handleExistingOptionalProgram(StudentOptionalProgramRequestDTO studentOptionalProgramReq, StudentOptionalProgramEntity gradEntity) { From 80603dd50b3572889ce999560d72de10cc5375e0 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 24 Sep 2024 14:21:13 -0700 Subject: [PATCH 2/2] Enhancement is done after code review. Enhancement is done after code review. --- .../api/gradstudent/service/DataConversionService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java index 571f552b..44577049 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java @@ -349,10 +349,10 @@ private void populate(OngoingUpdateFieldDTO field, GraduationStudentRecordEntity } private String getStringValue(Object value) { - if (value == null) - return null; - String str = (String) value; - return NULL_VALUE.equalsIgnoreCase(str)? null : str; + if (value instanceof String str) { + return NULL_VALUE.equalsIgnoreCase(str) ? null : str; + } + return null; } private StudentOptionalProgramEntity handleExistingOptionalProgram(StudentOptionalProgramRequestDTO studentOptionalProgramReq, StudentOptionalProgramEntity gradEntity) {