Skip to content

Commit 04c5c39

Browse files
authored
createdByName Issue fixed (#102)
* Issue with update and publish solved * KB-11314 | BE Issues - Access Settings - Training Plan * KB-11314 | BE Issues - Access Settings - Training Plan * KB-10947| KB-10947 | Learner unable to view Training Plan contents' created for Central Deputation conditions under My iGOT and also in Contents' TOC Page * KB-10947| KB-10947 | Learner unable to view Training Plan contents' created for Central Deputation conditions under My iGOT and also in Contents' TOC Page * updated according to review * Added logs to print the counts of plan * createdByIssue fixed * Updated according to review
1 parent 5a1d093 commit 04c5c39

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/main/java/com/igot/cb/service/CbPlanServiceImpl.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
import java.util.Map;
1616
import java.util.Set;
1717

18+
import com.igot.cb.user.UserUtilityService;
1819
import org.apache.commons.collections.CollectionUtils;
1920
import org.apache.commons.collections.MapUtils;
2021
import org.apache.commons.lang3.StringUtils;
22+
import org.springframework.beans.factory.annotation.Autowired;
2123
import org.springframework.http.HttpStatus;
2224
import org.springframework.stereotype.Service;
2325

@@ -68,6 +70,7 @@ public class CbPlanServiceImpl {
6870

6971
private final RequestValidator requestValidator;
7072

73+
7174
public CbPlanServiceImpl(AccessTokenValidator accessTokenValidator, CassandraOperation cassandraOperation,
7275
CbExtServerProperties serverProperties, UserAndOrgServiceImpl userAndOrgService,
7376
ContentInfoServiceImpl contentService, EsUtilService esUtilService, RequestValidator requestValidator) {
@@ -631,12 +634,24 @@ public ApiResponse searchCbPlan(SearchCriteria searchCriteria, String userOrgId,
631634
// Create a copy of item so we don’t mutate original
632635
Map<String, Object> enrichedItem = new HashMap<>(item);
633636
String createdBy = (String) enrichedItem.get(Constants.CREATED_BY);
634-
if (StringUtils.isNotBlank(createdBy)) {
635-
String createdByUserName = "";
636637

637-
enrichedItem.put(Constants.CREATED_BY_NAME, createdByUserName);
638+
if (item.containsKey(Constants.CREATED_BY) && item.get(Constants.CREATED_BY) != null) {
639+
Object createdByObj = item.get(Constants.CREATED_BY);
640+
Map<String, Object> userInfoMap = new HashMap<>();
641+
if (createdByObj instanceof String && !((String) createdByObj).trim().isEmpty()) {
642+
// fetch user details from DB
643+
userInfoMap = userAndOrgService.readUserProfile(
644+
(String) item.get(Constants.CREATED_BY),
645+
Arrays.asList(Constants.FIRSTNAME, Constants.USER_ID)
646+
);
647+
if (userInfoMap != null) {
648+
649+
enrichedItem.put(Constants.CREATED_BY_NAME,
650+
userInfoMap.get(Constants.FIRSTNAME));
651+
enrichedItem.put(Constants.CREATED_BY, item.get(Constants.CREATED_BY));
652+
}
653+
}
638654
}
639-
enrichedItem.put(Constants.CREATED_BY, createdBy);
640655

641656
if (item.containsKey(Constants.CONTENT_LIST) && item.get(Constants.CONTENT_LIST) != null) {
642657
Object contentListObj = item.get(Constants.CONTENT_LIST);
@@ -667,6 +682,7 @@ public ApiResponse searchCbPlan(SearchCriteria searchCriteria, String userOrgId,
667682
return response;
668683
}
669684

685+
670686
private void createSuccessResponse(ApiResponse response) {
671687
response.setParams(new ApiRespParam());
672688
response.getParams().setStatus(Constants.SUCCESS);

0 commit comments

Comments
 (0)