Skip to content

Commit 9d9fb73

Browse files
authored
isOnCentralDeputation issue is fixed (#103)
* 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 * isOnCentralDeputation issue is fixed
1 parent 04c5c39 commit 9d9fb73

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/main/java/com/igot/cb/util/RequestValidator.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.igot.cb.util;
22

3-
import java.util.ArrayList;
4-
import java.util.Arrays;
5-
import java.util.HashSet;
6-
import java.util.List;
7-
import java.util.Map;
8-
import java.util.Set;
3+
import java.util.*;
94

105
import org.apache.commons.collections.CollectionUtils;
116
import org.apache.commons.collections4.MapUtils;
@@ -136,17 +131,35 @@ public List<String> validateContextData(Map<String, Object> request, boolean isC
136131
errors.add("Validation Error: criteriaValue is missing for criteriaKey: " + criteriaKey);
137132
return errors; // no criteriaValue = no extra validation
138133
}
139-
List<String> criteriaValues = (List<String>) criteria.get(Constants.CRITERIA_VALUE);
140-
if (CollectionUtils.isEmpty(criteriaValues)) {
141-
errors.add("Validation Error: criteriaValue is empty for criteriaKey: " + criteriaKey);
142-
return errors; // empty criteriaValue = no extra validation
134+
if (!criteria.containsKey(Constants.CRITERIA_VALUE)) {
135+
errors.add("Validation Error: criteriaValue is missing for criteriaKey: " + criteriaKey);
136+
return errors;
137+
}
138+
139+
Object criteriaValueObj = criteria.get(Constants.CRITERIA_VALUE);
140+
List<String> criteriaValues = new ArrayList<>();
141+
142+
if (criteriaValueObj instanceof List) {
143+
criteriaValues = (List<String>) criteriaValueObj;
144+
} else if (criteriaValueObj instanceof Boolean) {
145+
// Convert boolean (or isOnCentralDeputation key) to string list
146+
criteriaValues = Collections.singletonList(String.valueOf(criteriaValueObj));
147+
} else if (criteriaValueObj instanceof String) {
148+
// Wrap single string into a list
149+
criteriaValues = Collections.singletonList((String) criteriaValueObj);
150+
} else {
151+
errors.add("Validation Error: Unsupported criteriaValue type for criteriaKey: "
152+
+ criteriaKey + ", type=" + criteriaValueObj.getClass().getSimpleName());
153+
return errors;
143154
}
155+
criteria.put(Constants.CRITERIA_VALUE, criteriaValues);
144156
if (Constants.ROOT_ORG_ID.equalsIgnoreCase(criteriaKey)) {
145157
rootOrgCriteriaFound = true;
146158
rootOrgIdsInCriteria.addAll(criteriaValues);
147159
}
148160
}
149161

162+
150163
if (!rootOrgCriteriaFound) {
151164
if (!isCCA) {
152165
errors.add(

0 commit comments

Comments
 (0)