Skip to content

Commit 8901264

Browse files
authored
Revert "Reapply "Revert changes to pseudo metadata (#133)" (#134) (#136)" (#137)
This reverts commit e77d026.
1 parent 61f87fb commit 8901264

File tree

9 files changed

+61
-51
lines changed

9 files changed

+61
-51
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.2</dapla-datadoc-model.version>
25+
<dapla-datadoc-model.version>1.4</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\": {\"pseudo_variables\": ["))
22+
.concatWith(Flowable.just("], \"datadoc_metadata\": {\"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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ 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())
152151
.encryptionKeyReference(funcDeclaration.getArgs().getOrDefault(KEY_REFERENCE, null))
153152
.encryptionAlgorithm(match.getFunc().getAlgorithm())
154153
.stableIdentifierVersion(sidSnapshotDate)

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

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

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

89
import java.util.List;
910
import java.util.Map;
@@ -17,25 +18,35 @@ public class FieldMetadata {
1718

1819
String shortName;
1920
String dataElementPath;
20-
String dataElementPattern;
2121
String encryptionKeyReference;
2222
String encryptionAlgorithm;
2323
String stableIdentifierVersion;
2424
boolean stableIdentifierType;
2525
Map<String, String> encryptionAlgorithmParameters;
2626

27-
public PseudoVariable toDatadocPseudoVariable() {
28-
return PseudoVariable.builder()
29-
.withShortName(shortName)
30-
.withDataElementPath(dataElementPath)
31-
.withDataElementPattern(dataElementPattern)
32-
.withEncryptionKeyReference(encryptionKeyReference)
27+
// Create a partial datadoc variable which only contains pseudonymization information
28+
public Variable toDatadocVariable() {
29+
final var pseudonymization =
30+
Pseudonymization.builder()
3331
.withEncryptionAlgorithm(encryptionAlgorithm)
32+
.withEncryptionKeyReference(encryptionKeyReference)
3433
.withEncryptionAlgorithmParameters(
35-
toEncryptionAlgorithmParameters())
34+
toEncryptionAlgorithmParameters()
35+
)
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();
3950
}
4051

4152
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::toDatadocPseudoVariable).map(Json::from);
38+
return datadocMetadata.map(FieldMetadata::toDatadocVariable).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,7 +44,6 @@ private static PseudoMetadataProcessor createPseudoMetadataProcessor() {
4444
processor.addMetadata(FieldMetadata.builder()
4545
.shortName("shortName")
4646
.dataElementPath("path")
47-
.dataElementPattern("pattern")
4847
.encryptionKeyReference("pattern")
4948
.encryptionAlgorithm("algorithm")
5049
.encryptionAlgorithmParameters(Map.of("key", "value"))
@@ -79,20 +78,21 @@ void processWithNullValues() throws JSONException {
7978
"processedValue v2"
8079
],
8180
"datadoc_metadata": {
82-
"pseudo_variables": [
81+
"variables": [
8382
{
8483
"short_name": "shortName",
8584
"data_element_path": "path",
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-
]
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+
}
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,7 +73,6 @@ private static PseudoMetadataProcessor createPseudoMetadataProcessor() {
7373
processor.addMetadata(FieldMetadata.builder()
7474
.shortName("shortName")
7575
.dataElementPath("path")
76-
.dataElementPattern("pattern")
7776
.encryptionKeyReference("pattern")
7877
.encryptionAlgorithm("algorithm")
7978
.encryptionAlgorithmParameters(Map.of("key", "value"))
@@ -108,20 +107,21 @@ void processWithNullValues() throws JSONException {
108107
"processedValue v2"
109108
],
110109
"datadoc_metadata": {
111-
"pseudo_variables": [
110+
"variables": [
112111
{
113112
"short_name": "shortName",
114113
"data_element_path": "path",
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-
]
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+
}
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-
"pseudo_variables": [
52+
"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,7 +42,6 @@ private static PseudoMetadataProcessor createPseudoMetadataProcessor() {
4242
processor.addMetadata(FieldMetadata.builder()
4343
.shortName("shortName")
4444
.dataElementPath("path")
45-
.dataElementPattern("pattern")
4645
.encryptionKeyReference("pattern")
4746
.encryptionAlgorithm("algorithm")
4847
.encryptionAlgorithmParameters(Map.of("key", "value"))
@@ -77,20 +76,21 @@ void processWithNullValues() throws JSONException {
7776
"processedValue v2"
7877
],
7978
"datadoc_metadata": {
80-
"pseudo_variables": [
79+
"variables": [
8180
{
8281
"short_name": "shortName",
8382
"data_element_path": "path",
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-
]
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+
}
9494
}
9595
]
9696
},

0 commit comments

Comments
 (0)