Skip to content

Commit 87bf034

Browse files
authored
CMR-7333 - support for DMR++ and DMR++ MISSING DATA URLs in UMM-G
* while testing, the revision_format_map.clj test was failing, it apparently is not stable for local builds. This change will more consistenly pass * updating some comments to make it clear which document type the function is used for * adding two enums to related URL for granules * CMR-7333 - API documentation cleanup to render properly in markdown editors
1 parent 7a47b1d commit 87bf034

File tree

20 files changed

+1752
-78
lines changed

20 files changed

+1752
-78
lines changed

ingest-app/docs/api.md

+102-44
Large diffs are not rendered by default.

ingest-app/src/cmr/ingest/config.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
(defconfig granule-umm-version
3030
"Defines the latest granule umm version accepted by ingest - it's the latest official version.
3131
This environment variable needs to be manually set when newer UMM version becomes official"
32-
{:default "1.6.2"})
32+
{:default "1.6.3"})
3333

3434
(defconfig variable-umm-version
3535
"Defines the latest variable umm version accepted by ingest - it's the latest official version.

search-app/docs/api.md

+28-14
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,7 @@ __Example Query__
12661266
curl "%CMR-ENDPOINT%/autocomplete?q=ice&type[]=platform&type[]=project"
12671267

12681268
__Example Result with Type Filter__
1269+
12691270
```
12701271
HTTP/1.1 200 OK
12711272
Content-Type: application/json; charset=UTF-8
@@ -1832,17 +1833,17 @@ Shapefile upload is only supported using POST with `multipart/form-data` and the
18321833

18331834
Examples:
18341835

1835-
**ESRI Shapefile**
1836+
**ESRI Shapefile**
18361837

1837-
curl -XPOST "%CMR-ENDPOINT%/collections" -F "shapefile=@box.zip;type=application/shapefile+zip" -F "provider=PROV1"
1838+
curl -XPOST "%CMR-ENDPOINT%/collections" -F "shapefile=@box.zip;type=application/shapefile+zip" -F "provider=PROV1"
18381839

1839-
**GeoJSON**
1840+
**GeoJSON**
18401841

1841-
curl -XPOST "%CMR-ENDPOINT%/collections" -F "shapefile=@box.geojson;type=application/geo+json" -F "provider=PROV1"
1842+
curl -XPOST "%CMR-ENDPOINT%/collections" -F "shapefile=@box.geojson;type=application/geo+json" -F "provider=PROV1"
18421843

1843-
**KML**
1844+
**KML**
18441845

1845-
curl -XPOST "%CMR-ENDPOINT%/collections" -F "shapefile=@box.kml;type=application/vnd.google-earth.kml+xml" -F "provider=PROV1"
1846+
curl -XPOST "%CMR-ENDPOINT%/collections" -F "shapefile=@box.kml;type=application/vnd.google-earth.kml+xml" -F "provider=PROV1"
18461847

18471848
Internally a WGS 84 Coordinate Reference System (CRS) is used. The system will attempt to transform shapefile geometry that uses a different CRS, but this is not guaranteed to work and the request will be rejected if a suitable transformation is not found.
18481849

@@ -1853,7 +1854,7 @@ Shapefiles are limited to 5000 points by default. A user using a shapefile with
18531854

18541855
Example:
18551856

1856-
curl -XPOST "%CMR-ENDPOINT%/collections" -F "simplify-shapefile=true" -F "shapefile=@africa.zip;type=application/shapefile+zip" -F "provider=PROV1"
1857+
curl -XPOST "%CMR-ENDPOINT%/collections" -F "simplify-shapefile=true" -F "shapefile=@africa.zip;type=application/shapefile+zip" -F "provider=PROV1"
18571858

18581859
Note that the simplification process attempts to preserve topology, i.e., the relationship between polygon outer boundaries and holes. The process uses the [Douglas-Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm) and as such may result in geometries with less coverage than the original shapefile and potentially a loss of matching results.
18591860

@@ -2106,15 +2107,15 @@ The parameters used for searching granules by spatial are the same as the spatia
21062107

21072108
As with collections, a shapefile can be uploaded to find granules that overlap the shapefile's geometry. See [Find collections by shapefile](#c-shapefile) for more details.
21082109

2109-
curl -XPOST "%CMR-ENDPOINT%/granules" -F "shapefile=@box.zip;type=application/shapefile+zip" -F "provider=PROV1"
2110+
curl -XPOST "%CMR-ENDPOINT%/granules" -F "shapefile=@box.zip;type=application/shapefile+zip" -F "provider=PROV1"
21102111

21112112
**NOTE**: This is an experimental feature and may not be enabled in all environments.
21122113

21132114
#### <a name="g-shapefile-simplification"></a> Simplifying shapefiles during granule search
21142115

21152116
As with collections, an uplodaed shapefile can be simplified by setting the `simplfiy-shapefile` parameter to `true`. See [Simplifying shapefiles during collection search](#c-shapefile-simplification) for more details.
21162117

2117-
curl -XPOST "%CMR-ENDPOINT%/granules" -F "simplify-shapefile=true" -F "shapefile=@africa.zip;type=application/shapefile+zip" -F "provider=PROV1"
2118+
curl -XPOST "%CMR-ENDPOINT%/granules" -F "simplify-shapefile=true" -F "shapefile=@africa.zip;type=application/shapefile+zip" -F "provider=PROV1"
21182119

21192120
#### <a name="g-orbit-number"></a> Find granules by orbit number
21202121

@@ -2169,7 +2170,7 @@ Find granules which have revision date within the ranges of datetimes. The datet
21692170

21702171
Find granules which were created within the ranges of datetimes. The datetime has to be in yyyy-MM-ddTHH:mm:ssZ format. The default is inclusive on the range boundaries.
21712172

2172-
curl "%CMR-ENDPOINT%/granules?collection_concept_id=%CMR-EXAMPLE-COLLECTION-ID%&created_at\[\]=2000-01-01T10:00:00Z,2010-03-10T12:00:00Z&created_at\[\]=2015-01-01T10:00:00Z,"
2173+
curl "%CMR-ENDPOINT%/granules?collection_concept_id=%CMR-EXAMPLE-COLLECTION-ID%&created_at\[\]=2000-01-01T10:00:00Z,2010-03-10T12:00:00Z&created_at\[\]=2015-01-01T10:00:00Z,"
21732174

21742175
#### <a name="g-production-date"></a> Find granules by production_date
21752176

@@ -2986,9 +2987,7 @@ Content-Type: application/json; charset=UTF-8
29862987

29872988
The humanizers report provides a list of fields that have been humanized in CSV format. The report format is: provider, concept id, product short name, product version, original field value, humanized field value.
29882989

2989-
```
2990-
curl "%CMR-ENDPOINT%/humanizers/report"
2991-
```
2990+
curl "%CMR-ENDPOINT%/humanizers/report"
29922991

29932992
Note that this report is currently generated every 24 hours with the expectation that this more than satisfies weekly usage needs.
29942993

@@ -3567,7 +3566,10 @@ These parameters will match fields within a variable. They are case insensitive
35673566
* options: ignore_case, or
35683567
measurement_identifiers parameter is a nested parameter with subfields: contextmedium, object and quantity. Multiple measurement_identifiers can be specified via different indexes to search variables. The following example searches for variables that have at least one measurement_identifier with contextmedium of Med1, object of Object1 and quantity of Q1, and another measurement_identifier with contextmedium of Med2 and object of Obj2.
35693568

3570-
curl -g "%CMR-ENDPOINT%/variables?measurement_identifiers\[0\]\[contextmedium\]=Med1&measurement_identifiers\[0\]\[object\]=Object1&measurement_identifiers\[0\]\[quantity\]=Q1&measurement_identifiers\[1\]\[contextmedium\]=med2&measurement_identifiers\[2\]\[object\]=Obj2"
3569+
3570+
````
3571+
curl -g "%CMR-ENDPOINT%/variables?measurement_identifiers\[0\]\[contextmedium\]=Med1&measurement_identifiers\[0\]\[object\]=Object1&measurement_identifiers\[0\]\[quantity\]=Q1&measurement_identifiers\[1\]\[contextmedium\]=med2&measurement_identifiers\[2\]\[object\]=Obj2"
3572+
````
35713573

35723574
The multiple measurement_identifiers are ANDed by default. User can specify `options[measurement-identifiers][or]=true` to make the measurement_identifiers ORed together.
35733575

@@ -3603,6 +3605,7 @@ The `references` field may contain multiple `reference` entries, each consisting
36033605
| revision-id | the internal CMR version number for the result |
36043606

36053607
__Example__
3608+
36063609
```
36073610
curl -i "%CMR-ENDPOINT%/variables?pretty=true&name=Variable1"
36083611
@@ -3638,6 +3641,7 @@ The JSON response includes the following fields.
36383641
* long_name
36393642

36403643
__Example__
3644+
36413645
```
36423646
curl -g -i "%CMR-ENDPOINT%/variables.json?pretty=true&name=Var*&options[name][pattern]=true"
36433647
@@ -3669,6 +3673,7 @@ Content-Length: 292
36693673
The UMM JSON response contains meta-metadata of the variable, the UMM fields and the associations field if applicable. The associations field only applies when there are collections associated with the variable and will list the collections that are associated with the variable.
36703674

36713675
__Example__
3676+
36723677
```
36733678
curl -g -i "%CMR-ENDPOINT%/variables.umm_json?name=Variable1234&pretty=true"
36743679
HTTP/1.1 200 OK
@@ -3853,6 +3858,7 @@ The `references` field may contain multiple `reference` entries, each consisting
38533858
| revision-id | the internal CMR version number for the result |
38543859

38553860
__Example__
3861+
38563862
```
38573863
curl -i "%CMR-ENDPOINT%/services?name=Service1&pretty=true"
38583864
@@ -3888,6 +3894,7 @@ The JSON response includes the following fields.
38883894
* long_name
38893895

38903896
__Example__
3897+
38913898
```
38923899
curl -g -i "%CMR-ENDPOINT%/services.json?pretty=true"
38933900
@@ -3933,6 +3940,7 @@ Content-Length: 944
39333940
The UMM JSON response contains meta-metadata of the service and the UMM fields.
39343941

39353942
__Example__
3943+
39363944
```
39373945
curl -g -i "%CMR-ENDPOINT%/services.umm_json?name=NSIDC_AtlasNorth&pretty=true"
39383946
HTTP/1.1 200 OK
@@ -4207,6 +4215,7 @@ The `references` field may contain multiple `reference` entries, each consisting
42074215
| revision-id | the internal CMR version number for the result |
42084216

42094217
__Example__
4218+
42104219
```
42114220
curl -i "%CMR-ENDPOINT%/tools?name=someTool1&pretty=true"
42124221
@@ -4242,6 +4251,7 @@ The JSON response includes the following fields.
42424251
* long_name
42434252

42444253
__Example__
4254+
42454255
```
42464256
curl -g -i "%CMR-ENDPOINT%/tools.json?pretty=true"
42474257
@@ -4273,6 +4283,7 @@ Content-Length: 944
42734283
The UMM JSON response contains meta-metadata of the tool and the UMM fields.
42744284

42754285
__Example__
4286+
42764287
```
42774288
curl -g -i "%CMR-ENDPOINT%/tools.umm_json?name=NSIDC_AtlasNorth&pretty=true"
42784289
HTTP/1.1 200 OK
@@ -4558,6 +4569,7 @@ The `references` field may contain multiple `reference` entries, each consisting
45584569
| revision-id | the internal CMR version number for the result |
45594570

45604571
__Example__
4572+
45614573
```
45624574
curl -i "%CMR-ENDPOINT%/subscriptions?name=someSub1&pretty=true"
45634575
@@ -4594,6 +4606,7 @@ The JSON response includes the following fields.
45944606
* collection_concept_id
45954607

45964608
__Example__
4609+
45974610
```
45984611
curl -g -i "%CMR-ENDPOINT%/subscriptions.json?pretty=true"
45994612
@@ -4627,6 +4640,7 @@ Content-Length: 944
46274640
The UMM JSON response contains meta-metadata of the subscription and the UMM fields.
46284641

46294642
__Example__
4643+
46304644
```
46314645
curl -g -i "%CMR-ENDPOINT%/subscriptions.umm_json?name=NSIDC_AtlasNorth&pretty=true"
46324646
HTTP/1.1 200 OK

search-app/test/cmr/search/test/data/metadata_retrieval/revision_format_map.clj

+16-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
[cmr.common.util :as util]
77
[cmr.search.data.metadata-retrieval.revision-format-map :as r]
88
[cmr.search.test.data.metadata-retrieval.test-metadata :as tm]
9-
[cmr.umm-spec.test.expected-conversion :as expected-conversion]))
9+
[cmr.umm-spec.test.expected-conversion :as expected-conversion]
10+
[digest :as digest]))
1011

1112
(use-fixtures :each tk/freeze-resume-time-fixture)
1213

@@ -96,9 +97,20 @@
9697
(r/add-additional-format nil :echo10 rfm)))))
9798
(testing "Compressed"
9899
(let [rfm (r/compress
99-
(r/concept->revision-format-map nil tm/dif10-concept #{:native}))]
100-
(is (= (assoc rfm :echo10 (util/string->lz4-bytes (:metadata tm/echo10-concept)))
101-
(r/add-additional-format nil :echo10 rfm))))))
100+
(r/concept->revision-format-map nil tm/dif10-concept #{:native}))
101+
expected (assoc rfm :echo10 (util/string->lz4-bytes (:metadata tm/echo10-concept)))
102+
actual (r/add-additional-format nil :echo10 rfm)]
103+
104+
; A test like (is(= expected actual)) does not work for everyone locally
105+
; as there seams to be some problem with testing byte arrays.
106+
; To get around this, a new test was come up with which drops the
107+
; compressed segment (byte array) which fails and tests that data sepratly
108+
; by doing a comparison on the md5 values
109+
110+
(is (= (util/dissoc-in expected [:echo10 :compressed])
111+
(util/dissoc-in actual [:echo10 :compressed])))
112+
(is (= (digest/md5 (String. (get-in expected [:echo10 :compressed]) "UTF-8"))
113+
(digest/md5 (String. (get-in actual [:echo10 :compressed] )"UTF-8")))))))
102114

103115
(defn test-rfm
104116
"Creates a revision format map with the specified formats."

system-int-test/test/cmr/system_int_test/ingest/granule_ingest_test.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@
665665
:identifiers [:identifier "a very nice granule :)"
666666
:identifier-type "a type of identifier"]})})
667667
(data-core/item->concept {:format :umm-json
668-
:version "1.6.2"}))
668+
:version "1.6.3"}))
669669
{:keys [status] :as response} (ingest/ingest-concept granule)]
670670
(is (#{200 201} status) (pr-str response))))
671671

umm-lib/resources/data/echo10/G1001765469-NSIDC_ECS.native.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@
217217
<Type>METADATA</Type>
218218
<MimeType>text/xml</MimeType>
219219
</OnlineResource>
220+
<OnlineResource>
221+
<URL>https://some.s3.bucket.exammple.org</URL>
222+
<Type>EXTENDED METADATA : DMR++</Type>
223+
<MimeType>text/xml</MimeType>
224+
</OnlineResource>
220225
</OnlineResources>
221226
<Orderable>true</Orderable>
222227
<Visible>true</Visible>
223-
</Granule>
228+
</Granule>

umm-lib/src/cmr/umm/echo10/related_url.clj

+20-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
(def resource-type->related-url-types
1111
"A mapping of ECHO10 OnlineResource's type to UMM RelatedURL's type and sub-type.
12-
This came from a list provided by Katie on ECHO10 collections, more may need to be added for granules."
12+
This came from a list provided by Katie on ECHO10 collections, more may need to
13+
be added for granules."
1314
{"STATIC URL" ["VIEW RELATED INFORMATION"]
1415
"GUIDE" ["VIEW RELATED INFORMATION" "USER'S GUIDE"]
1516
"HOMEPAGE" ["VIEW PROJECT HOME PAGE"]
@@ -51,7 +52,11 @@
5152
"ALGORITHM INFO" ["VIEW RELATED INFORMATION"]
5253
"GET DATA : OPENDAP DATA (DODS)" ["USE SERVICE API" "OPENDAP DATA"]
5354
"GET DATA : OPENDAP DATA" ["USE SERVICE API" "OPENDAP DATA"]
54-
"VIEW PROJECT HOME PAGE" ["VIEW PROJECT HOME PAGE"]})
55+
"VIEW PROJECT HOME PAGE" ["VIEW PROJECT HOME PAGE"]
56+
"DMR++" ["EXTENDED METADATA" "DMR++"]
57+
"EXTENDED METADATA : DMR++" ["EXTENDED METADATA" "DMR++"]
58+
"DMR++ MISSING DATA" ["EXTENDED METADATA" "DMR++ MISSING DATA"]
59+
"EXTENDED METADATA : DMR++ MISSING DATA" ["EXTENDED METADATA" "DMR++ MISSING DATA"]})
5560

5661
(def related-url-types->resource-types
5762
"A mapping of UMM RelatedURL's type to ECHO10 OnlineResource's type.
@@ -165,6 +170,18 @@
165170
(when description (x/element :URLDescription {} description))
166171
(when mime-type (x/element :MimeType {} mime-type))))))))
167172

173+
(defn- related-url->online-resource
174+
"Related-url-types->resource-types does not handle the use case for matching a
175+
subtype, if the type and subtype are extended metadata DMR values, then encode
176+
them in colon format"
177+
[related-url]
178+
(let [url-type (:type related-url)
179+
url-subtype (:sub-type related-url)]
180+
(if (and (= "EXTENDED METADATA" url-type)
181+
(some #{url-subtype} ["DMR++" "DMR++ MISSING DATA"]))
182+
(str url-type " : " url-subtype)
183+
(get related-url-types->resource-types url-type "USER SUPPORT"))))
184+
168185
(defn generate-resource-urls
169186
"Generates the OnlineResources element of an ECHO10 XML from a UMM related urls entry."
170187
[related-urls]
@@ -178,7 +195,7 @@
178195
(when description (x/element :Description {} description))
179196
;; There is not a well defined one to one mapping between related url type and resource type.
180197
;; This default value of "USER SUPPORT" is to get us by the xml schema validation.
181-
(x/element :Type {} (get related-url-types->resource-types type "USER SUPPORT"))
198+
(x/element :Type {} (related-url->online-resource related-url))
182199
(when mime-type (x/element :MimeType {} mime-type))))))))
183200

184201
(defn generate-browse-urls

umm-lib/src/cmr/umm/related_url_helper.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
(filter resource-url? related-urls))
115115

116116
(defn- related-url->link-type
117-
"Returns the atom link type of the related url"
117+
"Returns the atom link type of the related url - used for granules"
118118
[related-url]
119119
(cond
120120
(downloadable-url? related-url) "data"

umm-lib/test/cmr/umm/test/echo10/granule.clj

+11
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@
214214
<Description>Some description.</Description>
215215
<Type>Browse</Type>
216216
</OnlineResource>
217+
<OnlineResource>
218+
<URL>https://dmr.s3.bucket.example.org</URL>
219+
<Description>Some description about DMR buckets</Description>
220+
<Type>EXTENDED METADATA : DMR++</Type>
221+
</OnlineResource>
217222
</OnlineResources>
218223
<CloudCover>0.8</CloudCover>
219224
<AssociatedBrowseImageUrls>
@@ -347,6 +352,12 @@
347352
:url "ftp://camex.nsstc.nasa.gov/camex3/dc8capac/browse/"
348353
:description "Some description."
349354
:title "Some description. (Browse)"})
355+
(umm-c/map->RelatedURL
356+
{:type "EXTENDED METADATA"
357+
:sub-type "DMR++"
358+
:url "https://dmr.s3.bucket.example.org"
359+
:title "Some description about DMR buckets (EXTENDED METADATA : DMR++)"
360+
:description "Some description about DMR buckets"})
350361
(umm-c/map->RelatedURL
351362
{:type "GET RELATED VISUALIZATION"
352363
:url "http://nasa.gov/1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
(ns cmr.umm.test.echo10.related-url
2+
"Tests functions for granule related urls"
3+
(:require
4+
[clojure.test :refer :all]
5+
[cmr.common.util :as util :refer [are3]]
6+
[cmr.umm.echo10.related-url :as rurl]))
7+
8+
(deftest validate-xml
9+
(testing
10+
"Validate that the related-url->online-resource function correctly returns
11+
subtypes for the DMR use cases"
12+
(are3 [expected actual-type actual-subtype]
13+
(is (= expected
14+
(#'rurl/related-url->online-resource {:type actual-type
15+
:sub-type actual-subtype})))
16+
"Extended metadata with DMR++"
17+
"EXTENDED METADATA : DMR++"
18+
"EXTENDED METADATA"
19+
"DMR++"
20+
21+
"Extended metadata with DMR++ Missing Data"
22+
"EXTENDED METADATA : DMR++ MISSING DATA"
23+
"EXTENDED METADATA"
24+
"DMR++ MISSING DATA"
25+
26+
"A future case of extended metadata which should not be changed"
27+
"USER SUPPORT"
28+
"EXTENDED METADATA"
29+
"Future Kathryn Janeway"
30+
31+
"User support case for existing types"
32+
"USER SUPPORT"
33+
"DOWNLOAD SOFTWARE"
34+
"APP"
35+
36+
"User support should be assumed for a nil"
37+
"USER SUPPORT"
38+
"type"
39+
nil
40+
41+
"User support should be assumed for a nil"
42+
"USER SUPPORT"
43+
nil
44+
"sub"
45+
46+
"User support should be assumed for a nil"
47+
"USER SUPPORT"
48+
nil
49+
nil)))

0 commit comments

Comments
 (0)