Skip to content

Commit

Permalink
Improve dataset metadata documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBlissett committed Jul 25, 2023
1 parent 49c34ef commit 08c72e5
Showing 1 changed file with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ public DatasetResource(
})
@interface DatasetSearchParameters {}

@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Parameter(
name = "metadataKey",
description = "Key for the *metadata document* (not a dataset UUID).",
in = ParameterIn.PATH)
@interface MetadataDocumentKeyParameter {}

@Operation(
operationId = "searchDatasets",
summary = "Search across all datasets.",
Expand Down Expand Up @@ -533,7 +541,7 @@ public InputStream getMetadataDocument(UUID datasetKey) {
operationId = "getDocuments",
summary = "Retrieve GBIF metadata document of the dataset",
description =
"Gets a GBIF generated EML document overlaying GBIF information with any existing metadata document data.",
"Gets a GBIF-generated EML document overlaying GBIF information with any existing metadata document data.",
extensions =
@Extension(
name = "Order",
Expand Down Expand Up @@ -1139,7 +1147,9 @@ public List<Grid> listGrids(@PathVariable("key") UUID datasetKey) {
name = "Order",
properties = @ExtensionProperty(name = "Order", value = "0302")))
@Docs.DefaultEntityKeyParameter
@ApiResponse(responseCode = "200", description = "List of source metadata documents")
@ApiResponse(
responseCode = "200",
description = "List of source metadata documents including their metadata document keys")
@Docs.DefaultUnsuccessfulReadResponses
@GetMapping("{key}/metadata")
@Override
Expand All @@ -1155,36 +1165,36 @@ public List<Metadata> listMetadata(
@Extension(
name = "Order",
properties = @ExtensionProperty(name = "Order", value = "0303")))
@MetadataDocumentKeyParameter
@ApiResponse(responseCode = "200", description = "Metadata about a metadata document")
@Docs.DefaultUnsuccessfulReadResponses
@GetMapping("metadata/{key}")
@GetMapping("metadata/{metadataKey}")
@Override
@NullToNotFound("/dataset/metadata/{key}")
public Metadata getMetadata(@PathVariable int key) {
return metadataMapper.get(key);
@NullToNotFound("/dataset/metadata/{metadataKey}")
public Metadata getMetadata(@PathVariable int metadataKey) {
return metadataMapper.get(metadataKey);
}

@Override
@NullToNotFound
public InputStream getMetadataDocument(int key) {
return new ByteArrayInputStream(getMetadataDocumentAsBytes(key));
public InputStream getMetadataDocument(int metadataKey) {
return new ByteArrayInputStream(getMetadataDocumentAsBytes(metadataKey));
}

// TODO: 05/04/2020 change API to return byte[]?
@Operation(
operationId = "getMetadataDocument",
summary = "Retrieve a source metadata document of the dataset",
extensions =
@Extension(
name = "Order",
properties = @ExtensionProperty(name = "Order", value = "0304")))
@Docs.DefaultEntityKeyParameter
@MetadataDocumentKeyParameter
@ApiResponse(responseCode = "200", description = "Source metadata document in XML format")
@Docs.DefaultUnsuccessfulReadResponses
@GetMapping(value = "metadata/{key}/document", produces = MediaType.APPLICATION_XML_VALUE)
@NullToNotFound("/dataset/metadata/{key}/document")
public byte[] getMetadataDocumentAsBytes(@PathVariable int key) {
return registryDatasetService.getMetadataDocument(key);
@GetMapping(value = "metadata/{metadataKey}/document", produces = MediaType.APPLICATION_XML_VALUE)
@NullToNotFound("/dataset/metadata/{metadataKey}/document")
public byte[] getMetadataDocumentAsBytes(@PathVariable int metadataKey) {
return registryDatasetService.getMetadataDocument(metadataKey);
}

@Operation(
Expand All @@ -1194,12 +1204,13 @@ public byte[] getMetadataDocumentAsBytes(@PathVariable int key) {
@Extension(
name = "Order",
properties = @ExtensionProperty(name = "Order", value = "0305")))
@MetadataDocumentKeyParameter
@ApiResponse(responseCode = "204", description = "Metadata document deleted")
@Docs.DefaultUnsuccessfulReadResponses
@Docs.DefaultUnsuccessfulWriteResponses
@DeleteMapping("metadata/{key}")
@DeleteMapping("metadata/{metadataKey}")
@Override
public void deleteMetadata(@PathVariable("key") int metadataKey) {
public void deleteMetadata(@PathVariable("metadataKey") int metadataKey) {
metadataMapper.delete(metadataKey);
}

Expand Down

0 comments on commit 08c72e5

Please sign in to comment.