Skip to content

Commit

Permalink
Merge pull request #99 from I-GUIDE/98-mediaobject-move-attributes-to…
Browse files Browse the repository at this point in the history
…-dataset

Moving some attributes of MediaObject to DatasetMetadata
  • Loading branch information
pkdash authored Apr 23, 2024
2 parents 2952217 + 07525e5 commit d383bb5
Show file tree
Hide file tree
Showing 9 changed files with 931 additions and 1,709 deletions.
5 changes: 2 additions & 3 deletions api/models/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from beanie import Document

from api.models.user import Submission

from .schema import CoreMetadata
from .schema import CoreMetadata, DatasetMetadata


class CoreMetadataDOC(Document, CoreMetadata):
Expand Down Expand Up @@ -32,5 +31,5 @@ def as_submission(self) -> Submission:
)


class DatasetMetadataDOC(CoreMetadataDOC):
class DatasetMetadataDOC(CoreMetadataDOC, DatasetMetadata):
repository_identifier: str = None
6 changes: 3 additions & 3 deletions api/models/management/generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import typer

from api.models.schema import DatasetSchema
from api.models.schema import DatasetMetadata


def main(output_name: str = "api/models/schemas/schema.json"):
schema = DatasetSchema.schema()
json_schema = DatasetSchema.schema_json()#indent=2)
schema = DatasetMetadata.schema()
json_schema = DatasetMetadata.schema_json()#indent=2)
# Have to run it a few times for the definitions to get updated before inserted into another model
while "#/definitions/" in json_schema:
for definition in schema["definitions"]:
Expand Down
43 changes: 18 additions & 25 deletions api/models/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class PublisherOrganization(Organization):
)


class MediaObjectSourceOrganization(Organization):
name: str = Field(description="Name of the organization that created the media object.")
class SourceOrganization(Organization):
name: str = Field(description="Name of the organization that created the data.")


class DefinedTerm(SchemaBaseModel):
Expand Down Expand Up @@ -337,6 +337,9 @@ class PropertyValueBase(SchemaBaseModel):
maxValue: Optional[float] = Field(
title="Maximum value", description="The maximum allowed value for the property."
)
measurementTechnique: Optional[str] = Field(
title="Measurement technique", description="A technique or technology used in a measurement."
)

class Config:
title = "PropertyValue"
Expand Down Expand Up @@ -397,26 +400,6 @@ class MediaObject(SchemaBaseModel):
"unit of measurement."
)
name: str = Field(description="The name of the media object (file).")
additionalProperty: Optional[List[PropertyValue]] = Field(
title="Additional properties",
default=[],
description="Additional properties of the media object."
)
variableMeasured: Optional[List[Union[str, PropertyValue]]] = Field(
title="Variables measured", description="Measured variables."
)
spatialCoverage: Optional[Place] = Field(
title="Spatial coverage",
description="The spatial coverage of the media object."
)
temporalCoverage: Optional[TemporalCoverage] = Field(
title="Temporal coverage",
description="The temporal coverage of the media object."
)
sourceOrganization: Optional[MediaObjectSourceOrganization] = Field(
title="Source organization",
description="The organization that provided the media object."
)
sha256: Optional[str] = Field(title="SHA-256", description="The SHA-256 hash of the media object.")
isPartOf: Optional[List[MediaObjectPartOf]] = Field(
title="Is part of",
Expand Down Expand Up @@ -562,6 +545,16 @@ class CoreMetadata(SchemaBaseModel):
citation: Optional[List[str]] = Field(title="Citation", description="A bibliographic citation for the resource.")


class DatasetSchema(CoreMetadata):
# used only for generating the JSON-LD schema for a dataset.
pass
class DatasetMetadata(CoreMetadata):
variableMeasured: Optional[List[Union[str, PropertyValue]]] = Field(
title="Variables measured", description="Measured variables."
)
additionalProperty: Optional[List[PropertyValue]] = Field(
title="Additional properties",
default=[],
description="Additional properties of the dataset."
)
sourceOrganization: Optional[SourceOrganization] = Field(
title="Source organization",
description="The organization that provided the data for this dataset."
)
Loading

0 comments on commit d383bb5

Please sign in to comment.