Skip to content

Commit

Permalink
rename Timestamp to TemporalEntity; rename child classes; use tempora…
Browse files Browse the repository at this point in the history
…l entities in mex-model
  • Loading branch information
carolinscholl committed Feb 22, 2024
1 parent f76a764 commit 1a35f64
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 89 deletions.
12 changes: 5 additions & 7 deletions mex/common/models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
PersonID,
Text,
Theme,
Timestamp,
YearMonth,
YearMonthDay,
YearMonthDayTime,
)


Expand All @@ -37,9 +39,7 @@ class BaseActivity(BaseModel):
list[OrganizationalUnitID | PersonID | ContactPointID,], Field(min_length=1)
]
documentation: list[Link] = []
end: list[
Annotated[Timestamp, Field(examples=["2024-01-17", "2024", "2024-01"])]
] = []
end: list[YearMonth | YearMonthDay | YearMonthDayTime] = []
externalAssociate: list[OrganizationID | PersonID] = []
funderOrCommissioner: list[OrganizationID] = []
fundingProgram: list[str] = []
Expand All @@ -49,9 +49,7 @@ class BaseActivity(BaseModel):
publication: list[Link] = []
responsibleUnit: Annotated[list[OrganizationalUnitID], Field(min_length=1)]
shortName: list[Text] = []
start: list[
Annotated[Timestamp, Field(examples=["2023-01-16", "2023", "2023-02"])]
] = []
start: list[YearMonth | YearMonthDay | YearMonthDayTime] = []
succeeds: list[ActivityID] = []
theme: list[
Annotated[Theme, Field(examples=["https://mex.rki.de/item/theme-1"])]
Expand Down
8 changes: 5 additions & 3 deletions mex/common/models/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
MIMEType,
OrganizationID,
PersonID,
Timestamp,
YearMonth,
YearMonthDay,
YearMonthDayTime,
)


Expand All @@ -33,7 +35,7 @@ class BaseDistribution(BaseModel):
dataCurator: list[PersonID] = []
dataManager: list[PersonID] = []
downloadURL: Link | None = None
issued: Timestamp
issued: YearMonth | YearMonthDay | YearMonthDayTime
license: (
Annotated[License, Field(examples=["https://mex.rki.de/item/license-1"])] | None
) = None
Expand All @@ -46,7 +48,7 @@ class BaseDistribution(BaseModel):
]
| None
) = None
modified: Timestamp | None = None
modified: YearMonth | YearMonthDay | YearMonthDayTime | None = None
otherContributor: list[PersonID] = []
projectLeader: list[PersonID] = []
projectManager: list[PersonID] = []
Expand Down
16 changes: 8 additions & 8 deletions mex/common/models/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
ResourceTypeGeneral,
Text,
Theme,
TimestampDate,
TimestampDatetime,
TimestampYearMonth,
YearMonth,
YearMonthDay,
YearMonthDayTime,
)


Expand Down Expand Up @@ -59,7 +59,7 @@ class BaseResource(BaseModel):
]
contributingUnit: list[OrganizationalUnitID] = []
contributor: list[PersonID] = []
created: Union[TimestampYearMonth, TimestampDate, TimestampDatetime, None] = None
created: Union[YearMonth, YearMonthDay, YearMonthDayTime, None] = None
creator: list[PersonID] = []
description: list[Text] = []
distribution: list[DistributionID] = []
Expand Down Expand Up @@ -88,7 +88,7 @@ class BaseResource(BaseModel):
] = []
method: list[Text] = []
methodDescription: list[Text] = []
modified: Union[TimestampYearMonth, TimestampDate, TimestampDatetime, None] = None
modified: Union[YearMonth, YearMonthDay, YearMonthDayTime, None] = None
publication: list[Link] = []
publisher: list[OrganizationID] = []
qualityInformation: list[Text] = []
Expand All @@ -113,9 +113,9 @@ class BaseResource(BaseModel):
]
] = []
temporal: Union[
TimestampYearMonth,
TimestampDate,
TimestampDatetime,
YearMonth,
YearMonthDay,
YearMonthDayTime,
Annotated[
str,
Field(
Expand Down
4 changes: 2 additions & 2 deletions mex/common/public_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
Identifier,
Link,
LinkLanguage,
TemporalEntity,
Text,
TextLanguage,
Timestamp,
)

PublicApiFieldValueTypes = UUID | Enum | Timestamp | str | Link | Text
PublicApiFieldValueTypes = UUID | Enum | TemporalEntity | str | Link | Text
PublicApiFieldValueTypesOrList = (
PublicApiFieldValueTypes | list[PublicApiFieldValueTypes]
)
Expand Down
4 changes: 2 additions & 2 deletions mex/common/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic import AnyUrl, SecretStr
from pydantic import BaseModel as PydanticModel

from mex.common.types import PathWrapper, Timestamp
from mex.common.types import PathWrapper, TemporalEntity


class MExEncoder(json.JSONEncoder):
Expand All @@ -27,7 +27,7 @@ def default(self, obj: Any) -> Any:
return obj.value
if isinstance(obj, UUID):
return str(obj)
if isinstance(obj, Timestamp):
if isinstance(obj, TemporalEntity):
return str(obj)
if isinstance(obj, PurePath):
return obj.as_posix()
Expand Down
20 changes: 10 additions & 10 deletions mex/common/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
from mex.common.types.link import Link, LinkLanguage
from mex.common.types.path import AssetsPath, PathWrapper, WorkPath
from mex.common.types.sink import Sink
from mex.common.types.text import Text, TextLanguage
from mex.common.types.timestamp import (
from mex.common.types.temporal_entity import (
CET,
TIMESTAMP_FORMATS_BY_PRECISION,
TIMESTAMP_REGEX,
UTC,
Timestamp,
TimestampDate,
TimestampDatetime,
TemporalEntity,
TimestampPrecision,
TimestampYearMonth,
YearMonth,
YearMonthDay,
YearMonthDayTime,
)
from mex.common.types.text import Text, TextLanguage
from mex.common.types.vocabulary import (
AccessRestriction,
ActivityType,
Expand Down Expand Up @@ -85,10 +85,10 @@
"Theme",
"TIMESTAMP_FORMATS_BY_PRECISION",
"TIMESTAMP_REGEX",
"Timestamp",
"TimestampDate",
"TimestampDatetime",
"TimestampYearMonth",
"TemporalEntity",
"YearMonth",
"YearMonthDay",
"YearMonthDayTime",
"TimestampPrecision",
"UTC",
"VariableGroupID",
Expand Down
Loading

0 comments on commit 1a35f64

Please sign in to comment.