Skip to content

Commit aed1ff7

Browse files
authored
CMR-8975 Fixing when migrating down to 1.17.2 and a collection doesn't have a RelatedURL that an empty element doesn't show up. (#1886)
1 parent 6664ab9 commit aed1ff7

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

umm-spec-lib/src/cmr/umm_spec/migration/related_url_migration.clj

+9-8
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,12 @@
411411
"Change application/x-vnd.iso.19139-2+xml to Not provided for the
412412
RelatedUrls/GetService/MimeType element."
413413
[related-urls]
414-
(vec
415-
(for [related-url related-urls
416-
:let [service (:GetService related-url)]]
417-
(if service
418-
(if (= (:MimeType service) "application/x-vnd.iso.19139-2+xml")
419-
(assoc-in related-url [:GetService :MimeType] "Not provided")
420-
related-url)
421-
related-url))))
414+
(let [urls (for [related-url related-urls
415+
:let [service (:GetService related-url)]]
416+
(if service
417+
(if (= (:MimeType service) "application/x-vnd.iso.19139-2+xml")
418+
(assoc-in related-url [:GetService :MimeType] "Not provided")
419+
related-url)
420+
related-url))]
421+
(when (seq urls)
422+
(vec urls))))

umm-spec-lib/src/cmr/umm_spec/migration/version/collection.clj

+10-10
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@
687687
[context collection & _]
688688
;; if TilingIdentificationSystems Names are any but Military Grid Reference System,
689689
;; Migrate TilingIdentificationSystems/Coordinate1 and Coordinate2 from string to number.
690-
(def collection collection)
691690
(-> collection
692691
(m-spec/update-version :collection "1.17.3")
693692
(util/update-in-all [:TilingIdentificationSystems] #(if (= "Military Grid Reference System" (:TilingIdentificationSystemName %))
@@ -700,12 +699,13 @@
700699

701700
(defmethod interface/migrate-umm-version [:collection "1.17.3" "1.17.2"]
702701
[context collection & _]
703-
;; Remove the EULAIdentifiers field in UseConstraints
704-
;; Migrate TilingIdentificationSystems/Coordinate1 and Coordinate2 down if they are numbers, otherwise remove entire tiling identification system
705-
(-> collection
706-
(m-spec/update-version :collection "1.17.2")
707-
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MinimumValue] str)
708-
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MaximumValue] str)
709-
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MinimumValue] str)
710-
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MaximumValue] str)
711-
(update :RelatedUrls related-url/migrating-down-to_1_17_2)))
702+
;; Migrate TilingIdentificationSystems/Coordinate1 and Coordinate2 down if they are numbers.
703+
;; Replace a GetService MimeType to a valid value.
704+
(util/remove-nils-empty-maps-seqs
705+
(-> collection
706+
(m-spec/update-version :collection "1.17.2")
707+
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MinimumValue] str)
708+
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MaximumValue] str)
709+
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MinimumValue] str)
710+
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MaximumValue] str)
711+
(update :RelatedUrls related-url/migrating-down-to_1_17_2))))

umm-spec-lib/test/cmr/umm_spec/test/migration/version/collection.clj

+8-2
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,7 @@
37473747
(let [result (vm/migrate-umm {} :collection "1.17.3" "1.17.2" sample-collection)]
37483748
(is (= expected result)))
37493749

3750-
"Migrating TilingIdentificationSystems Coordinate1/Coordinate2 up"
3750+
"Migrating TilingIdentificationSystems Coordinate1/Coordinate2 down"
37513751
{:TilingIdentificationSystems [{:TilingIdentificationSystemName "Military Grid Reference System",
37523752
:Coordinate1 {:MinimumValue "-100",
37533753
:MaximumValue "-50"},
@@ -3774,4 +3774,10 @@
37743774
:Coordinate2 {:MinimumValue 1.5
37753775
:MaximumValue 10.5}}]
37763776
:RelatedUrls [{:GetService {:MimeType "application/x-vnd.iso.19139-2+xml"}}
3777-
{:GetService {:MimeType "application/json"}}]}))
3777+
{:GetService {:MimeType "application/json"}}]}
3778+
3779+
"Migrating nothing down"
3780+
{:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/collection/v1.17.2"
3781+
:Name "UMM-C",
3782+
:Version "1.17.2"}}
3783+
{}))

0 commit comments

Comments
 (0)