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
Show file tree
Hide file tree
Changes from 8 commits
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
76 changes: 76 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,27 @@ 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;

@Value("${notify.email.template}")
private String notificationEmailTemplate;

@Value("${bp.approval.request.mail.body}")
private String approvalRequetMailBody;

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

@Value("${bp.nomination.request.mail.body}")
private String nominationRequestMailBody;

public String getModificationRecordAllowActions() {
return modificationRecordAllowActions;
}
Expand Down Expand Up @@ -597,4 +618,59 @@ 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;
}

public String getNotificationEmailTemplate() {
return notificationEmailTemplate;
}

public void setNotificationEmailTemplate(String notificationEmailTemplate) {
this.notificationEmailTemplate = notificationEmailTemplate;
}

public String getApprovalRequetMailBody() {
return approvalRequetMailBody;
}

public void setApprovalRequetMailBody(String approvalRequetMailBody) {
this.approvalRequetMailBody = approvalRequetMailBody;
}

public String getRequestForwardedMailBody() {
return requestForwardedMailBody;
}

public void setRequestForwardedMailBody(String requestForwardedMailBody) {
this.requestForwardedMailBody = requestForwardedMailBody;
}

public String getNominationRequestMailBody() {
return nominationRequestMailBody;
}

public void setNominationRequestMailBody(String nominationRequestMailBody) {
this.nominationRequestMailBody = nominationRequestMailBody;
}
}
10 changes: 10 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,14 @@ 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";
public static final String FROM_EMAIL = "fromEmail";
public static final String DEV_HIERARCHY_STORE = "dev_hierarchy_store";
public static final String CONTENT_HIERARCHY = "content_hierarchy";
public static final String IDENTIFIER = "identifier";
public static final String HIERARCHY = "hierarchy";
public static final Object KARMYOGI_BHARAT = "Karmyogi Bharat";
}
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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Up @@ -11,12 +11,15 @@
import java.util.Map;
import java.util.stream.Collectors;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections.CollectionUtils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -98,6 +101,10 @@ public Response enrolBPWorkFlow(String rootOrg, String org, WfRequest wfRequest)
response.put(Constants.STATUS, HttpStatus.BAD_REQUEST);
return response;
}
Map<String, Object> courseAttributes = getCourseAttributes(wfRequest.getCourseId());
wfRequest.setCourseName((String) courseAttributes.get(Constants.COURSE_NAME));
wfRequest.setBatchName((String) courseBatchDetails.get(Constants.BATCH_NAME));
wfRequest.setBatchStartDate((Date) courseBatchDetails.get(Constants.START_DATE));
Response response = saveEnrollUserIntoWfStatus(rootOrg, org, wfRequest);
wfRequest.setServiceName(Constants.BLENDED_PROGRAM_SERVICE_NAME);
producer.push(configuration.getWorkflowApplicationTopic(), wfRequest);
Expand All @@ -107,7 +114,12 @@ 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.setBatchName((String) batchDetailsMap.get(Constants.BATCH_NAME));
wfRequest.setBatchStartDate((Date) batchDetailsMap.get(Constants.BATCH_START_DATE));
Map<String, Object> courseAttributes = getCourseAttributes(wfRequest.getCourseId());
wfRequest.setCourseName((String) courseAttributes.get(Constants.COURSE_NAME));
if (Constants.BATCH_START_DATE_ERROR.equals(validationError)) {
response.put(Constants.ERROR_MESSAGE, configuration.getBatchInProgressMessage());
response.put(Constants.STATUS, HttpStatus.BAD_REQUEST);
Expand Down Expand Up @@ -200,7 +212,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)) {
Expand All @@ -221,10 +233,15 @@ private Map<String, Object> getCurrentBatchAttributes(String batchId, String cou
Date batchStartDate = courseBatch.containsKey(Constants.START_DATE)
? (Date) courseBatch.get(Constants.START_DATE)
: null;
String batchName = batchAttributes != null
&& courseBatch.containsKey(Constants.NAME)
? (String) courseBatch.get(Constants.NAME)
: "";
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.BATCH_NAME, batchName);
return result;
} catch (Exception e) {
logger.error(String.format("Failed to retrieve course batch details. CourseId: %s, BatchId: %s",
Expand Down Expand Up @@ -322,12 +339,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;
Expand Down Expand Up @@ -497,6 +517,10 @@ public Response adminEnrolBPWorkFlow(String rootOrg, String org, WfRequest wfReq
response.put(Constants.MESSAGE, "Not allowed to enroll the user to the Blended Program");
response.put(Constants.STATUS, HttpStatus.OK);
} else {
Map<String, Object> courseAttributes = getCourseAttributes(wfRequest.getCourseId());
wfRequest.setCourseName((String) courseAttributes.get(Constants.COURSE_NAME));
wfRequest.setBatchName((String) courseBatchDetails.get(Constants.NAME));
wfRequest.setBatchStartDate((Date) courseBatchDetails.get(Constants.BATCH_START_DATE));
response = saveAdminEnrollUserIntoWfStatus(rootOrg, org, wfRequest);
// producer.push(configuration.getWorkFlowNotificationTopic(), wfRequest);
wfRequest.setAction(Constants.INITIATE);
Expand Down Expand Up @@ -567,6 +591,10 @@ public Response removeBPWorkFlow(String rootOrg, String org, WfRequest wfRequest
response.put(Constants.ERROR_MESSAGE, HttpStatus.INTERNAL_SERVER_ERROR);
} else if (approvedLearners.size() == 1)
wfRequest.setWfId(approvedLearners.get(0).getWfId());
Map<String, Object> getCourseAttributes = getCourseAttributes(wfRequest.getCourseId());
wfRequest.setBatchName((String) courseBatchDetails.get(Constants.BATCH_NAME));
wfRequest.setBatchStartDate((Date) courseBatchDetails.get(Constants.BATCH_START_DATE));
wfRequest.setCourseName((String) getCourseAttributes.get(Constants.COURSE_NAME));
response = workflowService.workflowTransition(rootOrg, org, wfRequest,userId,role);

response.put(Constants.STATUS, HttpStatus.OK);
Expand Down Expand Up @@ -675,12 +703,13 @@ public boolean enrollmentDateValidations(List<Map<String, Object>> enrolledCours
public List<Map<String, Object>> getUserEnrolmentDetails(WfRequest wfRequest) {
Map<String, Object> propertyMap = new HashMap<>();
propertyMap.put(Constants.USER_ID, wfRequest.getUserId());
return cassandraOperation.getRecordsByProperties(
List<Map<String, Object>> allEnrollmentDetails = cassandraOperation.getRecordsByProperties(
Constants.KEYSPACE_SUNBIRD_COURSES,
Constants.USER_ENROLMENTS,
propertyMap,
Arrays.asList(Constants.BATCH_ID, Constants.USER_ID, Constants.COURSE_ID)
Arrays.asList(Constants.BATCH_ID, Constants.USER_ID, Constants.COURSE_ID, Constants.ACTIVE)
);
return allEnrollmentDetails.stream().filter( e -> (boolean)e.get(Constants.ACTIVE)).collect(Collectors.toList());
}

/**
Expand Down Expand Up @@ -995,7 +1024,18 @@ private void handleApprovalRequest(WfRequest wfRequest) {
} catch (IOException e) {
throw new ApplicationException(Constants.WORKFLOW_PARSING_ERROR_MESSAGE, e);
}
}


public Map<String, Object> getCourseAttributes(String courseId){
Map<String, Object> propertiesMap = new HashMap<>();
Map<String, Object> courseDetails = new HashMap<>();
propertiesMap.put(Constants.IDENTIFIER, courseId);
List<Map<String, Object>> coursesDataList = cassandraOperation.getRecordsByProperties(Constants.DEV_HIERARCHY_STORE,
Constants.CONTENT_HIERARCHY,
propertiesMap,
Arrays.asList(Constants.IDENTIFIER, Constants.HIERARCHY));
Map<String, Object> hierarchy = new Gson().fromJson((String) coursesDataList.get(0).get("hierarchy"), new TypeToken<HashMap<String, Object>>(){}.getType());
courseDetails.put(Constants.COURSE_NAME, (String) hierarchy.get(Constants.NAME));
return courseDetails;
}
}
Loading