Skip to content

Commit

Permalink
update migration func to substitute correct enums
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaeng72 committed Oct 25, 2024
1 parent 1845d8d commit be169a6
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions umm-spec-lib/src/cmr/umm_spec/migration/version/collection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -748,27 +748,32 @@
;; Add AssociatedDOIs/Type enums: IsPreviousVersionOf and IsNewVersionOf
;; Add PREPRINT, INREVIEW, and SUPERSEDED enums to CollectionProgress
;; Remove NOT APPLICABLE enum from CollectionProgress
(-> collection
(m-spec/update-version :collection "1.18.2")))

;; TODO what does this method actually do? Is it to update the actual data?
;(defmethod interface/migrate-umm-version [:collection "1.18.2" "1.18.1"]
; [_context collection & _]
; ;; Migrating down version 1.18.2 to 1.18.1
; ;; Remove AssociatedDOIs/Type enums: IsPreviousVersionOf and IsNewVersionOf
; ;; Remove PREPRINT, INREVIEW, and SUPERSEDED enums to CollectionProgress
; ;; Add back in NOT APPLICABLE enum in CollectionProgress
; (util/remove-nils-empty-maps-seqs
; (-> collection
; (m-spec/update-version :collection "1.18.1")
; (as-> rc
; (let [sct (get-in rc [:AssociatedDOIs :Type])]
; (if (or (= "IsPreviousVersionOf" sct)
; (= "IsNewVersionOf" sct))
; (update-in rc [:AssociatedDOIs] dissoc :Type)
; rc)))
; ;; Change CollectionProgress enum to NOT APPLICABLE if its value is PREPRINT, INREVIEW, or SUPERSEDED
; (let [CollectionProgress (:CollectionProgress collection)]
; (if (or (= "PREPRINT" CollectionProgress) (= "INREVIEW" CollectionProgress) (= "SUPERSEDED" CollectionProgress))
; (assoc collection :CollectionProgress "NOT APPLICABLE")
; collection)))))
(m-spec/update-version collection :collection "1.18.2")
;; Change CollectionProgress to "NOT PROVIDED" if its value is "NOT APPLICABLE"
(let [CollectionProgress (:CollectionProgress collection)]
(if (or (= "NOT APPLICABLE" CollectionProgress))
(assoc collection :CollectionProgress "NOT PROVIDED")
collection)))

(defmethod interface/migrate-umm-version [:collection "1.18.2" "1.18.1"]
[_context collection & _]
;; Migrating down version 1.18.2 to 1.18.1
;; Remove AssociatedDOIs/Type enums: IsPreviousVersionOf and IsNewVersionOf
;; Remove PREPRINT, INREVIEW, and SUPERSEDED enums to CollectionProgress
;; Add back in NOT APPLICABLE enum in CollectionProgress
(m-spec/update-version collection :collection "1.18.1")
;; Change AssociatedDOIs/Type to 'Related Dataset' if its enum value is IsPreviousVersionOf and IsNewVersionOf
;; TODO
;(as-> rc
; (let [sct (get-in rc [:AssociatedDOIs :Type])]
; (if (or (= "IsPreviousVersionOf" sct)
; (= "IsNewVersionOf" sct))
; (update-in rc [:AssociatedDOIs] dissoc :Type)
; rc)))
;; Change CollectionProgress enum to COMPLETED if its enum value is PREPRINT, INREVIEW, or SUPERSEDED
(let [CollectionProgress (:CollectionProgress collection)]
(if (or (= "PREPRINT" CollectionProgress)
(= "INREVIEW" CollectionProgress)
(= "SUPERSEDED" CollectionProgress))
(assoc collection :CollectionProgress "COMPLETED")
collection)))

0 comments on commit be169a6

Please sign in to comment.