Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify date format for all contains_data_* fields #51

Merged
merged 9 commits into from
Apr 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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;
Expand Down Expand Up @@ -232,7 +231,7 @@ public class Variable implements Serializable
*/
@JsonProperty("contains_data_from")
@JsonPropertyDescription("The instance variable in the data set contains data from 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 variables only contain data for the most recent periods/years, e.g. if the entire data set contains data from 1970 to 2020, while some instance variables only contain data from 1998 onwards.")
private Date containsDataFrom;
private String containsDataFrom;
/**
* Contains data up until
* <p>
Expand All @@ -241,11 +240,11 @@ public class Variable implements Serializable
*/
@JsonProperty("contains_data_until")
@JsonPropertyDescription("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.")
private Date containsDataUntil;
private String containsDataUntil;
@JsonIgnore
@Valid
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
private final static long serialVersionUID = 2841624760609543476L;
private final static long serialVersionUID = 1640768487711195113L;

/**
* No args constructor for use in serialization
Expand Down Expand Up @@ -299,7 +298,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<Object> name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String dataSource, List<Object> populationDescription, List<Object> comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List<Object> invalidValueDescription, List<CustomType__1> customType, UUID id, Date containsDataFrom, Date containsDataUntil) {
public Variable(String shortName, String dataElementPath, List<Object> name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String dataSource, List<Object> populationDescription, List<Object> comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List<Object> invalidValueDescription, List<CustomType__1> customType, UUID id, String containsDataFrom, String containsDataUntil) {
super();
this.shortName = shortName;
this.dataElementPath = dataElementPath;
Expand Down Expand Up @@ -745,7 +744,7 @@ public void setId(UUID id) {
*
*/
@JsonProperty("contains_data_from")
public Date getContainsDataFrom() {
public String getContainsDataFrom() {
return containsDataFrom;
}

Expand All @@ -756,7 +755,7 @@ public Date getContainsDataFrom() {
*
*/
@JsonProperty("contains_data_from")
public void setContainsDataFrom(Date containsDataFrom) {
public void setContainsDataFrom(String containsDataFrom) {
this.containsDataFrom = containsDataFrom;
}

Expand All @@ -767,7 +766,7 @@ public void setContainsDataFrom(Date containsDataFrom) {
*
*/
@JsonProperty("contains_data_until")
public Date getContainsDataUntil() {
public String getContainsDataUntil() {
return containsDataUntil;
}

Expand All @@ -778,7 +777,7 @@ public Date getContainsDataUntil() {
*
*/
@JsonProperty("contains_data_until")
public void setContainsDataUntil(Date containsDataUntil) {
public void setContainsDataUntil(String containsDataUntil) {
this.containsDataUntil = containsDataUntil;
}

Expand Down Expand Up @@ -992,7 +991,7 @@ public VariableBuilder() {
super();
}

public VariableBuilder(String shortName, String dataElementPath, List<Object> name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String dataSource, List<Object> populationDescription, List<Object> comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List<Object> invalidValueDescription, List<CustomType__1> customType, UUID id, Date containsDataFrom, Date containsDataUntil) {
public VariableBuilder(String shortName, String dataElementPath, List<Object> name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String dataSource, List<Object> populationDescription, List<Object> comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List<Object> invalidValueDescription, List<CustomType__1> customType, UUID id, String containsDataFrom, String containsDataUntil) {
super(shortName, dataElementPath, name, dataType, variableRole, definitionUri, directPersonIdentifying, dataSource, populationDescription, comment, temporalityType, measurementUnit, multiplicationFactor, format, classificationUri, specialValue, invalidValueDescription, customType, id, containsDataFrom, containsDataUntil);
}

Expand All @@ -1011,7 +1010,7 @@ public VariableBuilderBase() {
}

@SuppressWarnings("unchecked")
public VariableBuilderBase(String shortName, String dataElementPath, List<Object> name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String dataSource, List<Object> populationDescription, List<Object> comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List<Object> invalidValueDescription, List<CustomType__1> customType, UUID id, Date containsDataFrom, Date containsDataUntil) {
public VariableBuilderBase(String shortName, String dataElementPath, List<Object> name, Variable.DataType dataType, Variable.VariableRole variableRole, URI definitionUri, Boolean directPersonIdentifying, String dataSource, List<Object> populationDescription, List<Object> comment, no.ssb.dapla.metadata.datadoc.Dataset.TemporalityTypeType temporalityType, String measurementUnit, Integer multiplicationFactor, String format, URI classificationUri, SpecialValues specialValue, List<Object> invalidValueDescription, List<CustomType__1> customType, UUID id, String containsDataFrom, String 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));
Expand Down Expand Up @@ -1120,12 +1119,12 @@ public Variable.VariableBuilderBase withId(UUID id) {
return this;
}

public Variable.VariableBuilderBase withContainsDataFrom(Date containsDataFrom) {
public Variable.VariableBuilderBase withContainsDataFrom(String containsDataFrom) {
((Variable) this.instance).containsDataFrom = containsDataFrom;
return this;
}

public Variable.VariableBuilderBase withContainsDataUntil(Date containsDataUntil) {
public Variable.VariableBuilderBase withContainsDataUntil(String containsDataUntil) {
((Variable) this.instance).containsDataUntil = containsDataUntil;
return this;
}
Expand Down
15 changes: 8 additions & 7 deletions generated/python/datadoc_model/datadoc_model/model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# generated by datamodel-codegen:
# filename: metadata-container-json-schema.json
# timestamp: 2024-04-23T13:18:29+00:00
# timestamp: 2024-04-25T13:29:06+00:00

from __future__ import annotations

from datetime import date
from enum import Enum
from typing import Any, Literal, Optional, Union
from uuid import UUID
Expand Down Expand Up @@ -300,12 +301,12 @@ class Dataset(DatadocBaseModel):
description="Last change made by identifiable person. ",
title="Metadata last updated by",
)
contains_data_from: Optional[str] = Field(
contains_data_from: Optional[date] = Field(
None,
description="The data set contains data from date/time",
title="Contains data from",
)
contains_data_until: Optional[str] = Field(
contains_data_until: Optional[date] = Field(
None,
description="The data set contains data up until date/time",
title="Contains data up until",
Expand Down Expand Up @@ -422,12 +423,12 @@ class Variable(DatadocBaseModel):
description="Unique SSB identifier for the instance variable in the data set",
title="Identifier",
)
contains_data_from: Optional[AwareDatetime] = Field(
contains_data_from: Optional[date] = Field(
None,
description="The instance variable in the data set contains data from 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 variables only contain data for the most recent periods/years, e.g. if the entire data set contains data from 1970 to 2020, while some instance variables only contain data from 1998 onwards.",
title="Contains data from",
)
contains_data_until: Optional[AwareDatetime] = Field(
contains_data_until: Optional[date] = Field(
None,
description="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.",
title="Contains data up until",
Expand All @@ -438,8 +439,8 @@ class DatadocMetadata(DatadocBaseModel):
percentage_complete: Optional[int] = Field(
None, description="Percentage of obligatory metadata fields populated."
)
document_version: Literal["3.2.0"] = Field(
"3.2.0", description="Version of this model"
document_version: Literal["3.3.0"] = Field(
"3.3.0", description="Version of this model"
)
dataset: Optional[Dataset] = None
variables: Optional[list[Variable]] = None
Expand Down
2 changes: 1 addition & 1 deletion generated/python/datadoc_model/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ssb-datadoc-model"
version = "5.2.0"
version = "5.3.0"
description = "Data Model for use in Statistics Norway's Metadata system"
authors = ["Statistics Norway <[email protected]>"]
license = "MIT"
Expand Down
12 changes: 7 additions & 5 deletions src/datadoc/datadoc-json-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"document_version": {
"description": "Version of this model",
"const": "3.2.0"
"const": "3.3.0"
},
"dataset": {
"type": "object",
Expand Down Expand Up @@ -205,12 +205,14 @@
"contains_data_from": {
"title": "Contains data from",
"description": "The data set contains data from date/time",
"type": "string"
"type": "string",
"format": "date"
},
"contains_data_until": {
"title": "Contains data up until",
"description": "The data set contains data up until date/time",
"type": "string"
"type": "string",
"format": "date"
}
},
"required": [
Expand Down Expand Up @@ -438,13 +440,13 @@
"title": "Contains data from",
"description": "The instance variable in the data set contains data from 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 variables only contain data for the most recent periods/years, e.g. if the entire data set contains data from 1970 to 2020, while some instance variables only contain data from 1998 onwards.",
"type": "string",
"format": "date-time"
"format": "date"
},
"contains_data_until": {
"title": "Contains data up until",
"description": "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.",
"type": "string",
"format": "date-time"
"format": "date"
}
},
"required": [
Expand Down
Loading