diff --git a/src/main/java/no/ssb/dlp/pseudo/service/pseudo/RecordMapProcessorFactory.java b/src/main/java/no/ssb/dlp/pseudo/service/pseudo/RecordMapProcessorFactory.java index fb7e50e..52e52be 100644 --- a/src/main/java/no/ssb/dlp/pseudo/service/pseudo/RecordMapProcessorFactory.java +++ b/src/main/java/no/ssb/dlp/pseudo/service/pseudo/RecordMapProcessorFactory.java @@ -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()) @@ -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 pseudoKeysetsOf(List encryptedKeysets) { @@ -192,5 +199,4 @@ private MapFailureStrategy getMapFailureStrategy(Map config) { config.getOrDefault(MapFuncConfig.Param.MAP_FAILURE_STRATEGY, null) ).map(String::valueOf).map(MapFailureStrategy::valueOf).orElse(MapFailureStrategy.RETURN_ORIGINAL); } - }