Skip to content

Commit

Permalink
CMR-4874 fixes bug, adds test coverage (#504)
Browse files Browse the repository at this point in the history
* CMR-4874 fixes bug, adds test coverage

* CMR-4874 more bug fixes

* CMR-4874 doc string
  • Loading branch information
daniel-zamora authored and mschmele committed Apr 25, 2018
1 parent 6779814 commit 2cd78e1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
31 changes: 22 additions & 9 deletions umm-spec-lib/src/cmr/umm_spec/migration/version/service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,34 @@
(assoc related-url :SubType nil)
related-url))

(defn- migrate-types-down
"Migrates CoverageSpatialExtent and CoverageTemporalExtent types from 1.1 to 1.0"
[coverage-type]
(if-let [type (get-in coverage-type [:CoverageSpatialExtent :CoverageSpatialExtentTypeType])]
(-> coverage-type
(assoc :Type type)
(assoc-in [:CoverageSpatialExtent :Type] type))))

(defn- migrate-coverage-type-down
"Migrate CoverageType changes down from 1.1 to 1.0"
[coverage-type]
(-> coverage-type
(assoc :Type (get-in coverage-type [:CoverageSpatialExtent :CoverageSpatialExtentTypeType]))
(update :CoverageTemporalExtent dissoc :CoverageTemporalExtentTypeType)
migrate-types-down
(update :CoverageTemporalExtent dissoc :CoverageTemporalExtentType)
(update :CoverageSpatialExtent dissoc :CoverageSpatialExtentTypeType)))

(defn- migrate-coverage-type-up
"Migrate CoverageType changes up from 1.0 to 1.1"
[coverage-type]
(-> coverage-type
(update :CoverageSpatialExtent
assoc :CoverageSpatialExtentTypeType (get coverage-type :Type))
(dissoc :Type)))
(if-let [type (or (get-in coverage-type [:CoverageSpatialExtent :Type])
(get coverage-type :Type))]
(-> coverage-type
(update :CoverageSpatialExtent
assoc :CoverageSpatialExtentTypeType type)
(update :CoverageSpatialExtent dissoc :Type)
(dissoc :Type))
(dissoc coverage-type :Type)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Service Migration Implementations
Expand All @@ -35,10 +48,8 @@
[context s & _]
(-> s
(assoc :AccessConstraints (first (:AccessConstraints s)))
(update :AccessConstraints #(util/trunc % 1024))
(update :UseConstraints #(util/trunc % 1024))
(update-in [:ServiceQuality :Lineage] #(util/trunc % 100))
(assoc :RelatedURLs [(:RelatedURL s)])
(assoc :UseConstraints (first (:UseConstraints s)))
(update :Coverage migrate-coverage-type-up)
(dissoc :RelatedURL)
(util/update-in-each [:ServiceOrganizations] dissoc :Uuid)
Expand All @@ -47,7 +58,9 @@
(defmethod interface/migrate-umm-version [:service "1.1" "1.0"]
[context s & _]
(-> s
(assoc :AccessConstraints [(:AccessConstraints s)])
(assoc :AccessConstraints [(util/trunc (:AccessConstraints s) 1024)])
(assoc :UseConstraints [(util/trunc (:UseConstraints s) 1024)])
(update-in [:ServiceQuality :Lineage] #(util/trunc % 100))
(assoc :RelatedURL (first (:RelatedURLs s)))
(update :RelatedURL migrate-related-url-subtype-down)
(update :Coverage migrate-coverage-type-down)
Expand Down
19 changes: 13 additions & 6 deletions umm-spec-lib/test/cmr/umm_spec/test/migration/version/service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
:Description "OPeNDAP Service"
:Type "GET SERVICE"
:URL "https://acdisc.gesdisc.eosdis.nasa.gov/opendap/Aqua_AIRS_Level3/AIRX3STD.006/"},
:Coverage {:Type "SPATIAL_POINT"}
:AccessConstraints ["TEST"]})
:Coverage {:Type "SPATIAL_POINT"
:CoverageSpatialExtent {:Type "SPATIAL_POINT"}}
:AccessConstraints [(apply str (repeat 1024 "x"))]
:UseConstraints [(apply str (repeat 1024 "x"))]
:ServiceQuality {:QualityFlag "Available"
:Lineage (apply str (repeat 100 "x"))}})

(def service-concept-1-1
{:Coverage {:CoverageSpatialExtent {:CoverageSpatialExtentTypeType "SPATIAL_POINT"}}
:AccessConstraints "TEST"
:UseConstraints "TEST"
:ServiceOrganizations [{:Roles ["SERVICE PROVIDER"]
:ShortName "TEST ShortName"}]
:RelatedURLs [{:URLContentType "CollectionURL"
Expand All @@ -49,6 +54,7 @@
(vm/migrate-umm {} :service "1.0" "1.1"
{:Coverage {:Type "SPATIAL_POINT"}
:AccessConstraints ["TEST"]
:UseConstraints ["TEST"]
:ServiceOrganizations [{:Roles ["SERVICE PROVIDER"]
:ShortName "TEST ShortName"
:Uuid "TEST Uuid"}]
Expand All @@ -62,8 +68,9 @@
{:RelatedURLs [{:URL "https://acdisc.gesdisc.eosdis.nasa.gov/opendap/Aqua_AIRS_Level3/AIRX3STD.006/" :Description "OPeNDAP Service"
:Type "GET SERVICE"
:URLContentType "CollectionURL"}]
:AccessConstraints "TEST"
:AccessConstraints (apply str (repeat 4000 "x"))
:UseConstraints (apply str (repeat 20000 "x"))
:ServiceQuality {:QualityFlag "Available"
:Lineage (apply str (repeat 4000 "x"))}
:Coverage {:CoverageSpatialExtent {:CoverageSpatialExtentTypeType
"SPATIAL_POINT"}
:CoverageTemporalExtent {:CoverageTemporalExtentTypeType
"TIME_STAMP"}}}))))
"SPATIAL_POINT"}}}))))

0 comments on commit 2cd78e1

Please sign in to comment.