@rr0/cms
Version:
RR0 Content Management System (CMS)
41 lines (40 loc) • 1.54 kB
JavaScript
import assert from "assert";
import { Level2Date as EdtfDate } from "@rr0/time";
import { OrganizationPlace } from "../../../place/OrganizationPlace.js";
export class UfoSearchCaseRR0Mapper {
constructor(cityService, baseUrl, copyright, authors) {
this.cityService = cityService;
this.baseUrl = baseUrl;
this.copyright = copyright;
this.authors = authors;
}
getDescription(c) {
const description = ["observation"];
return description.join(" ");
}
map(context, sourceCase, sourceTime) {
const authors = this.authors;
const url = sourceCase.url;
const title = "cas n° " + sourceCase.id;
const publication = { publisher: this.copyright, time: EdtfDate.fromDate(sourceTime) };
const caseSource = { url, title, authors, publication, events: [], previousSourceRefs: [] };
const placeName = sourceCase.location;
const place = placeName ? this.getPlace(context, placeName) : undefined;
return {
id: sourceCase.id,
type: "event",
eventType: "sighting",
url,
events: [],
time: sourceCase.time,
place,
description: this.getDescription(sourceCase),
sources: [caseSource]
};
}
getPlace(context, placeName) {
const org = this.cityService.find(context, placeName, undefined);
assert.ok(org, `Could not find place "${placeName}"`);
return new OrganizationPlace(org);
}
}