Skip to content

Commit

Permalink
Simplify course-program-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemare committed Jan 29, 2025
1 parent c2ce7f2 commit 3cbf641
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions src/nl/surf/eduhub_rio_mapper/rio/aangeboden_opleiding.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
:eersteInstroomDatum [:firstStartDate false]
:onderwijsaanbiedercode [:educationOffererCode true]
:onderwijslocatiecode [:educationLocationCode true]
:opleidingseenheidSleutel [::rio/opleidingscode false]
:toestemmingDeelnameSTAP [:consentParticipationSTAP true]
:voertaal [:teachingLanguage false]})

Expand Down Expand Up @@ -144,36 +143,35 @@
:validTo (:validTo %))
timelineOverrides)]
(fn [k] {:pre [(keyword? k)]}
(if (= k :opleidingseenheidSleutel)
opleidingscode
(if-let [[translation consumer] (mapping-course-program->aangeboden-opleiding k)]
(if (ooapi-mapping? (name k))
(rio-helper/ooapi-mapping (name k) (translation (if consumer rio-consumer course-program)))
(translation (if consumer rio-consumer course-program)))
(case k
;; Required field. If found in the resolve phase, will be added to the entity under the rioCode key,
;; otherwise use the eigen sleutel value (an UUID).
:aangebodenOpleidingCode (or rioCode id)
;; See opleidingseenheid for explanation of timelineOverrides and periods.
:begindatum (first (sort (conj (map :validFrom timelineOverrides) validFrom)))
:einddatum (last (sort (conj (map :validTo timelineOverrides) validTo)))
:ISCED (rio-helper/narrow-isced fieldsOfStudy)
:afwijkendeOpleidingsduur (when duration-map {:opleidingsduurEenheid (:eenheid duration-map)
:opleidingsduurOmvang (:omvang duration-map)})
:niveau (rio-helper/level-sector-mapping level sector)
:vorm (rio-helper/ooapi-mapping "vorm" modeOfStudy)

:cohorten (mapv #(course-program-offering-adapter %)
offerings)

;; See opleidingseenheid for explanation of timelineOverrides and periods.
:periodes (->> (conj periods course-program)
(mapv #(course-program-timeline-override-adapter %)))

;; These are in the xsd but ignored by us
:eigenAangebodenOpleidingSleutel (some-> id str/lower-case) ;; resolve to the ooapi id
:opleidingserkenningSleutel nil
:voVakerkenningSleutel nil))))))
(if-let [[translation consumer] (mapping-course-program->aangeboden-opleiding k)]
(if (ooapi-mapping? (name k))
(rio-helper/ooapi-mapping (name k) (translation (if consumer rio-consumer course-program)))
(translation (if consumer rio-consumer course-program)))
(case k
:opleidingseenheidSleutel opleidingscode
;; Required field. If found in the resolve phase, will be added to the entity under the rioCode key,
;; otherwise use the eigen sleutel value (an UUID).
:aangebodenOpleidingCode (or rioCode id)
;; See opleidingseenheid for explanation of timelineOverrides and periods.
:begindatum (first (sort (conj (map :validFrom timelineOverrides) validFrom)))
:einddatum (last (sort (conj (map :validTo timelineOverrides) validTo)))
:ISCED (rio-helper/narrow-isced fieldsOfStudy)
:afwijkendeOpleidingsduur (when duration-map {:opleidingsduurEenheid (:eenheid duration-map)
:opleidingsduurOmvang (:omvang duration-map)})
:niveau (rio-helper/level-sector-mapping level sector)
:vorm (rio-helper/ooapi-mapping "vorm" modeOfStudy)

:cohorten (mapv #(course-program-offering-adapter %)
offerings)

;; See opleidingseenheid for explanation of timelineOverrides and periods.
:periodes (->> (conj periods course-program)
(mapv #(course-program-timeline-override-adapter %)))

;; These are in the xsd but ignored by us
:eigenAangebodenOpleidingSleutel (some-> id str/lower-case) ;; resolve to the ooapi id
:opleidingserkenningSleutel nil
:voVakerkenningSleutel nil)))))

(defn ->aangeboden-opleiding
"Converts a program or course into the right kind of AangebodenOpleiding."
Expand Down

0 comments on commit 3cbf641

Please sign in to comment.