Skip to content

Commit

Permalink
Add data_element_pattern field (#27)
Browse files Browse the repository at this point in the history
* Add data_element_pattern field

* [GENERATE] Java classes from JSON Schema

* [GENERATE] Pydantic models from JSON Schema

---------

Co-authored-by: dapla-bot[bot] <143391972+dapla-bot[bot]@users.noreply.github.com>
  • Loading branch information
mmwinther and dapla-bot[bot] authored Dec 6, 2023
1 parent 08121c6 commit c4c8b4f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@JsonPropertyOrder({
"short_name",
"data_element_path",
"data_element_pattern",
"stable_identifier_type",
"stable_identifier_version",
"encryption_algorithm",
Expand All @@ -55,12 +56,21 @@ public class PseudoVariable implements Serializable
/**
* Data element path
* <p>
* Path to one or multiple data element(s) in the dataset.Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path.
* Path to a single, concrete data element in the dataset.Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path.
*
*/
@JsonProperty("data_element_path")
@JsonPropertyDescription("Path to one or multiple data element(s) in the dataset.")
@JsonPropertyDescription("Path to a single, concrete data element in the dataset.")
private String dataElementPath;
/**
* Data element pattern
* <p>
* Pattern which matched this variable (if a pattern was used).Typically a glob pattern.
*
*/
@JsonProperty("data_element_pattern")
@JsonPropertyDescription("Pattern which matched this variable (if a pattern was used).")
private String dataElementPattern;
/**
* Stable identifier type
* <p>
Expand Down Expand Up @@ -132,7 +142,7 @@ public class PseudoVariable implements Serializable
@JsonIgnore
@Valid
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
private final static long serialVersionUID = -6450199571654355576L;
private final static long serialVersionUID = -1415496424825597852L;

/**
* No args constructor for use in serialization
Expand All @@ -148,24 +158,27 @@ public PseudoVariable() {
* @param encryptionKeyReference
* Encryption key reference. Name of or reference to the encryption key used to pseudonymize the variable.
* @param dataElementPath
* Data element path. Path to one or multiple data element(s) in the dataset.
* Data element path. Path to a single, concrete data element in the dataset.
* @param sourceVariable
* Source variable. Short name of the source variable.
* @param sourceVariableDatatype
* Source variable data type. Data type of the variable prior to pseudonymization.
* @param encryptionAlgorithmParameters
* Encryption algorithm parameters. Parameters supplied to the encryption algorithm.
* @param dataElementPattern
* Data element pattern. Pattern which matched this variable (if a pattern was used).
* @param stableIdentifierVersion
* Stable identifier version. Version of stable identifier the variable was mapped to prior to pseudonymization.
* @param shortName
* Short name. Physical name of the variable in the dataset. Should match the recommended short name.
* @param encryptionAlgorithm
* Encryption algorithm. The encryption algorithm used to pseudonymize the variable.
*/
public PseudoVariable(String shortName, String dataElementPath, String stableIdentifierType, String stableIdentifierVersion, String encryptionAlgorithm, String encryptionKeyReference, List<EncryptionAlgorithmParameter> encryptionAlgorithmParameters, String sourceVariable, PseudoVariable.SourceVariableDatatype sourceVariableDatatype) {
public PseudoVariable(String shortName, String dataElementPath, String dataElementPattern, String stableIdentifierType, String stableIdentifierVersion, String encryptionAlgorithm, String encryptionKeyReference, List<EncryptionAlgorithmParameter> encryptionAlgorithmParameters, String sourceVariable, PseudoVariable.SourceVariableDatatype sourceVariableDatatype) {
super();
this.shortName = shortName;
this.dataElementPath = dataElementPath;
this.dataElementPattern = dataElementPattern;
this.stableIdentifierType = stableIdentifierType;
this.stableIdentifierVersion = stableIdentifierVersion;
this.encryptionAlgorithm = encryptionAlgorithm;
Expand Down Expand Up @@ -202,7 +215,7 @@ public void setShortName(String shortName) {
/**
* Data element path
* <p>
* Path to one or multiple data element(s) in the dataset.Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path.
* Path to a single, concrete data element in the dataset.Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path.
*
*/
@JsonProperty("data_element_path")
Expand All @@ -213,14 +226,36 @@ public String getDataElementPath() {
/**
* Data element path
* <p>
* Path to one or multiple data element(s) in the dataset.Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path.
* Path to a single, concrete data element in the dataset.Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path.
*
*/
@JsonProperty("data_element_path")
public void setDataElementPath(String dataElementPath) {
this.dataElementPath = dataElementPath;
}

/**
* Data element pattern
* <p>
* Pattern which matched this variable (if a pattern was used).Typically a glob pattern.
*
*/
@JsonProperty("data_element_pattern")
public String getDataElementPattern() {
return dataElementPattern;
}

/**
* Data element pattern
* <p>
* Pattern which matched this variable (if a pattern was used).Typically a glob pattern.
*
*/
@JsonProperty("data_element_pattern")
public void setDataElementPattern(String dataElementPattern) {
this.dataElementPattern = dataElementPattern;
}

/**
* Stable identifier type
* <p>
Expand Down Expand Up @@ -401,6 +436,10 @@ public String toString() {
sb.append('=');
sb.append(((this.dataElementPath == null)?"<null>":this.dataElementPath));
sb.append(',');
sb.append("dataElementPattern");
sb.append('=');
sb.append(((this.dataElementPattern == null)?"<null>":this.dataElementPattern));
sb.append(',');
sb.append("stableIdentifierType");
sb.append('=');
sb.append(((this.stableIdentifierType == null)?"<null>":this.stableIdentifierType));
Expand Down Expand Up @@ -450,6 +489,7 @@ public int hashCode() {
result = ((result* 31)+((this.sourceVariable == null)? 0 :this.sourceVariable.hashCode()));
result = ((result* 31)+((this.sourceVariableDatatype == null)? 0 :this.sourceVariableDatatype.hashCode()));
result = ((result* 31)+((this.encryptionAlgorithmParameters == null)? 0 :this.encryptionAlgorithmParameters.hashCode()));
result = ((result* 31)+((this.dataElementPattern == null)? 0 :this.dataElementPattern.hashCode()));
result = ((result* 31)+((this.stableIdentifierVersion == null)? 0 :this.stableIdentifierVersion.hashCode()));
result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode()));
result = ((result* 31)+((this.shortName == null)? 0 :this.shortName.hashCode()));
Expand All @@ -466,7 +506,7 @@ public boolean equals(Object other) {
return false;
}
PseudoVariable rhs = ((PseudoVariable) other);
return (((((((((((this.stableIdentifierType == rhs.stableIdentifierType)||((this.stableIdentifierType!= null)&&this.stableIdentifierType.equals(rhs.stableIdentifierType)))&&((this.encryptionKeyReference == rhs.encryptionKeyReference)||((this.encryptionKeyReference!= null)&&this.encryptionKeyReference.equals(rhs.encryptionKeyReference))))&&((this.dataElementPath == rhs.dataElementPath)||((this.dataElementPath!= null)&&this.dataElementPath.equals(rhs.dataElementPath))))&&((this.sourceVariable == rhs.sourceVariable)||((this.sourceVariable!= null)&&this.sourceVariable.equals(rhs.sourceVariable))))&&((this.sourceVariableDatatype == rhs.sourceVariableDatatype)||((this.sourceVariableDatatype!= null)&&this.sourceVariableDatatype.equals(rhs.sourceVariableDatatype))))&&((this.encryptionAlgorithmParameters == rhs.encryptionAlgorithmParameters)||((this.encryptionAlgorithmParameters!= null)&&this.encryptionAlgorithmParameters.equals(rhs.encryptionAlgorithmParameters))))&&((this.stableIdentifierVersion == rhs.stableIdentifierVersion)||((this.stableIdentifierVersion!= null)&&this.stableIdentifierVersion.equals(rhs.stableIdentifierVersion))))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.shortName == rhs.shortName)||((this.shortName!= null)&&this.shortName.equals(rhs.shortName))))&&((this.encryptionAlgorithm == rhs.encryptionAlgorithm)||((this.encryptionAlgorithm!= null)&&this.encryptionAlgorithm.equals(rhs.encryptionAlgorithm))));
return ((((((((((((this.stableIdentifierType == rhs.stableIdentifierType)||((this.stableIdentifierType!= null)&&this.stableIdentifierType.equals(rhs.stableIdentifierType)))&&((this.encryptionKeyReference == rhs.encryptionKeyReference)||((this.encryptionKeyReference!= null)&&this.encryptionKeyReference.equals(rhs.encryptionKeyReference))))&&((this.dataElementPath == rhs.dataElementPath)||((this.dataElementPath!= null)&&this.dataElementPath.equals(rhs.dataElementPath))))&&((this.sourceVariable == rhs.sourceVariable)||((this.sourceVariable!= null)&&this.sourceVariable.equals(rhs.sourceVariable))))&&((this.sourceVariableDatatype == rhs.sourceVariableDatatype)||((this.sourceVariableDatatype!= null)&&this.sourceVariableDatatype.equals(rhs.sourceVariableDatatype))))&&((this.encryptionAlgorithmParameters == rhs.encryptionAlgorithmParameters)||((this.encryptionAlgorithmParameters!= null)&&this.encryptionAlgorithmParameters.equals(rhs.encryptionAlgorithmParameters))))&&((this.dataElementPattern == rhs.dataElementPattern)||((this.dataElementPattern!= null)&&this.dataElementPattern.equals(rhs.dataElementPattern))))&&((this.stableIdentifierVersion == rhs.stableIdentifierVersion)||((this.stableIdentifierVersion!= null)&&this.stableIdentifierVersion.equals(rhs.stableIdentifierVersion))))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.shortName == rhs.shortName)||((this.shortName!= null)&&this.shortName.equals(rhs.shortName))))&&((this.encryptionAlgorithm == rhs.encryptionAlgorithm)||((this.encryptionAlgorithm!= null)&&this.encryptionAlgorithm.equals(rhs.encryptionAlgorithm))));
}


Expand Down
11 changes: 8 additions & 3 deletions generated/python/datadoc_model/datadoc_model/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: metadata-container-json-schema.json
# timestamp: 2023-11-22T13:01:43+00:00
# timestamp: 2023-12-05T13:27:31+00:00

from __future__ import annotations

Expand Down Expand Up @@ -113,9 +113,14 @@ class PseudoVariable(BaseModel):
)
data_element_path: Optional[str] = Field(
None,
description='Path to one or multiple data element(s) in the dataset.',
description='Path to a single, concrete data element in the dataset.',
title='Data element path',
)
data_element_pattern: Optional[str] = Field(
None,
description='Pattern which matched this variable (if a pattern was used).',
title='Data element pattern',
)
stable_identifier_type: Optional[str] = Field(
None,
description='Type of stable identifier the variable was mapped to prior to pseudonymization.',
Expand Down Expand Up @@ -152,7 +157,7 @@ class PseudoVariable(BaseModel):


class PseudonymizationJsonSchema(BaseModel):
document_version: Literal['0.0.1'] = '0.0.1'
document_version: Literal['0.1.0'] = '0.1.0'
pseudo_dataset: PseudoDataset
pseudo_variables: list[PseudoVariable]

Expand Down
10 changes: 8 additions & 2 deletions src/pseudonymization/pseudonymization-json-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"properties": {
"document_version": {
"$comment": "Version of this Json Schema",
"const": "0.0.1"
"const": "0.1.0"
},
"pseudo_dataset": {
"properties": {
Expand Down Expand Up @@ -41,9 +41,15 @@
"data_element_path": {
"type": "string",
"title": "Data element path",
"description": "Path to one or multiple data element(s) in the dataset.",
"description": "Path to a single, concrete data element in the dataset.",
"$comment": "Only for use in heirarchical datasets. Use JsonPath dot-notation to specify the path."
},
"data_element_pattern": {
"type": "string",
"title": "Data element pattern",
"description": "Pattern which matched this variable (if a pattern was used).",
"$comment": "Typically a glob pattern."
},
"stable_identifier_type": {
"type": "string",
"title": "Stable identifier type",
Expand Down

0 comments on commit c4c8b4f

Please sign in to comment.