@rr0/cms
Version:
RR0 Content Management System (CMS)
40 lines (39 loc) • 1.45 kB
JavaScript
import assert from "assert";
import { Level2Date as EdtfDate } from "@rr0/time";
import { OrganizationPlace } from "../../../place/OrganizationPlace.js";
/**
* Maps FUFORA cases to RR0 cases.
*/
export class FuforaCaseSummaryRR0Mapper {
constructor(cityService, baseUrl, copyright, authors) {
this.cityService = cityService;
this.baseUrl = baseUrl;
this.copyright = copyright;
this.authors = authors;
}
map(context, sourceCase, sourceTime) {
const id = sourceCase.id;
const source = {
previousSourceRefs: [], events: [],
url: sourceCase.url, title: "cas n° " + id, authors: this.authors,
publication: { publisher: this.copyright, time: EdtfDate.fromDate(sourceTime) }
};
const cityName = sourceCase.city || sourceCase.sightingPlace;
const city = this.cityService.find(context, cityName, undefined);
assert.ok(city, `Could not find city "${cityName}" for case ${id} at ${sourceCase.dateTime}`);
return {
type: "event",
eventType: "sighting",
events: [],
id,
time: sourceCase.dateTime,
place: new OrganizationPlace(city),
description: this.getDescription(sourceCase),
sources: [source]
};
}
getDescription(c) {
const description = ["observation"];
return description.join(", ");
}
}