Skip to content

Commit

Permalink
KB-7361 | Menu PLANNING DEVELOPMENT Transform insights into action p…
Browse files Browse the repository at this point in the history
…lans 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.
  • Loading branch information
tarentomaheshvakkund authored Dec 18, 2024
1 parent dff8bf4 commit 35bc27c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/sunbird/common/util/CbExtServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ public String getPublicAssessmentCloudCertificateFolderName() {
@Value("${qr.custom.self.registration.logoupload.path}")
private String qrCustomerSelfRegistrationLogoPath;

@Value("${map.id.counter.enabled}")
private String mapIdCounterEnabled;


public String getCiosCloudIconFolderName() {
return ciosCloudIconFolderName;
Expand Down Expand Up @@ -3362,4 +3365,12 @@ public String getQrCustomerSelfRegistrationLogoPath() {
public void setQrCustomerSelfRegistrationLogoPath(String qrCustomerSelfRegistrationLogoPath) {
this.qrCustomerSelfRegistrationLogoPath = qrCustomerSelfRegistrationLogoPath;
}

public String getMapIdCounterEnabled() {
return mapIdCounterEnabled;
}

public void setMapIdCounterEnabled(String mapIdCounterEnabled) {
this.mapIdCounterEnabled = mapIdCounterEnabled;
}
}
1 change: 1 addition & 0 deletions src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ public class Constants {
public static final String IS_REGISTRATION_LINK_ACTIVE = "api.org.isqrcode.active";
public static final String IS_WHATSAPP_CONSENT="isWhatsappConsent";
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 ";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public SBApiResponse getSelfRegistrationQRAndLink(String authUserToken, Map<Stri
try {
File qrCodeFile = generateQRCodeFile(registrationLink, qrCodeFilePath, orgId);
File qrCodeLogoFile = QRCode.from(registrationLink).to(ImageType.JPG).withSize(750, 750).file(qrCodeFilePath);
outgoingResponse = uploadQRCodeFile(qrCodeFile);
SBApiResponse qrLogoUploadResponse = uploadQRCodeFile(qrCodeLogoFile);
if (outgoingResponse.getResponseCode() == HttpStatus.OK && qrLogoUploadResponse.getResponseCode() == HttpStatus.OK) {
CustomSelfRegistrationModel customSelfRegistrationModel = getCustomSelfRegistrationModel(requestBody, orgId, registrationLink, qrCodeFile, qrCodeLogoFile,userId, uniqueId);
Expand Down
36 changes: 27 additions & 9 deletions src/main/java/org/sunbird/org/service/ExtendedOrgServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package org.sunbird.org.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -543,7 +538,30 @@ private String createMapId(Map<String, Object> requestData) {
mapIdList.add(org.getMapId());
}
}
mapIdNew = prefix + (mapIdList.size() + 1);
if (Constants.ENABLED.equalsIgnoreCase(configProperties.getMapIdCounterEnabled())) {
String finalPrefix = prefix;
List<Integer> numbers = existingOrgList.stream()
.map(OrgHierarchy::getMapId) // Extract mapId
.filter(mapId -> mapId.startsWith(finalPrefix)) // Filter by prefix
.map(mapId -> {
// Find all numeric parts and extract the last one
Matcher matcher = Pattern.compile("\\d+").matcher(mapId);
String lastNumber = null;
while (matcher.find()) {
lastNumber = matcher.group(); // Update with the current match
}
return lastNumber; // Return the last matched number
})
.filter(Objects::nonNull) // Exclude null values
.map(Integer::parseInt) // Convert to integers
.collect(Collectors.toList()); // Collect into a list

// Find the maximum number or default to 0 if the list is empty
int maxNumber = numbers.isEmpty() ? 0 : Collections.max(numbers);
mapIdNew = prefix + (maxNumber + 1);
}else{
mapIdNew = prefix + (mapIdList.size() + 1);
}
} else {
mapIdNew = prefix + "1";
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ qr.custom.self.registration.upload.path: https://portal.dev.karmayogibharat.net
qr.custom.self.registration.skip.validation: false
qr.custom.self.registration.uploadlogo.folder.name: customselfregistration-logo
qr.custom.self.registration.logoupload.path: https://portal.dev.karmayogibharat.net/content-store/customselfregistration-logo/
map.id.counter.enabled: enabled

#PublicUserEventBulkonboard
public.user.event.bulk.onboard.topic=dev.public.user.event.bulk.onboard
Expand Down

0 comments on commit 35bc27c

Please sign in to comment.