Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cbrelease 4.8.6 #116

Open
wants to merge 25 commits into
base: cbrelease-4.8.6_hotfix
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
66f171c
109810:added active true condition for a user enrolled in differet ba…
ravisaurav-tarento Oct 17, 2023
d7cb7a0
109810:modified the active batch filter criteria
ravisaurav-tarento Oct 18, 2023
e543ddd
Dev 4.8.8 pagination (#114)
Sahil-tarento Oct 20, 2023
4a0a6f8
KBE-542BE : Analysis and Implementation Email Domain approval from SP…
Sahil-tarento Oct 20, 2023
2c197c8
107258:Changes to add batch name, course name, batch start date and n…
ravisaurav-tarento Oct 22, 2023
0bafb5a
Update application.properties
ravisaurav-tarento Oct 22, 2023
b0682a2
107258:modified property name in the config class to coorect value
ravisaurav-tarento Oct 23, 2023
f34a2e6
Merge branch 'cbrelease-4.8.6' of https://github.com/ravisaurav-taren…
ravisaurav-tarento Oct 23, 2023
c1d3452
Domain Pagination and Query changes
Sahil-tarento Oct 23, 2023
c79b2fe
Merge pull request #117 from Sahil-tarento/4.8.8-pagination
SaipradeepR Oct 23, 2023
f83855b
Resolved Conflicts
Sahil-tarento Oct 23, 2023
d40ac11
Merge pull request #115 from Sahil-tarento/4.8.8-updateDomainRequest
SaipradeepR Oct 23, 2023
f92bbc5
Updated the count variable Implementation
Sahil-tarento Oct 23, 2023
a2dd257
Merge pull request #118 from Sahil-tarento/4.8.8-updateDomainRequest
SaipradeepR Oct 23, 2023
1aa52ed
BE : Analysis and Implementation Email Domain approval from SPV Porta…
Sahil-tarento Oct 25, 2023
31adf27
KBE 595 -BE - CB-Ext changes w.r.t. extPatch API
tarentomaheshvakkund Oct 25, 2023
f3b5040
Retained the previous code in comment mode
tarentomaheshvakkund Oct 26, 2023
9a80139
Merge pull request #120 from tarentomaheshvakkund/4.8.8-verfiedKarmay…
SaipradeepR Oct 26, 2023
d0e999b
Made the changes for adding the entity for Wf_domain_user_info (#121)
Sahil-tarento Oct 26, 2023
9df2af8
107261:changes related to notification to PC and MDO
ravisaurav-tarento Oct 26, 2023
5f1a8a2
107261:created constant for KArmyogi bharat
ravisaurav-tarento Oct 26, 2023
3a59c9b
Bug Fix for verifiedKarmayogi. (#123)
tarentomaheshvakkund Oct 27, 2023
893406e
107261:resolved conflicts
ravisaurav-tarento Oct 27, 2023
01bab3e
107261:Added constant formatted to adrress the recepient in the mail…
ravisaurav-tarento Oct 30, 2023
e73bc1b
107261:Created a new model class for batch name, batch start date, co…
ravisaurav-tarento Oct 30, 2023
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
Prev Previous commit
Next Next commit
107258:Changes to add batch name, course name, batch start date and n…
…ew mail body, subject line for notification mail
ravisaurav-tarento committed Oct 22, 2023
commit 2c197c8dfcd89dc19c5aa0426548ba7ff32bfc28
32 changes: 32 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Configuration.java
Original file line number Diff line number Diff line change
@@ -164,6 +164,15 @@ public class Configuration {
@Value("${blended.program.batch.in.progress.message}")
private String batchInProgressMessage;

@Value("${bp.mail.body.forwarded.to}")
private String learnerForwardedMailBody;

@Value("${bp.mail.body.rejected.or.remove}")
private String rejectedOrRemovedMailBody;

@Value("${bp.mail.body.approve=}")
private String approvedMailBody;

public String getModificationRecordAllowActions() {
return modificationRecordAllowActions;
}
@@ -597,4 +606,27 @@ public void setBatchInProgressMessage(String batchInProgressMessage) {
this.batchInProgressMessage = batchInProgressMessage;
}

public String getLearnerForwardedMailBody() {
return learnerForwardedMailBody;
}

public void setLearnerForwardedMailBody(String learnerForwardedMailBody) {
this.learnerForwardedMailBody = learnerForwardedMailBody;
}

public String getRejectedOrRemovedMailBody() {
return rejectedOrRemovedMailBody;
}

public void setRejectedOrRemovedMailBody(String rejectedOrRemovedMailBody) {
this.rejectedOrRemovedMailBody = rejectedOrRemovedMailBody;
}

public String getApprovedMailBody() {
return approvedMailBody;
}

public void setApprovedMailBody(String approvedMailBody) {
this.approvedMailBody = approvedMailBody;
}
}
4 changes: 4 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Constants.java
Original file line number Diff line number Diff line change
@@ -239,4 +239,8 @@ private Constants() {

public static final String TRUE="True";
public static final String ACTIVE = "active";
public static final String DESCRIPTION = "description";
public static final String COURSE_NAME = "courseName";
public static final String BATCH_NAME = "batchName";
public static final String BATCH_START_DATE = "batchStartDate";
}
33 changes: 33 additions & 0 deletions src/main/java/org/sunbird/workflow/models/WfRequest.java
ravisaurav-tarento marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sunbird.workflow.models;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

@@ -26,8 +27,15 @@ public class WfRequest {
private String deptName;

private String rootOrgId;

private String courseId;

private String courseName;

private String batchName;

private Date batchStartDate;

public String getState() {
return state;
}
@@ -123,4 +131,29 @@ public String getCourseId() {
public void setCourseId(String courseId) {
this.courseId = courseId;
}

public String getCourseName() {
return courseName;
}

public void setCourseName(String courseName) {
this.courseName = courseName;
}

public String getBatchName() {
return batchName;
}

public void setBatchName(String batchName) {
this.batchName = batchName;
}

public Date getBatchStartDate() {
return batchStartDate;
}

public void setBatchStartDate(Date batchStartDate) {
this.batchStartDate = batchStartDate;
}

}
ravisaurav-tarento marked this conversation as resolved.
Show resolved Hide resolved
ravisaurav-tarento marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -107,7 +107,11 @@ public Response enrolBPWorkFlow(String rootOrg, String org, WfRequest wfRequest)
@Override
public Response updateBPWorkFlow(String rootOrg, String org, WfRequest wfRequest,String userId,String role) {
Response response = new Response();
String validationError = validateBatchUserRequestAccess(wfRequest);
Map<String, Object> batchDetailsMap = new HashMap<>();
String validationError = validateBatchUserRequestAccess(wfRequest, batchDetailsMap);
wfRequest.setCourseName((String) batchDetailsMap.get(Constants.COURSE_NAME));
wfRequest.setBatchName((String) batchDetailsMap.get(Constants.BATCH_NAME));
wfRequest.setBatchStartDate((Date) batchDetailsMap.get(Constants.BATCH_START_DATE));
if (Constants.BATCH_START_DATE_ERROR.equals(validationError)) {
response.put(Constants.ERROR_MESSAGE, configuration.getBatchInProgressMessage());
response.put(Constants.STATUS, HttpStatus.BAD_REQUEST);
@@ -200,7 +204,7 @@ private Map<String, Object> getCurrentBatchAttributes(String batchId, String cou
Constants.KEYSPACE_SUNBIRD_COURSES,
Constants.TABLE_COURSE_BATCH,
propertyMap,
Arrays.asList(Constants.BATCH_ATTRIBUTES, Constants.ENROLMENT_END_DATE, Constants.START_DATE));
Arrays.asList(Constants.BATCH_ATTRIBUTES, Constants.ENROLMENT_END_DATE, Constants.START_DATE, Constants.NAME, Constants.DESCRIPTION));
if (CollectionUtils.isNotEmpty(batchAttributesDetails)) {
Map<String, Object> courseBatch = (Map<String, Object>) batchAttributesDetails.get(0);
if (courseBatch.containsKey(Constants.BATCH_ATTRIBUTES)) {
@@ -221,10 +225,20 @@ private Map<String, Object> getCurrentBatchAttributes(String batchId, String cou
Date batchStartDate = courseBatch.containsKey(Constants.START_DATE)
? (Date) courseBatch.get(Constants.START_DATE)
: null;
String courseName = batchAttributes != null
&& courseBatch.containsKey(Constants.NAME)
? (String) courseBatch.get(Constants.NAME)
: "";
String batchName = batchAttributes != null
&& courseBatch.containsKey(Constants.DESCRIPTION)
? (String) courseBatch.get(Constants.DESCRIPTION)
: "";
Map<String, Object> result = new HashMap<>();
result.put(Constants.CURRENT_BATCH_SIZE, currentBatchSize);
result.put(Constants.ENROLMENT_END_DATE, enrollmentEndDate);
result.put(Constants.START_DATE, batchStartDate);
result.put(Constants.COURSE_NAME, courseName);
result.put(Constants.BATCH_NAME, batchName);
return result;
} catch (Exception e) {
logger.error(String.format("Failed to retrieve course batch details. CourseId: %s, BatchId: %s",
@@ -322,12 +336,15 @@ public void processWFRequest(WfRequest wfRequest) {
}


private String validateBatchUserRequestAccess(WfRequest wfRequest) {
private String validateBatchUserRequestAccess(WfRequest wfRequest, Map<String, Object> batchDetailsMap) {
Map<String, Object> courseBatchDetails = getCurrentBatchAttributes(wfRequest.getApplicationId(),
wfRequest.getCourseId());
batchDetailsMap.put(Constants.BATCH_START_DATE, courseBatchDetails.get(Constants.START_DATE));
batchDetailsMap.put(Constants.COURSE_NAME, courseBatchDetails.get(Constants.COURSE_NAME));
batchDetailsMap.put(Constants.BATCH_NAME, courseBatchDetails.get(Constants.BATCH_NAME));
boolean nonEnrolmentState = configuration.getBpBatchFullValidationExcludeStates().contains(wfRequest.getAction());
if(nonEnrolmentState)
return "";
Map<String, Object> courseBatchDetails = getCurrentBatchAttributes(wfRequest.getApplicationId(),
wfRequest.getCourseId());
boolean batchStartDateValid = validateBatchStartDate(courseBatchDetails);
if(!batchStartDateValid)
return Constants.BATCH_START_DATE_ERROR;
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@
@Service
public class NotificationServiceImpl {

public static final String EMAILTEMPLATE = "emailtemplate";
Logger logger = LogManager.getLogger(ApplicationProcessingConsumer.class);

@Autowired
@@ -71,12 +70,30 @@ public class NotificationServiceImpl {

private static final String TO_VALUE_CONST = "toValue";

public static final String EMAILTEMPLATE = "emailtemplate";

private static final String COURSE_NAME_TAG = "#course_name";

private static final String BATCH_NAME_TAG = "#batch_name";

private static final String Role_TAG = "#role";

private static final String ACT_TAG = "#action";

private static final String BATCH_START_DATE_TAG = "#batch_start_date";

private static final String MAIL_SUBJECT = "Your request is #state";

private static final String MDO_MAIL_SUBJECT = "Request for approval";

private static final String ENROLMENT_ACTION_SUBJECT = "Enrollment #action";

private static final String MAIL_BODY = "Your request to update #fieldKey to #toValue is #state ";

private static final String BP_MAIL_BODY = "Your request for batch enrollment is #state.";

private static final String BP_MDO_PC_SUBJECT_LINE = "Enrollment Request Forwarded to #role";

/**
* Send notification to the user based on state of application
*
@@ -97,19 +114,18 @@ public void sendNotification(WfRequest wfRequest) {
logger.info("Enter's in the notification block");
Set<String> usersId = new HashSet<>();
usersId.add(wfRequest.getUserId());
switch (wfRequest.getServiceName()) {
case Constants.BLENDED_PROGRAM_SERVICE_NAME:
case Constants.ONE_STEP_MDO_APPROVAL:
case Constants.ONE_STEP_PC_APPROVAL:
case Constants.TWO_STEP_MDO_AND_PC_APPROVAL:
case Constants.TWO_STEP_PC_AND_MDO_APPROVAL:
break;
default:
usersId.add(wfStatusEntity.getApplicationId());
Set<String> blendedProgrammeServiceNames = new HashSet<>();
blendedProgrammeServiceNames.addAll(Arrays.asList(Constants.BLENDED_PROGRAM_SERVICE_NAME,
Constants.ONE_STEP_MDO_APPROVAL,
Constants.ONE_STEP_PC_APPROVAL,
Constants.TWO_STEP_MDO_AND_PC_APPROVAL,
Constants.TWO_STEP_PC_AND_MDO_APPROVAL));
if(!blendedProgrammeServiceNames.contains(wfRequest.getServiceName())){
usersId.add(wfStatusEntity.getApplicationId());
}
HashMap<String, Object> usersObj = userProfileWfService.getUsersResult(usersId);
Map<String, Object> recipientInfo;
if (Constants.BLENDED_PROGRAM_SERVICE_NAME.equalsIgnoreCase(wfRequest.getServiceName())) {
if (blendedProgrammeServiceNames.contains(wfRequest.getServiceName())) {
recipientInfo = (Map<String, Object>)usersObj.get(wfRequest.getUserId());
} else {
recipientInfo = (Map<String, Object>)usersObj.get(wfStatusEntity.getApplicationId());
@@ -123,14 +139,54 @@ public void sendNotification(WfRequest wfRequest) {
Template template = new Template();
template.setId(EMAILTEMPLATE);
Optional<HashMap<String, Object>> updatedFieldValue = wfRequest.getUpdateFieldValues().stream().findFirst();
String subjectLine = "";
if (updatedFieldValue.isPresent()) {
if (Constants.BLENDED_PROGRAM_SERVICE_NAME.equalsIgnoreCase(wfRequest.getServiceName())) {
params.put("body", BP_MAIL_BODY.replace(STATE_NAME_TAG, wfStatusEntity.getCurrentStatus()));
} else {
if (blendedProgrammeServiceNames.contains(wfRequest.getServiceName())) {
switch (wfStatusEntity.getCurrentStatus()){
case Constants.SEND_FOR_PC_APPROVAL:
subjectLine = BP_MDO_PC_SUBJECT_LINE.replace(Role_TAG,Constants.PROGRAM_COORDINATOR.replace("_"," "));
params.put("body",configuration.getLearnerForwardedMailBody()
.replace(COURSE_NAME_TAG, wfRequest.getCourseName())
.replace(BATCH_NAME_TAG, wfRequest.getBatchName())
.replace(BATCH_START_DATE_TAG, wfRequest.getBatchStartDate().toString())
.replace(Role_TAG,Constants.PROGRAM_COORDINATOR.replace("_"," ")));
break;
case Constants.SEND_FOR_MDO_APPROVAL:
subjectLine = BP_MDO_PC_SUBJECT_LINE.replace(Role_TAG,Constants.MDO_ADMIN.split("_")[0]);
params.put("body",configuration.getApprovedMailBody()
.replace(COURSE_NAME_TAG, wfRequest.getCourseName())
.replace(BATCH_NAME_TAG, wfRequest.getBatchName())
.replace(BATCH_START_DATE_TAG, wfRequest.getBatchStartDate().toString())
.replace(Role_TAG,Constants.MDO_ADMIN.split("_")[0]));
break;
case Constants.APPROVED:
subjectLine = ENROLMENT_ACTION_SUBJECT.replace(ACT_TAG, wfStatusEntity.getCurrentStatus());
params.put("body", configuration.getApprovedMailBody()
.replace(BATCH_NAME_TAG, wfRequest.getBatchName())
.replace(COURSE_NAME_TAG, wfRequest.getCourseName())
.replace(BATCH_START_DATE_TAG, wfRequest.getBatchStartDate().toString()));
break;
case Constants.REJECTED:
case Constants.REMOVED:
subjectLine = ENROLMENT_ACTION_SUBJECT.replace(ACT_TAG, wfStatusEntity.getCurrentStatus());
params.put("body",configuration.getRejectedOrRemovedMailBody()
.replace(BATCH_NAME_TAG, wfRequest.getBatchName())
.replace(COURSE_NAME_TAG, wfRequest.getCourseName())
.replace(ACT_TAG,wfStatusEntity.getCurrentStatus())
.replace(BATCH_START_DATE_TAG, wfRequest.getBatchStartDate().toString()));
break;
default:
subjectLine = MAIL_SUBJECT.replace(STATE_NAME_TAG, wfStatusEntity.getCurrentStatus());
params.put("body", BP_MAIL_BODY.replace(STATE_NAME_TAG, wfStatusEntity.getCurrentStatus()));
break;
}
}
else {
HashMap<String, Object> toValue = (HashMap<String, Object>) updatedFieldValue.get().get(TO_VALUE_CONST);
params.put("body", MAIL_BODY.replace(STATE_NAME_TAG, wfStatusEntity.getCurrentStatus())
.replace(FIELD_KEY_TAG, toValue.entrySet().iterator().next().getKey()).replace(TO_VALUE_TAG, (String) toValue.entrySet().iterator().next().getValue()));
}
subjectLine = MAIL_SUBJECT.replace(STATE_NAME_TAG, wfStatusEntity.getCurrentStatus());
}
}
if (StringUtils.isNotBlank(wfRequest.getComment())) {
String body = (String) params.get("body");
@@ -141,7 +197,7 @@ public void sendNotification(WfRequest wfRequest) {
params.put("orgImageUrl", null);
template.setParams(params);
Config config = new Config();
config.setSubject(MAIL_SUBJECT.replace(STATE_NAME_TAG, wfStatusEntity.getCurrentStatus()));
config.setSubject(subjectLine);
config.setSender((String)senderInfo.get("email"));
Map<String, Object> req = new HashMap<>();
request.setTemplate(template);