From 46b6815f5df55908c017eea666bb2a6a409e4bbc Mon Sep 17 00:00:00 2001 From: Joergen Date: Tue, 23 Apr 2024 14:47:19 +0200 Subject: [PATCH 1/6] Changed type for datasource field --- src/datadoc/datadoc-json-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 6ff23d1..216abf5 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -67,7 +67,7 @@ "data_source": { "title": "Data source", "description": "Data source. Set either for the data set or instance variable.", - "$ref": "./languageStringType.json#/languageStringType" + "$ref": "string" }, "population_description": { "title": "Description of population", @@ -294,7 +294,7 @@ "data_source": { "title": "Data source", "description": "Data source. Set at data set level, but can be overwritten at variable instance level.", - "$ref": "./languageStringType.json#/languageStringType" + "$ref": "string" }, "population_description": { "title": "Population description", From 6c2daf24df1b93b175fea157211f42ed35a49aa5 Mon Sep 17 00:00:00 2001 From: Joergen Date: Tue, 23 Apr 2024 14:48:48 +0200 Subject: [PATCH 2/6] Bump version 5.1.0 -> 5.2.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 f9b6a01..a1db1fa 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 = "5.1.0" +version = "5.2.0" description = "Data Model for use in Statistics Norway's Metadata system" authors = ["Statistics Norway "] license = "MIT" From 64b0f974a1200f82e63d9b181fd11ae6a703c7ad Mon Sep 17 00:00:00 2001 From: Joergen Date: Tue, 23 Apr 2024 15:06:31 +0200 Subject: [PATCH 3/6] Changed version of datadoc-json-schema --- 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 216abf5..2eaf299 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": "3.1.0" + "const": "3.2.0" }, "dataset": { "type": "object", From e9709b56a0ae2453d477fe4c85e3ceca48ffa0c2 Mon Sep 17 00:00:00 2001 From: Joergen Date: Tue, 23 Apr 2024 15:17:10 +0200 Subject: [PATCH 4/6] Fixed error in json stucture causing pyhton generation to fail --- src/datadoc/datadoc-json-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datadoc/datadoc-json-schema.json b/src/datadoc/datadoc-json-schema.json index 2eaf299..7063ebe 100644 --- a/src/datadoc/datadoc-json-schema.json +++ b/src/datadoc/datadoc-json-schema.json @@ -67,7 +67,7 @@ "data_source": { "title": "Data source", "description": "Data source. Set either for the data set or instance variable.", - "$ref": "string" + "type": "string" }, "population_description": { "title": "Description of population", @@ -294,7 +294,7 @@ "data_source": { "title": "Data source", "description": "Data source. Set at data set level, but can be overwritten at variable instance level.", - "$ref": "string" + "type": "string" }, "population_description": { "title": "Population description", From 99d34fb18bd164099df69d8e5932fa0ee78c4225 Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:17:53 +0000 Subject: [PATCH 5/6] [GENERATE] Java classes from JSON Schema --- .../ssb/dapla/metadata/datadoc/Dataset.java | 30 +++++++++++-------- .../ssb/dapla/metadata/datadoc/Variable.java | 30 +++++++++++-------- 2 files changed, 36 insertions(+), 24 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 a39a76c..dadbdb6 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 @@ -120,12 +120,14 @@ public class Dataset implements Serializable @NotNull private List description = new ArrayList(); /** - * Reusableb langugage string type + * Data source + *

+ * Data source. Set either for the data set or instance variable. * */ @JsonProperty("data_source") - @Valid - private List dataSource = new ArrayList(); + @JsonPropertyDescription("Data source. Set either for the data set or instance variable.") + private String dataSource; /** * Reusableb langugage string type * (Required) @@ -335,7 +337,7 @@ public class Dataset implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 3214435550238803228L; + private final static long serialVersionUID = -226168508644193475L; /** * No args constructor for use in serialization @@ -403,7 +405,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, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, String 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, String 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, String owner, String filePath, Date metadataCreatedDate, String metadataCreatedBy, Date metadataLastUpdatedDate, String metadataLastUpdatedBy, String containsDataFrom, String containsDataUntil) { super(); this.shortName = shortName; this.assessment = assessment; @@ -576,20 +578,24 @@ public void setDescription(List description) { } /** - * Reusableb langugage string type + * Data source + *

+ * Data source. Set either for the data set or instance variable. * */ @JsonProperty("data_source") - public List getDataSource() { + public String getDataSource() { return dataSource; } /** - * Reusableb langugage string type + * Data source + *

+ * Data source. Set either for the data set or instance variable. * */ @JsonProperty("data_source") - public void setDataSource(List dataSource) { + public void setDataSource(String dataSource) { this.dataSource = dataSource; } @@ -1305,7 +1311,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, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, String 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, String 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, String 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); } @@ -1324,7 +1330,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, String unitType, Dataset.TemporalityTypeType temporalityType, String subjectField, List keyword, List spatialCoverageDescription, Boolean containsPersonalData, Dataset.UseRestriction useRestriction, Date useRestrictionDate, List customType, UUID id, String 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, String 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, String 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)); @@ -1368,7 +1374,7 @@ public Dataset.DatasetBuilderBase withDescription(List description) { return this; } - public Dataset.DatasetBuilderBase withDataSource(List dataSource) { + public Dataset.DatasetBuilderBase withDataSource(String dataSource) { ((Dataset) this.instance).dataSource = dataSource; 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 9b48f30..cb54bdd 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 @@ -123,12 +123,14 @@ public class Variable implements Serializable @NotNull private Boolean directPersonIdentifying; /** - * Reusableb langugage string type + * Data source + *

+ * Data source. Set at data set level, but can be overwritten at variable instance level. * */ @JsonProperty("data_source") - @Valid - private List dataSource = new ArrayList(); + @JsonPropertyDescription("Data source. Set at data set level, but can be overwritten at variable instance level.") + private String dataSource; /** * Reusableb langugage string type * @@ -243,7 +245,7 @@ public class Variable implements Serializable @JsonIgnore @Valid private Map additionalProperties = new LinkedHashMap(); - private final static long serialVersionUID = 1019444275429139130L; + private final static long serialVersionUID = 2841624760609543476L; /** * No args constructor for use in serialization @@ -297,7 +299,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, 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) { + public Variable(String shortName, String dataElementPath, List name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String 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; @@ -487,20 +489,24 @@ public void setDirectPersonIdentifying(Boolean directPersonIdentifying) { } /** - * Reusableb langugage string type + * Data source + *

+ * Data source. Set at data set level, but can be overwritten at variable instance level. * */ @JsonProperty("data_source") - public List getDataSource() { + public String getDataSource() { return dataSource; } /** - * Reusableb langugage string type + * Data source + *

+ * Data source. Set at data set level, but can be overwritten at variable instance level. * */ @JsonProperty("data_source") - public void setDataSource(List dataSource) { + public void setDataSource(String dataSource) { this.dataSource = dataSource; } @@ -986,7 +992,7 @@ public VariableBuilder() { super(); } - 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) { + public VariableBuilder(String shortName, String dataElementPath, List name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String 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 +1011,7 @@ public VariableBuilderBase() { } @SuppressWarnings("unchecked") - 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) { + public VariableBuilderBase(String shortName, String dataElementPath, List name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String 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)); @@ -1054,7 +1060,7 @@ public Variable.VariableBuilderBase withDirectPersonIdentifying(Boolean directPe return this; } - public Variable.VariableBuilderBase withDataSource(List dataSource) { + public Variable.VariableBuilderBase withDataSource(String dataSource) { ((Variable) this.instance).dataSource = dataSource; return this; } From 195cfa2876d53dd04077e26eb5b78c47b5823a7d Mon Sep 17 00:00:00 2001 From: "dapla-bot[bot]" <143391972+dapla-bot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:18:29 +0000 Subject: [PATCH 6/6] [GENERATE] Pydantic models from JSON Schema --- generated/python/datadoc_model/datadoc_model/model.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generated/python/datadoc_model/datadoc_model/model.py b/generated/python/datadoc_model/datadoc_model/model.py index 1a1c390..4ffaa30 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-03-13T15:13:32+00:00 +# timestamp: 2024-04-23T13:18:29+00:00 from __future__ import annotations @@ -208,7 +208,7 @@ class Dataset(DatadocBaseModel): description: Optional[LanguageStringType] = Field( None, description="Free text description of the data set", title="Description" ) - data_source: Optional[LanguageStringType] = Field( + data_source: Optional[str] = Field( None, description="Data source. Set either for the data set or instance variable.", title="Data source", @@ -368,7 +368,7 @@ class Variable(DatadocBaseModel): description="Direct Person identifying Information (DPI). Some of the values \u200b\u200bin 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 \u200b\u200bcan be organization number, others social security numbers (sole proprietorships).", title="Direct Person identifying Information (DPI)", ) - data_source: Optional[LanguageStringType] = Field( + data_source: Optional[str] = Field( None, description="Data source. Set at data set level, but can be overwritten at variable instance level.", title="Data source", @@ -438,8 +438,8 @@ class DatadocMetadata(DatadocBaseModel): percentage_complete: Optional[int] = Field( None, description="Percentage of obligatory metadata fields populated." ) - document_version: Literal["3.1.0"] = Field( - "3.1.0", description="Version of this model" + document_version: Literal["3.2.0"] = Field( + "3.2.0", description="Version of this model" ) dataset: Optional[Dataset] = None variables: Optional[list[Variable]] = None