Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMR-9392 adding Grid Draft records to the CMR. #1961

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common-lib/src/cmr/common/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@
:service-draft ["1.0.0"]
:variable-draft ["1.0.0"]
:data-quality-summary-draft ["1.0.0"]
:order-option-draft ["1.0.0"]}
:order-option-draft ["1.0.0"]
:grid-draft ["1.0.0"]}
:parser #(json/parse-string % true)})

(defconfig approved-pipeline-documentation
Expand Down
9 changes: 5 additions & 4 deletions ingest-app/src/cmr/ingest/api/generic_documents.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
{:collection-draft :umm-c
:service-draft :umm-s
:tool-draft :umm-t
:variable-draft :umm-var
:data-quality-summary-draft :data-quality-summary
eereiter marked this conversation as resolved.
Show resolved Hide resolved
:order-option-draft :order-option})
:variable-draft :umm-var})

(defn is-draft-concept?
"This function checks to see if the concept to be ingested or updated
Expand Down Expand Up @@ -116,8 +114,11 @@
content-type (get headers "content-type")
{:keys [spec-key spec-version document-name format]}
(pull-metadata-specific-information request-context concept-type content-type raw-document)]
;; Check to see if the passed in record contains the MetadataSpecification/Name field and its
;; value matches that from the concept name in the route parameters.
(if (and (not= concept-type spec-key)
(not= (concept-type draft-concept->spec-map) spec-key))
(not= (concept-type draft-concept->spec-map) spec-key)
(not= (common-concepts/get-concept-type-of-draft concept-type) spec-key))
(throw (UnsupportedOperationException. (format "%s version %s is not supported." spec-key spec-version)))
{:concept (assoc {}
:metadata raw-document
Expand Down
28 changes: 28 additions & 0 deletions schemas/resources/schemas/grid-draft/v1.0.0/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"MetadataSpecification": {
"URL": "https://cdn.earthdata.nasa.gov/generic/index/v0.0.1",
"Name": "Generic-Index",
"Version": "0.0.1"
},
"Generic": {
"Name": "Grid Draft",
"Version": "1.0.0"
},
"SubConceptType": "GD",
"IndexSetup" : {
"index": {
"number_of_shards": 3,
"number_of_replicas": 1,
"refresh_interval": "1s"
}
},
"Indexes":
[
{
"Description": "Draft Grid Name",
"Field": ".Name",
"Name": "name",
"Mapping": "string"
}
]
}
85 changes: 85 additions & 0 deletions schemas/resources/schemas/grid-draft/v1.0.0/ingest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## <a name="grid-draft"></a> Grid Draft

#### <a name="provider-info-grid-draft"></a> /providers/&lt;provider-id&gt;/grid-drafts/&lt;native-id&gt;

### <a name="create-update-grid-draft"></a> Create / Update a Grid Draft

Grid Draft concepts can be created or updated by sending an HTTP PUT with the metadata to the URL `%CMR-ENDPOINT%/providers/<provider-id>/grid-drafts/<native-id>`. The response will include the [concept id](#concept-id) and the [revision id](#revision-id). The contents of the metadata is passed in the body of the request.

```
curl -XPOST \
-H "Cmr-Pretty: true" \
-H "Content-Type:application/vnd.nasa.cmr.umm+json" \
-H "Authorization: Bearer XXXX" \
"%CMR-ENDPOINT%/providers/PROV1/grid-drafts/sampleNativeId" \
-d @samplGrid.json
```

#### Successful Response in XML

```
<?xml version="1.0" encoding="UTF-8"?>
<result>
<concept-id>GD1200000000-PROV1</concept-id>
<revision-id>1</revision-id>
<warnings></warnings>
<existing-errors></existing-errors>
</result>
```
Subsequent ingests to the Grid Draft record will result in updates to it's metadata as well as increment the revision-id of the record.

#### Successful Response in JSON

By passing the option `-H "Accept: application/json"` to `curl`, one may
get a JSON response:

```
{"concept-id":"GD1200000000-PROV1","revision-id":1,"warnings":null,"existing-errors":null}
```

### <a name="delete-grid-draft"></a> Delete a Grid Draft

Grid Draft metadata can be deleted by sending an HTTP DELETE to the URL `%CMR-ENDPOINT%/providers/<provider-id>/grid-drafts/<native-id>`. The response will include the [concept id](#concept-id) and the [revision id](#revision-id) of the tombstone.

```
curl -XDELETE \
-H "Cmr-Pretty: true" \
-H "Authorization: Bearer XXXX" \
%CMR-ENDPOINT%/providers/PROV1/grid-drafts/sampleNative23Id"
```

#### Successful Response in XML

```
<?xml version="1.0" encoding="UTF-8"?>
<result>
<concept-id>GD1200000000-PROV1</concept-id>
<revision-id>2</revision-id>
</result>
```

#### Successful Response in JSON

```
{"concept-id":"GD1200000000-PROV1","revision-id":2,"warnings":null,"existing-errors":null}
```

Attempting to delete an already deleted record will return
the following error message

#### Unsuccessful Response in XML

```
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Concept with native-id [sampleNative23Id] and concept-id [GD1200000000-PROV1] is already deleted.</error>
</errors>
```

#### Unsuccessful Response in JSON

```
"errors": [
"Concept with native-id [sampleNative23Id] and concept-id [GD1200000000-PROV1] is already deleted."
]
```
118 changes: 118 additions & 0 deletions schemas/resources/schemas/grid-draft/v1.0.0/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"MetadataSpecification": {
"URL": "https://cdn.earthdata.nasa.gov/generic/grid/v0.0.1",
"Name": "Grid",
"Version": "0.0.1"
},
"Name": "Grid-A7-v1",
"LongName": "Grid A-7 version 1.0",
"Version": "v1.0",
"Description": "A sample grid",
"GridDefinition": {
"CoordinateReferenceSystemID": {
"Type": "EPSG",
"Code": "EPSG:4326",
"Title": "WGS84 - World Geodetic System 1984, used in GPS - EPSG:4326",
"URL": "https://epsg.io/4326"
},
"DimensionSize": {
"Height": 1,
"Width": 1,
"Time": 2,
"Other": {
"Name": "Other Dimension Size",
"Value": "42",
"Description": "Details about the other dimension size."
}
},

"SpatialConstraint": {
"0_360_DegreeProjection": true,
"NorthBoundingCoordinate": 90.0,
"EastBoundingCoordinate": 0.0,
"SouthBoundingCoordinate": -90.0,
"WestBoundingCoordinate": 90.0,
"SpatialResolution": {
"Unit": "Degree",
"LongitudeResolution": "0.0005",
"LatitudeResolution": "90.000"
}
},
"DimensionScale": {
"0_360_DegreeProjection": true,
"X":
{
"Minimum": "-360-00-00.000",
"Maximum": "360-00-00.00",
"Unit": "Degrees-Minutes-Seconds",
"Resolution": 0.125
},
"Y":
{
"Minimum": "-360-00-00.000",
"Maximum": "360-00-00.00",
"Unit": "Degrees-Minutes-Seconds",
"Resolution": 0.5
},
"Time":
{
"Minimum": "2020-01-01T00:00:00.001Z",
"Maximum": "2020-01-30T23:59:59Z",
"Unit": "DateTime",
"Resolution": 0.125
},
"Other":
{
"Minimum": 0,
"Maximum": 44,
"Unit": "Meter",
"Resolution": 0.5
}
},

"Distortion": {
"Description": "Distortion around the grid edge",
"Percent": 31
},
"Uniform-Grid": true,
"Bounded-Grid": true
},
"Organization": {
"ShortName": "NASA/GSFC/SED/ESD/GCDC/GESDISC",
"LongName": "Goddard Earth Sciences Data and Information Services Center (formerly Goddard DAAC), Global Change Data Center, Earth Sciences Division, Science and Exploration Directorate, Goddard Space Flight Center, NASA",
"RelatedURLs": [
{
"URL": "https://example.gov",
"URLContentType": "C-Type",
"Type": "Type"
}
],
"ContactMechanisms": [
{
"Type": "Email",
"Value": "[email protected]"
},{
"Type": "Email",
"Value": "[email protected]"
}
]
},
"MetadataDate": {"Create": "2022-04-20T08:00:00Z"},
"RelatedURLs": [
{
"URL": "https://example.gov",
"URLContentType": "C-Type",
"Type": "Type"
},{
"URL": "https://example.gov/two",
"Description": "Details about the URL or page",
"URLContentType": "C-Type",
"Type": "Type"
}
],
"AdditionalAttribute": {
"Name": "attribute-1",
"Description": "Sample",
"DataType": "STRING"
}
}
Loading