Skip to content

Commit

Permalink
Paths in datadoc should not contain the array indices. (#113)
Browse files Browse the repository at this point in the history
* Paths in datadoc should not contain the array indices.

* Code cleanup
  • Loading branch information
bjornandre authored May 10, 2024
1 parent 2b9fbb6 commit 84a4cf8
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private String process(PseudoOperation operation,
}
metadataProcessor.addMetadata(FieldMetadata.builder()
.shortName(field.getName())
.dataElementPath(field.getPath().substring(1).replace('/', '.')) // Skip leading slash and use dot as separator
.dataElementPath(normalizePath(field.getPath())) // Skip leading slash and use dot as separator
.dataElementPattern(match.getRule().getPattern())
.encryptionKeyReference(funcDeclaration.getArgs().getOrDefault(KEY_REFERENCE, null))
.encryptionAlgorithm(match.getFunc().getAlgorithm())
Expand Down Expand Up @@ -179,6 +179,13 @@ private String process(PseudoOperation operation,
}
}

private static String normalizePath(String path) {
// Normalize the path by skipping leading '/' and use dot as separator
return path.substring(1).replace('/', '.')
// Also replace the [] separator in nested structs
.replaceAll("\\[\\d*]", "");
}


// TODO: This should not be needed
protected static List<PseudoKeyset> pseudoKeysetsOf(List<EncryptedKeysetWrapper> encryptedKeysets) {
Expand All @@ -192,5 +199,4 @@ private MapFailureStrategy getMapFailureStrategy(Map<String, String> config) {
config.getOrDefault(MapFuncConfig.Param.MAP_FAILURE_STRATEGY, null)
).map(String::valueOf).map(MapFailureStrategy::valueOf).orElse(MapFailureStrategy.RETURN_ORIGINAL);
}

}

0 comments on commit 84a4cf8

Please sign in to comment.