Skip to content

Commit

Permalink
4.8.4 bug fixes v2 (#68)
Browse files Browse the repository at this point in the history
* Fix for parsing issue while creating batch
  • Loading branch information
karthik-tarento authored Aug 25, 2023
1 parent 9eeac62 commit 4817531
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ public void setStartDate(Date startDate) {
this.startDate = startDate;
}

public int getStatus() {
public Integer getStatus() {
return status;
}

public void setStatus(int status) {
public void setStatus(Integer status) {
this.status = status;
}

Expand Down Expand Up @@ -222,15 +222,15 @@ public Map<String, Object> getBatchAttributes() {
return batchAttributes;
}

public void setBatchAttributes(Map<String, Object> batchAttributes) {
this.batchAttributes = batchAttributes;
}

public void setBatchAttributes(String batchAttributesStr) {
public void setBatchAttributes(Object batchAttributesObj) {
try {
this.batchAttributes = (new ObjectMapper()).readValue(batchAttributesStr,
if(batchAttributesObj instanceof String) {
this.batchAttributes = (new ObjectMapper()).readValue((String) batchAttributesObj,
new TypeReference<Map<String, Object>>() {
});
} else if (batchAttributesObj instanceof Map) {
this.batchAttributes = (Map<String,Object>) batchAttributesObj;
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void createCourseBatch(Request actorMessage) throws Throwable {
ProjectUtil.formatMessage(
ResponseCode.invalidRequestParameter.getErrorMessage(), PARTICIPANTS));
}
CourseBatch courseBatch = JsonUtil.convert(request, CourseBatch.class);
CourseBatch courseBatch = JsonUtil.convertFromString(request, CourseBatch.class);
courseBatch.setStatus(setCourseBatchStatus(actorMessage.getRequestContext(), (String) request.get(JsonKey.START_DATE)));
String courseId = (String) request.get(JsonKey.COURSE_ID);
Map<String, Object> contentDetails = getContentDetails(actorMessage.getRequestContext(),courseId, headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public static <T> T convertWithDateFormat(Object value, Class<T> clazz, SimpleDa
mapperWithDateFormat.setDateFormat(dateFormat);
return mapperWithDateFormat.convertValue(value, clazz);
}

public static <T> T convertFromString(Object value, Class<T> clazz) throws Exception {
String strValue = mapper.writeValueAsString(value);
return deserialize(strValue, clazz);
}
}

0 comments on commit 4817531

Please sign in to comment.