Skip to content

Commit

Permalink
4.8.21 merged v (#295)
Browse files Browse the repository at this point in the history
* Fix - Adding validation for Group in admin extPatch API - KB-7703 (#259)

* Fix - Adding validation for Group in admin extPatch API - KB-7703

* Code refactor

* Review Changes

* 4.8.20 dev v6 (#266)

* KB-7361 | Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation.1.

1. While creating a new qrcode for registration for a particular organisation need to deactivate the old  qr - we are expiring the qrcodes .

* KB-7361 | Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation.

1. Added new qr logo .

* KB-7361 | Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation.

1. Logo path added.

* KB-7361 | Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation. (#265)

1. Logo path added.

---------

Co-authored-by: tarentomaheshvakkund <[email protected]>
Co-authored-by: sureshece16 <[email protected]>

* KB-7361 | Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation. (#267) (#269)

1. Attribute name changed.

Co-authored-by: tarentomaheshvakkund <[email protected]>

* KB-7361 | Menu PLANNING DEVELOPMENT Transform insights into action plans You're in a company-managed project      Projects  Karmayogi Bharat KB-6422 KB-7361 Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation. (#272)

1. Upload for qrcode was missing added.
2. New Logic added to increment the counter value for the mapid.
3. It is configurable based on the flag, if enabled it will work with new logic else it will work as per old logic.

* KB-7361 | Testing and Enhancements | BE | Self Registration | QR Code generation and registration link generation. (#274)

1. Noof user onboarded count should be based on the organisation not the link .

* New Profile update API to replace learner private update API (#271)

* Bug fix of certificate reissue for physical event. (#279)

* Reject all profile approval pending requests if admin marks NOT-MY-USER (#232) (#280)

* "If zero users for the BP approval, marking report as completed with zero count"

* "Reject all profile approval pending requests if admin marks NOT-MY-USER"

* KAR-858: Reject all profile approval pending requests if admin marks NOT-MY-USER

* Bug Fix: Added Profile Approval Auto Rejection Comment (#282)

* Bug Fix: Added Profile Approval Auto Rejection Comment (#283)

* Bug Fix: Added Profile Approval Auto Rejection Comment

* Bug Fix: Added Profile Approval Auto Rejection Comment

* Added filter to fetch only onboarded org (sborgid is not null) in API- /org/v2/ext/signup/search (#294)

---------

Co-authored-by: sreerag-tarento <[email protected]>
Co-authored-by: SaipradeepR <[email protected]>
Co-authored-by: tarentomaheshvakkund <[email protected]>
Co-authored-by: sureshece16 <[email protected]>
Co-authored-by: vikrantbipin <[email protected]>
  • Loading branch information
6 people authored Jan 27, 2025
1 parent 08decb8 commit 30c8a1d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.sunbird.bpreports.postgres.entity.WfStatusEntity;

import java.util.List;

public interface WfStatusEntityRepository extends JpaRepository<WfStatusEntity, String> {

Page<WfStatusEntity> findByApplicationId(String applicationId, Pageable pageable);

@Query(value = "SELECT * FROM wf_status WHERE userid= :userId and service_name= :service and current_status= :currentStatus", nativeQuery = true)
List<WfStatusEntity> findProfileApprovalRequests(String userId, String service, String currentStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3380,7 +3380,7 @@ public void setMapIdCounterEnabled(String mapIdCounterEnabled) {
this.mapIdCounterEnabled = mapIdCounterEnabled;

}

public String getCourseRecommendationsByDesignationKey() {
return courseRecommendationsByDesignationKey;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,10 @@ public class Constants {
public static final String QR_LOGO_PATH = "qrCodeLogoPath";
public static final String ENABLED = "enabled";
public static final String INVALID_GROUP_MESSAGE = "Invalid Group : Group can be only among one of these ";
public static final String SEND_FOR_APPROVAL = "SEND_FOR_APPROVAL";
public static final String ERR_MSG_APPROVAL_REQUEST = "Error while rejecting approval requests";
public static final String FAILED_MSG_APPROVAL_REQUEST = "Failed to reject approval requests for userId: {}";
public static final String PROFILE_APPROVAL_AUTO_REJECT_MESSAGE ="You are no longer recognized as a user by your current organization. Reach out to your MDO or submit a \"Transfer Request\".";
public static final String API_COURSE_RECOMMENDATIONS ="api.insights.get.courses.recommendations.designation";
public static final String COURSE_LIST ="courseList";
public static final String DESIGNATION_FILLED_DURING_ENROLLMENT = "Designation (filled during enrollment)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public class CertificateServiceImpl {

ObjectMapper mapper = new ObjectMapper();

public void generateCertificateEventAndPushToKafka(String userId, String eventId, String batchId, double completionPercentage, long etsForEvent, boolean publicCert) throws IOException {
public void generateCertificateEventAndPushToKafka(String userId, String eventId, String batchId, double completionPercentage, long etsForEvent, boolean publicCert, boolean reissue) throws IOException {
List<String> userIds = Collections.singletonList(userId);
String eventJson = generateIssueCertificateEvent(batchId, eventId, userIds, completionPercentage, userId, etsForEvent, publicCert);
String eventJson = generateIssueCertificateEvent(batchId, eventId, userIds, completionPercentage, userId, etsForEvent, publicCert, reissue);
if (pushTokafkaEnabled) {
String topic = serverProperties.getUserIssueCertificateForEventTopic();
kafkaTemplate.send(topic, userId, eventJson);
}
}

public String generateIssueCertificateEvent(String batchId, String eventId, List<String> userIds, double eventCompletionPercentage, String userId, long ets, boolean publicCert) throws JsonProcessingException {
public String generateIssueCertificateEvent(String batchId, String eventId, List<String> userIds, double eventCompletionPercentage, String userId, long ets, boolean publicCert, boolean reissue) throws JsonProcessingException {

// Generate a UUID for the message ID
String mid = UUID.randomUUID().toString();
Expand All @@ -59,6 +59,9 @@ public String generateIssueCertificateEvent(String batchId, String eventId, List
if (publicCert) {
edata.put("certStore", "public");
}
if (reissue) {
edata.put("reIssue", true);
}
edata.put("batchId", batchId);
edata.put("eventId", eventId);
edata.put("userIds", userIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private Map<String, String> processRecord(CSVRecord record, int expectedFieldCou
markRecordAsFailed(updatedRecord, "Failed to update enrollment");
return updatedRecord;
}
certificateService.generateCertificateEventAndPushToKafka(userId, eventId, batchId, completionPercentage, etsForEvent, publicCert);
certificateService.generateCertificateEventAndPushToKafka(userId, eventId, batchId, completionPercentage, etsForEvent, publicCert, false);
if (!publicCert) {
karmaPointsService.generateKarmaPointEventAndPushToKafka(userId, eventId, batchId, etsForEvent);
}
Expand All @@ -263,7 +263,7 @@ private Map<String, String> processRecord(CSVRecord record, int expectedFieldCou
if (reissue) {
//If enrollment status is complete and want to reissue the certificate
etsForEvent = ((Date) enrollmentRecord.get(Constants.COMPLETED_ON)).getTime();
certificateService.generateCertificateEventAndPushToKafka(userId, eventId, batchId, completionPercentage, etsForEvent, publicCert);
certificateService.generateCertificateEventAndPushToKafka(userId, eventId, batchId, completionPercentage, etsForEvent, publicCert, true);
} else {
markRecordAsFailed(updatedRecord, "Event already completed");
return updatedRecord;
Expand All @@ -276,7 +276,7 @@ private Map<String, String> processRecord(CSVRecord record, int expectedFieldCou
markRecordAsFailed(updatedRecord, "Failed to enroll");
return updatedRecord;
}
certificateService.generateCertificateEventAndPushToKafka(userId, eventId, batchId, completionPercentage, etsForEvent, publicCert);
certificateService.generateCertificateEventAndPushToKafka(userId, eventId, batchId, completionPercentage, etsForEvent, publicCert, false);
if (!publicCert) {
karmaPointsService.generateKarmaPointEventAndPushToKafka(userId, eventId, batchId, etsForEvent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.sunbird.org.model.OrgHierarchy;

public interface OrgHierarchyRepository extends JpaRepository<OrgHierarchy, Integer> {
@Query(value = "SELECT * FROM org_hierarchy_v4 org WHERE org.orgname ~* ?1", nativeQuery = true)
@Query(value = "SELECT * FROM org_hierarchy_v4 org WHERE org.orgname ~* ?1 AND org.sborgid IS NOT NULL AND org.sborgid != ''", nativeQuery = true)
List<OrgHierarchy> searchOrgWithHierarchy(String orgName);

List<OrgHierarchy> findAllByOrgName(String orgName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,14 +661,17 @@ private void processBulkUpload(HashMap<String, String> inputDataMap) throws IOEx
} else {
if (nextRow.getCell(0).getCellType() == CellType.STRING) {
String designation = nextRow.getCell(0).getStringCellValue().trim();
logger.info("Bulk upload desingation: " + designation);
if (CollectionUtils.isNotEmpty(orgDesignation) && orgDesignation.contains(designation)) {
logger.info("The orgDesignation size: " + orgDesignation.size());
if (CollectionUtils.isNotEmpty(orgFrameworkTerms)) {
List<Map<String, Object>> associations = (List<Map<String, Object>>) orgFrameworkTerms.get(0).get(Constants.ASSOCIATIONS);
if (CollectionUtils.isEmpty(associations)) { // For the first association Object addition
Map<String, Object> designationObject = getDesignationObject(getAllDesignationForOrg, designation);
if (MapUtils.isNotEmpty(designationObject)) {
associationIdentifier = (String) designationObject.get(Constants.IDENTIFIER);
} else {
logger.error("Issue while adding the designation for org: " + designation + "for org: " + frameworkId);
invalidErrList.add("Issue while adding the designation for org");
}
} else {
Expand All @@ -680,6 +683,7 @@ private void processBulkUpload(HashMap<String, String> inputDataMap) throws IOEx
if (MapUtils.isNotEmpty(designationObject)) {
associationIdentifier = (String) designationObject.get(Constants.IDENTIFIER);
} else {
logger.error("Issue while adding the designation for org: " + designation + "for org: " + frameworkId + " association is present");
invalidErrList.add("Issue while adding the designation for org");
}
}
Expand All @@ -689,10 +693,12 @@ private void processBulkUpload(HashMap<String, String> inputDataMap) throws IOEx
if (masterDesignation.contains(designation)) {
designationMappingInfoMap.put(Constants.DESIGNATION, designation);
} else {
logger.error("Invalid designation for org.");
invalidErrList.add("Invalid designation for org: " + designation);
}
}
} else {
logger.error("Invalid column type for designation.");
invalidErrList.add("Invalid column type for designation. Expecting string format");
}
}
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.sunbird.bpreports.postgres.entity.WfStatusEntity;
import org.sunbird.bpreports.postgres.repository.WfStatusEntityRepository;
import org.sunbird.cache.DataCacheMgr;
import org.sunbird.cassandra.utils.CassandraOperation;
import org.sunbird.common.model.SBApiResponse;
Expand Down Expand Up @@ -119,6 +121,9 @@ public class ProfileServiceImpl implements ProfileService {
@Autowired
CbExtServerProperties serverProperties;

@Autowired
WfStatusEntityRepository wfStatusEntityRepository;

private Logger log = LoggerFactory.getLogger(getClass().getName());

@Override
Expand Down Expand Up @@ -1971,6 +1976,16 @@ public SBApiResponse profileMDOAdminUpdate(Map<String, Object> request, String u
existingProfileDetails.put(changedObj, profileDetailsMap.get(changedObj));
if (Constants.PROFILE_STATUS.equalsIgnoreCase(changedObj)) {
updatedProfileStatus = (String) profileDetailsMap.get(changedObj);
if (Constants.NOT_MY_USER.equalsIgnoreCase(updatedProfileStatus)) {
boolean isRejected = rejectProfileApprovalRequestById(userId);
if (!isRejected) {
log.error(Constants.FAILED_MSG_APPROVAL_REQUEST, userId);
response.getParams().setStatus(Constants.FAILED);
response.getParams().setErr(Constants.ERR_MSG_APPROVAL_REQUEST);
response.setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR);
return response;
}
}
}
} else if (profileDetailsMap.get(changedObj) instanceof ArrayList) {
// KB-3718
Expand Down Expand Up @@ -2436,6 +2451,33 @@ public SBApiResponse bulkUploadV2(MultipartFile mFile, String orgId, String chan
return response;
}

private boolean rejectProfileApprovalRequestById(String userId) {
try {
// Fetch pending approval requests for the user
List<WfStatusEntity> pendingApprovalRequests = wfStatusEntityRepository.findProfileApprovalRequests(
userId, Constants.PROFILE, Constants.SEND_FOR_APPROVAL);
if (CollectionUtils.isEmpty(pendingApprovalRequests)) {
log.info("No pending approval requests found for user: {}", userId);
return true;
}
// Update and save all requests in bulk
pendingApprovalRequests.forEach(request -> {
request.setCurrentStatus(Constants.REJECTED_UPPER_CASE);
request.setInWorkflow(Boolean.FALSE);
request.setComment(Constants.PROFILE_APPROVAL_AUTO_REJECT_MESSAGE);
request.setLastUpdatedOn(new Date());
});
wfStatusEntityRepository.saveAll(pendingApprovalRequests);
log.info("Successfully rejected {} profile approval requests for user: {}",
pendingApprovalRequests.size(), userId);
return true;
} catch (Exception ex) {
// Log the exception and return failure
log.error("Error rejecting profile approval requests for user: {}", userId, ex);
return false;
}
}

}


Expand Down

0 comments on commit 30c8a1d

Please sign in to comment.