From da27e9f0d1e859bcc38c0ae54defb2bd97df91e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:05:21 +0100 Subject: [PATCH 01/49] Added ARRAY to data_type-enum for variable. --- src/datadoc/datadoc-json-schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index b383b92..e8998a6 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -212,7 +212,8 @@ "INTEGER", "DATETIME", "BOOLEAN", - "FLOAT" + "FLOAT", + "ARRAY" ] }, "variable_role": { From 5af8a65ff20c308f02d77dbd8f2525209c4386bb Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:06:09 +0000 Subject: [PATCH 02/49] [GENERATE] Java classes from JSON Schema --- .../src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java index 987303d..f232b4c 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java @@ -817,7 +817,8 @@ public enum DataType { INTEGER("INTEGER"), DATETIME("DATETIME"), BOOLEAN("BOOLEAN"), - FLOAT("FLOAT"); + FLOAT("FLOAT"), + ARRAY("ARRAY"); private final String value; private final static Map CONSTANTS = new HashMap(); From 1e62950905768e67e6870f18b3b65183e74b6ba4 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:06:54 +0000 Subject: [PATCH 03/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 7a86ce1..836daf4 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-01-05T12:58:00+00:00 +# timestamp: 2024-02-05T10:06:54+00:00 from __future__ import annotations @@ -40,6 +40,7 @@ class DataType(str, Enum): DATETIME = "DATETIME" BOOLEAN = "BOOLEAN" FLOAT = "FLOAT" + ARRAY = "ARRAY" class VariableRole(str, Enum): From e46592d78f06abfecc9bd2ca94e51f1043eafbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:26:07 +0100 Subject: [PATCH 04/49] New attribute multiplication_factor added variable model. --- src/datadoc/datadoc-json-schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index e8998a6..61e1cc8 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -265,6 +265,11 @@ "$comment": "TODO: measurement_unit implemented as string. In the future this should be implemente as enum? See https://www.ssb.no/klass/klassifikasjoner/303/koder", "type": "string" }, + "multiplication_factor": { + "title": "Multiplication factor", + "description": "A multiplication factor is a number that amplifies or increases the base value of something else.", + "type": "integer" + }, "format": { "title": "Format", "description": "The format of the values ​​(physical format or regular expression) in machine-readable form for validation. This can be used as a further specification of the data type (dataType) in those cases where this is relevant.", From d41475e667a3d714243b4616ead5b6fa9424d609 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:26:56 +0000 Subject: [PATCH 05/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Variable.java | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java index f232b4c..6b37139 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java @@ -34,6 +34,7 @@ "comment", "temporality_type", "measurement_unit", + "multiplication_factor", "format", "classification_uri", "sentinel_value_uri", @@ -144,6 +145,15 @@ public class Variable implements Serializable @JsonProperty("measurement_unit") @JsonPropertyDescription("Measurement unit") private String measurementUnit; + /** + * Multiplication factor + *

+ * A multiplication factor is a number that amplifies or increases the base value of something else. + * + */ + @JsonProperty("multiplication_factor") + @JsonPropertyDescription("A multiplication factor is a number that amplifies or increases the base value of something else.") + private Integer multiplicationFactor; /** * Format *

@@ -210,7 +220,7 @@ public class Variable implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -2952914587996934465L; + private final static long serialVersionUID = -3016237275954677161L; /** * No args constructor for use in serialization @@ -255,10 +265,12 @@ public Variable() { * Short name. Physical name of the variable in the dataset. Should match the recommended short name. * @param dataSource * Data source. Data source. Set at data set level, but can be overwritten at variable instance level. + * @param multiplicationFactor + * Multiplication factor. A multiplication factor is a number that amplifies or increases the base value of something else. * @param invalidValueDescription * Invalid value(s) description. Invalid value(s) description used in addition (or as an alternative) to standard sentinel values. */ - public Variable(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public Variable(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { super(); this.shortName = shortName; this.name = name; @@ -271,6 +283,7 @@ public Variable(String shortName, LanguageStringType name, Variable.DataType dat this.comment = comment; this.temporalityType = temporalityType; this.measurementUnit = measurementUnit; + this.multiplicationFactor = multiplicationFactor; this.format = format; this.classificationUri = classificationUri; this.sentinelValueUri = sentinelValueUri; @@ -516,6 +529,28 @@ public void setMeasurementUnit(String measurementUnit) { this.measurementUnit = measurementUnit; } + /** + * Multiplication factor + *

+ * A multiplication factor is a number that amplifies or increases the base value of something else. + * + */ + @JsonProperty("multiplication_factor") + public Integer getMultiplicationFactor() { + return multiplicationFactor; + } + + /** + * Multiplication factor + *

+ * A multiplication factor is a number that amplifies or increases the base value of something else. + * + */ + @JsonProperty("multiplication_factor") + public void setMultiplicationFactor(Integer multiplicationFactor) { + this.multiplicationFactor = multiplicationFactor; + } + /** * Format *

@@ -726,6 +761,10 @@ public String toString() { sb.append('='); sb.append(((this.measurementUnit == null)?"":this.measurementUnit)); sb.append(','); + sb.append("multiplicationFactor"); + sb.append('='); + sb.append(((this.multiplicationFactor == null)?"":this.multiplicationFactor)); + sb.append(','); sb.append("format"); sb.append('='); sb.append(((this.format == null)?"":this.format)); @@ -787,6 +826,7 @@ public int hashCode() { result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); result = ((result* 31)+((this.shortName == null)? 0 :this.shortName.hashCode())); result = ((result* 31)+((this.dataSource == null)? 0 :this.dataSource.hashCode())); + result = ((result* 31)+((this.multiplicationFactor == null)? 0 :this.multiplicationFactor.hashCode())); result = ((result* 31)+((this.invalidValueDescription == null)? 0 :this.invalidValueDescription.hashCode())); return result; } @@ -800,7 +840,7 @@ public boolean equals(Object other) { return false; } Variable rhs = ((Variable) other); - return ((((((((((((((((((((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil)))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.sentinelValueUri == rhs.sentinelValueUri)||((this.sentinelValueUri!= null)&&this.sentinelValueUri.equals(rhs.sentinelValueUri))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); + return (((((((((((((((((((((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil)))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.sentinelValueUri == rhs.sentinelValueUri)||((this.sentinelValueUri!= null)&&this.sentinelValueUri.equals(rhs.sentinelValueUri))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); } @@ -863,8 +903,8 @@ public VariableBuilder() { super(); } - public VariableBuilder(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { - super(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, format, classificationUri, sentinelValueUri, invalidValueDescription, id, containsDataFrom, containsDataUntil); + public VariableBuilder(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + super(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, sentinelValueUri, invalidValueDescription, id, containsDataFrom, containsDataUntil); } } @@ -882,10 +922,10 @@ public VariableBuilderBase() { } @SuppressWarnings("unchecked") - public VariableBuilderBase(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public VariableBuilderBase(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Variable.VariableBuilder.class)) { - this.instance = ((T) new Variable(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, format, classificationUri, sentinelValueUri, invalidValueDescription, id, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Variable(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, sentinelValueUri, invalidValueDescription, id, containsDataFrom, containsDataUntil)); } } @@ -951,6 +991,11 @@ public Variable.VariableBuilderBase withMeasurementUnit(String measurementUnit) return this; } + public Variable.VariableBuilderBase withMultiplicationFactor(Integer multiplicationFactor) { + ((Variable) this.instance).multiplicationFactor = multiplicationFactor; + return this; + } + public Variable.VariableBuilderBase withFormat(String format) { ((Variable) this.instance).format = format; return this; From 92e9ee3d86157e9d4f551834f90fad6ab75be391 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:27:30 +0000 Subject: [PATCH 06/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 836daf4..59d62a3 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-05T10:06:54+00:00 +# timestamp: 2024-02-05T14:27:30+00:00 from __future__ import annotations @@ -329,6 +329,11 @@ class Variable(DatadocBaseModel): measurement_unit: Optional[str] = Field( None, description="Measurement unit", title="Measurement unit" ) + multiplication_factor: Optional[int] = Field( + None, + description="A multiplication factor is a number that amplifies or increases the base value of something else.", + title="Multiplication factor", + ) format: Optional[str] = Field( None, description="The format of the values \u200b\u200b(physical format or regular expression) in machine-readable form for validation. This can be used as a further specification of the data type (dataType) in those cases where this is relevant.", From 4b6dc7a866b2a6f7a6c7b165996be8d835de7799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:06:48 +0100 Subject: [PATCH 07/49] Replaced 'sentinel_value_uri' with a new object called 'special_value' (new object includes sentinel values and other values). --- src/datadoc/datadoc-json-schema.json | 64 +++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 61e1cc8..c0d9ee3 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -267,7 +267,7 @@ }, "multiplication_factor": { "title": "Multiplication factor", - "description": "A multiplication factor is a number that amplifies or increases the base value of something else.", + "description": "A multiplication factor for a value/result is a number that multiplies that value/result.", "type": "integer" }, "format": { @@ -281,11 +281,63 @@ "type": "string", "format": "uri" }, - "sentinel_value_uri": { - "title": "Sentinel value URI", - "description": "A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant", - "type": "string", - "format": "uri" + "special_value": { + "title": "Special values", + "type": "object", + "properties": { + "sentinel": { + "title": "Sentinel values", + "type": "object", + "properties": { + "sentinel_value_uri": { + "title": "Sentinel value URI", + "description": "A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/"), + "$comment": "Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway.", + "type": "string", + "format": "uri" + }, + "sentinel_value_elements": { + "title": "Sentinel value elements", + "description": "A selection (subset) of sentinel values in the 'sentinel_value_uri' ​​applicable to the data set.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "other_value": { + "description": "Other special values not represented as 'sentinel_values' in a standardized code list.", + "type": "array", + "items": { + "type": "object", + "properties": { + "code":{ + "title": "Code", + "description": "Other value code", + "type": "string" + }, + "name": { + "title": "Name", + "description": "Other value name (text)", + "$ref": "./no/languageStringType.json#/languageStringType" + }, + "valid_from": { + "title": "Valid from", + "description": "Other value valid from date", + "type": "string", + "format": "date-time" + }, + "valid_until": { + "title": "Valid until", + "description": "Other value until date", + "type": "string", + "format": "date-time" + } + } + } + } + } }, "invalid_value_description": { "title": "Invalid value(s) description", From 2ff2a0bd405c1b97d470ddf76223ec262a0f9516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:27:35 +0100 Subject: [PATCH 08/49] Replaced 'sentinel_value_uri' with a new object called 'special_value' (new object includes sentinel values and other values). --- src/datadoc/datadoc-json-schema.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index c0d9ee3..c6d4016 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -291,7 +291,7 @@ "properties": { "sentinel_value_uri": { "title": "Sentinel value URI", - "description": "A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/"), + "description": "A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/)", "$comment": "Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway.", "type": "string", "format": "uri" @@ -307,7 +307,8 @@ } }, "other_value": { - "description": "Other special values not represented as 'sentinel_values' in a standardized code list.", + "title": "Other special values", + "description": "Other special values not represented as 'sentinel_value' in a standardized code list.", "type": "array", "items": { "type": "object", From 3bbabb45a4fca574252baf60f77410b8e8eb1e7e Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:28:21 +0000 Subject: [PATCH 09/49] [GENERATE] Java classes from JSON Schema --- .../dapla/metadata/datadoc/OtherValue.java | 316 ++++++++++++++++++ .../metadata/datadoc/SentinelValues.java | 242 ++++++++++++++ .../dapla/metadata/datadoc/SpecialValues.java | 241 +++++++++++++ .../ssb/dapla/metadata/datadoc/Variable.java | 72 ++-- 4 files changed, 835 insertions(+), 36 deletions(-) create mode 100644 generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java create mode 100644 generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SentinelValues.java create mode 100644 generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SpecialValues.java diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java new file mode 100644 index 0000000..c246e83 --- /dev/null +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java @@ -0,0 +1,316 @@ + +package no.ssb.dapla.metadata.datadoc; + +import java.io.Serializable; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "code", + "name", + "valid_from", + "valid_until" +}) +@Generated("jsonschema2pojo") +public class OtherValue implements Serializable +{ + + /** + * Code + *

+ * Other value code + * + */ + @JsonProperty("code") + @JsonPropertyDescription("Other value code") + private String code; + /** + * Reusable langugage string type + * + */ + @JsonProperty("name") + @Valid + private LanguageStringType name; + /** + * Valid from + *

+ * Other value valid from date + * + */ + @JsonProperty("valid_from") + @JsonPropertyDescription("Other value valid from date") + private Date validFrom; + /** + * Valid until + *

+ * Other value until date + * + */ + @JsonProperty("valid_until") + @JsonPropertyDescription("Other value until date") + private Date validUntil; + @JsonIgnore + @Valid + private Map additionalProperties = new LinkedHashMap(); + private final static long serialVersionUID = -5723978274694723388L; + + /** + * No args constructor for use in serialization + * + */ + public OtherValue() { + } + + /** + * + * @param code + * Code. Other value code. + * @param name + * Name. Other value name (text). + * @param validUntil + * Valid until. Other value until date. + * @param validFrom + * Valid from. Other value valid from date. + */ + public OtherValue(String code, LanguageStringType name, Date validFrom, Date validUntil) { + super(); + this.code = code; + this.name = name; + this.validFrom = validFrom; + this.validUntil = validUntil; + } + + public static OtherValue.OtherValueBuilderBase builder() { + return new OtherValue.OtherValueBuilder(); + } + + /** + * Code + *

+ * Other value code + * + */ + @JsonProperty("code") + public String getCode() { + return code; + } + + /** + * Code + *

+ * Other value code + * + */ + @JsonProperty("code") + public void setCode(String code) { + this.code = code; + } + + /** + * Reusable langugage string type + * + */ + @JsonProperty("name") + public LanguageStringType getName() { + return name; + } + + /** + * Reusable langugage string type + * + */ + @JsonProperty("name") + public void setName(LanguageStringType name) { + this.name = name; + } + + /** + * Valid from + *

+ * Other value valid from date + * + */ + @JsonProperty("valid_from") + public Date getValidFrom() { + return validFrom; + } + + /** + * Valid from + *

+ * Other value valid from date + * + */ + @JsonProperty("valid_from") + public void setValidFrom(Date validFrom) { + this.validFrom = validFrom; + } + + /** + * Valid until + *

+ * Other value until date + * + */ + @JsonProperty("valid_until") + public Date getValidUntil() { + return validUntil; + } + + /** + * Valid until + *

+ * Other value until date + * + */ + @JsonProperty("valid_until") + public void setValidUntil(Date validUntil) { + this.validUntil = validUntil; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(OtherValue.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('['); + sb.append("code"); + sb.append('='); + sb.append(((this.code == null)?"":this.code)); + sb.append(','); + sb.append("name"); + sb.append('='); + sb.append(((this.name == null)?"":this.name)); + sb.append(','); + sb.append("validFrom"); + sb.append('='); + sb.append(((this.validFrom == null)?"":this.validFrom)); + sb.append(','); + sb.append("validUntil"); + sb.append('='); + sb.append(((this.validUntil == null)?"":this.validUntil)); + sb.append(','); + sb.append("additionalProperties"); + sb.append('='); + sb.append(((this.additionalProperties == null)?"":this.additionalProperties)); + sb.append(','); + if (sb.charAt((sb.length()- 1)) == ',') { + sb.setCharAt((sb.length()- 1), ']'); + } else { + sb.append(']'); + } + return sb.toString(); + } + + @Override + public int hashCode() { + int result = 1; + result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode())); + result = ((result* 31)+((this.validUntil == null)? 0 :this.validUntil.hashCode())); + result = ((result* 31)+((this.code == null)? 0 :this.code.hashCode())); + result = ((result* 31)+((this.validFrom == null)? 0 :this.validFrom.hashCode())); + result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); + return result; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof OtherValue) == false) { + return false; + } + OtherValue rhs = ((OtherValue) other); + return ((((((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name)))&&((this.validUntil == rhs.validUntil)||((this.validUntil!= null)&&this.validUntil.equals(rhs.validUntil))))&&((this.code == rhs.code)||((this.code!= null)&&this.code.equals(rhs.code))))&&((this.validFrom == rhs.validFrom)||((this.validFrom!= null)&&this.validFrom.equals(rhs.validFrom))))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties)))); + } + + public static class OtherValueBuilder + extends OtherValue.OtherValueBuilderBase + { + + + public OtherValueBuilder() { + super(); + } + + public OtherValueBuilder(String code, LanguageStringType name, Date validFrom, Date validUntil) { + super(code, name, validFrom, validUntil); + } + + } + + public static abstract class OtherValueBuilderBase{ + + protected T instance; + + @SuppressWarnings("unchecked") + public OtherValueBuilderBase() { + // Skip initialization when called from subclass + if (this.getClass().equals(OtherValue.OtherValueBuilder.class)) { + this.instance = ((T) new OtherValue()); + } + } + + @SuppressWarnings("unchecked") + public OtherValueBuilderBase(String code, LanguageStringType name, Date validFrom, Date validUntil) { + // Skip initialization when called from subclass + if (this.getClass().equals(OtherValue.OtherValueBuilder.class)) { + this.instance = ((T) new OtherValue(code, name, validFrom, validUntil)); + } + } + + public T build() { + T result; + result = this.instance; + this.instance = null; + return result; + } + + public OtherValue.OtherValueBuilderBase withCode(String code) { + ((OtherValue) this.instance).code = code; + return this; + } + + public OtherValue.OtherValueBuilderBase withName(LanguageStringType name) { + ((OtherValue) this.instance).name = name; + return this; + } + + public OtherValue.OtherValueBuilderBase withValidFrom(Date validFrom) { + ((OtherValue) this.instance).validFrom = validFrom; + return this; + } + + public OtherValue.OtherValueBuilderBase withValidUntil(Date validUntil) { + ((OtherValue) this.instance).validUntil = validUntil; + return this; + } + + public OtherValue.OtherValueBuilderBase withAdditionalProperty(String name, Object value) { + ((OtherValue) this.instance).additionalProperties.put(name, value); + return this; + } + + } + +} diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SentinelValues.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SentinelValues.java new file mode 100644 index 0000000..3faf8c6 --- /dev/null +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SentinelValues.java @@ -0,0 +1,242 @@ + +package no.ssb.dapla.metadata.datadoc; + +import java.io.Serializable; +import java.net.URI; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; + + +/** + * Sentinel values + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "sentinel_value_uri", + "sentinel_value_elements" +}) +@Generated("jsonschema2pojo") +public class SentinelValues implements Serializable +{ + + /** + * Sentinel value URI + *

+ * A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/) Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway. + * + */ + @JsonProperty("sentinel_value_uri") + @JsonPropertyDescription("A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/)") + private URI sentinelValueUri; + /** + * Sentinel value elements + *

+ * A selection (subset) of sentinel values in the 'sentinel_value_uri' ​​applicable to the data set. + * + */ + @JsonProperty("sentinel_value_elements") + @JsonPropertyDescription("A selection (subset) of sentinel values in the 'sentinel_value_uri' \u200b\u200bapplicable to the data set.") + @Valid + private List sentinelValueElements = new ArrayList(); + @JsonIgnore + @Valid + private Map additionalProperties = new LinkedHashMap(); + private final static long serialVersionUID = 6740706452491998917L; + + /** + * No args constructor for use in serialization + * + */ + public SentinelValues() { + } + + /** + * + * @param sentinelValueElements + * Sentinel value elements. A selection (subset) of sentinel values in the 'sentinel_value_uri' ​​applicable to the data set. + * @param sentinelValueUri + * Sentinel value URI. A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/). + */ + public SentinelValues(URI sentinelValueUri, List sentinelValueElements) { + super(); + this.sentinelValueUri = sentinelValueUri; + this.sentinelValueElements = sentinelValueElements; + } + + public static SentinelValues.SentinelValuesBuilderBase builder() { + return new SentinelValues.SentinelValuesBuilder(); + } + + /** + * Sentinel value URI + *

+ * A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/) Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway. + * + */ + @JsonProperty("sentinel_value_uri") + public URI getSentinelValueUri() { + return sentinelValueUri; + } + + /** + * Sentinel value URI + *

+ * A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/) Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway. + * + */ + @JsonProperty("sentinel_value_uri") + public void setSentinelValueUri(URI sentinelValueUri) { + this.sentinelValueUri = sentinelValueUri; + } + + /** + * Sentinel value elements + *

+ * A selection (subset) of sentinel values in the 'sentinel_value_uri' ​​applicable to the data set. + * + */ + @JsonProperty("sentinel_value_elements") + public List getSentinelValueElements() { + return sentinelValueElements; + } + + /** + * Sentinel value elements + *

+ * A selection (subset) of sentinel values in the 'sentinel_value_uri' ​​applicable to the data set. + * + */ + @JsonProperty("sentinel_value_elements") + public void setSentinelValueElements(List sentinelValueElements) { + this.sentinelValueElements = sentinelValueElements; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(SentinelValues.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('['); + sb.append("sentinelValueUri"); + sb.append('='); + sb.append(((this.sentinelValueUri == null)?"":this.sentinelValueUri)); + sb.append(','); + sb.append("sentinelValueElements"); + sb.append('='); + sb.append(((this.sentinelValueElements == null)?"":this.sentinelValueElements)); + sb.append(','); + sb.append("additionalProperties"); + sb.append('='); + sb.append(((this.additionalProperties == null)?"":this.additionalProperties)); + sb.append(','); + if (sb.charAt((sb.length()- 1)) == ',') { + sb.setCharAt((sb.length()- 1), ']'); + } else { + sb.append(']'); + } + return sb.toString(); + } + + @Override + public int hashCode() { + int result = 1; + result = ((result* 31)+((this.sentinelValueElements == null)? 0 :this.sentinelValueElements.hashCode())); + result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); + result = ((result* 31)+((this.sentinelValueUri == null)? 0 :this.sentinelValueUri.hashCode())); + return result; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof SentinelValues) == false) { + return false; + } + SentinelValues rhs = ((SentinelValues) other); + return ((((this.sentinelValueElements == rhs.sentinelValueElements)||((this.sentinelValueElements!= null)&&this.sentinelValueElements.equals(rhs.sentinelValueElements)))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.sentinelValueUri == rhs.sentinelValueUri)||((this.sentinelValueUri!= null)&&this.sentinelValueUri.equals(rhs.sentinelValueUri)))); + } + + public static class SentinelValuesBuilder + extends SentinelValues.SentinelValuesBuilderBase + { + + + public SentinelValuesBuilder() { + super(); + } + + public SentinelValuesBuilder(URI sentinelValueUri, List sentinelValueElements) { + super(sentinelValueUri, sentinelValueElements); + } + + } + + public static abstract class SentinelValuesBuilderBase{ + + protected T instance; + + @SuppressWarnings("unchecked") + public SentinelValuesBuilderBase() { + // Skip initialization when called from subclass + if (this.getClass().equals(SentinelValues.SentinelValuesBuilder.class)) { + this.instance = ((T) new SentinelValues()); + } + } + + @SuppressWarnings("unchecked") + public SentinelValuesBuilderBase(URI sentinelValueUri, List sentinelValueElements) { + // Skip initialization when called from subclass + if (this.getClass().equals(SentinelValues.SentinelValuesBuilder.class)) { + this.instance = ((T) new SentinelValues(sentinelValueUri, sentinelValueElements)); + } + } + + public T build() { + T result; + result = this.instance; + this.instance = null; + return result; + } + + public SentinelValues.SentinelValuesBuilderBase withSentinelValueUri(URI sentinelValueUri) { + ((SentinelValues) this.instance).sentinelValueUri = sentinelValueUri; + return this; + } + + public SentinelValues.SentinelValuesBuilderBase withSentinelValueElements(List sentinelValueElements) { + ((SentinelValues) this.instance).sentinelValueElements = sentinelValueElements; + return this; + } + + public SentinelValues.SentinelValuesBuilderBase withAdditionalProperty(String name, Object value) { + ((SentinelValues) this.instance).additionalProperties.put(name, value); + return this; + } + + } + +} diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SpecialValues.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SpecialValues.java new file mode 100644 index 0000000..51f9b04 --- /dev/null +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/SpecialValues.java @@ -0,0 +1,241 @@ + +package no.ssb.dapla.metadata.datadoc; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; + + +/** + * Special values + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "sentinel", + "other_value" +}) +@Generated("jsonschema2pojo") +public class SpecialValues implements Serializable +{ + + /** + * Sentinel values + *

+ * + * + */ + @JsonProperty("sentinel") + @Valid + private SentinelValues sentinel; + /** + * Other special values + *

+ * Other special values not represented as 'sentinel_value' in a standardized code list. + * + */ + @JsonProperty("other_value") + @JsonPropertyDescription("Other special values not represented as 'sentinel_value' in a standardized code list.") + @Valid + private List otherValue = new ArrayList(); + @JsonIgnore + @Valid + private Map additionalProperties = new LinkedHashMap(); + private final static long serialVersionUID = 5889699621554465663L; + + /** + * No args constructor for use in serialization + * + */ + public SpecialValues() { + } + + /** + * + * @param sentinel + * Sentinel values. + * @param otherValue + * Other special values. Other special values not represented as 'sentinel_value' in a standardized code list. + */ + public SpecialValues(SentinelValues sentinel, List otherValue) { + super(); + this.sentinel = sentinel; + this.otherValue = otherValue; + } + + public static SpecialValues.SpecialValuesBuilderBase builder() { + return new SpecialValues.SpecialValuesBuilder(); + } + + /** + * Sentinel values + *

+ * + * + */ + @JsonProperty("sentinel") + public SentinelValues getSentinel() { + return sentinel; + } + + /** + * Sentinel values + *

+ * + * + */ + @JsonProperty("sentinel") + public void setSentinel(SentinelValues sentinel) { + this.sentinel = sentinel; + } + + /** + * Other special values + *

+ * Other special values not represented as 'sentinel_value' in a standardized code list. + * + */ + @JsonProperty("other_value") + public List getOtherValue() { + return otherValue; + } + + /** + * Other special values + *

+ * Other special values not represented as 'sentinel_value' in a standardized code list. + * + */ + @JsonProperty("other_value") + public void setOtherValue(List otherValue) { + this.otherValue = otherValue; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(SpecialValues.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('['); + sb.append("sentinel"); + sb.append('='); + sb.append(((this.sentinel == null)?"":this.sentinel)); + sb.append(','); + sb.append("otherValue"); + sb.append('='); + sb.append(((this.otherValue == null)?"":this.otherValue)); + sb.append(','); + sb.append("additionalProperties"); + sb.append('='); + sb.append(((this.additionalProperties == null)?"":this.additionalProperties)); + sb.append(','); + if (sb.charAt((sb.length()- 1)) == ',') { + sb.setCharAt((sb.length()- 1), ']'); + } else { + sb.append(']'); + } + return sb.toString(); + } + + @Override + public int hashCode() { + int result = 1; + result = ((result* 31)+((this.sentinel == null)? 0 :this.sentinel.hashCode())); + result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); + result = ((result* 31)+((this.otherValue == null)? 0 :this.otherValue.hashCode())); + return result; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof SpecialValues) == false) { + return false; + } + SpecialValues rhs = ((SpecialValues) other); + return ((((this.sentinel == rhs.sentinel)||((this.sentinel!= null)&&this.sentinel.equals(rhs.sentinel)))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.otherValue == rhs.otherValue)||((this.otherValue!= null)&&this.otherValue.equals(rhs.otherValue)))); + } + + public static class SpecialValuesBuilder + extends SpecialValues.SpecialValuesBuilderBase + { + + + public SpecialValuesBuilder() { + super(); + } + + public SpecialValuesBuilder(SentinelValues sentinel, List otherValue) { + super(sentinel, otherValue); + } + + } + + public static abstract class SpecialValuesBuilderBase{ + + protected T instance; + + @SuppressWarnings("unchecked") + public SpecialValuesBuilderBase() { + // Skip initialization when called from subclass + if (this.getClass().equals(SpecialValues.SpecialValuesBuilder.class)) { + this.instance = ((T) new SpecialValues()); + } + } + + @SuppressWarnings("unchecked") + public SpecialValuesBuilderBase(SentinelValues sentinel, List otherValue) { + // Skip initialization when called from subclass + if (this.getClass().equals(SpecialValues.SpecialValuesBuilder.class)) { + this.instance = ((T) new SpecialValues(sentinel, otherValue)); + } + } + + public T build() { + T result; + result = this.instance; + this.instance = null; + return result; + } + + public SpecialValues.SpecialValuesBuilderBase withSentinel(SentinelValues sentinel) { + ((SpecialValues) this.instance).sentinel = sentinel; + return this; + } + + public SpecialValues.SpecialValuesBuilderBase withOtherValue(List otherValue) { + ((SpecialValues) this.instance).otherValue = otherValue; + return this; + } + + public SpecialValues.SpecialValuesBuilderBase withAdditionalProperty(String name, Object value) { + ((SpecialValues) this.instance).additionalProperties.put(name, value); + return this; + } + + } + +} diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java index 6b37139..ed618e4 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java @@ -37,7 +37,7 @@ "multiplication_factor", "format", "classification_uri", - "sentinel_value_uri", + "special_value", "invalid_value_description", "id", "contains_data_from", @@ -148,11 +148,11 @@ public class Variable implements Serializable /** * Multiplication factor *

- * A multiplication factor is a number that amplifies or increases the base value of something else. + * A multiplication factor for a value/result is a number that multiplies that value/result. * */ @JsonProperty("multiplication_factor") - @JsonPropertyDescription("A multiplication factor is a number that amplifies or increases the base value of something else.") + @JsonPropertyDescription("A multiplication factor for a value/result is a number that multiplies that value/result.") private Integer multiplicationFactor; /** * Format @@ -173,14 +173,14 @@ public class Variable implements Serializable @JsonPropertyDescription("Link (URI) to valid classification or code list") private URI classificationUri; /** - * Sentinel value URI + * Special values *

- * A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant + * * */ - @JsonProperty("sentinel_value_uri") - @JsonPropertyDescription("A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values \u200b\u200bhave been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant") - private URI sentinelValueUri; + @JsonProperty("special_value") + @Valid + private SpecialValues specialValue; /** * Reusable langugage string type * @@ -220,7 +220,7 @@ public class Variable implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -3016237275954677161L; + private final static long serialVersionUID = 5809523046221217841L; /** * No args constructor for use in serialization @@ -231,6 +231,8 @@ public Variable() { /** * + * @param specialValue + * Special values. * @param containsDataUntil * Contains data up until. The instance variable in the data set contains data up to and including this date. This can be useful information for data sets that contain many instance variables in addition to data for many periods/years. In many cases, it will then be the case that some of the instance variables in the data set are terminated (no longer updated) after a given point in time. * @param containsDataFrom @@ -253,8 +255,6 @@ public Variable() { * Direct Person identifying Information (DPI). Direct Person identifying Information (DPI). Some of the values ​​in an instance variable kan be DPI, others not. In this case, DPI is set equal to true. For example, the variable exporter where some of the values ​​can be organization number, others social security numbers (sole proprietorships). * @param variableRole * Variable role. Role of the instance variable in the data set. - * @param sentinelValueUri - * Sentinel value URI. A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant. * @param name * Name. Variable names can be inherited from VarDef, but can also be documented/changed here. * @param comment @@ -266,11 +266,11 @@ public Variable() { * @param dataSource * Data source. Data source. Set at data set level, but can be overwritten at variable instance level. * @param multiplicationFactor - * Multiplication factor. A multiplication factor is a number that amplifies or increases the base value of something else. + * Multiplication factor. A multiplication factor for a value/result is a number that multiplies that value/result. * @param invalidValueDescription * Invalid value(s) description. Invalid value(s) description used in addition (or as an alternative) to standard sentinel values. */ - public Variable(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public Variable(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { super(); this.shortName = shortName; this.name = name; @@ -286,7 +286,7 @@ public Variable(String shortName, LanguageStringType name, Variable.DataType dat this.multiplicationFactor = multiplicationFactor; this.format = format; this.classificationUri = classificationUri; - this.sentinelValueUri = sentinelValueUri; + this.specialValue = specialValue; this.invalidValueDescription = invalidValueDescription; this.id = id; this.containsDataFrom = containsDataFrom; @@ -532,7 +532,7 @@ public void setMeasurementUnit(String measurementUnit) { /** * Multiplication factor *

- * A multiplication factor is a number that amplifies or increases the base value of something else. + * A multiplication factor for a value/result is a number that multiplies that value/result. * */ @JsonProperty("multiplication_factor") @@ -543,7 +543,7 @@ public Integer getMultiplicationFactor() { /** * Multiplication factor *

- * A multiplication factor is a number that amplifies or increases the base value of something else. + * A multiplication factor for a value/result is a number that multiplies that value/result. * */ @JsonProperty("multiplication_factor") @@ -596,25 +596,25 @@ public void setClassificationUri(URI classificationUri) { } /** - * Sentinel value URI + * Special values *

- * A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant + * * */ - @JsonProperty("sentinel_value_uri") - public URI getSentinelValueUri() { - return sentinelValueUri; + @JsonProperty("special_value") + public SpecialValues getSpecialValue() { + return specialValue; } /** - * Sentinel value URI + * Special values *

- * A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values ​​have been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant + * * */ - @JsonProperty("sentinel_value_uri") - public void setSentinelValueUri(URI sentinelValueUri) { - this.sentinelValueUri = sentinelValueUri; + @JsonProperty("special_value") + public void setSpecialValue(SpecialValues specialValue) { + this.specialValue = specialValue; } /** @@ -773,9 +773,9 @@ public String toString() { sb.append('='); sb.append(((this.classificationUri == null)?"":this.classificationUri)); sb.append(','); - sb.append("sentinelValueUri"); + sb.append("specialValue"); sb.append('='); - sb.append(((this.sentinelValueUri == null)?"":this.sentinelValueUri)); + sb.append(((this.specialValue == null)?"":this.specialValue)); sb.append(','); sb.append("invalidValueDescription"); sb.append('='); @@ -808,6 +808,7 @@ public String toString() { @Override public int hashCode() { int result = 1; + result = ((result* 31)+((this.specialValue == null)? 0 :this.specialValue.hashCode())); result = ((result* 31)+((this.containsDataUntil == null)? 0 :this.containsDataUntil.hashCode())); result = ((result* 31)+((this.containsDataFrom == null)? 0 :this.containsDataFrom.hashCode())); result = ((result* 31)+((this.dataType == null)? 0 :this.dataType.hashCode())); @@ -819,7 +820,6 @@ public int hashCode() { result = ((result* 31)+((this.measurementUnit == null)? 0 :this.measurementUnit.hashCode())); result = ((result* 31)+((this.directPersonIdentifying == null)? 0 :this.directPersonIdentifying.hashCode())); result = ((result* 31)+((this.variableRole == null)? 0 :this.variableRole.hashCode())); - result = ((result* 31)+((this.sentinelValueUri == null)? 0 :this.sentinelValueUri.hashCode())); result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode())); result = ((result* 31)+((this.comment == null)? 0 :this.comment.hashCode())); result = ((result* 31)+((this.id == null)? 0 :this.id.hashCode())); @@ -840,7 +840,7 @@ public boolean equals(Object other) { return false; } Variable rhs = ((Variable) other); - return (((((((((((((((((((((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil)))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.sentinelValueUri == rhs.sentinelValueUri)||((this.sentinelValueUri!= null)&&this.sentinelValueUri.equals(rhs.sentinelValueUri))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); + return (((((((((((((((((((((this.specialValue == rhs.specialValue)||((this.specialValue!= null)&&this.specialValue.equals(rhs.specialValue)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); } @@ -903,8 +903,8 @@ public VariableBuilder() { super(); } - public VariableBuilder(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { - super(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, sentinelValueUri, invalidValueDescription, id, containsDataFrom, containsDataUntil); + public VariableBuilder(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + super(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil); } } @@ -922,10 +922,10 @@ public VariableBuilderBase() { } @SuppressWarnings("unchecked") - public VariableBuilderBase(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, URI sentinelValueUri, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public VariableBuilderBase(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Variable.VariableBuilder.class)) { - this.instance = ((T) new Variable(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, sentinelValueUri, invalidValueDescription, id, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Variable(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil)); } } @@ -1006,8 +1006,8 @@ public Variable.VariableBuilderBase withClassificationUri(URI classificationUri) return this; } - public Variable.VariableBuilderBase withSentinelValueUri(URI sentinelValueUri) { - ((Variable) this.instance).sentinelValueUri = sentinelValueUri; + public Variable.VariableBuilderBase withSpecialValue(SpecialValues specialValue) { + ((Variable) this.instance).specialValue = specialValue; return this; } From 16613ad8dc782093ace169165789c3d40cdc995a Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:28:53 +0000 Subject: [PATCH 10/49] [GENERATE] Pydantic models from JSON Schema --- .../datadoc_model/datadoc_model/model.py | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 59d62a3..d6b757f 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-05T14:27:30+00:00 +# timestamp: 2024-02-05T16:28:53+00:00 from __future__ import annotations @@ -51,6 +51,19 @@ class VariableRole(str, Enum): ATTRIBUTE = "ATTRIBUTE" +class Sentinel(DatadocBaseModel): + sentinel_value_uri: Optional[AnyUrl] = Field( + None, + description="A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/)", + title="Sentinel value URI", + ) + sentinel_value_elements: Optional[list[str]] = Field( + None, + description="A selection (subset) of sentinel values in the 'sentinel_value_uri' \u200b\u200bapplicable to the data set.", + title="Sentinel value elements", + ) + + class LanguageStringType(DatadocBaseModel): en: Optional[str] = None nn: Optional[str] = None @@ -277,6 +290,28 @@ class Dataset(DatadocBaseModel): ) +class OtherValueItem(DatadocBaseModel): + code: Optional[str] = Field(None, description="Other value code", title="Code") + name: Optional[LanguageStringType] = Field( + None, description="Other value name (text)", title="Name" + ) + valid_from: Optional[AwareDatetime] = Field( + None, description="Other value valid from date", title="Valid from" + ) + valid_until: Optional[AwareDatetime] = Field( + None, description="Other value until date", title="Valid until" + ) + + +class SpecialValue(DatadocBaseModel): + sentinel: Optional[Sentinel] = Field(None, title="Sentinel values") + other_value: Optional[list[OtherValueItem]] = Field( + None, + description="Other special values not represented as 'sentinel_value' in a standardized code list.", + title="Other special values", + ) + + class Variable(DatadocBaseModel): short_name: Optional[str] = Field( None, @@ -331,7 +366,7 @@ class Variable(DatadocBaseModel): ) multiplication_factor: Optional[int] = Field( None, - description="A multiplication factor is a number that amplifies or increases the base value of something else.", + description="A multiplication factor for a value/result is a number that multiplies that value/result.", title="Multiplication factor", ) format: Optional[str] = Field( @@ -344,11 +379,7 @@ class Variable(DatadocBaseModel): description="Link (URI) to valid classification or code list", title="Classification or codelist URI", ) - sentinel_value_uri: Optional[AnyUrl] = Field( - None, - description="A link (URI) to an overview of sentinel values included in the variable. Proposals for the standardization of sentinel values \u200b\u200bhave been drafted, but this has not yet been processed by the Standards Committee in Statistics Norway: 01 - In total, 02 - Sum, 03 - Subtotal, 04 - Other, 05 - Rest, 06 - Invalid value, 07 - Unspecified, 08 - Not relevant", - title="Sentinel value URI", - ) + special_value: Optional[SpecialValue] = Field(None, title="Special values") invalid_value_description: Optional[LanguageStringType] = Field( None, description="Invalid value(s) description used in addition (or as an alternative) to standard sentinel values.", From 58a8ae2ea8214937de13860e5c8ba0d33663de15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:26:10 +0100 Subject: [PATCH 11/49] Added 'data_element_path' for documentation of hierarchical datasets. --- src/datadoc/datadoc-json-schema.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index c6d4016..c1265be 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -196,7 +196,13 @@ "short_name": { "type": "string", "title": "Short name", - "description": "Physical name of the variable in the dataset. Should match the recommended short name." + "description": "Physical name of the variable (data element) in the dataset. Should match the recommended short name." + }, + "data_element_path": { + "title": "Data element path", + "description": "The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.", + "$comment": "For hierarchical datasets only, eg. json and xml documents.", + "type": "string" }, "name": { "title": "Name", From 111722867b9e22afd88b860f5d0b0410b7c1647c Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:26:46 +0000 Subject: [PATCH 12/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Variable.java | 69 +++++++++++++++---- 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java index ed618e4..b30c5c9 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java @@ -24,6 +24,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "short_name", + "data_element_path", "name", "data_type", "variable_role", @@ -50,14 +51,23 @@ public class Variable implements Serializable /** * Short name *

- * Physical name of the variable in the dataset. Should match the recommended short name. + * Physical name of the variable (data element) in the dataset. Should match the recommended short name. * (Required) * */ @JsonProperty("short_name") - @JsonPropertyDescription("Physical name of the variable in the dataset. Should match the recommended short name.") + @JsonPropertyDescription("Physical name of the variable (data element) in the dataset. Should match the recommended short name.") @NotNull private String shortName; + /** + * Data element path + *

+ * The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.For hierarchical datasets only, eg. json and xml documents. + * + */ + @JsonProperty("data_element_path") + @JsonPropertyDescription("The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.") + private String dataElementPath; /** * Reusable langugage string type * (Required) @@ -220,7 +230,7 @@ public class Variable implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 5809523046221217841L; + private final static long serialVersionUID = 5333202438673960670L; /** * No args constructor for use in serialization @@ -255,6 +265,8 @@ public Variable() { * Direct Person identifying Information (DPI). Direct Person identifying Information (DPI). Some of the values ​​in an instance variable kan be DPI, others not. In this case, DPI is set equal to true. For example, the variable exporter where some of the values ​​can be organization number, others social security numbers (sole proprietorships). * @param variableRole * Variable role. Role of the instance variable in the data set. + * @param dataElementPath + * Data element path. The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name. * @param name * Name. Variable names can be inherited from VarDef, but can also be documented/changed here. * @param comment @@ -262,7 +274,7 @@ public Variable() { * @param id * Identifier. Unique SSB identifier for the instance variable in the data set. * @param shortName - * Short name. Physical name of the variable in the dataset. Should match the recommended short name. + * Short name. Physical name of the variable (data element) in the dataset. Should match the recommended short name. * @param dataSource * Data source. Data source. Set at data set level, but can be overwritten at variable instance level. * @param multiplicationFactor @@ -270,9 +282,10 @@ public Variable() { * @param invalidValueDescription * Invalid value(s) description. Invalid value(s) description used in addition (or as an alternative) to standard sentinel values. */ - public Variable(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public Variable(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { super(); this.shortName = shortName; + this.dataElementPath = dataElementPath; this.name = name; this.dataType = dataType; this.variableRole = variableRole; @@ -300,7 +313,7 @@ public static Variable.VariableBuilderBase builder() { /** * Short name *

- * Physical name of the variable in the dataset. Should match the recommended short name. + * Physical name of the variable (data element) in the dataset. Should match the recommended short name. * (Required) * */ @@ -312,7 +325,7 @@ public String getShortName() { /** * Short name *

- * Physical name of the variable in the dataset. Should match the recommended short name. + * Physical name of the variable (data element) in the dataset. Should match the recommended short name. * (Required) * */ @@ -321,6 +334,28 @@ public void setShortName(String shortName) { this.shortName = shortName; } + /** + * Data element path + *

+ * The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.For hierarchical datasets only, eg. json and xml documents. + * + */ + @JsonProperty("data_element_path") + public String getDataElementPath() { + return dataElementPath; + } + + /** + * Data element path + *

+ * The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.For hierarchical datasets only, eg. json and xml documents. + * + */ + @JsonProperty("data_element_path") + public void setDataElementPath(String dataElementPath) { + this.dataElementPath = dataElementPath; + } + /** * Reusable langugage string type * (Required) @@ -721,6 +756,10 @@ public String toString() { sb.append('='); sb.append(((this.shortName == null)?"":this.shortName)); sb.append(','); + sb.append("dataElementPath"); + sb.append('='); + sb.append(((this.dataElementPath == null)?"":this.dataElementPath)); + sb.append(','); sb.append("name"); sb.append('='); sb.append(((this.name == null)?"":this.name)); @@ -820,6 +859,7 @@ public int hashCode() { result = ((result* 31)+((this.measurementUnit == null)? 0 :this.measurementUnit.hashCode())); result = ((result* 31)+((this.directPersonIdentifying == null)? 0 :this.directPersonIdentifying.hashCode())); result = ((result* 31)+((this.variableRole == null)? 0 :this.variableRole.hashCode())); + result = ((result* 31)+((this.dataElementPath == null)? 0 :this.dataElementPath.hashCode())); result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode())); result = ((result* 31)+((this.comment == null)? 0 :this.comment.hashCode())); result = ((result* 31)+((this.id == null)? 0 :this.id.hashCode())); @@ -840,7 +880,7 @@ public boolean equals(Object other) { return false; } Variable rhs = ((Variable) other); - return (((((((((((((((((((((this.specialValue == rhs.specialValue)||((this.specialValue!= null)&&this.specialValue.equals(rhs.specialValue)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); + return ((((((((((((((((((((((this.specialValue == rhs.specialValue)||((this.specialValue!= null)&&this.specialValue.equals(rhs.specialValue)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.dataElementPath == rhs.dataElementPath)||((this.dataElementPath!= null)&&this.dataElementPath.equals(rhs.dataElementPath))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); } @@ -903,8 +943,8 @@ public VariableBuilder() { super(); } - public VariableBuilder(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { - super(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil); + public VariableBuilder(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + super(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil); } } @@ -922,10 +962,10 @@ public VariableBuilderBase() { } @SuppressWarnings("unchecked") - public VariableBuilderBase(String shortName, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public VariableBuilderBase(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Variable.VariableBuilder.class)) { - this.instance = ((T) new Variable(shortName, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Variable(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil)); } } @@ -941,6 +981,11 @@ public Variable.VariableBuilderBase withShortName(String shortName) { return this; } + public Variable.VariableBuilderBase withDataElementPath(String dataElementPath) { + ((Variable) this.instance).dataElementPath = dataElementPath; + return this; + } + public Variable.VariableBuilderBase withName(LanguageStringType name) { ((Variable) this.instance).name = name; return this; From a19c25bb043102c3a385ee8920bc24293545c09f Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:27:20 +0000 Subject: [PATCH 13/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index d6b757f..b8dac1f 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-05T16:28:53+00:00 +# timestamp: 2024-02-06T09:27:20+00:00 from __future__ import annotations @@ -315,9 +315,14 @@ class SpecialValue(DatadocBaseModel): class Variable(DatadocBaseModel): short_name: Optional[str] = Field( None, - description="Physical name of the variable in the dataset. Should match the recommended short name.", + description="Physical name of the variable (data element) in the dataset. Should match the recommended short name.", title="Short name", ) + data_element_path: Optional[str] = Field( + None, + description="The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.", + title="Data element path", + ) name: Optional[LanguageStringType] = Field( None, description="Variable names can be inherited from VarDef, but can also be documented/changed here", From 4343f3874682d872b8ba45e69f4614090b54e576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:11:54 +0100 Subject: [PATCH 14/49] Added 'customType' attribute to dataset. --- src/datadoc/datadoc-json-schema.json | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index c1265be..6483586 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -118,6 +118,36 @@ "description": "Description of the data set's spatial coverage", "$ref": "./no/languageStringType.json#/languageStringType" }, + "custom_type": { + "title": "Custom type for dataset metadata", + "description": "Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects).", + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "title": "Key", + "description": "Custom type KEY", + "type": "string" + }, + "value": { + "title": "Value", + "description": "Custom type VALUE (of type string, array or object).", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object" + } + ] + } + } + } + }, "id": { "title": "Identifier", "description": "Unique identifier for the data set", @@ -319,7 +349,7 @@ "items": { "type": "object", "properties": { - "code":{ + "code": { "title": "Code", "description": "Other value code", "type": "string" @@ -387,4 +417,4 @@ "dataset", "variables" ] -} +} \ No newline at end of file From c92b91dcc24638d0640792ae30895a8ed5232f01 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:12:51 +0000 Subject: [PATCH 15/49] [GENERATE] Java classes from JSON Schema --- .../dapla/metadata/datadoc/CustomType.java | 231 ++++++++++++++++++ .../ssb/dapla/metadata/datadoc/Dataset.java | 60 ++++- 2 files changed, 284 insertions(+), 7 deletions(-) create mode 100644 generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType.java diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType.java new file mode 100644 index 0000000..592f0fa --- /dev/null +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType.java @@ -0,0 +1,231 @@ + +package no.ssb.dapla.metadata.datadoc; + +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "key", + "value" +}) +@Generated("jsonschema2pojo") +public class CustomType implements Serializable +{ + + /** + * Key + *

+ * Custom type KEY + * + */ + @JsonProperty("key") + @JsonPropertyDescription("Custom type KEY") + private String key; + /** + * Value + *

+ * Custom type VALUE (of type string, array or object). + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Custom type VALUE (of type string, array or object).") + private Object value; + @JsonIgnore + @Valid + private Map additionalProperties = new LinkedHashMap(); + private final static long serialVersionUID = 5187573791864322508L; + + /** + * No args constructor for use in serialization + * + */ + public CustomType() { + } + + /** + * + * @param value + * Value. Custom type VALUE (of type string, array or object). + * @param key + * Key. Custom type KEY. + */ + public CustomType(String key, Object value) { + super(); + this.key = key; + this.value = value; + } + + public static CustomType.CustomTypeBuilderBase builder() { + return new CustomType.CustomTypeBuilder(); + } + + /** + * Key + *

+ * Custom type KEY + * + */ + @JsonProperty("key") + public String getKey() { + return key; + } + + /** + * Key + *

+ * Custom type KEY + * + */ + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + /** + * Value + *

+ * Custom type VALUE (of type string, array or object). + * + */ + @JsonProperty("value") + public Object getValue() { + return value; + } + + /** + * Value + *

+ * Custom type VALUE (of type string, array or object). + * + */ + @JsonProperty("value") + public void setValue(Object value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(CustomType.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('['); + sb.append("key"); + sb.append('='); + sb.append(((this.key == null)?"":this.key)); + sb.append(','); + sb.append("value"); + sb.append('='); + sb.append(((this.value == null)?"":this.value)); + sb.append(','); + sb.append("additionalProperties"); + sb.append('='); + sb.append(((this.additionalProperties == null)?"":this.additionalProperties)); + sb.append(','); + if (sb.charAt((sb.length()- 1)) == ',') { + sb.setCharAt((sb.length()- 1), ']'); + } else { + sb.append(']'); + } + return sb.toString(); + } + + @Override + public int hashCode() { + int result = 1; + result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); + result = ((result* 31)+((this.value == null)? 0 :this.value.hashCode())); + result = ((result* 31)+((this.key == null)? 0 :this.key.hashCode())); + return result; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof CustomType) == false) { + return false; + } + CustomType rhs = ((CustomType) other); + return ((((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties)))&&((this.value == rhs.value)||((this.value!= null)&&this.value.equals(rhs.value))))&&((this.key == rhs.key)||((this.key!= null)&&this.key.equals(rhs.key)))); + } + + public static class CustomTypeBuilder + extends CustomType.CustomTypeBuilderBase + { + + + public CustomTypeBuilder() { + super(); + } + + public CustomTypeBuilder(String key, Object value) { + super(key, value); + } + + } + + public static abstract class CustomTypeBuilderBase{ + + protected T instance; + + @SuppressWarnings("unchecked") + public CustomTypeBuilderBase() { + // Skip initialization when called from subclass + if (this.getClass().equals(CustomType.CustomTypeBuilder.class)) { + this.instance = ((T) new CustomType()); + } + } + + @SuppressWarnings("unchecked") + public CustomTypeBuilderBase(String key, Object value) { + // Skip initialization when called from subclass + if (this.getClass().equals(CustomType.CustomTypeBuilder.class)) { + this.instance = ((T) new CustomType(key, value)); + } + } + + public T build() { + T result; + result = this.instance; + this.instance = null; + return result; + } + + public CustomType.CustomTypeBuilderBase withKey(String key) { + ((CustomType) this.instance).key = key; + return this; + } + + public CustomType.CustomTypeBuilderBase withValue(Object value) { + ((CustomType) this.instance).value = value; + return this; + } + + public CustomType.CustomTypeBuilderBase withAdditionalProperty(String name, Object value) { + ((CustomType) this.instance).additionalProperties.put(name, value); + return this; + } + + } + +} diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 015ec29..5408c01 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -40,6 +40,7 @@ "subject_field", "keyword", "spatial_coverage_description", + "custom_type", "id", "owner", "file_path", @@ -200,6 +201,16 @@ public class Dataset implements Serializable @JsonProperty("spatial_coverage_description") @Valid private LanguageStringType spatialCoverageDescription; + /** + * Custom type for dataset metadata + *

+ * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * + */ + @JsonProperty("custom_type") + @JsonPropertyDescription("Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects).") + @Valid + private List customType = new ArrayList(); /** * Identifier *

@@ -296,7 +307,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 1788379209809172251L; + private final static long serialVersionUID = 4994401799637210377L; /** * No args constructor for use in serialization @@ -349,6 +360,8 @@ public Dataset() { * Metadata last updated date. Last updated date for metadata about the dataset. * @param version * Version. Version of data set. + * @param customType + * Custom type for dataset metadata. Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). * @param metadataCreatedDate * Metadata created date. Created date for metadata about the data set. * @param name @@ -358,7 +371,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -376,6 +389,7 @@ public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetS this.subjectField = subjectField; this.keyword = keyword; this.spatialCoverageDescription = spatialCoverageDescription; + this.customType = customType; this.id = id; this.owner = owner; this.filePath = filePath; @@ -727,6 +741,28 @@ public void setSpatialCoverageDescription(LanguageStringType spatialCoverageDesc this.spatialCoverageDescription = spatialCoverageDescription; } + /** + * Custom type for dataset metadata + *

+ * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * + */ + @JsonProperty("custom_type") + public List getCustomType() { + return customType; + } + + /** + * Custom type for dataset metadata + *

+ * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * + */ + @JsonProperty("custom_type") + public void setCustomType(List customType) { + this.customType = customType; + } + /** * Identifier *

@@ -1013,6 +1049,10 @@ public String toString() { sb.append('='); sb.append(((this.spatialCoverageDescription == null)?"":this.spatialCoverageDescription)); sb.append(','); + sb.append("customType"); + sb.append('='); + sb.append(((this.customType == null)?"":this.customType)); + sb.append(','); sb.append("id"); sb.append('='); sb.append(((this.id == null)?"":this.id)); @@ -1085,6 +1125,7 @@ public int hashCode() { result = ((result* 31)+((this.filePath == null)? 0 :this.filePath.hashCode())); result = ((result* 31)+((this.metadataLastUpdatedDate == null)? 0 :this.metadataLastUpdatedDate.hashCode())); result = ((result* 31)+((this.version == null)? 0 :this.version.hashCode())); + result = ((result* 31)+((this.customType == null)? 0 :this.customType.hashCode())); result = ((result* 31)+((this.metadataCreatedDate == null)? 0 :this.metadataCreatedDate.hashCode())); result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode())); result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); @@ -1102,7 +1143,7 @@ public boolean equals(Object other) { return false; } Dataset rhs = ((Dataset) other); - return (((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.registerUri == rhs.registerUri)||((this.registerUri!= null)&&this.registerUri.equals(rhs.registerUri))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); + return ((((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.registerUri == rhs.registerUri)||((this.registerUri!= null)&&this.registerUri.equals(rhs.registerUri))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); } @@ -1162,8 +1203,8 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { - super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } } @@ -1181,10 +1222,10 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { - this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); } } @@ -1275,6 +1316,11 @@ public Dataset.DatasetBuilderBase withSpatialCoverageDescription(LanguageStringT return this; } + public Dataset.DatasetBuilderBase withCustomType(List customType) { + ((Dataset) this.instance).customType = customType; + return this; + } + public Dataset.DatasetBuilderBase withId(UUID id) { ((Dataset) this.instance).id = id; return this; From 6467ce971545a0c8b1ca106ccb2bfdc370b1bf55 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:13:23 +0000 Subject: [PATCH 16/49] [GENERATE] Pydantic models from JSON Schema --- .../datadoc_model/datadoc_model/model.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index b8dac1f..dd4b61d 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,11 +1,11 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-06T09:27:20+00:00 +# timestamp: 2024-02-06T15:13:23+00:00 from __future__ import annotations from enum import Enum -from typing import Any, Literal, Optional +from typing import Any, Literal, Optional, Union from uuid import UUID from pydantic import AnyUrl, AwareDatetime, Field @@ -34,6 +34,15 @@ class DatasetState(str, Enum): OUTPUT_DATA = "OUTPUT_DATA" +class CustomTypeItem(DatadocBaseModel): + key: Optional[str] = Field(None, description="Custom type KEY", title="Key") + value: Optional[Union[str, list, dict[str, Any]]] = Field( + None, + description="Custom type VALUE (of type string, array or object).", + title="Value", + ) + + class DataType(str, Enum): STRING = "STRING" INTEGER = "INTEGER" @@ -247,6 +256,11 @@ class Dataset(DatadocBaseModel): description="Description of the data set's spatial coverage", title="Spatial coverage description", ) + custom_type: Optional[list[CustomTypeItem]] = Field( + None, + description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects).", + title="Custom type for dataset metadata", + ) id: Optional[UUID] = Field( None, description="Unique identifier for the data set", title="Identifier" ) From b358e5575023b2c083c358a80a16f4d2a1a0dca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:54:10 +0100 Subject: [PATCH 17/49] Added 'customType' attribute to variable metadata. --- src/datadoc/datadoc-json-schema.json | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 6483586..ed09eab 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -120,7 +120,7 @@ }, "custom_type": { "title": "Custom type for dataset metadata", - "description": "Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects).", + "description": "Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", "type": "array", "items": { "type": "object", @@ -381,6 +381,36 @@ "description": "Invalid value(s) description used in addition (or as an alternative) to standard sentinel values.", "$ref": "./no/languageStringType.json#/languageStringType" }, + "custom_type": { + "title": "Custom type for variable metadata", + "description": "Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "title": "Key", + "description": "Custom type KEY", + "type": "string" + }, + "value": { + "title": "Value", + "description": "Custom type VALUE (of type string, array or object).", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object" + } + ] + } + } + } + }, "id": { "title": "Identifier", "description": "Unique SSB identifier for the instance variable in the data set", From 8b14e209058220f01d9e9fafb47744dd6fddb134 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 12:55:05 +0000 Subject: [PATCH 18/49] [GENERATE] Java classes from JSON Schema --- .../dapla/metadata/datadoc/CustomType__1.java | 231 ++++++++++++++++++ .../ssb/dapla/metadata/datadoc/Dataset.java | 10 +- .../ssb/dapla/metadata/datadoc/Variable.java | 62 ++++- 3 files changed, 291 insertions(+), 12 deletions(-) create mode 100644 generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType__1.java diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType__1.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType__1.java new file mode 100644 index 0000000..18c92d6 --- /dev/null +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/CustomType__1.java @@ -0,0 +1,231 @@ + +package no.ssb.dapla.metadata.datadoc; + +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "key", + "value" +}) +@Generated("jsonschema2pojo") +public class CustomType__1 implements Serializable +{ + + /** + * Key + *

+ * Custom type KEY + * + */ + @JsonProperty("key") + @JsonPropertyDescription("Custom type KEY") + private String key; + /** + * Value + *

+ * Custom type VALUE (of type string, array or object). + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Custom type VALUE (of type string, array or object).") + private Object value; + @JsonIgnore + @Valid + private Map additionalProperties = new LinkedHashMap(); + private final static long serialVersionUID = 9007834125759711144L; + + /** + * No args constructor for use in serialization + * + */ + public CustomType__1() { + } + + /** + * + * @param value + * Value. Custom type VALUE (of type string, array or object). + * @param key + * Key. Custom type KEY. + */ + public CustomType__1(String key, Object value) { + super(); + this.key = key; + this.value = value; + } + + public static CustomType__1 .CustomType__1BuilderBase builder() { + return new CustomType__1 .CustomType__1Builder(); + } + + /** + * Key + *

+ * Custom type KEY + * + */ + @JsonProperty("key") + public String getKey() { + return key; + } + + /** + * Key + *

+ * Custom type KEY + * + */ + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + /** + * Value + *

+ * Custom type VALUE (of type string, array or object). + * + */ + @JsonProperty("value") + public Object getValue() { + return value; + } + + /** + * Value + *

+ * Custom type VALUE (of type string, array or object). + * + */ + @JsonProperty("value") + public void setValue(Object value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(CustomType__1 .class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('['); + sb.append("key"); + sb.append('='); + sb.append(((this.key == null)?"":this.key)); + sb.append(','); + sb.append("value"); + sb.append('='); + sb.append(((this.value == null)?"":this.value)); + sb.append(','); + sb.append("additionalProperties"); + sb.append('='); + sb.append(((this.additionalProperties == null)?"":this.additionalProperties)); + sb.append(','); + if (sb.charAt((sb.length()- 1)) == ',') { + sb.setCharAt((sb.length()- 1), ']'); + } else { + sb.append(']'); + } + return sb.toString(); + } + + @Override + public int hashCode() { + int result = 1; + result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); + result = ((result* 31)+((this.value == null)? 0 :this.value.hashCode())); + result = ((result* 31)+((this.key == null)? 0 :this.key.hashCode())); + return result; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof CustomType__1) == false) { + return false; + } + CustomType__1 rhs = ((CustomType__1) other); + return ((((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties)))&&((this.value == rhs.value)||((this.value!= null)&&this.value.equals(rhs.value))))&&((this.key == rhs.key)||((this.key!= null)&&this.key.equals(rhs.key)))); + } + + public static class CustomType__1Builder + extends CustomType__1 .CustomType__1BuilderBase + { + + + public CustomType__1Builder() { + super(); + } + + public CustomType__1Builder(String key, Object value) { + super(key, value); + } + + } + + public static abstract class CustomType__1BuilderBase{ + + protected T instance; + + @SuppressWarnings("unchecked") + public CustomType__1BuilderBase() { + // Skip initialization when called from subclass + if (this.getClass().equals(CustomType__1 .CustomType__1Builder.class)) { + this.instance = ((T) new CustomType__1()); + } + } + + @SuppressWarnings("unchecked") + public CustomType__1BuilderBase(String key, Object value) { + // Skip initialization when called from subclass + if (this.getClass().equals(CustomType__1 .CustomType__1Builder.class)) { + this.instance = ((T) new CustomType__1(key, value)); + } + } + + public T build() { + T result; + result = this.instance; + this.instance = null; + return result; + } + + public CustomType__1 .CustomType__1BuilderBase withKey(String key) { + ((CustomType__1) this.instance).key = key; + return this; + } + + public CustomType__1 .CustomType__1BuilderBase withValue(Object value) { + ((CustomType__1) this.instance).value = value; + return this; + } + + public CustomType__1 .CustomType__1BuilderBase withAdditionalProperty(String name, Object value) { + ((CustomType__1) this.instance).additionalProperties.put(name, value); + return this; + } + + } + +} diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 5408c01..94323c6 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -204,11 +204,11 @@ public class Dataset implements Serializable /** * Custom type for dataset metadata *

- * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). * */ @JsonProperty("custom_type") - @JsonPropertyDescription("Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects).") + @JsonPropertyDescription("Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).") @Valid private List customType = new ArrayList(); /** @@ -361,7 +361,7 @@ public Dataset() { * @param version * Version. Version of data set. * @param customType - * Custom type for dataset metadata. Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * Custom type for dataset metadata. Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). * @param metadataCreatedDate * Metadata created date. Created date for metadata about the data set. * @param name @@ -744,7 +744,7 @@ public void setSpatialCoverageDescription(LanguageStringType spatialCoverageDesc /** * Custom type for dataset metadata *

- * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). * */ @JsonProperty("custom_type") @@ -755,7 +755,7 @@ public List getCustomType() { /** * Custom type for dataset metadata *

- * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects). + * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). * */ @JsonProperty("custom_type") diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java index b30c5c9..fdcde14 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java @@ -3,9 +3,11 @@ import java.io.Serializable; import java.net.URI; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.UUID; import javax.annotation.processing.Generated; @@ -40,6 +42,7 @@ "classification_uri", "special_value", "invalid_value_description", + "custom_type", "id", "contains_data_from", "contains_data_until" @@ -198,6 +201,16 @@ public class Variable implements Serializable @JsonProperty("invalid_value_description") @Valid private LanguageStringType invalidValueDescription; + /** + * Custom type for variable metadata + *

+ * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). + * + */ + @JsonProperty("custom_type") + @JsonPropertyDescription("Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).") + @Valid + private List customType = new ArrayList(); /** * Identifier *

@@ -230,7 +243,7 @@ public class Variable implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 5333202438673960670L; + private final static long serialVersionUID = 1684720938968430884L; /** * No args constructor for use in serialization @@ -263,6 +276,8 @@ public Variable() { * Measurement unit. Measurement unit. * @param directPersonIdentifying * Direct Person identifying Information (DPI). Direct Person identifying Information (DPI). Some of the values ​​in an instance variable kan be DPI, others not. In this case, DPI is set equal to true. For example, the variable exporter where some of the values ​​can be organization number, others social security numbers (sole proprietorships). + * @param customType + * Custom type for variable metadata. Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). * @param variableRole * Variable role. Role of the instance variable in the data set. * @param dataElementPath @@ -282,7 +297,7 @@ public Variable() { * @param invalidValueDescription * Invalid value(s) description. Invalid value(s) description used in addition (or as an alternative) to standard sentinel values. */ - public Variable(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public Variable(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { super(); this.shortName = shortName; this.dataElementPath = dataElementPath; @@ -301,6 +316,7 @@ public Variable(String shortName, String dataElementPath, LanguageStringType nam this.classificationUri = classificationUri; this.specialValue = specialValue; this.invalidValueDescription = invalidValueDescription; + this.customType = customType; this.id = id; this.containsDataFrom = containsDataFrom; this.containsDataUntil = containsDataUntil; @@ -670,6 +686,28 @@ public void setInvalidValueDescription(LanguageStringType invalidValueDescriptio this.invalidValueDescription = invalidValueDescription; } + /** + * Custom type for variable metadata + *

+ * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). + * + */ + @JsonProperty("custom_type") + public List getCustomType() { + return customType; + } + + /** + * Custom type for variable metadata + *

+ * Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects). + * + */ + @JsonProperty("custom_type") + public void setCustomType(List customType) { + this.customType = customType; + } + /** * Identifier *

@@ -820,6 +858,10 @@ public String toString() { sb.append('='); sb.append(((this.invalidValueDescription == null)?"":this.invalidValueDescription)); sb.append(','); + sb.append("customType"); + sb.append('='); + sb.append(((this.customType == null)?"":this.customType)); + sb.append(','); sb.append("id"); sb.append('='); sb.append(((this.id == null)?"":this.id)); @@ -858,6 +900,7 @@ public int hashCode() { result = ((result* 31)+((this.temporalityType == null)? 0 :this.temporalityType.hashCode())); result = ((result* 31)+((this.measurementUnit == null)? 0 :this.measurementUnit.hashCode())); result = ((result* 31)+((this.directPersonIdentifying == null)? 0 :this.directPersonIdentifying.hashCode())); + result = ((result* 31)+((this.customType == null)? 0 :this.customType.hashCode())); result = ((result* 31)+((this.variableRole == null)? 0 :this.variableRole.hashCode())); result = ((result* 31)+((this.dataElementPath == null)? 0 :this.dataElementPath.hashCode())); result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode())); @@ -880,7 +923,7 @@ public boolean equals(Object other) { return false; } Variable rhs = ((Variable) other); - return ((((((((((((((((((((((this.specialValue == rhs.specialValue)||((this.specialValue!= null)&&this.specialValue.equals(rhs.specialValue)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.dataElementPath == rhs.dataElementPath)||((this.dataElementPath!= null)&&this.dataElementPath.equals(rhs.dataElementPath))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); + return (((((((((((((((((((((((this.specialValue == rhs.specialValue)||((this.specialValue!= null)&&this.specialValue.equals(rhs.specialValue)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.dataType == rhs.dataType)||((this.dataType!= null)&&this.dataType.equals(rhs.dataType))))&&((this.format == rhs.format)||((this.format!= null)&&this.format.equals(rhs.format))))&&((this.classificationUri == rhs.classificationUri)||((this.classificationUri!= null)&&this.classificationUri.equals(rhs.classificationUri))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.definitionUri == rhs.definitionUri)||((this.definitionUri!= null)&&this.definitionUri.equals(rhs.definitionUri))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.measurementUnit == rhs.measurementUnit)||((this.measurementUnit!= null)&&this.measurementUnit.equals(rhs.measurementUnit))))&&((this.directPersonIdentifying == rhs.directPersonIdentifying)||((this.directPersonIdentifying!= null)&&this.directPersonIdentifying.equals(rhs.directPersonIdentifying))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.variableRole == rhs.variableRole)||((this.variableRole!= null)&&this.variableRole.equals(rhs.variableRole))))&&((this.dataElementPath == rhs.dataElementPath)||((this.dataElementPath!= null)&&this.dataElementPath.equals(rhs.dataElementPath))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.comment == rhs.comment)||((this.comment!= null)&&this.comment.equals(rhs.comment))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource))))&&((this.multiplicationFactor == rhs.multiplicationFactor)||((this.multiplicationFactor!= null)&&this.multiplicationFactor.equals(rhs.multiplicationFactor))))&&((this.invalidValueDescription == rhs.invalidValueDescription)||((this.invalidValueDescription!= null)&&this.invalidValueDescription.equals(rhs.invalidValueDescription)))); } @@ -943,8 +986,8 @@ public VariableBuilder() { super(); } - public VariableBuilder(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { - super(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil); + public VariableBuilder(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { + super(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, customType, id, containsDataFrom, containsDataUntil); } } @@ -962,10 +1005,10 @@ public VariableBuilderBase() { } @SuppressWarnings("unchecked") - public VariableBuilderBase(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, UUID id, Date containsDataFrom, Date containsDataUntil) { + public VariableBuilderBase(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Variable.VariableBuilder.class)) { - this.instance = ((T) new Variable(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, id, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Variable(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, customType, id, containsDataFrom, containsDataUntil)); } } @@ -1061,6 +1104,11 @@ public Variable.VariableBuilderBase withInvalidValueDescription(LanguageStringTy return this; } + public Variable.VariableBuilderBase withCustomType(List customType) { + ((Variable) this.instance).customType = customType; + return this; + } + public Variable.VariableBuilderBase withId(UUID id) { ((Variable) this.instance).id = id; return this; From 7b406cb9275cd3fe82dc0216861509232f08f2dc Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 12:55:42 +0000 Subject: [PATCH 19/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index dd4b61d..7a9997a 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-06T15:13:23+00:00 +# timestamp: 2024-02-07T12:55:41+00:00 from __future__ import annotations @@ -258,7 +258,7 @@ class Dataset(DatadocBaseModel): ) custom_type: Optional[list[CustomTypeItem]] = Field( None, - description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array og objects).", + description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", title="Custom type for dataset metadata", ) id: Optional[UUID] = Field( @@ -404,6 +404,11 @@ class Variable(DatadocBaseModel): description="Invalid value(s) description used in addition (or as an alternative) to standard sentinel values.", title="Invalid value(s) description", ) + custom_type: Optional[list[CustomTypeItem]] = Field( + None, + description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", + title="Custom type for variable metadata", + ) id: Optional[UUID] = Field( None, description="Unique SSB identifier for the instance variable in the data set", From 36fedf64d54f53ec851b2ef35fe3c545d1f67bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:31:58 +0100 Subject: [PATCH 20/49] register_uri attribute removed. --- src/datadoc/datadoc-json-schema.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index ed09eab..f05f862 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -69,11 +69,6 @@ "description": "Data source. Set either for the data set or instance variable.", "$ref": "./no/languageStringType.json#/languageStringType" }, - "register_uri": { - "title": "Register", - "description": "Link to register", - "$ref": "./no/languageStringType.json#/languageStringType" - }, "population_description": { "title": "Description of population", "description": "Description of the population covered in the data set. Includes unit type, spatial coverage and period of time.", From a7531585363ff2644943c22031b9f184852162b2 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:32:30 +0000 Subject: [PATCH 21/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 7a9997a..9bca559 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-07T12:55:41+00:00 +# timestamp: 2024-02-12T08:32:30+00:00 from __future__ import annotations @@ -215,9 +215,6 @@ class Dataset(DatadocBaseModel): description="Data source. Set either for the data set or instance variable.", title="Data source", ) - register_uri: Optional[LanguageStringType] = Field( - None, description="Link to register", title="Register" - ) population_description: Optional[LanguageStringType] = Field( None, description="Description of the population covered in the data set. Includes unit type, spatial coverage and period of time.", From 33a1c9bed1d317695026349a72493c78a534acaf Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:33:14 +0000 Subject: [PATCH 22/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 53 +++---------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 94323c6..6383b3f 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -31,7 +31,6 @@ "name", "description", "data_source", - "register_uri", "population_description", "version", "version_description", @@ -124,13 +123,6 @@ public class Dataset implements Serializable @JsonProperty("data_source") @Valid private LanguageStringType dataSource; - /** - * Reusable langugage string type - * - */ - @JsonProperty("register_uri") - @Valid - private LanguageStringType registerUri; /** * Reusable langugage string type * (Required) @@ -307,7 +299,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 4994401799637210377L; + private final static long serialVersionUID = -3205570993110718772L; /** * No args constructor for use in serialization @@ -340,8 +332,6 @@ public Dataset() { * Unit type. Unit Type for data file, table or data set. See Definitions of Unit Types https://www.ssb.no/en/metadata/definisjoner-av-statistiske-enheter. * @param assessment * Assessment. Value assessment (sensitivity classification) for the data set. - * @param registerUri - * Register. Link to register. * @param spatialCoverageDescription * Spatial coverage description. Description of the data set's spatial coverage. * @param metadataCreatedBy @@ -371,7 +361,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -380,7 +370,6 @@ public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetS this.name = name; this.description = description; this.dataSource = dataSource; - this.registerUri = registerUri; this.populationDescription = populationDescription; this.version = version; this.versionDescription = versionDescription; @@ -559,24 +548,6 @@ public void setDataSource(LanguageStringType dataSource) { this.dataSource = dataSource; } - /** - * Reusable langugage string type - * - */ - @JsonProperty("register_uri") - public LanguageStringType getRegisterUri() { - return registerUri; - } - - /** - * Reusable langugage string type - * - */ - @JsonProperty("register_uri") - public void setRegisterUri(LanguageStringType registerUri) { - this.registerUri = registerUri; - } - /** * Reusable langugage string type * (Required) @@ -1013,10 +984,6 @@ public String toString() { sb.append('='); sb.append(((this.dataSource == null)?"":this.dataSource)); sb.append(','); - sb.append("registerUri"); - sb.append('='); - sb.append(((this.registerUri == null)?"":this.registerUri)); - sb.append(','); sb.append("populationDescription"); sb.append('='); sb.append(((this.populationDescription == null)?"":this.populationDescription)); @@ -1115,7 +1082,6 @@ public int hashCode() { result = ((result* 31)+((this.subjectField == null)? 0 :this.subjectField.hashCode())); result = ((result* 31)+((this.unitType == null)? 0 :this.unitType.hashCode())); result = ((result* 31)+((this.assessment == null)? 0 :this.assessment.hashCode())); - result = ((result* 31)+((this.registerUri == null)? 0 :this.registerUri.hashCode())); result = ((result* 31)+((this.spatialCoverageDescription == null)? 0 :this.spatialCoverageDescription.hashCode())); result = ((result* 31)+((this.metadataCreatedBy == null)? 0 :this.metadataCreatedBy.hashCode())); result = ((result* 31)+((this.id == null)? 0 :this.id.hashCode())); @@ -1143,7 +1109,7 @@ public boolean equals(Object other) { return false; } Dataset rhs = ((Dataset) other); - return ((((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.registerUri == rhs.registerUri)||((this.registerUri!= null)&&this.registerUri.equals(rhs.registerUri))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); + return (((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); } @@ -1203,8 +1169,8 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { - super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } } @@ -1222,10 +1188,10 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { - this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); } } @@ -1271,11 +1237,6 @@ public Dataset.DatasetBuilderBase withDataSource(LanguageStringType dataSource) return this; } - public Dataset.DatasetBuilderBase withRegisterUri(LanguageStringType registerUri) { - ((Dataset) this.instance).registerUri = registerUri; - return this; - } - public Dataset.DatasetBuilderBase withPopulationDescription(LanguageStringType populationDescription) { ((Dataset) this.instance).populationDescription = populationDescription; return this; From c1f2ae8fb530f4ca7ee82ff91b1fd58604ed10f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:35:39 +0100 Subject: [PATCH 23/49] subject_field changed to string (from languageStringType) --- src/datadoc/datadoc-json-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index f05f862..75930a6 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -98,7 +98,7 @@ "subject_field": { "title": "Subject field", "description": "Primary area of statistics in which the data set is included", - "$ref": "./no/languageStringType.json#/languageStringType" + "type": "string" }, "keyword": { "title": "Keyword(s)", From c43b4ad1d14feeb537e7d8dd1467dc1ede8348b2 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:36:07 +0000 Subject: [PATCH 24/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 9bca559..7a32fd1 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T08:32:30+00:00 +# timestamp: 2024-02-12T08:36:07+00:00 from __future__ import annotations @@ -238,7 +238,7 @@ class Dataset(DatadocBaseModel): description="Temporality type. Either for the instance variable or the data set", title="Temporality type", ) - subject_field: Optional[LanguageStringType] = Field( + subject_field: Optional[str] = Field( None, description="Primary area of statistics in which the data set is included", title="Subject field", From 8352eb743155f36597e98974e119172301e1ee4f Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:36:49 +0000 Subject: [PATCH 25/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 6383b3f..ef399f9 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -168,14 +168,16 @@ public class Dataset implements Serializable @JsonProperty("temporality_type") private Dataset.TemporalityTypeType temporalityType; /** - * Reusable langugage string type + * Subject field + *

+ * Primary area of statistics in which the data set is included * (Required) * */ @JsonProperty("subject_field") - @Valid + @JsonPropertyDescription("Primary area of statistics in which the data set is included") @NotNull - private LanguageStringType subjectField; + private String subjectField; /** * Keyword(s) *

@@ -299,7 +301,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -3205570993110718772L; + private final static long serialVersionUID = 1476933305730808179L; /** * No args constructor for use in serialization @@ -361,7 +363,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -653,22 +655,26 @@ public void setTemporalityType(Dataset.TemporalityTypeType temporalityType) { } /** - * Reusable langugage string type + * Subject field + *

+ * Primary area of statistics in which the data set is included * (Required) * */ @JsonProperty("subject_field") - public LanguageStringType getSubjectField() { + public String getSubjectField() { return subjectField; } /** - * Reusable langugage string type + * Subject field + *

+ * Primary area of statistics in which the data set is included * (Required) * */ @JsonProperty("subject_field") - public void setSubjectField(LanguageStringType subjectField) { + public void setSubjectField(String subjectField) { this.subjectField = subjectField; } @@ -1169,7 +1175,7 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } @@ -1188,7 +1194,7 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); @@ -1262,7 +1268,7 @@ public Dataset.DatasetBuilderBase withTemporalityType(Dataset.TemporalityTypeTyp return this; } - public Dataset.DatasetBuilderBase withSubjectField(LanguageStringType subjectField) { + public Dataset.DatasetBuilderBase withSubjectField(String subjectField) { ((Dataset) this.instance).subjectField = subjectField; return this; } From 39bcd1d3fe1f5213b05815b93e2bfb38ac45d0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 09:46:35 +0100 Subject: [PATCH 26/49] Added new attribute contains_personal_data --- src/datadoc/datadoc-json-schema.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 75930a6..a895c17 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -113,6 +113,11 @@ "description": "Description of the data set's spatial coverage", "$ref": "./no/languageStringType.json#/languageStringType" }, + "contains_personal_data": { + "title": "Contains personal data", + "description": "Does the dataset contain personal data (true or false)?", + "type": "boolean" + }, "custom_type": { "title": "Custom type for dataset metadata", "description": "Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", @@ -204,6 +209,7 @@ "unit_type", "description", "subject_field", + "contains_personal_data", "id", "owner", "file_path", From d1799d7651962f22a47171181d1ea8340d769268 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:47:23 +0000 Subject: [PATCH 27/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 63 ++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index ef399f9..69eb76e 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -39,6 +39,7 @@ "subject_field", "keyword", "spatial_coverage_description", + "contains_personal_data", "custom_type", "id", "owner", @@ -195,6 +196,17 @@ public class Dataset implements Serializable @JsonProperty("spatial_coverage_description") @Valid private LanguageStringType spatialCoverageDescription; + /** + * Contains personal data + *

+ * Does the dataset contain personal data (true or false)? + * (Required) + * + */ + @JsonProperty("contains_personal_data") + @JsonPropertyDescription("Does the dataset contain personal data (true or false)?") + @NotNull + private Boolean containsPersonalData; /** * Custom type for dataset metadata *

@@ -301,7 +313,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 1476933305730808179L; + private final static long serialVersionUID = -2927904274780206031L; /** * No args constructor for use in serialization @@ -348,6 +360,8 @@ public Dataset() { * Contains data from. The data set contains data from date/time. * @param filePath * File path. The file path contains the data set's name and the path to where it is stored. + * @param containsPersonalData + * Contains personal data. Does the dataset contain personal data (true or false)?. * @param metadataLastUpdatedDate * Metadata last updated date. Last updated date for metadata about the dataset. * @param version @@ -363,7 +377,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -380,6 +394,7 @@ public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetS this.subjectField = subjectField; this.keyword = keyword; this.spatialCoverageDescription = spatialCoverageDescription; + this.containsPersonalData = containsPersonalData; this.customType = customType; this.id = id; this.owner = owner; @@ -718,6 +733,30 @@ public void setSpatialCoverageDescription(LanguageStringType spatialCoverageDesc this.spatialCoverageDescription = spatialCoverageDescription; } + /** + * Contains personal data + *

+ * Does the dataset contain personal data (true or false)? + * (Required) + * + */ + @JsonProperty("contains_personal_data") + public Boolean getContainsPersonalData() { + return containsPersonalData; + } + + /** + * Contains personal data + *

+ * Does the dataset contain personal data (true or false)? + * (Required) + * + */ + @JsonProperty("contains_personal_data") + public void setContainsPersonalData(Boolean containsPersonalData) { + this.containsPersonalData = containsPersonalData; + } + /** * Custom type for dataset metadata *

@@ -1022,6 +1061,10 @@ public String toString() { sb.append('='); sb.append(((this.spatialCoverageDescription == null)?"":this.spatialCoverageDescription)); sb.append(','); + sb.append("containsPersonalData"); + sb.append('='); + sb.append(((this.containsPersonalData == null)?"":this.containsPersonalData)); + sb.append(','); sb.append("customType"); sb.append('='); sb.append(((this.customType == null)?"":this.customType)); @@ -1095,6 +1138,7 @@ public int hashCode() { result = ((result* 31)+((this.owner == null)? 0 :this.owner.hashCode())); result = ((result* 31)+((this.containsDataFrom == null)? 0 :this.containsDataFrom.hashCode())); result = ((result* 31)+((this.filePath == null)? 0 :this.filePath.hashCode())); + result = ((result* 31)+((this.containsPersonalData == null)? 0 :this.containsPersonalData.hashCode())); result = ((result* 31)+((this.metadataLastUpdatedDate == null)? 0 :this.metadataLastUpdatedDate.hashCode())); result = ((result* 31)+((this.version == null)? 0 :this.version.hashCode())); result = ((result* 31)+((this.customType == null)? 0 :this.customType.hashCode())); @@ -1115,7 +1159,7 @@ public boolean equals(Object other) { return false; } Dataset rhs = ((Dataset) other); - return (((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); + return ((((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.containsPersonalData == rhs.containsPersonalData)||((this.containsPersonalData!= null)&&this.containsPersonalData.equals(rhs.containsPersonalData))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); } @@ -1175,8 +1219,8 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { - super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } } @@ -1194,10 +1238,10 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { - this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); } } @@ -1283,6 +1327,11 @@ public Dataset.DatasetBuilderBase withSpatialCoverageDescription(LanguageStringT return this; } + public Dataset.DatasetBuilderBase withContainsPersonalData(Boolean containsPersonalData) { + ((Dataset) this.instance).containsPersonalData = containsPersonalData; + return this; + } + public Dataset.DatasetBuilderBase withCustomType(List customType) { ((Dataset) this.instance).customType = customType; return this; From 3792859eab3de9ab2682f156c2a1b1051568607a Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:47:54 +0000 Subject: [PATCH 28/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 7a32fd1..e6a1f4a 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T08:36:07+00:00 +# timestamp: 2024-02-12T08:47:54+00:00 from __future__ import annotations @@ -253,6 +253,11 @@ class Dataset(DatadocBaseModel): description="Description of the data set's spatial coverage", title="Spatial coverage description", ) + contains_personal_data: Optional[bool] = Field( + None, + description="Does the dataset contain personal data (true or false)?", + title="Contains personal data", + ) custom_type: Optional[list[CustomTypeItem]] = Field( None, description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", From b77d07098bc821150277ab424882f4bb8013781d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:55:01 +0100 Subject: [PATCH 29/49] Added use_restriction and use_restriction_date. --- src/datadoc/datadoc-json-schema.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index a895c17..52d669a 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -115,9 +115,25 @@ }, "contains_personal_data": { "title": "Contains personal data", - "description": "Does the dataset contain personal data (true or false)?", + "description": "Is there any personal data amongst this data (data set)?", "type": "boolean" }, + "use_restriction": { + "title": "Use restriction", + "description": "Data set use restriction", + "type": "string", + "enum": [ + "DELETION_ANONYMIZATION", + "PROCESS_LIMITATIONS", + "SECONDARY_USE_RESTRICTIONS" + ] + }, + "use_restriction_date": { + "title": "Use restriction date", + "description": "Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised.", + "type": "string", + "format": "date-time" + }, "custom_type": { "title": "Custom type for dataset metadata", "description": "Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", From ee5f3209c98a5a1056c06f20c9d78d6001460372 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:55:34 +0000 Subject: [PATCH 30/49] [GENERATE] Pydantic models from JSON Schema --- .../datadoc_model/datadoc_model/model.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index e6a1f4a..d7aedca 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T08:47:54+00:00 +# timestamp: 2024-02-12T14:55:34+00:00 from __future__ import annotations @@ -34,6 +34,12 @@ class DatasetState(str, Enum): OUTPUT_DATA = "OUTPUT_DATA" +class UseRestriction(str, Enum): + DELETION_ANONYMIZATION = "DELETION_ANONYMIZATION" + PROCESS_LIMITATIONS = "PROCESS_LIMITATIONS" + SECONDARY_USE_RESTRICTIONS = "SECONDARY_USE_RESTRICTIONS" + + class CustomTypeItem(DatadocBaseModel): key: Optional[str] = Field(None, description="Custom type KEY", title="Key") value: Optional[Union[str, list, dict[str, Any]]] = Field( @@ -255,9 +261,17 @@ class Dataset(DatadocBaseModel): ) contains_personal_data: Optional[bool] = Field( None, - description="Does the dataset contain personal data (true or false)?", + description="Is there any personal data amongst this data (data set)?", title="Contains personal data", ) + use_restriction: Optional[UseRestriction] = Field( + None, description="Data set use restriction", title="Use restriction" + ) + use_restriction_date: Optional[AwareDatetime] = Field( + None, + description="Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised.", + title="Use restriction date", + ) custom_type: Optional[list[CustomTypeItem]] = Field( None, description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", From 36ec1d389193b12ff1eadf3fb0287dda386307aa Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:56:18 +0000 Subject: [PATCH 31/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 162 ++++++++++++++++-- 1 file changed, 150 insertions(+), 12 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 69eb76e..5cccdc0 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -40,6 +40,8 @@ "keyword", "spatial_coverage_description", "contains_personal_data", + "use_restriction", + "use_restriction_date", "custom_type", "id", "owner", @@ -199,14 +201,32 @@ public class Dataset implements Serializable /** * Contains personal data *

- * Does the dataset contain personal data (true or false)? + * Is there any personal data amongst this data (data set)? * (Required) * */ @JsonProperty("contains_personal_data") - @JsonPropertyDescription("Does the dataset contain personal data (true or false)?") + @JsonPropertyDescription("Is there any personal data amongst this data (data set)?") @NotNull private Boolean containsPersonalData; + /** + * Use restriction + *

+ * Data set use restriction + * + */ + @JsonProperty("use_restriction") + @JsonPropertyDescription("Data set use restriction") + private Dataset.UseRestriction useRestriction; + /** + * Use restriction date + *

+ * Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised. + * + */ + @JsonProperty("use_restriction_date") + @JsonPropertyDescription("Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised.") + private Date useRestrictionDate; /** * Custom type for dataset metadata *

@@ -313,7 +333,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -2927904274780206031L; + private final static long serialVersionUID = -8972953542524169720L; /** * No args constructor for use in serialization @@ -360,8 +380,10 @@ public Dataset() { * Contains data from. The data set contains data from date/time. * @param filePath * File path. The file path contains the data set's name and the path to where it is stored. + * @param useRestriction + * Use restriction. Data set use restriction. * @param containsPersonalData - * Contains personal data. Does the dataset contain personal data (true or false)?. + * Contains personal data. Is there any personal data amongst this data (data set)?. * @param metadataLastUpdatedDate * Metadata last updated date. Last updated date for metadata about the dataset. * @param version @@ -372,12 +394,14 @@ public Dataset() { * Metadata created date. Created date for metadata about the data set. * @param name * Name. Name of data set. + * @param useRestrictionDate + * Use restriction date. Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised. * @param shortName * Short name. Name of (physical) data file, data table or dataset. * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -395,6 +419,8 @@ public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetS this.keyword = keyword; this.spatialCoverageDescription = spatialCoverageDescription; this.containsPersonalData = containsPersonalData; + this.useRestriction = useRestriction; + this.useRestrictionDate = useRestrictionDate; this.customType = customType; this.id = id; this.owner = owner; @@ -736,7 +762,7 @@ public void setSpatialCoverageDescription(LanguageStringType spatialCoverageDesc /** * Contains personal data *

- * Does the dataset contain personal data (true or false)? + * Is there any personal data amongst this data (data set)? * (Required) * */ @@ -748,7 +774,7 @@ public Boolean getContainsPersonalData() { /** * Contains personal data *

- * Does the dataset contain personal data (true or false)? + * Is there any personal data amongst this data (data set)? * (Required) * */ @@ -757,6 +783,50 @@ public void setContainsPersonalData(Boolean containsPersonalData) { this.containsPersonalData = containsPersonalData; } + /** + * Use restriction + *

+ * Data set use restriction + * + */ + @JsonProperty("use_restriction") + public Dataset.UseRestriction getUseRestriction() { + return useRestriction; + } + + /** + * Use restriction + *

+ * Data set use restriction + * + */ + @JsonProperty("use_restriction") + public void setUseRestriction(Dataset.UseRestriction useRestriction) { + this.useRestriction = useRestriction; + } + + /** + * Use restriction date + *

+ * Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised. + * + */ + @JsonProperty("use_restriction_date") + public Date getUseRestrictionDate() { + return useRestrictionDate; + } + + /** + * Use restriction date + *

+ * Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised. + * + */ + @JsonProperty("use_restriction_date") + public void setUseRestrictionDate(Date useRestrictionDate) { + this.useRestrictionDate = useRestrictionDate; + } + /** * Custom type for dataset metadata *

@@ -1065,6 +1135,14 @@ public String toString() { sb.append('='); sb.append(((this.containsPersonalData == null)?"":this.containsPersonalData)); sb.append(','); + sb.append("useRestriction"); + sb.append('='); + sb.append(((this.useRestriction == null)?"":this.useRestriction)); + sb.append(','); + sb.append("useRestrictionDate"); + sb.append('='); + sb.append(((this.useRestrictionDate == null)?"":this.useRestrictionDate)); + sb.append(','); sb.append("customType"); sb.append('='); sb.append(((this.customType == null)?"":this.customType)); @@ -1138,12 +1216,14 @@ public int hashCode() { result = ((result* 31)+((this.owner == null)? 0 :this.owner.hashCode())); result = ((result* 31)+((this.containsDataFrom == null)? 0 :this.containsDataFrom.hashCode())); result = ((result* 31)+((this.filePath == null)? 0 :this.filePath.hashCode())); + result = ((result* 31)+((this.useRestriction == null)? 0 :this.useRestriction.hashCode())); result = ((result* 31)+((this.containsPersonalData == null)? 0 :this.containsPersonalData.hashCode())); result = ((result* 31)+((this.metadataLastUpdatedDate == null)? 0 :this.metadataLastUpdatedDate.hashCode())); result = ((result* 31)+((this.version == null)? 0 :this.version.hashCode())); result = ((result* 31)+((this.customType == null)? 0 :this.customType.hashCode())); result = ((result* 31)+((this.metadataCreatedDate == null)? 0 :this.metadataCreatedDate.hashCode())); result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode())); + result = ((result* 31)+((this.useRestrictionDate == null)? 0 :this.useRestrictionDate.hashCode())); result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); result = ((result* 31)+((this.shortName == null)? 0 :this.shortName.hashCode())); result = ((result* 31)+((this.dataSource == null)? 0 :this.dataSource.hashCode())); @@ -1159,7 +1239,7 @@ public boolean equals(Object other) { return false; } Dataset rhs = ((Dataset) other); - return ((((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.containsPersonalData == rhs.containsPersonalData)||((this.containsPersonalData!= null)&&this.containsPersonalData.equals(rhs.containsPersonalData))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); + return ((((((((((((((((((((((((((((((this.versionDescription == rhs.versionDescription)||((this.versionDescription!= null)&&this.versionDescription.equals(rhs.versionDescription)))&&((this.containsDataUntil == rhs.containsDataUntil)||((this.containsDataUntil!= null)&&this.containsDataUntil.equals(rhs.containsDataUntil))))&&((this.datasetState == rhs.datasetState)||((this.datasetState!= null)&&this.datasetState.equals(rhs.datasetState))))&&((this.datasetStatus == rhs.datasetStatus)||((this.datasetStatus!= null)&&this.datasetStatus.equals(rhs.datasetStatus))))&&((this.description == rhs.description)||((this.description!= null)&&this.description.equals(rhs.description))))&&((this.populationDescription == rhs.populationDescription)||((this.populationDescription!= null)&&this.populationDescription.equals(rhs.populationDescription))))&&((this.metadataLastUpdatedBy == rhs.metadataLastUpdatedBy)||((this.metadataLastUpdatedBy!= null)&&this.metadataLastUpdatedBy.equals(rhs.metadataLastUpdatedBy))))&&((this.temporalityType == rhs.temporalityType)||((this.temporalityType!= null)&&this.temporalityType.equals(rhs.temporalityType))))&&((this.subjectField == rhs.subjectField)||((this.subjectField!= null)&&this.subjectField.equals(rhs.subjectField))))&&((this.unitType == rhs.unitType)||((this.unitType!= null)&&this.unitType.equals(rhs.unitType))))&&((this.assessment == rhs.assessment)||((this.assessment!= null)&&this.assessment.equals(rhs.assessment))))&&((this.spatialCoverageDescription == rhs.spatialCoverageDescription)||((this.spatialCoverageDescription!= null)&&this.spatialCoverageDescription.equals(rhs.spatialCoverageDescription))))&&((this.metadataCreatedBy == rhs.metadataCreatedBy)||((this.metadataCreatedBy!= null)&&this.metadataCreatedBy.equals(rhs.metadataCreatedBy))))&&((this.id == rhs.id)||((this.id!= null)&&this.id.equals(rhs.id))))&&((this.keyword == rhs.keyword)||((this.keyword!= null)&&this.keyword.equals(rhs.keyword))))&&((this.owner == rhs.owner)||((this.owner!= null)&&this.owner.equals(rhs.owner))))&&((this.containsDataFrom == rhs.containsDataFrom)||((this.containsDataFrom!= null)&&this.containsDataFrom.equals(rhs.containsDataFrom))))&&((this.filePath == rhs.filePath)||((this.filePath!= null)&&this.filePath.equals(rhs.filePath))))&&((this.useRestriction == rhs.useRestriction)||((this.useRestriction!= null)&&this.useRestriction.equals(rhs.useRestriction))))&&((this.containsPersonalData == rhs.containsPersonalData)||((this.containsPersonalData!= null)&&this.containsPersonalData.equals(rhs.containsPersonalData))))&&((this.metadataLastUpdatedDate == rhs.metadataLastUpdatedDate)||((this.metadataLastUpdatedDate!= null)&&this.metadataLastUpdatedDate.equals(rhs.metadataLastUpdatedDate))))&&((this.version == rhs.version)||((this.version!= null)&&this.version.equals(rhs.version))))&&((this.customType == rhs.customType)||((this.customType!= null)&&this.customType.equals(rhs.customType))))&&((this.metadataCreatedDate == rhs.metadataCreatedDate)||((this.metadataCreatedDate!= null)&&this.metadataCreatedDate.equals(rhs.metadataCreatedDate))))&&((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name))))&&((this.useRestrictionDate == rhs.useRestrictionDate)||((this.useRestrictionDate!= null)&&this.useRestrictionDate.equals(rhs.useRestrictionDate))))&&((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.dataSource == rhs.dataSource)||((this.dataSource!= null)&&this.dataSource.equals(rhs.dataSource)))); } @@ -1219,8 +1299,8 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { - super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } } @@ -1238,10 +1318,10 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { - this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); + this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); } } @@ -1332,6 +1412,16 @@ public Dataset.DatasetBuilderBase withContainsPersonalData(Boolean containsPerso return this; } + public Dataset.DatasetBuilderBase withUseRestriction(Dataset.UseRestriction useRestriction) { + ((Dataset) this.instance).useRestriction = useRestriction; + return this; + } + + public Dataset.DatasetBuilderBase withUseRestrictionDate(Date useRestrictionDate) { + ((Dataset) this.instance).useRestrictionDate = useRestrictionDate; + return this; + } + public Dataset.DatasetBuilderBase withCustomType(List customType) { ((Dataset) this.instance).customType = customType; return this; @@ -1601,4 +1691,52 @@ public static Dataset.UnitType fromValue(String value) { } + + /** + * Use restriction + *

+ * Data set use restriction + * + */ + @Generated("jsonschema2pojo") + public enum UseRestriction { + + DELETION_ANONYMIZATION("DELETION_ANONYMIZATION"), + PROCESS_LIMITATIONS("PROCESS_LIMITATIONS"), + SECONDARY_USE_RESTRICTIONS("SECONDARY_USE_RESTRICTIONS"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.UseRestriction c: values()) { + CONSTANTS.put(c.value, c); + } + } + + UseRestriction(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.UseRestriction fromValue(String value) { + Dataset.UseRestriction constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + } From a1fb58eef5078314cffd0d47eca1637bb369c638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:09:34 +0100 Subject: [PATCH 32/49] Changed languageStringType to support many languages. --- src/datadoc/no/languageStringType.json | 37 +++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/datadoc/no/languageStringType.json b/src/datadoc/no/languageStringType.json index d3ff6b6..2975c5b 100644 --- a/src/datadoc/no/languageStringType.json +++ b/src/datadoc/no/languageStringType.json @@ -1,22 +1,29 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - + "languageStringType": { - "$comment": "Reusable langugage string type", - "type": "object", - "properties": { - "en": { - "type": "string" - }, - "nn": { - "type": "string" - }, - "nb": { - "type": "string" + "$comment": "Reusableb langugage string type", + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "languageCode": { + "title": "Language code", + "description": "Language code (ISO 639-1)", + "type": "string" + }, + "languageText": { + "title": "Language text", + "description": "Language text", + "type": "string" + } + }, + "required": [ + "languageCode", + "languageText" + ] } - }, - "required": [ - "nb" ] } } \ No newline at end of file From 37063e2664f905c64adee38749c17c555c693cdd Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:10:09 +0000 Subject: [PATCH 33/49] [GENERATE] Pydantic models from JSON Schema --- .../datadoc_model/datadoc_model/model.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index d7aedca..aafb130 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T14:55:34+00:00 +# timestamp: 2024-02-12T15:10:09+00:00 from __future__ import annotations @@ -8,7 +8,7 @@ from typing import Any, Literal, Optional, Union from uuid import UUID -from pydantic import AnyUrl, AwareDatetime, Field +from pydantic import AnyUrl, AwareDatetime, Field, RootModel from datadoc_model.datadoc_base_model import DatadocBaseModel @@ -79,10 +79,17 @@ class Sentinel(DatadocBaseModel): ) -class LanguageStringType(DatadocBaseModel): - en: Optional[str] = None - nn: Optional[str] = None - nb: Optional[str] = None +class LanguageStringTypeItem(DatadocBaseModel): + languageCode: Optional[str] = Field( + None, description="Language code (ISO 639-1)", title="Language code" + ) + languageText: Optional[str] = Field( + None, description="Language text", title="Language text" + ) + + +class LanguageStringType(RootModel[Optional[list[LanguageStringTypeItem]]]): + root: Optional[list[LanguageStringTypeItem]] = None class UnitType(str, Enum): From c42c4e16c1677d28c1593a20e3a50b9bd17bfa7c Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:11:03 +0000 Subject: [PATCH 34/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 106 ++++---- .../metadata/datadoc/LanguageStringType.java | 231 ------------------ .../dapla/metadata/datadoc/OtherValue.java | 24 +- .../ssb/dapla/metadata/datadoc/Variable.java | 78 +++--- 4 files changed, 105 insertions(+), 334 deletions(-) delete mode 100644 generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/LanguageStringType.java diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 5cccdc0..9c1c600 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -102,39 +102,39 @@ public class Dataset implements Serializable @NotNull private Dataset.DataSetState datasetState; /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("name") @Valid @NotNull - private LanguageStringType name; + private List name = new ArrayList(); /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("description") @Valid @NotNull - private LanguageStringType description; + private List description = new ArrayList(); /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("data_source") @Valid - private LanguageStringType dataSource; + private List dataSource = new ArrayList(); /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("population_description") @Valid @NotNull - private LanguageStringType populationDescription; + private List populationDescription = new ArrayList(); /** * Version *

@@ -147,12 +147,12 @@ public class Dataset implements Serializable @NotNull private String version; /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("version_description") @Valid - private LanguageStringType versionDescription; + private List versionDescription = new ArrayList(); /** * Unit type *

@@ -192,12 +192,12 @@ public class Dataset implements Serializable @Valid private List keyword = new ArrayList(); /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("spatial_coverage_description") @Valid - private LanguageStringType spatialCoverageDescription; + private List spatialCoverageDescription = new ArrayList(); /** * Contains personal data *

@@ -249,14 +249,14 @@ public class Dataset implements Serializable @NotNull private UUID id; /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("owner") @Valid @NotNull - private LanguageStringType owner; + private List owner = new ArrayList(); /** * File path *

@@ -333,7 +333,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -8972953542524169720L; + private final static long serialVersionUID = -7019746965862498234L; /** * No args constructor for use in serialization @@ -401,7 +401,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -534,80 +534,80 @@ public void setDatasetState(Dataset.DataSetState datasetState) { } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("name") - public LanguageStringType getName() { + public List getName() { return name; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("name") - public void setName(LanguageStringType name) { + public void setName(List name) { this.name = name; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("description") - public LanguageStringType getDescription() { + public List getDescription() { return description; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("description") - public void setDescription(LanguageStringType description) { + public void setDescription(List description) { this.description = description; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("data_source") - public LanguageStringType getDataSource() { + public List getDataSource() { return dataSource; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("data_source") - public void setDataSource(LanguageStringType dataSource) { + public void setDataSource(List dataSource) { this.dataSource = dataSource; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("population_description") - public LanguageStringType getPopulationDescription() { + public List getPopulationDescription() { return populationDescription; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("population_description") - public void setPopulationDescription(LanguageStringType populationDescription) { + public void setPopulationDescription(List populationDescription) { this.populationDescription = populationDescription; } @@ -636,20 +636,20 @@ public void setVersion(String version) { } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("version_description") - public LanguageStringType getVersionDescription() { + public List getVersionDescription() { return versionDescription; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("version_description") - public void setVersionDescription(LanguageStringType versionDescription) { + public void setVersionDescription(List versionDescription) { this.versionDescription = versionDescription; } @@ -742,20 +742,20 @@ public void setKeyword(List keyword) { } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("spatial_coverage_description") - public LanguageStringType getSpatialCoverageDescription() { + public List getSpatialCoverageDescription() { return spatialCoverageDescription; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("spatial_coverage_description") - public void setSpatialCoverageDescription(LanguageStringType spatialCoverageDescription) { + public void setSpatialCoverageDescription(List spatialCoverageDescription) { this.spatialCoverageDescription = spatialCoverageDescription; } @@ -874,22 +874,22 @@ public void setId(UUID id) { } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("owner") - public LanguageStringType getOwner() { + public List getOwner() { return owner; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("owner") - public void setOwner(LanguageStringType owner) { + public void setOwner(List owner) { this.owner = owner; } @@ -1299,7 +1299,7 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } @@ -1318,7 +1318,7 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, LanguageStringType spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); @@ -1352,22 +1352,22 @@ public Dataset.DatasetBuilderBase withDatasetState(Dataset.DataSetState datasetS return this; } - public Dataset.DatasetBuilderBase withName(LanguageStringType name) { + public Dataset.DatasetBuilderBase withName(List name) { ((Dataset) this.instance).name = name; return this; } - public Dataset.DatasetBuilderBase withDescription(LanguageStringType description) { + public Dataset.DatasetBuilderBase withDescription(List description) { ((Dataset) this.instance).description = description; return this; } - public Dataset.DatasetBuilderBase withDataSource(LanguageStringType dataSource) { + public Dataset.DatasetBuilderBase withDataSource(List dataSource) { ((Dataset) this.instance).dataSource = dataSource; return this; } - public Dataset.DatasetBuilderBase withPopulationDescription(LanguageStringType populationDescription) { + public Dataset.DatasetBuilderBase withPopulationDescription(List populationDescription) { ((Dataset) this.instance).populationDescription = populationDescription; return this; } @@ -1377,7 +1377,7 @@ public Dataset.DatasetBuilderBase withVersion(String version) { return this; } - public Dataset.DatasetBuilderBase withVersionDescription(LanguageStringType versionDescription) { + public Dataset.DatasetBuilderBase withVersionDescription(List versionDescription) { ((Dataset) this.instance).versionDescription = versionDescription; return this; } @@ -1402,7 +1402,7 @@ public Dataset.DatasetBuilderBase withKeyword(List keyword) { return this; } - public Dataset.DatasetBuilderBase withSpatialCoverageDescription(LanguageStringType spatialCoverageDescription) { + public Dataset.DatasetBuilderBase withSpatialCoverageDescription(List spatialCoverageDescription) { ((Dataset) this.instance).spatialCoverageDescription = spatialCoverageDescription; return this; } @@ -1432,7 +1432,7 @@ public Dataset.DatasetBuilderBase withId(UUID id) { return this; } - public Dataset.DatasetBuilderBase withOwner(LanguageStringType owner) { + public Dataset.DatasetBuilderBase withOwner(List owner) { ((Dataset) this.instance).owner = owner; return this; } diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/LanguageStringType.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/LanguageStringType.java deleted file mode 100644 index d34088b..0000000 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/LanguageStringType.java +++ /dev/null @@ -1,231 +0,0 @@ - -package no.ssb.dapla.metadata.datadoc; - -import java.io.Serializable; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.processing.Generated; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; - - -/** - * Reusable langugage string type - * - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "en", - "nn", - "nb" -}) -@Generated("jsonschema2pojo") -public class LanguageStringType implements Serializable -{ - - @JsonProperty("en") - private String en; - @JsonProperty("nn") - private String nn; - /** - * - * (Required) - * - */ - @JsonProperty("nb") - @NotNull - private String nb; - @JsonIgnore - @Valid - private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -2807086073068172838L; - - /** - * No args constructor for use in serialization - * - */ - public LanguageStringType() { - } - - public LanguageStringType(String en, String nn, String nb) { - super(); - this.en = en; - this.nn = nn; - this.nb = nb; - } - - public static LanguageStringType.LanguageStringTypeBuilderBase builder() { - return new LanguageStringType.LanguageStringTypeBuilder(); - } - - @JsonProperty("en") - public String getEn() { - return en; - } - - @JsonProperty("en") - public void setEn(String en) { - this.en = en; - } - - @JsonProperty("nn") - public String getNn() { - return nn; - } - - @JsonProperty("nn") - public void setNn(String nn) { - this.nn = nn; - } - - /** - * - * (Required) - * - */ - @JsonProperty("nb") - public String getNb() { - return nb; - } - - /** - * - * (Required) - * - */ - @JsonProperty("nb") - public void setNb(String nb) { - this.nb = nb; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(LanguageStringType.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('['); - sb.append("en"); - sb.append('='); - sb.append(((this.en == null)?"":this.en)); - sb.append(','); - sb.append("nn"); - sb.append('='); - sb.append(((this.nn == null)?"":this.nn)); - sb.append(','); - sb.append("nb"); - sb.append('='); - sb.append(((this.nb == null)?"":this.nb)); - sb.append(','); - sb.append("additionalProperties"); - sb.append('='); - sb.append(((this.additionalProperties == null)?"":this.additionalProperties)); - sb.append(','); - if (sb.charAt((sb.length()- 1)) == ',') { - sb.setCharAt((sb.length()- 1), ']'); - } else { - sb.append(']'); - } - return sb.toString(); - } - - @Override - public int hashCode() { - int result = 1; - result = ((result* 31)+((this.nn == null)? 0 :this.nn.hashCode())); - result = ((result* 31)+((this.en == null)? 0 :this.en.hashCode())); - result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode())); - result = ((result* 31)+((this.nb == null)? 0 :this.nb.hashCode())); - return result; - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - if ((other instanceof LanguageStringType) == false) { - return false; - } - LanguageStringType rhs = ((LanguageStringType) other); - return (((((this.nn == rhs.nn)||((this.nn!= null)&&this.nn.equals(rhs.nn)))&&((this.en == rhs.en)||((this.en!= null)&&this.en.equals(rhs.en))))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))))&&((this.nb == rhs.nb)||((this.nb!= null)&&this.nb.equals(rhs.nb)))); - } - - public static class LanguageStringTypeBuilder - extends LanguageStringType.LanguageStringTypeBuilderBase - { - - - public LanguageStringTypeBuilder() { - super(); - } - - public LanguageStringTypeBuilder(String en, String nn, String nb) { - super(en, nn, nb); - } - - } - - public static abstract class LanguageStringTypeBuilderBase{ - - protected T instance; - - @SuppressWarnings("unchecked") - public LanguageStringTypeBuilderBase() { - // Skip initialization when called from subclass - if (this.getClass().equals(LanguageStringType.LanguageStringTypeBuilder.class)) { - this.instance = ((T) new LanguageStringType()); - } - } - - @SuppressWarnings("unchecked") - public LanguageStringTypeBuilderBase(String en, String nn, String nb) { - // Skip initialization when called from subclass - if (this.getClass().equals(LanguageStringType.LanguageStringTypeBuilder.class)) { - this.instance = ((T) new LanguageStringType(en, nn, nb)); - } - } - - public T build() { - T result; - result = this.instance; - this.instance = null; - return result; - } - - public LanguageStringType.LanguageStringTypeBuilderBase withEn(String en) { - ((LanguageStringType) this.instance).en = en; - return this; - } - - public LanguageStringType.LanguageStringTypeBuilderBase withNn(String nn) { - ((LanguageStringType) this.instance).nn = nn; - return this; - } - - public LanguageStringType.LanguageStringTypeBuilderBase withNb(String nb) { - ((LanguageStringType) this.instance).nb = nb; - return this; - } - - public LanguageStringType.LanguageStringTypeBuilderBase withAdditionalProperty(String name, Object value) { - ((LanguageStringType) this.instance).additionalProperties.put(name, value); - return this; - } - - } - -} diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java index c246e83..261a180 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/OtherValue.java @@ -2,8 +2,10 @@ package no.ssb.dapla.metadata.datadoc; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import javax.annotation.processing.Generated; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -36,12 +38,12 @@ public class OtherValue implements Serializable @JsonPropertyDescription("Other value code") private String code; /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("name") @Valid - private LanguageStringType name; + private List name = new ArrayList(); /** * Valid from *

@@ -63,7 +65,7 @@ public class OtherValue implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -5723978274694723388L; + private final static long serialVersionUID = 7799050029710232246L; /** * No args constructor for use in serialization @@ -83,7 +85,7 @@ public OtherValue() { * @param validFrom * Valid from. Other value valid from date. */ - public OtherValue(String code, LanguageStringType name, Date validFrom, Date validUntil) { + public OtherValue(String code, List name, Date validFrom, Date validUntil) { super(); this.code = code; this.name = name; @@ -118,20 +120,20 @@ public void setCode(String code) { } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("name") - public LanguageStringType getName() { + public List getName() { return name; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("name") - public void setName(LanguageStringType name) { + public void setName(List name) { this.name = name; } @@ -253,7 +255,7 @@ public OtherValueBuilder() { super(); } - public OtherValueBuilder(String code, LanguageStringType name, Date validFrom, Date validUntil) { + public OtherValueBuilder(String code, List name, Date validFrom, Date validUntil) { super(code, name, validFrom, validUntil); } @@ -272,7 +274,7 @@ public OtherValueBuilderBase() { } @SuppressWarnings("unchecked") - public OtherValueBuilderBase(String code, LanguageStringType name, Date validFrom, Date validUntil) { + public OtherValueBuilderBase(String code, List name, Date validFrom, Date validUntil) { // Skip initialization when called from subclass if (this.getClass().equals(OtherValue.OtherValueBuilder.class)) { this.instance = ((T) new OtherValue(code, name, validFrom, validUntil)); @@ -291,7 +293,7 @@ public OtherValue.OtherValueBuilderBase withCode(String code) { return this; } - public OtherValue.OtherValueBuilderBase withName(LanguageStringType name) { + public OtherValue.OtherValueBuilderBase withName(List name) { ((OtherValue) this.instance).name = name; return this; } diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java index fdcde14..9b48f30 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Variable.java @@ -72,14 +72,14 @@ public class Variable implements Serializable @JsonPropertyDescription("The path (dot notation) to the data element in a hierarchical data structure, eg. 'person.adress'. Must be given in addition to the short_name.") private String dataElementPath; /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("name") @Valid @NotNull - private LanguageStringType name; + private List name = new ArrayList(); /** * Data type *

@@ -123,26 +123,26 @@ public class Variable implements Serializable @NotNull private Boolean directPersonIdentifying; /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("data_source") @Valid - private LanguageStringType dataSource; + private List dataSource = new ArrayList(); /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("population_description") @Valid - private LanguageStringType populationDescription; + private List populationDescription = new ArrayList(); /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("comment") @Valid - private LanguageStringType comment; + private List comment = new ArrayList(); /** * Reusable temporalitytype type * @@ -195,12 +195,12 @@ public class Variable implements Serializable @Valid private SpecialValues specialValue; /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("invalid_value_description") @Valid - private LanguageStringType invalidValueDescription; + private List invalidValueDescription = new ArrayList(); /** * Custom type for variable metadata *

@@ -243,7 +243,7 @@ public class Variable implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 1684720938968430884L; + private final static long serialVersionUID = 1019444275429139130L; /** * No args constructor for use in serialization @@ -297,7 +297,7 @@ public Variable() { * @param invalidValueDescription * Invalid value(s) description. Invalid value(s) description used in addition (or as an alternative) to standard sentinel values. */ - public Variable(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { + public Variable(String shortName, String dataElementPath, List name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, List dataSource, List populationDescription, List comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { super(); this.shortName = shortName; this.dataElementPath = dataElementPath; @@ -373,22 +373,22 @@ public void setDataElementPath(String dataElementPath) { } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("name") - public LanguageStringType getName() { + public List getName() { return name; } /** - * Reusable langugage string type + * Reusableb langugage string type * (Required) * */ @JsonProperty("name") - public void setName(LanguageStringType name) { + public void setName(List name) { this.name = name; } @@ -487,56 +487,56 @@ public void setDirectPersonIdentifying(Boolean directPersonIdentifying) { } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("data_source") - public LanguageStringType getDataSource() { + public List getDataSource() { return dataSource; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("data_source") - public void setDataSource(LanguageStringType dataSource) { + public void setDataSource(List dataSource) { this.dataSource = dataSource; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("population_description") - public LanguageStringType getPopulationDescription() { + public List getPopulationDescription() { return populationDescription; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("population_description") - public void setPopulationDescription(LanguageStringType populationDescription) { + public void setPopulationDescription(List populationDescription) { this.populationDescription = populationDescription; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("comment") - public LanguageStringType getComment() { + public List getComment() { return comment; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("comment") - public void setComment(LanguageStringType comment) { + public void setComment(List comment) { this.comment = comment; } @@ -669,20 +669,20 @@ public void setSpecialValue(SpecialValues specialValue) { } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("invalid_value_description") - public LanguageStringType getInvalidValueDescription() { + public List getInvalidValueDescription() { return invalidValueDescription; } /** - * Reusable langugage string type + * Reusableb langugage string type * */ @JsonProperty("invalid_value_description") - public void setInvalidValueDescription(LanguageStringType invalidValueDescription) { + public void setInvalidValueDescription(List invalidValueDescription) { this.invalidValueDescription = invalidValueDescription; } @@ -986,7 +986,7 @@ public VariableBuilder() { super(); } - public VariableBuilder(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { + public VariableBuilder(String shortName, String dataElementPath, List name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, List dataSource, List populationDescription, List comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { super(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, customType, id, containsDataFrom, containsDataUntil); } @@ -1005,7 +1005,7 @@ public VariableBuilderBase() { } @SuppressWarnings("unchecked") - public VariableBuilderBase(String shortName, String dataElementPath, LanguageStringType name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, LanguageStringType dataSource, LanguageStringType populationDescription, LanguageStringType comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, LanguageStringType invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { + public VariableBuilderBase(String shortName, String dataElementPath, List name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, List dataSource, List populationDescription, List comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List invalidValueDescription, List customType, UUID id, Date containsDataFrom, Date containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Variable.VariableBuilder.class)) { this.instance = ((T) new Variable(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, customType, id, containsDataFrom, containsDataUntil)); @@ -1029,7 +1029,7 @@ public Variable.VariableBuilderBase withDataElementPath(String dataElementPath) return this; } - public Variable.VariableBuilderBase withName(LanguageStringType name) { + public Variable.VariableBuilderBase withName(List name) { ((Variable) this.instance).name = name; return this; } @@ -1054,17 +1054,17 @@ public Variable.VariableBuilderBase withDirectPersonIdentifying(Boolean directPe return this; } - public Variable.VariableBuilderBase withDataSource(LanguageStringType dataSource) { + public Variable.VariableBuilderBase withDataSource(List dataSource) { ((Variable) this.instance).dataSource = dataSource; return this; } - public Variable.VariableBuilderBase withPopulationDescription(LanguageStringType populationDescription) { + public Variable.VariableBuilderBase withPopulationDescription(List populationDescription) { ((Variable) this.instance).populationDescription = populationDescription; return this; } - public Variable.VariableBuilderBase withComment(LanguageStringType comment) { + public Variable.VariableBuilderBase withComment(List comment) { ((Variable) this.instance).comment = comment; return this; } @@ -1099,7 +1099,7 @@ public Variable.VariableBuilderBase withSpecialValue(SpecialValues specialValue) return this; } - public Variable.VariableBuilderBase withInvalidValueDescription(LanguageStringType invalidValueDescription) { + public Variable.VariableBuilderBase withInvalidValueDescription(List invalidValueDescription) { ((Variable) this.instance).invalidValueDescription = invalidValueDescription; return this; } From 78e8942c0ad736dcbd8d3106bc0d2b175ac8596c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:49:35 +0100 Subject: [PATCH 35/49] Bumped to json schema to version 3.0.0 --- src/datadoc/datadoc-json-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 52d669a..37e3ab3 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -10,7 +10,7 @@ }, "document_version": { "description": "Version of this model", - "const": "2.0.0" + "const": "3.0.0" }, "dataset": { "type": "object", From 9864f52e9c6349a6029b1dd7920ec1837207c6e5 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:50:41 +0000 Subject: [PATCH 36/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index aafb130..b341b6e 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T15:10:09+00:00 +# timestamp: 2024-02-12T15:50:41+00:00 from __future__ import annotations @@ -453,8 +453,8 @@ class DatadocJsonSchema(DatadocBaseModel): percentage_complete: Optional[int] = Field( None, description="Percentage of obligatory metadata fields populated." ) - document_version: Literal["2.0.0"] = Field( - "2.0.0", description="Version of this model" + document_version: Literal["3.0.0"] = Field( + "3.0.0", description="Version of this model" ) dataset: Optional[Dataset] = None variables: Optional[list[Variable]] = None From 7e9e13670666e3a4a74771e25de24bdf4f6e196c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:07:23 +0100 Subject: [PATCH 37/49] Changed 'unit_type'-type to string --- src/datadoc/datadoc-json-schema.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 37e3ab3..781feaf 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -87,8 +87,7 @@ "unit_type": { "title": "Unit type", "description": "Unit Type for data file, table or data set. See Definitions of Unit Types https://www.ssb.no/en/metadata/definisjoner-av-statistiske-enheter", - "type": "string", - "$ref": "./no/unitType.json#/unitType" + "type": "string" }, "temporality_type": { "title": "Temporality type", From 612069670d9388ce9902a56b7455011eef64f48c Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:07:57 +0000 Subject: [PATCH 38/49] [GENERATE] Pydantic models from JSON Schema --- .../datadoc_model/datadoc_model/model.py | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index b341b6e..b9ff56f 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T15:50:41+00:00 +# timestamp: 2024-02-12T16:07:57+00:00 from __future__ import annotations @@ -92,30 +92,6 @@ class LanguageStringType(RootModel[Optional[list[LanguageStringTypeItem]]]): root: Optional[list[LanguageStringTypeItem]] = None -class UnitType(str, Enum): - ARBEIDSULYKKE = "ARBEIDSULYKKE" - BOLIG = "BOLIG" - BYGNING = "BYGNING" - EIENDOM = "EIENDOM" - FAMILIE = "FAMILIE" - FORETAK = "FORETAK" - FYLKE = "FYLKE" - HAVNEANLOEP = "HAVNEANLOEP" - HUSHOLDNING = "HUSHOLDNING" - KJOERETOEY = "KJOERETOEY" - KOMMUNE = "KOMMUNE" - KURS = "KURS" - LOVBRUDD = "LOVBRUDD" - PERSON = "PERSON" - STAT = "STAT" - STORFE = "STORFE" - TRAFIKKULYKKE = "TRAFIKKULYKKE" - TRANSAKSJON = "TRANSAKSJON" - VARE_TJENESTE = "VARE_TJENESTE" - VERDIPAPIR = "VERDIPAPIR" - VIRKSOMHET = "VIRKSOMHET" - - class TemporalityTypeType(str, Enum): FIXED = "FIXED" STATUS = "STATUS" @@ -241,7 +217,7 @@ class Dataset(DatadocBaseModel): description="Dataset version information in the form of descriptive text", title="Version description", ) - unit_type: Optional[UnitType] = Field( + unit_type: Optional[str] = Field( None, description="Unit Type for data file, table or data set. See Definitions of Unit Types https://www.ssb.no/en/metadata/definisjoner-av-statistiske-enheter", title="Unit type", From 32ed62d41f5b329c2909055d539081ade1199db9 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:08:51 +0000 Subject: [PATCH 39/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 82 ++----------------- 1 file changed, 8 insertions(+), 74 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 9c1c600..1fc860a 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -163,7 +163,7 @@ public class Dataset implements Serializable @JsonProperty("unit_type") @JsonPropertyDescription("Unit Type for data file, table or data set. See Definitions of Unit Types https://www.ssb.no/en/metadata/definisjoner-av-statistiske-enheter") @NotNull - private Dataset.UnitType unitType; + private String unitType; /** * Reusable temporalitytype type * @@ -333,7 +333,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = -7019746965862498234L; + private final static long serialVersionUID = -7459109918184248449L; /** * No args constructor for use in serialization @@ -401,7 +401,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -661,7 +661,7 @@ public void setVersionDescription(List versionDescription) { * */ @JsonProperty("unit_type") - public Dataset.UnitType getUnitType() { + public String getUnitType() { return unitType; } @@ -673,7 +673,7 @@ public Dataset.UnitType getUnitType() { * */ @JsonProperty("unit_type") - public void setUnitType(Dataset.UnitType unitType) { + public void setUnitType(String unitType) { this.unitType = unitType; } @@ -1299,7 +1299,7 @@ public DatasetBuilder() { super(); } - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); } @@ -1318,7 +1318,7 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { + public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); @@ -1382,7 +1382,7 @@ public Dataset.DatasetBuilderBase withVersionDescription(List versionDes return this; } - public Dataset.DatasetBuilderBase withUnitType(Dataset.UnitType unitType) { + public Dataset.DatasetBuilderBase withUnitType(String unitType) { ((Dataset) this.instance).unitType = unitType; return this; } @@ -1626,72 +1626,6 @@ public static Dataset.TemporalityTypeType fromValue(String value) { } - /** - * Unit type - *

- * Unit Type for data file, table or data set. See Definitions of Unit Types https://www.ssb.no/en/metadata/definisjoner-av-statistiske-enheter - * - */ - @Generated("jsonschema2pojo") - public enum UnitType { - - ARBEIDSULYKKE("ARBEIDSULYKKE"), - BOLIG("BOLIG"), - BYGNING("BYGNING"), - EIENDOM("EIENDOM"), - FAMILIE("FAMILIE"), - FORETAK("FORETAK"), - FYLKE("FYLKE"), - HAVNEANLOEP("HAVNEANLOEP"), - HUSHOLDNING("HUSHOLDNING"), - KJOERETOEY("KJOERETOEY"), - KOMMUNE("KOMMUNE"), - KURS("KURS"), - LOVBRUDD("LOVBRUDD"), - PERSON("PERSON"), - STAT("STAT"), - STORFE("STORFE"), - TRAFIKKULYKKE("TRAFIKKULYKKE"), - TRANSAKSJON("TRANSAKSJON"), - VARE_TJENESTE("VARE_TJENESTE"), - VERDIPAPIR("VERDIPAPIR"), - VIRKSOMHET("VIRKSOMHET"); - private final String value; - private final static Map CONSTANTS = new HashMap(); - - static { - for (Dataset.UnitType c: values()) { - CONSTANTS.put(c.value, c); - } - } - - UnitType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - @JsonValue - public String value() { - return this.value; - } - - @JsonCreator - public static Dataset.UnitType fromValue(String value) { - Dataset.UnitType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } - - } - - /** * Use restriction *

From bef970a9f382511d4627ee291e08fdcb52be9a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Roar=20Joneid?= <38685892+BjornRoarJoneid@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:11:57 +0100 Subject: [PATCH 40/49] Removed unitType.json --- src/datadoc/no/unitType.json | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/datadoc/no/unitType.json diff --git a/src/datadoc/no/unitType.json b/src/datadoc/no/unitType.json deleted file mode 100644 index 40d195b..0000000 --- a/src/datadoc/no/unitType.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - - "unitType": { - "title": "Unit type", - "description": "Unit Type for data file, table or data set. See Definitions of Unit Types https://www.ssb.no/en/metadata/definisjoner-av-statistiske-enheter", - "type": "string", - "enum": [ - "ARBEIDSULYKKE", - "BOLIG", - "BYGNING", - "EIENDOM", - "FAMILIE", - "FORETAK", - "FYLKE", - "HAVNEANLOEP", - "HUSHOLDNING", - "KJOERETOEY", - "KOMMUNE", - "KURS", - "LOVBRUDD", - "PERSON", - "STAT", - "STORFE", - "TRAFIKKULYKKE", - "TRANSAKSJON", - "VARE_TJENESTE", - "VERDIPAPIR", - "VIRKSOMHET" - ] - } -} \ No newline at end of file From aa469cda4c9bc04939dc7aaf8de2e2478615a891 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:12:27 +0000 Subject: [PATCH 41/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index b9ff56f..d85ee11 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-12T16:07:57+00:00 +# timestamp: 2024-02-12T16:12:27+00:00 from __future__ import annotations From bec2ccb5efc1c153e3cb62436b38135ba14dee0d Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:12:35 +0000 Subject: [PATCH 42/49] [GENERATE] Pydantic models from JSON Schema --- .../datadoc_model/datadoc_model/model.py | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index eca1650..9af6d4e 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,10 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -<<<<<<< HEAD -# timestamp: 2024-02-12T16:12:27+00:00 -======= -# timestamp: 2024-02-21T09:13:37+00:00 ->>>>>>> origin/main +# timestamp: 2024-02-22T09:12:35+00:00 from __future__ import annotations @@ -44,7 +40,7 @@ class UseRestriction(str, Enum): SECONDARY_USE_RESTRICTIONS = "SECONDARY_USE_RESTRICTIONS" -class CustomTypeItem(DatadocBaseModel): +class CustomTypeForDatasetMetadatum(DatadocBaseModel): key: Optional[str] = Field(None, description="Custom type KEY", title="Key") value: Optional[Union[str, list, dict[str, Any]]] = Field( None, @@ -70,7 +66,7 @@ class VariableRole(str, Enum): ATTRIBUTE = "ATTRIBUTE" -class Sentinel(DatadocBaseModel): +class SentinelValues(DatadocBaseModel): sentinel_value_uri: Optional[AnyUrl] = Field( None, description="A link (URI) to a standardized list of sentinel values included in the variable, eg. a link to a codelist in Klass (https://www.ssb.no/en/klass/)", @@ -83,7 +79,15 @@ class Sentinel(DatadocBaseModel): ) -<<<<<<< HEAD +class CustomTypeForVariableMetadatum(DatadocBaseModel): + key: Optional[str] = Field(None, description="Custom type KEY", title="Key") + value: Optional[Union[str, list, dict[str, Any]]] = Field( + None, + description="Custom type VALUE (of type string, array or object).", + title="Value", + ) + + class LanguageStringTypeItem(DatadocBaseModel): languageCode: Optional[str] = Field( None, description="Language code (ISO 639-1)", title="Language code" @@ -97,8 +101,6 @@ class LanguageStringType(RootModel[Optional[list[LanguageStringTypeItem]]]): root: Optional[list[LanguageStringTypeItem]] = None -======= ->>>>>>> origin/main class TemporalityTypeType(str, Enum): FIXED = "FIXED" STATUS = "STATUS" @@ -262,7 +264,7 @@ class Dataset(DatadocBaseModel): description="Use restriction date, eg. the date (deadline) for when data must be deleted/anonymised.", title="Use restriction date", ) - custom_type: Optional[list[CustomTypeItem]] = Field( + custom_type: Optional[list[CustomTypeForDatasetMetadatum]] = Field( None, description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", title="Custom type for dataset metadata", @@ -310,7 +312,7 @@ class Dataset(DatadocBaseModel): ) -class OtherValueItem(DatadocBaseModel): +class OtherSpecialValue(DatadocBaseModel): code: Optional[str] = Field(None, description="Other value code", title="Code") name: Optional[LanguageStringType] = Field( None, description="Other value name (text)", title="Name" @@ -323,9 +325,9 @@ class OtherValueItem(DatadocBaseModel): ) -class SpecialValue(DatadocBaseModel): - sentinel: Optional[Sentinel] = Field(None, title="Sentinel values") - other_value: Optional[list[OtherValueItem]] = Field( +class SpecialValues(DatadocBaseModel): + sentinel: Optional[SentinelValues] = Field(None, title="Sentinel values") + other_value: Optional[list[OtherSpecialValue]] = Field( None, description="Other special values not represented as 'sentinel_value' in a standardized code list.", title="Other special values", @@ -404,13 +406,13 @@ class Variable(DatadocBaseModel): description="Link (URI) to valid classification or code list", title="Classification or codelist URI", ) - special_value: Optional[SpecialValue] = Field(None, title="Special values") + special_value: Optional[SpecialValues] = Field(None, title="Special values") invalid_value_description: Optional[LanguageStringType] = Field( None, description="Invalid value(s) description used in addition (or as an alternative) to standard sentinel values.", title="Invalid value(s) description", ) - custom_type: Optional[list[CustomTypeItem]] = Field( + custom_type: Optional[list[CustomTypeForVariableMetadatum]] = Field( None, description="Extend the DataDoc model by adding custom metadata elements as key-value-pairs (string, array or objects).", title="Custom type for variable metadata", @@ -436,13 +438,8 @@ class DatadocMetadata(DatadocBaseModel): percentage_complete: Optional[int] = Field( None, description="Percentage of obligatory metadata fields populated." ) -<<<<<<< HEAD document_version: Literal["3.0.0"] = Field( "3.0.0", description="Version of this model" -======= - document_version: Literal["2.1.0"] = Field( - "2.1.0", description="Version of this model" ->>>>>>> origin/main ) dataset: Optional[Dataset] = None variables: Optional[list[Variable]] = None From 4383fb1fa08533c621b5f1cc415cf6c041f0e39a Mon Sep 17 00:00:00 2001 From: Miles Mason Winther <42948872+mmwinther@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:15:42 +0100 Subject: [PATCH 43/49] Release python-v5.0.0 --- generated/python/datadoc_model/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/pyproject.toml b/generated/python/datadoc_model/pyproject.toml index 09f1833..12e6c56 100644 --- a/generated/python/datadoc_model/pyproject.toml +++ b/generated/python/datadoc_model/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ssb-datadoc-model" -version = "4.3.0" +version = "5.0.0" description = "Data Model for use in Statistics Norway's Metadata system" authors = ["Statistics Norway "] license = "MIT" From 74eea14db34f843f81d1e33d81874356ece4d0a7 Mon Sep 17 00:00:00 2001 From: Miles Mason Winther <42948872+mmwinther@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:17:50 +0100 Subject: [PATCH 44/49] Format pom.xml --- generated/java/datadoc-model/pom.xml | 112 ++++++++++++++------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/generated/java/datadoc-model/pom.xml b/generated/java/datadoc-model/pom.xml index 5366f2b..58ad41f 100644 --- a/generated/java/datadoc-model/pom.xml +++ b/generated/java/datadoc-model/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 no.ssb.dapla.metadata datadoc-model @@ -13,7 +15,8 @@ ${jdk.version} UTF-8 UTF-8 - artifactregistry://europe-north1-maven.pkg.dev/artifact-registry-5n/dapla-stat-maven/ + + artifactregistry://europe-north1-maven.pkg.dev/artifact-registry-5n/dapla-stat-maven/ statisticsnorway/ssb-datadoc-model @@ -35,66 +38,66 @@ - commons-lang - commons-lang - ${commons-lang.version} + commons-lang + commons-lang + ${commons-lang.version} - com.fasterxml.jackson.core - jackson-databind - ${jackson-databind.version} + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} - jakarta.validation - jakarta.validation-api - ${jakarta.validation-api.version} + jakarta.validation + jakarta.validation-api + ${jakarta.validation-api.version} - - - org.apache.maven.plugins - maven-release-plugin - ${maven-release-plugin.version} - - java-v@{project.version} - - - - org.jsonschema2pojo - jsonschema2pojo-maven-plugin - ${jsonschema2pojo-maven-plugin.version} - - ${basedir}../../../../src - ${basedir}/src/main/java - no.ssb.dapla.metadata - true - true - true - true - true - true - true - - - - - generate - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${jdk.version} - ${jdk.version} - - - + + + org.apache.maven.plugins + maven-release-plugin + ${maven-release-plugin.version} + + java-v@{project.version} + + + + org.jsonschema2pojo + jsonschema2pojo-maven-plugin + ${jsonschema2pojo-maven-plugin.version} + + ${basedir}../../../../src + ${basedir}/src/main/java + no.ssb.dapla.metadata + true + true + true + true + true + true + true + + + + + generate + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${jdk.version} + ${jdk.version} + + + @@ -104,7 +107,6 @@ ${artifactregistry-maven-wagon.version} - @@ -158,4 +160,4 @@ - + \ No newline at end of file From 4277a39bdac4b2cb37cd47d44e317e907556eb7c Mon Sep 17 00:00:00 2001 From: Miles Mason Winther <42948872+mmwinther@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:19:00 +0100 Subject: [PATCH 45/49] Give workflows names --- .github/workflows/generate-java.yml | 27 +++++++------- .github/workflows/generate-python.yml | 51 ++++++++++++++------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/.github/workflows/generate-java.yml b/.github/workflows/generate-java.yml index 26786a3..da48f7d 100644 --- a/.github/workflows/generate-java.yml +++ b/.github/workflows/generate-java.yml @@ -1,13 +1,14 @@ +name: Generate Java on: push: branches: - - "**" - - "!main" + - "**" + - "!main" paths: - - "src/**" - - "generated/java/datadoc-model/pom.xml" - - ".github/workflows/generate-java.yml" + - "src/**" + - "generated/java/datadoc-model/pom.xml" + - ".github/workflows/generate-java.yml" # Allow only one generate workflow to run at a time. This avoids race conditions when # pushing to the same branch. @@ -38,10 +39,10 @@ jobs: - name: Generate Java run: | - pushd generated/java/datadoc-model - rm -rf src/main/java - ./mvnw jsonschema2pojo:generate - popd + pushd generated/java/datadoc-model + rm -rf src/main/java + ./mvnw jsonschema2pojo:generate + popd - name: Check for modified files id: git-check @@ -50,11 +51,11 @@ jobs: - name: Commit if: steps.git-check.outputs.modified == 'true' run: | - git add -A - git commit -m '[GENERATE] Java classes from JSON Schema' + git add -A + git commit -m '[GENERATE] Java classes from JSON Schema' - name: Push if: steps.git-check.outputs.modified == 'true' run: | - git pull --rebase origin "${GITHUB_REF}" - git push origin "${GITHUB_REF}" + git pull --rebase origin "${GITHUB_REF}" + git push origin "${GITHUB_REF}" diff --git a/.github/workflows/generate-python.yml b/.github/workflows/generate-python.yml index e75b08d..a289613 100644 --- a/.github/workflows/generate-python.yml +++ b/.github/workflows/generate-python.yml @@ -1,12 +1,13 @@ +name: Generate Python on: push: branches: - - "**" - - "!main" + - "**" + - "!main" paths: - - "src/**/*.json" - - ".github/workflows/generate-python.yml" + - "src/**/*.json" + - ".github/workflows/generate-python.yml" # Allow only one generate workflow to run at a time. This avoids race conditions when # pushing to the same branch. @@ -40,29 +41,29 @@ jobs: - name: Install pipx run: | - python -m pip install --upgrade pipx - python -m pipx ensurepath + python -m pip install --upgrade pipx + python -m pipx ensurepath - name: Install datamodel-codegen run: | - python -m pipx install datamodel-code-generator==0.25.2 + python -m pipx install datamodel-code-generator==0.25.2 - name: Generate Python run: > - datamodel-codegen - --input-file-type jsonschema - --input src/metadata-container-json-schema.json - --output-model-type pydantic_v2.BaseModel - --base-class "datadoc_model.datadoc_base_model.DatadocBaseModel" - --use-default - --use-title-as-name - --use-one-literal-as-default - --force-optional - --use-subclass-enum - --use-standard-collections - --use-double-quotes - --target-python-version 3.10 - --output generated/python/datadoc_model/datadoc_model/model.py + datamodel-codegen + --input-file-type jsonschema + --input src/metadata-container-json-schema.json + --output-model-type pydantic_v2.BaseModel + --base-class "datadoc_model.datadoc_base_model.DatadocBaseModel" + --use-default + --use-title-as-name + --use-one-literal-as-default + --force-optional + --use-subclass-enum + --use-standard-collections + --use-double-quotes + --target-python-version 3.10 + --output generated/python/datadoc_model/datadoc_model/model.py - name: Check for modified files id: git-check @@ -71,11 +72,11 @@ jobs: - name: Commit if: steps.git-check.outputs.modified == 'true' run: | - git add -A - git commit -m '[GENERATE] Pydantic models from JSON Schema' + git add -A + git commit -m '[GENERATE] Pydantic models from JSON Schema' - name: Push if: steps.git-check.outputs.modified == 'true' run: | - git pull --rebase origin "${GITHUB_REF}" - git push origin "${GITHUB_REF}" + git pull --rebase origin "${GITHUB_REF}" + git push origin "${GITHUB_REF}" From 65c0176bd412b91160ffada9a9a825291539c68a Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:20:10 +0000 Subject: [PATCH 46/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 9af6d4e..1e8c45c 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-22T09:12:35+00:00 +# timestamp: 2024-02-22T09:20:10+00:00 from __future__ import annotations From 9327a8062bc7f14430687119237c571b94819afc Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:20:57 +0000 Subject: [PATCH 47/49] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java index 8201dfa..1fc860a 100644 --- a/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java +++ b/generated/java/datadoc-model/src/main/java/no/ssb/dapla/metadata/datadoc/Dataset.java @@ -333,11 +333,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); -<<<<<<< HEAD private final static long serialVersionUID = -7459109918184248449L; -======= - private final static long serialVersionUID = 8856456406912570855L; ->>>>>>> origin/main /** * No args constructor for use in serialization @@ -405,11 +401,7 @@ public Dataset() { * @param dataSource * Data source. Data source. Set either for the data set or instance variable. */ -<<<<<<< HEAD public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { -======= - public Dataset(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { ->>>>>>> origin/main super(); this.shortName = shortName; this.assessment = assessment; @@ -1307,13 +1299,8 @@ public DatasetBuilder() { super(); } -<<<<<<< HEAD public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); -======= - public DatasetBuilder(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { - super(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, registerUri, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil); ->>>>>>> origin/main } } @@ -1331,11 +1318,7 @@ public DatasetBuilderBase() { } @SuppressWarnings("unchecked") -<<<<<<< HEAD public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, List name, List description, List dataSource, List populationDescription, String version, List versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, List owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { -======= - public DatasetBuilderBase(String shortName, Dataset.Assessment assessment, Dataset.DataSetStatus datasetStatus, Dataset.DataSetState datasetState, LanguageStringType name, LanguageStringType description, LanguageStringType dataSource, LanguageStringType registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List keyword, LanguageStringType spatialCoverageDescription, UUID id, LanguageStringType owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { ->>>>>>> origin/main // Skip initialization when called from subclass if (this.getClass().equals(Dataset.DatasetBuilder.class)) { this.instance = ((T) new Dataset(shortName, assessment, datasetStatus, datasetState, name, description, dataSource, populationDescription, version, versionDescription, unitType, temporalityType, subjectField, keyword, spatialCoverageDescription, containsPersonalData, useRestriction, useRestrictionDate, customType, id, owner, filePath, metadataCreatedDate, metadataCreatedBy, metadataLastUpdatedDate, metadataLastUpdatedBy, containsDataFrom, containsDataUntil)); @@ -1642,7 +1625,6 @@ public static Dataset.TemporalityTypeType fromValue(String value) { } -<<<<<<< HEAD /** * Use restriction @@ -1691,6 +1673,4 @@ public static Dataset.UseRestriction fromValue(String value) { } -======= ->>>>>>> origin/main } From e2d42742c02304c058089b531294b112d50b2164 Mon Sep 17 00:00:00 2001 From: Miles Mason Winther <42948872+mmwinther@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:59:20 +0100 Subject: [PATCH 48/49] Remove no directory since it's not norwegian-specific --- src/datadoc/datadoc-json-schema.json | 30 +++++++++---------- src/datadoc/{no => }/languageStringType.json | 0 src/datadoc/{no => }/temporalityTypeType.json | 0 3 files changed, 15 insertions(+), 15 deletions(-) rename src/datadoc/{no => }/languageStringType.json (100%) rename src/datadoc/{no => }/temporalityTypeType.json (100%) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 781feaf..97cdfb0 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -57,22 +57,22 @@ "name": { "title": "Name", "description": "Name of data set", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "description": { "title": "Description", "description": "Free text description of the data set", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "data_source": { "title": "Data source", "description": "Data source. Set either for the data set or instance variable.", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "population_description": { "title": "Description of population", "description": "Description of the population covered in the data set. Includes unit type, spatial coverage and period of time.", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "version": { "title": "Version", @@ -82,7 +82,7 @@ "version_description": { "title": "Version description", "description": "Dataset version information in the form of descriptive text", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "unit_type": { "title": "Unit type", @@ -92,7 +92,7 @@ "temporality_type": { "title": "Temporality type", "description": "Temporality type. Either for the instance variable or the data set", - "$ref": "./no/temporalityTypeType.json#/temporalityTypeType" + "$ref": "./temporalityTypeType.json#/temporalityTypeType" }, "subject_field": { "title": "Subject field", @@ -110,7 +110,7 @@ "spatial_coverage_description": { "title": "Spatial coverage description", "description": "Description of the data set's spatial coverage", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "contains_personal_data": { "title": "Contains personal data", @@ -173,7 +173,7 @@ "owner": { "title": "Owner", "description": "Owner of the data set (responsible division in Statistics Norway). See also Classification of organisational units https://www.ssb.no/en/klass/klassifikasjoner/83", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "file_path": { "title": "File path", @@ -253,7 +253,7 @@ "name": { "title": "Name", "description": "Variable names can be inherited from VarDef, but can also be documented/changed here", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "data_type": { "title": "Data type", @@ -294,22 +294,22 @@ "data_source": { "title": "Data source", "description": "Data source. Set at data set level, but can be overwritten at variable instance level.", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "population_description": { "title": "Population description", "description": "The population the variable describes can be specified in more detail here. Set at dataset level, but can be overwritten at instance variable level.", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "comment": { "title": "Comment", "description": "Further clarification of the variables definition", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "temporality_type": { "title": "Temporality type", "description": "Temporality type. Set either for variable instance or dataset.", - "$ref": "./no/temporalityTypeType.json#/temporalityTypeType" + "$ref": "./temporalityTypeType.json#/temporalityTypeType" }, "measurement_unit": { "title": "Measurement unit", @@ -373,7 +373,7 @@ "name": { "title": "Name", "description": "Other value name (text)", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "valid_from": { "title": "Valid from", @@ -395,7 +395,7 @@ "invalid_value_description": { "title": "Invalid value(s) description", "description": "Invalid value(s) description used in addition (or as an alternative) to standard sentinel values.", - "$ref": "./no/languageStringType.json#/languageStringType" + "$ref": "./languageStringType.json#/languageStringType" }, "custom_type": { "title": "Custom type for variable metadata", diff --git a/src/datadoc/no/languageStringType.json b/src/datadoc/languageStringType.json similarity index 100% rename from src/datadoc/no/languageStringType.json rename to src/datadoc/languageStringType.json diff --git a/src/datadoc/no/temporalityTypeType.json b/src/datadoc/temporalityTypeType.json similarity index 100% rename from src/datadoc/no/temporalityTypeType.json rename to src/datadoc/temporalityTypeType.json From 3fa85ff522f6aa1a2b6908462255914e2b4399e0 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 10:00:48 +0000 Subject: [PATCH 49/49] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 1e8c45c..68420e1 100644 --- a/generated/python/datadoc_model/datadoc_model/model.py +++ b/generated/python/datadoc_model/datadoc_model/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: metadata-container-json-schema.json -# timestamp: 2024-02-22T09:20:10+00:00 +# timestamp: 2024-02-22T10:00:48+00:00 from __future__ import annotations