@rr0/cms
Version:
RR0 Content Management System (CMS)
50 lines (49 loc) • 1.76 kB
JavaScript
import assert from "assert";
import { Level2Date as EdtfDate } from "@rr0/time";
import { OrganizationPlace } from "../../../place/OrganizationPlace.js";
/**
* Maps SCEAU cases to RR0 cases.
*/
export class SceauCaseSummaryRR0Mapper {
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: new EdtfDate({
year: sourceTime.getFullYear(),
month: sourceTime.getMonth(),
day: sourceTime.getDate(),
hour: sourceTime.getHours(),
minute: sourceTime.getSeconds()
})
}
};
const cityName = sourceCase.ville;
const city = this.cityService.find(context, cityName, undefined);
assert.ok(city, `Could not find city "${cityName}" for case ${id} at ${sourceCase.dateCas}`);
const place = new OrganizationPlace(city);
return {
type: "event",
eventType: "sighting",
events: [],
id,
time: EdtfDate.fromString(sourceCase.dateCas),
place,
description: this.getDescription(sourceCase),
sources: [source]
};
}
getDescription(c) {
const description = ["observation"];
return description.join(", ");
}
}