Skip to content

Commit

Permalink
Remove unit_type enum (#42)
Browse files Browse the repository at this point in the history
* Remove unit_type enum

* Release v4.2.0

* Bump version of datadoc model

* [GENERATE] Pydantic models from JSON Schema

* [GENERATE] Java classes from JSON Schema

---------

Co-authored-by: dapla-bot[bot] <143391972+dapla-bot[bot]@users.noreply.github.com>
  • Loading branch information
mmwinther and dapla-bot[bot] authored Feb 21, 2024
1 parent 6cbabf2 commit 15f70cd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,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
*
Expand Down Expand Up @@ -296,7 +296,7 @@ public class Dataset implements Serializable
@JsonIgnore
@Valid
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
private final static long serialVersionUID = 1788379209809172251L;
private final static long serialVersionUID = 8856456406912570855L;

/**
* No args constructor for use in serialization
Expand Down Expand Up @@ -358,7 +358,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<String> 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, String unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List<String> keyword, LanguageStringType spatialCoverageDescription, 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;
Expand Down Expand Up @@ -633,7 +633,7 @@ public void setVersionDescription(LanguageStringType versionDescription) {
*
*/
@JsonProperty("unit_type")
public Dataset.UnitType getUnitType() {
public String getUnitType() {
return unitType;
}

Expand All @@ -645,7 +645,7 @@ public Dataset.UnitType getUnitType() {
*
*/
@JsonProperty("unit_type")
public void setUnitType(Dataset.UnitType unitType) {
public void setUnitType(String unitType) {
this.unitType = unitType;
}

Expand Down Expand Up @@ -1162,7 +1162,7 @@ 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<String> keyword, LanguageStringType spatialCoverageDescription, 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 registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, String unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List<String> 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);
}

Expand All @@ -1181,7 +1181,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 registerUri, LanguageStringType populationDescription, String version, LanguageStringType versionDescription, Dataset.UnitType unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List<String> 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, String unitType, Dataset.TemporalityTypeType temporalityType, LanguageStringType subjectField, List<String> keyword, LanguageStringType spatialCoverageDescription, 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));
Expand Down Expand Up @@ -1250,7 +1250,7 @@ public Dataset.DatasetBuilderBase withVersionDescription(LanguageStringType vers
return this;
}

public Dataset.DatasetBuilderBase withUnitType(Dataset.UnitType unitType) {
public Dataset.DatasetBuilderBase withUnitType(String unitType) {
((Dataset) this.instance).unitType = unitType;
return this;
}
Expand Down Expand Up @@ -1473,70 +1473,4 @@ public static Dataset.TemporalityTypeType fromValue(String value) {

}


/**
* Unit type
* <p>
* 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<String, Dataset.UnitType> CONSTANTS = new HashMap<String, Dataset.UnitType>();

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;
}
}

}

}
32 changes: 4 additions & 28 deletions generated/python/datadoc_model/datadoc_model/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: metadata-container-json-schema.json
# timestamp: 2024-02-08T15:06:13+00:00
# timestamp: 2024-02-21T08:51:44+00:00

from __future__ import annotations

Expand Down Expand Up @@ -56,30 +56,6 @@ class LanguageStringType(DatadocBaseModel):
nb: Optional[str] = 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"
Expand Down Expand Up @@ -208,7 +184,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",
Expand Down Expand Up @@ -369,8 +345,8 @@ class DatadocMetadata(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["2.1.0"] = Field(
"2.1.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 = "4.1.3"
version = "4.2.0"
description = "Data Model for use in Statistics Norway's Metadata system"
authors = ["Statistics Norway <[email protected]>"]
license = "MIT"
Expand Down
5 changes: 2 additions & 3 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": "2.0.0"
"const": "2.1.0"
},
"dataset": {
"type": "object",
Expand Down Expand Up @@ -92,8 +92,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",
Expand Down
32 changes: 0 additions & 32 deletions src/datadoc/no/unitType.json

This file was deleted.

0 comments on commit 15f70cd

Please sign in to comment.