Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public Response getScreenerFormPaths(@Context SecurityIdentity identity,

try {
List<Benefit> benefits = screenerRepository.getBenefitsInScreener(screener);
List<FormPath> paths = new ArrayList<>(inputSchemaService.extractAllInputPaths(benefits));
List<FormPath> paths = new ArrayList<>(inputSchemaService.extractUniqueInputPaths(benefits));
Collections.sort(paths, new Comparator<FormPath>() {
public int compare(FormPath fp1, FormPath fp2) {
// compare two instance of `Score` and return `int` as result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,29 @@ public class InputSchemaService {
* Extracts all unique input paths from all benefits in a screener.
*
* @param benefits List of benefits containing checks with inputDefinitions
* @return Set of unique dot-separated paths (e.g., "people.applicant.dateOfBirth")
* @return List of unique FormPath objects
*/
public Set<FormPath> extractAllInputPaths(List<Benefit> benefits) {
Set<FormPath> pathSet = new HashSet<>();
public List<FormPath> extractUniqueInputPaths(List<Benefit> benefits) {
Map<String, String> pathTypeMap = new HashMap<>();

for (Benefit benefit : benefits) {
List<CheckConfig> checks = benefit.getChecks();
if (checks == null) continue;

for (CheckConfig check : checks) {
JsonNode transformedSchema = transformInputDefinitionSchema(check);
List<FormPath> paths = extractJsonSchemaPaths(transformedSchema);
pathSet.addAll(paths);
List<FormPath> checkFormPaths = extractJsonSchemaPaths(transformedSchema);
for (FormPath checkFormPath : checkFormPaths) {
// If the same path exists with different types, keep the first one found
pathTypeMap.putIfAbsent(checkFormPath.getPath(), checkFormPath.getType());
}
}
}

return pathSet;
// Convert to sorted list of FormPath objects
return pathTypeMap.entrySet().stream()
.map(entry -> new FormPath(entry.getKey(), entry.getValue()))
.toList();
}

/**
Expand Down
Loading