Skip to content

Commit

Permalink
CMR-8975 Fixing when migrating down to 1.17.2 and a collection doesn'…
Browse files Browse the repository at this point in the history
…t have a RelatedURL that an empty element doesn't show up. (#1886)
  • Loading branch information
eereiter committed Apr 14, 2023
1 parent 6664ab9 commit aed1ff7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,12 @@
"Change application/x-vnd.iso.19139-2+xml to Not provided for the
RelatedUrls/GetService/MimeType element."
[related-urls]
(vec
(for [related-url related-urls
:let [service (:GetService related-url)]]
(if service
(if (= (:MimeType service) "application/x-vnd.iso.19139-2+xml")
(assoc-in related-url [:GetService :MimeType] "Not provided")
related-url)
related-url))))
(let [urls (for [related-url related-urls
:let [service (:GetService related-url)]]
(if service
(if (= (:MimeType service) "application/x-vnd.iso.19139-2+xml")
(assoc-in related-url [:GetService :MimeType] "Not provided")
related-url)
related-url))]
(when (seq urls)
(vec urls))))
20 changes: 10 additions & 10 deletions umm-spec-lib/src/cmr/umm_spec/migration/version/collection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@
[context collection & _]
;; if TilingIdentificationSystems Names are any but Military Grid Reference System,
;; Migrate TilingIdentificationSystems/Coordinate1 and Coordinate2 from string to number.
(def collection collection)
(-> collection
(m-spec/update-version :collection "1.17.3")
(util/update-in-all [:TilingIdentificationSystems] #(if (= "Military Grid Reference System" (:TilingIdentificationSystemName %))
Expand All @@ -700,12 +699,13 @@

(defmethod interface/migrate-umm-version [:collection "1.17.3" "1.17.2"]
[context collection & _]
;; Remove the EULAIdentifiers field in UseConstraints
;; Migrate TilingIdentificationSystems/Coordinate1 and Coordinate2 down if they are numbers, otherwise remove entire tiling identification system
(-> collection
(m-spec/update-version :collection "1.17.2")
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MinimumValue] str)
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MaximumValue] str)
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MinimumValue] str)
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MaximumValue] str)
(update :RelatedUrls related-url/migrating-down-to_1_17_2)))
;; Migrate TilingIdentificationSystems/Coordinate1 and Coordinate2 down if they are numbers.
;; Replace a GetService MimeType to a valid value.
(util/remove-nils-empty-maps-seqs
(-> collection
(m-spec/update-version :collection "1.17.2")
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MinimumValue] str)
(util/update-in-all [:TilingIdentificationSystems :Coordinate1 :MaximumValue] str)
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MinimumValue] str)
(util/update-in-all [:TilingIdentificationSystems :Coordinate2 :MaximumValue] str)
(update :RelatedUrls related-url/migrating-down-to_1_17_2))))
Original file line number Diff line number Diff line change
Expand Up @@ -3747,7 +3747,7 @@
(let [result (vm/migrate-umm {} :collection "1.17.3" "1.17.2" sample-collection)]
(is (= expected result)))

"Migrating TilingIdentificationSystems Coordinate1/Coordinate2 up"
"Migrating TilingIdentificationSystems Coordinate1/Coordinate2 down"
{:TilingIdentificationSystems [{:TilingIdentificationSystemName "Military Grid Reference System",
:Coordinate1 {:MinimumValue "-100",
:MaximumValue "-50"},
Expand All @@ -3774,4 +3774,10 @@
:Coordinate2 {:MinimumValue 1.5
:MaximumValue 10.5}}]
:RelatedUrls [{:GetService {:MimeType "application/x-vnd.iso.19139-2+xml"}}
{:GetService {:MimeType "application/json"}}]}))
{:GetService {:MimeType "application/json"}}]}

"Migrating nothing down"
{:MetadataSpecification {:URL "https://cdn.earthdata.nasa.gov/umm/collection/v1.17.2"
:Name "UMM-C",
:Version "1.17.2"}}
{}))

0 comments on commit aed1ff7

Please sign in to comment.