UNPKG

@rr0/cms

Version:

RR0 Content Management System (CMS)

54 lines (53 loc) 1.99 kB
import assert from "assert"; import { Level2Date as EdtfDate } from "@rr0/time"; import { OrganizationPlace } from "../../../place/OrganizationPlace.js"; /** * Maps a Base OVNI France case to a RR0 case. */ export class BaseOvniFranceCaseSummaryRR0Mapper { constructor(depService, cityService, baseUrl, copyright, authors) { this.depService = depService; this.cityService = cityService; this.baseUrl = baseUrl; this.copyright = copyright; this.authors = authors; } map(context, sourceCase, sourceTime) { const caseSource = { previousSourceRefs: [], events: [], url: sourceCase.url, title: "cas n° " + sourceCase.id, authors: this.authors, publication: { publisher: this.copyright, time: EdtfDate.fromDate(sourceTime) } }; const depCode = sourceCase.depCode; const dep = this.depService.getById(depCode, undefined); assert.ok(dep, `Could not find department "${depCode}"`); const placeName = sourceCase.city; const city = this.cityService.find(context, placeName, dep); assert.ok(city, `Could not find city of name "${placeName}" in department of code "${dep.id}"`); return { type: "event", eventType: "sighting", events: [], time: sourceCase.time, place: new OrganizationPlace(city), description: this.getDescription(sourceCase), sources: [caseSource] }; } getDescription(c) { const description = ["observation"]; if (c.landing) { description.push("avec atterrissage"); } if (c.entities) { description.push("avec entités"); } if (c.physicalEffect) { description.push("avec effet physique"); } if (c.witnessEffect) { description.push("avec effet sur témoin"); } return description.join(", "); } }