Skip to content

Commit 57240a8

Browse files
authored
Revert changes to pseudo metadata (#133)
1 parent 40906f2 commit 57240a8

File tree

9 files changed

+51
-61
lines changed

9 files changed

+51
-61
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ssb-datadoc-model.url>https://maven.pkg.github.com/statisticsnorway/ssb-datadoc-model</ssb-datadoc-model.url>
2323
<github.repository>statisticsnorway/pseudo-service</github.repository>
2424
<exec.mainClass>no.ssb.dlp.pseudo.service.Application</exec.mainClass>
25-
<dapla-datadoc-model.version>1.4</dapla-datadoc-model.version>
25+
<dapla-datadoc-model.version>1.2</dapla-datadoc-model.version>
2626
<artifactregistry-maven-wagon.version>2.2.1</artifactregistry-maven-wagon.version>
2727
<dapla-dlp-pseudo-core.version>2.0.6</dapla-dlp-pseudo-core.version>
2828
<micronaut.version>4.7.6</micronaut.version>

src/main/java/no/ssb/dlp/pseudo/service/pseudo/PseudoResponseSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static Flowable<String> serialize(Flowable<String> data, Flowable<String>
1919
return enclose(data.concatMap(item -> Flowable.just(item, ","))
2020
.startWith("\"data\": [")
2121
.skipLast(1) // Skip last comma
22-
.concatWith(Flowable.just("], \"datadoc_metadata\": {\"variables\": ["))
22+
.concatWith(Flowable.just("], \"datadoc_metadata\": {\"pseudo_variables\": ["))
2323
.concatWith(metadata.concatMap(item -> Flowable.just(item, ",")).skipLast(1))
2424
.concatWith(Flowable.just("]}, \"metrics\": ["))
2525
.concatWith(metrics.concatMap(item -> Flowable.just(item, ",")).skipLast(1))

src/main/java/no/ssb/dlp/pseudo/service/pseudo/RecordMapProcessorFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ private String process(PseudoOperation operation,
148148
metadataProcessor.addMetadata(FieldMetadata.builder()
149149
.shortName(field.getName())
150150
.dataElementPath(normalizePath(field.getPath())) // Skip leading slash and use dot as separator
151+
.dataElementPattern(match.getRule().getPattern())
151152
.encryptionKeyReference(funcDeclaration.getArgs().getOrDefault(KEY_REFERENCE, null))
152153
.encryptionAlgorithm(match.getFunc().getAlgorithm())
153154
.stableIdentifierVersion(sidSnapshotDate)

src/main/java/no/ssb/dlp/pseudo/service/pseudo/metadata/FieldMetadata.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import lombok.Builder;
44
import lombok.Value;
5-
import no.ssb.dapla.metadata.datadoc.EncryptionAlgorithmParameter;
6-
import no.ssb.dapla.metadata.datadoc.Pseudonymization;
7-
import no.ssb.dapla.metadata.datadoc.Variable;
5+
import no.ssb.dapla.metadata.EncryptionAlgorithmParameter;
6+
import no.ssb.dapla.metadata.PseudoVariable;
87

98
import java.util.List;
109
import java.util.Map;
@@ -18,35 +17,25 @@ public class FieldMetadata {
1817

1918
String shortName;
2019
String dataElementPath;
20+
String dataElementPattern;
2121
String encryptionKeyReference;
2222
String encryptionAlgorithm;
2323
String stableIdentifierVersion;
2424
boolean stableIdentifierType;
2525
Map<String, String> encryptionAlgorithmParameters;
2626

27-
// Create a partial datadoc variable which only contains pseudonymization information
28-
public Variable toDatadocVariable() {
29-
final var pseudonymization =
30-
Pseudonymization.builder()
31-
.withEncryptionAlgorithm(encryptionAlgorithm)
27+
public PseudoVariable toDatadocPseudoVariable() {
28+
return PseudoVariable.builder()
29+
.withShortName(shortName)
30+
.withDataElementPath(dataElementPath)
31+
.withDataElementPattern(dataElementPattern)
3232
.withEncryptionKeyReference(encryptionKeyReference)
33+
.withEncryptionAlgorithm(encryptionAlgorithm)
3334
.withEncryptionAlgorithmParameters(
34-
toEncryptionAlgorithmParameters()
35-
)
35+
toEncryptionAlgorithmParameters())
3636
.withStableIdentifierVersion(stableIdentifierVersion)
3737
.withStableIdentifierType(stableIdentifierType ? STABLE_IDENTIFIER_TYPE : null)
3838
.build();
39-
return Variable.builder()
40-
.withShortName(shortName)
41-
.withDataElementPath(dataElementPath)
42-
.withPseudonymization(pseudonymization)
43-
// we explicitly set these keys to 'null' so that their keys don't show up in the serialized json object
44-
.withName(null)
45-
.withPopulationDescription(null)
46-
.withComment(null)
47-
.withInvalidValueDescription(null)
48-
.withCustomType(null)
49-
.build();
5039
}
5140

5241
private List<EncryptionAlgorithmParameter> toEncryptionAlgorithmParameters() {

src/main/java/no/ssb/dlp/pseudo/service/pseudo/metadata/PseudoMetadataProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void addMetric(FieldMetric fieldMetric) {
3535
metrics.onNext(fieldMetric);
3636
}
3737
public Publisher<String> getMetadata() {
38-
return datadocMetadata.map(FieldMetadata::toDatadocVariable).map(Json::from);
38+
return datadocMetadata.map(FieldMetadata::toDatadocPseudoVariable).map(Json::from);
3939
}
4040
public Publisher<String> getLogs() {
4141
return logs.map(Json::from);

src/test/java/no/ssb/dlp/pseudo/service/pseudo/DepseudoFieldTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private static PseudoMetadataProcessor createPseudoMetadataProcessor() {
4444
processor.addMetadata(FieldMetadata.builder()
4545
.shortName("shortName")
4646
.dataElementPath("path")
47+
.dataElementPattern("pattern")
4748
.encryptionKeyReference("pattern")
4849
.encryptionAlgorithm("algorithm")
4950
.encryptionAlgorithmParameters(Map.of("key", "value"))
@@ -78,21 +79,20 @@ void processWithNullValues() throws JSONException {
7879
"processedValue v2"
7980
],
8081
"datadoc_metadata": {
81-
"variables": [
82+
"pseudo_variables": [
8283
{
8384
"short_name": "shortName",
8485
"data_element_path": "path",
85-
"pseudonymization": {
86-
"encryption_key_reference": "pattern",
87-
"encryption_algorithm": "algorithm",
88-
"stable_identifier_version": "stableIdVersion",
89-
"stable_identifier_type": "FREG_SNR",
90-
"encryption_algorithm_parameters": [
91-
{
92-
"key": "value"
93-
}
94-
]
95-
}
86+
"data_element_pattern": "pattern",
87+
"encryption_key_reference": "pattern",
88+
"encryption_algorithm": "algorithm",
89+
"stable_identifier_version": "stableIdVersion",
90+
"stable_identifier_type": "FREG_SNR",
91+
"encryption_algorithm_parameters": [
92+
{
93+
"key": "value"
94+
}
95+
]
9696
}
9797
]
9898
},

src/test/java/no/ssb/dlp/pseudo/service/pseudo/PseudoFieldTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private static PseudoMetadataProcessor createPseudoMetadataProcessor() {
7373
processor.addMetadata(FieldMetadata.builder()
7474
.shortName("shortName")
7575
.dataElementPath("path")
76+
.dataElementPattern("pattern")
7677
.encryptionKeyReference("pattern")
7778
.encryptionAlgorithm("algorithm")
7879
.encryptionAlgorithmParameters(Map.of("key", "value"))
@@ -107,21 +108,20 @@ void processWithNullValues() throws JSONException {
107108
"processedValue v2"
108109
],
109110
"datadoc_metadata": {
110-
"variables": [
111+
"pseudo_variables": [
111112
{
112113
"short_name": "shortName",
113114
"data_element_path": "path",
114-
"pseudonymization": {
115-
"stable_identifier_type": "FREG_SNR",
116-
"stable_identifier_version": "stableIdVersion",
117-
"encryption_algorithm": "algorithm",
118-
"encryption_key_reference": "pattern",
119-
"encryption_algorithm_parameters": [
120-
{
121-
"key": "value"
122-
}
123-
]
124-
}
115+
"data_element_pattern": "pattern",
116+
"stable_identifier_type": "FREG_SNR",
117+
"stable_identifier_version": "stableIdVersion",
118+
"encryption_algorithm": "algorithm",
119+
"encryption_key_reference": "pattern",
120+
"encryption_algorithm_parameters": [
121+
{
122+
"key": "value"
123+
}
124+
]
125125
}
126126
]
127127
},

src/test/java/no/ssb/dlp/pseudo/service/pseudo/PseudoResponseSerializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void testSerializeMap() throws JSONException {
4949
}
5050
],
5151
"datadoc_metadata": {
52-
"variables": [
52+
"pseudo_variables": [
5353
{
5454
"variable_descriptions": {
5555
"name": {

src/test/java/no/ssb/dlp/pseudo/service/pseudo/RepseudoFieldTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private static PseudoMetadataProcessor createPseudoMetadataProcessor() {
4242
processor.addMetadata(FieldMetadata.builder()
4343
.shortName("shortName")
4444
.dataElementPath("path")
45+
.dataElementPattern("pattern")
4546
.encryptionKeyReference("pattern")
4647
.encryptionAlgorithm("algorithm")
4748
.encryptionAlgorithmParameters(Map.of("key", "value"))
@@ -76,21 +77,20 @@ void processWithNullValues() throws JSONException {
7677
"processedValue v2"
7778
],
7879
"datadoc_metadata": {
79-
"variables": [
80+
"pseudo_variables": [
8081
{
8182
"short_name": "shortName",
8283
"data_element_path": "path",
83-
"pseudonymization": {
84-
"encryption_key_reference": "pattern",
85-
"encryption_algorithm": "algorithm",
86-
"stable_identifier_version": "stableIdVersion",
87-
"stable_identifier_type": "FREG_SNR",
88-
"encryption_algorithm_parameters": [
89-
{
90-
"key": "value"
91-
}
92-
]
93-
}
84+
"data_element_pattern": "pattern",
85+
"encryption_key_reference": "pattern",
86+
"encryption_algorithm": "algorithm",
87+
"stable_identifier_version": "stableIdVersion",
88+
"stable_identifier_type": "FREG_SNR",
89+
"encryption_algorithm_parameters": [
90+
{
91+
"key": "value"
92+
}
93+
]
9494
}
9595
]
9696
},

0 commit comments

Comments
 (0)