Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -567,7 +568,7 @@ private void updateCourseBatchDate(CourseBatch courseBatch, Map<String, Object>
? (String) req.get(JsonKey.START_DATE)
: courseBatch.getStartDate());
courseBatch.setEndDate(
requestedEndDate != null ? (String) req.get(JsonKey.END_DATE) : courseBatch.getEndDate());
requestedEndDate != null ? null : courseBatch.getEndDate());
courseBatch.setEnrollmentEndDate(
requestedEnrollmentEndDate == null ? null : (String) req.get(JsonKey.ENROLLMENT_END_DATE));
}
Expand Down Expand Up @@ -697,7 +698,17 @@ private Date getDate(String key, SimpleDateFormat format, Map<String, Object> ma
return format.parse(format.format(new Date()));
} else {
if (StringUtils.isNotBlank((String) map.get(key))) {
return format.parse((String) map.get(key));
Date d = format.parse((String) map.get(key));
if (key.equals(JsonKey.END_DATE) || key.equals(JsonKey.ENROLLMENT_END_DATE)) {
Calendar cal =
Calendar.getInstance(
TimeZone.getTimeZone(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_TIMEZONE)));
cal.setTime(d);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
return cal.getTime();
}
return d;
} else {
return null;
}
Expand Down Expand Up @@ -751,7 +762,8 @@ private void validateBatchEnrollmentEndDate(
ResponseCode.enrollmentEndDateEndError.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
if (requestedEnrollmentEndDate != null && requestedEnrollmentEndDate.before(todayDate)) {
if (requestedEnrollmentEndDate != null && !requestedEnrollmentEndDate.equals(existingEnrollmentEndDate)
&& requestedEnrollmentEndDate.before(todayDate)) {
throw new ProjectCommonException(
ResponseCode.enrollmentEndDateUpdateError.getErrorCode(),
ResponseCode.enrollmentEndDateUpdateError.getErrorMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void enrollCourseBatch(Request actorMessage) {
courseBatchDao.readById(
(String) courseMap.get(JsonKey.COURSE_ID), (String) courseMap.get(JsonKey.BATCH_ID));
validateCourseBatch(
courseBatch, courseMap, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY));
courseBatch, courseMap, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY), ActorOperations.ENROLL_COURSE.getValue());

UserCourses userCourseResult =
userCourseDao.read(
Expand Down Expand Up @@ -161,7 +161,7 @@ private void unenrollCourseBatch(Request actorMessage) {
courseBatchDao.readById(
(String) request.get(JsonKey.COURSE_ID), (String) request.get(JsonKey.BATCH_ID));
validateCourseBatch(
courseBatch, request, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY));
courseBatch, request, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY), ActorOperations.UNENROLL_COURSE.getValue());
UserCourses userCourseResult =
userCourseDao.read(
(String) request.get(JsonKey.BATCH_ID), (String) request.get(JsonKey.USER_ID));
Expand Down Expand Up @@ -247,7 +247,7 @@ public static Map<String, Object> getCourseObjectFromEkStep(
* @Params
*/
private void validateCourseBatch(
CourseBatch courseBatchDetails, Map<String, Object> request, String requestedBy) {
CourseBatch courseBatchDetails, Map<String, Object> request, String requestedBy, String actorOperation) {

if (ProjectUtil.isNull(courseBatchDetails)) {
ProjectCommonException.throwClientErrorException(
Expand Down Expand Up @@ -278,7 +278,9 @@ private void validateCourseBatch(
if (StringUtils.isNotBlank(courseBatchDetails.getEnrollmentEndDate())) {
courseBatchEnrollmentEndDate = format.parse(courseBatchDetails.getEnrollmentEndDate());
}
if (courseBatchEnrollmentEndDate != null && courseBatchEnrollmentEndDate.before(todaydate)) {
if (ActorOperations.ENROLL_COURSE.getValue().equals(actorOperation)
&& courseBatchEnrollmentEndDate != null
&& courseBatchEnrollmentEndDate.before(todaydate)) {
ProjectLogger.log(
"CourseEnrollmentActor validateCourseBatch Enrollment Date has ended.",
LoggerEnum.INFO.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class CourseBatch implements Serializable {
private String createdDate;
private List<String> createdFor;
private String description;

@JsonInclude(JsonInclude.Include.ALWAYS)
private String endDate;

@JsonInclude(JsonInclude.Include.ALWAYS)
Expand Down