Skip to content

Commit

Permalink
metadatasetresponses now include replaced/replaces information (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
cschu committed Jul 14, 2021
1 parent c6f22a0 commit 9e88373
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions datameta/api/metadatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ class ReplacementMsetResponse(DataHolderBase):

@classmethod
def from_metadataset(cls, metadataset: MetaDataSet, replaces: List[Tuple[Any, MetaDataSet]], metadata_with_access: Dict[str, MetaDatum]):

return cls(
id = get_identifier(metadataset),
record = get_record_from_metadataset(metadataset, metadata_with_access),
file_ids = get_mset_associated_files(metadataset, metadata_with_access),
user_id = get_identifier(metadataset.user),
replaces = [get_identifier(mset) for _, mset in replaces],
submission_id = get_identifier(metadataset.submission) if metadataset.submission else None,
service_executions = collect_service_executions(metadata_with_access, metadataset)
service_executions = collect_service_executions(metadata_with_access, metadataset),
)


Expand All @@ -73,6 +74,8 @@ class MetaDataSetResponse(DataHolderBase):
user_id : str
submission_id : Optional[str] = None
service_executions : Optional[Dict[str, Optional[MetaDataSetServiceExecution]]] = None
replaces : Optional[List[str]] = None
replaced_by : Optional[str] = None

@staticmethod
def from_metadataset(metadataset: MetaDataSet, metadata_with_access: Dict[str, MetaDatum]):
Expand All @@ -87,7 +90,9 @@ def from_metadataset(metadataset: MetaDataSet, metadata_with_access: Dict[str, M
file_ids = get_mset_associated_files(metadataset, metadata_with_access),
user_id = get_identifier(metadataset.user),
submission_id = get_identifier(metadataset.submission) if metadataset.submission else None,
service_executions = collect_service_executions(metadata_with_access, metadataset)
service_executions = collect_service_executions(metadata_with_access, metadataset),
replaces = [get_identifier(mset) for event in metadataset.replaces_via_event for mset in event.replaced_metadatasets] if metadataset.replaces_via_event else None,
replaced_by = get_identifier(metadataset.replaced_via_event.new_metadataset) if metadataset.replaced_via_event else None
)


Expand Down
8 changes: 8 additions & 0 deletions datameta/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,14 @@ components:
$ref: "#/components/schemas/NullableIdentifier"
userId:
$ref: "#/components/schemas/Identifier"
replaces:
type: array
items:
type: object
nullable: true
replacedBy:
type: object
nullable: true
required:
- record
additionalProperties: false
Expand Down

0 comments on commit 9e88373

Please sign in to comment.