diff --git a/time/datasource/CaseSource.ts b/time/datasource/CaseSource.ts index 491d16fd64..75e099c6a8 100644 --- a/time/datasource/CaseSource.ts +++ b/time/datasource/CaseSource.ts @@ -5,11 +5,12 @@ import { RR0SsgContext } from "../../RR0SsgContext" */ export interface CaseSource { /** - * @param author The datasource author to mention as a source. - * @param copyright The datasource name/copyright to mention as a source. - * @protected + * @member {string[]} authors The datasource authors to mention as a source. + */ + readonly authors: string[] + /** + * @member {string} authors The datasource name to mention as a source. */ - readonly author: string readonly copyright: string /** diff --git a/time/datasource/ChronologyReplacer.ts b/time/datasource/ChronologyReplacer.ts index 7144d37405..85ab50edf4 100644 --- a/time/datasource/ChronologyReplacer.ts +++ b/time/datasource/ChronologyReplacer.ts @@ -39,8 +39,10 @@ export class ChronologyReplacer implements DomReplacement StringUtil.removeAccents(author).replace(specialChars, "")).join("-") const fileName = path.join(path.dirname(context.inputFile.name), - StringUtil.removeAccents(datasource.author).replace(specialChars, "") + "_" + authorsStr + "_" + StringUtil.removeAccents(datasource.copyright).replace(specialChars, "") + ".csv") fs.writeFileSync(fileName, csvContents, {encoding: "utf-8"}) } diff --git a/time/datasource/DatasourceTestCase.ts b/time/datasource/DatasourceTestCase.ts index aa89610eea..a6c7a60c9a 100644 --- a/time/datasource/DatasourceTestCase.ts +++ b/time/datasource/DatasourceTestCase.ts @@ -36,7 +36,8 @@ export class DatasourceTestCase { if (sources?.length > 0) { const source = sources[0] const publicationStr = source.publication ? `, ${source.publication.time}` : "" - const sourceStr = ` ${datasource.author}: ${authorStr}: cas n° ${caseNumber}, ${datasource.copyright}${publicationStr}` expect(item.innerHTML).toBe( diff --git a/time/datasource/acufo/AcufoDatasource.ts b/time/datasource/acufo/AcufoDatasource.ts index c2090dd56c..15942cc3d3 100644 --- a/time/datasource/acufo/AcufoDatasource.ts +++ b/time/datasource/acufo/AcufoDatasource.ts @@ -15,7 +15,7 @@ interface QueryParameters { } export class AcufoDatasource extends HttpSource implements CaseSource { - readonly author = "Gross, Patrick" + readonly authors = ["Gross, Patrick"] readonly copyright = "ACUFO/ALSACAT (Les ovnis vus de près)" constructor(readonly baseUrl = "https://ufologie.patrickgross.org", readonly searchPath = "alsacat") { diff --git a/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.ts b/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.ts index 947e8a20c4..717534b92d 100644 --- a/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.ts +++ b/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryMapper.ts @@ -11,7 +11,7 @@ import { BaseOvniFranceCase } from "./BaseOvniFranceCase" export class BaseOvniFranceCaseSummaryMapper implements CaseMapper { constructor( - readonly baseUrl: string, readonly copyright: string, readonly author: string + readonly baseUrl: string, readonly copyright: string, readonly authors: string ) { } diff --git a/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.test.ts b/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.test.ts index 6e84e4e4d0..68e6ea179a 100644 --- a/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.test.ts +++ b/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.test.ts @@ -13,7 +13,7 @@ import { chambonSurVoueize23 } from "../../../org/eu/fr/region/naq/23/chambon/Ch function expectedSource(datasource: BaseOvniFranceHttpDatasource, dataDate: Date, caseNumber: number) { const url = new URL(datasource.searchPath + "?typlist=20&page=0&numobs=" + caseNumber, datasource.baseUrl) - return new OnlineSource(url, "cas n° " + caseNumber, [datasource.author], + return new OnlineSource(url, "cas n° " + caseNumber, datasource.authors, {publisher: datasource.copyright, time: dataDate.toLocaleString()}) } diff --git a/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.ts b/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.ts index d54554bf65..b46f1e1896 100644 --- a/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.ts +++ b/time/datasource/baseovnifrance/BaseOvniFranceCaseSummaryRR0Mapper.ts @@ -14,12 +14,12 @@ export class BaseOvniFranceCaseSummaryRR0Mapper implements CaseMapper csvMapper.map(context, csvCase, dataDate)) .sort(baseOvniFranceSortComparator) diff --git a/time/datasource/baseovnifrance/BaseOvniFranceDatasource.ts b/time/datasource/baseovnifrance/BaseOvniFranceDatasource.ts index 0a43d1f08d..d39fb18526 100644 --- a/time/datasource/baseovnifrance/BaseOvniFranceDatasource.ts +++ b/time/datasource/baseovnifrance/BaseOvniFranceDatasource.ts @@ -1,7 +1,10 @@ import { BaseOvniFranceCaseSummary } from "./BaseOvniFranceCaseSummary" import { CaseSource } from "../CaseSource" +import { RR0SsgContext } from "../../../RR0SsgContext" export abstract class BaseOvniFranceDatasource implements CaseSource { - readonly author = "Chastan, Luc" + readonly authors = ["Chastan, Luc"] readonly copyright = "Base OVNI France" + + abstract getAll(context: RR0SsgContext): Promise } diff --git a/time/datasource/baseovnifrance/BaseOvniFranceRR0Mapping.ts b/time/datasource/baseovnifrance/BaseOvniFranceRR0Mapping.ts index 0f3426e452..7c26a17967 100644 --- a/time/datasource/baseovnifrance/BaseOvniFranceRR0Mapping.ts +++ b/time/datasource/baseovnifrance/BaseOvniFranceRR0Mapping.ts @@ -9,7 +9,7 @@ export const baseOvniFranceDatasource = new BaseOvniFranceHttpDatasource() export const baseOvniFranceRR0Mapper = new BaseOvniFranceCaseSummaryRR0Mapper( departmentService, cityService, - baseOvniFranceDatasource.baseUrl, baseOvniFranceDatasource.copyright, baseOvniFranceDatasource.author + baseOvniFranceDatasource.baseUrl, baseOvniFranceDatasource.copyright, baseOvniFranceDatasource.authors ) export const baseOvniFranceRR0Mapping: RR0CaseMapping = { diff --git a/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.ts b/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.ts index dcb5e7dc0e..e7da9ef295 100644 --- a/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.ts +++ b/time/datasource/fufora/FuforaCaseSummaryRR0Mapper.ts @@ -13,12 +13,12 @@ export class FuforaCaseSummaryRR0Mapper implements CaseMapper { - readonly author = "FUFORA" + readonly authors = ["FUFORA"] readonly copyright = "Base de données observationnelle" + + abstract getAll(context: RR0SsgContext): Promise } diff --git a/time/datasource/fufora/FuforaRR0Mapping.ts b/time/datasource/fufora/FuforaRR0Mapping.ts index e7d8e95e1a..f287aad0d8 100644 --- a/time/datasource/fufora/FuforaRR0Mapping.ts +++ b/time/datasource/fufora/FuforaRR0Mapping.ts @@ -7,7 +7,7 @@ export const fuforaDatasource = new FuforaHttpDatasource() export const fuforaRR0Mapper = new FuforaCaseSummaryRR0Mapper(cityService, fuforaDatasource.baseUrl, fuforaDatasource.copyright, - fuforaDatasource.author) + fuforaDatasource.authors) export const fuforaRR0Mapping = {datasource: fuforaDatasource, mapper: fuforaRR0Mapper} diff --git a/time/datasource/geipan/GeipanCaseSummaryMapper.ts b/time/datasource/geipan/GeipanCaseSummaryMapper.ts index cd9fc9173a..d341fc3a1e 100644 --- a/time/datasource/geipan/GeipanCaseSummaryMapper.ts +++ b/time/datasource/geipan/GeipanCaseSummaryMapper.ts @@ -13,7 +13,7 @@ import { CountryCode } from "../../../org/country/CountryCode" */ export class GeipanCaseSummaryMapper implements CaseMapper { - constructor(readonly baseUrl: string, readonly copyright: string, readonly author: string) { + constructor(readonly baseUrl: string, readonly copyright: string, readonly authors: string[]) { } map(context: RR0SsgContext, csvCase: GeipanCase, sourceTime: Date): GeipanCaseSummary { diff --git a/time/datasource/geipan/GeipanCaseSummaryRR0Mapper.ts b/time/datasource/geipan/GeipanCaseSummaryRR0Mapper.ts index dda766b8fc..aa09c2e7c3 100644 --- a/time/datasource/geipan/GeipanCaseSummaryRR0Mapper.ts +++ b/time/datasource/geipan/GeipanCaseSummaryRR0Mapper.ts @@ -17,7 +17,7 @@ export class GeipanCaseSummaryRR0Mapper implements CaseMapper { const exportMapper = new CsvMapper(";") const data = fs.readFileSync("time/datasource/geipan/export_cas_pub_20210219111412.csv", {encoding: "latin1"}) const csvMapper = new GeipanCaseSummaryMapper(geipanHttpDatasource.baseUrl, geipanHttpDatasource.searchPath, - geipanHttpDatasource.author) + geipanHttpDatasource.authors) const cases = exportMapper.read(context, data).map(csvCase => csvMapper.map(context, csvCase, dataDate)) expect(cases.length).toEqual(2768) const expected1 = geipanTestCaseSummaries[0] diff --git a/time/datasource/geipan/GeipanDatasource.ts b/time/datasource/geipan/GeipanDatasource.ts index b1e1a4e3b2..ea4da9abd9 100644 --- a/time/datasource/geipan/GeipanDatasource.ts +++ b/time/datasource/geipan/GeipanDatasource.ts @@ -1,4 +1,10 @@ -export abstract class GeipanDatasource { - readonly author = "GEIPAN" +import { CaseSource } from "../CaseSource" +import { GeipanCaseSummary } from "./GeipanCaseSummary" +import { RR0SsgContext } from "../../../RR0SsgContext" + +export abstract class GeipanDatasource implements CaseSource { + readonly authors = ["GEIPAN"] readonly copyright = "Catalogue de cas" + + abstract getAll(context: RR0SsgContext): Promise } diff --git a/time/datasource/geipan/GeipanFileDatasource.ts b/time/datasource/geipan/GeipanFileDatasource.ts index 9ca76961a2..e5add67276 100644 --- a/time/datasource/geipan/GeipanFileDatasource.ts +++ b/time/datasource/geipan/GeipanFileDatasource.ts @@ -36,7 +36,7 @@ export class GeipanFileDatasource extends GeipanDatasource implements CaseSource const exportMapper = new CsvMapper(";") const file = SsgFile.read(context, this.fileName, "latin1") const csvMapper = new GeipanCaseSummaryMapper(geipanHttpDatasource.baseUrl, geipanHttpDatasource.searchPath, - geipanHttpDatasource.author) + geipanHttpDatasource.authors) return exportMapper.read(context, file.contents).map(csvCase => csvMapper.map(context, csvCase, file.lastModified)) } } diff --git a/time/datasource/geipan/GeipanHttpDatasource.ts b/time/datasource/geipan/GeipanHttpDatasource.ts index e16c94f014..2eabfc1dd4 100644 --- a/time/datasource/geipan/GeipanHttpDatasource.ts +++ b/time/datasource/geipan/GeipanHttpDatasource.ts @@ -6,7 +6,6 @@ import { GeipanCaseSummary } from "./GeipanCaseSummary" import { TimeContext } from "../../TimeContext" import { ObjectUtil } from "../../../util/ObjectUtil" import assert from "assert" -import { CaseSource } from "../CaseSource" import { GeipanCaseClassification, GeipanCaseClassification_calc, @@ -38,7 +37,7 @@ interface QueryParameters { field_agregation_index_value: string } -export class GeipanHttpDatasource extends GeipanDatasource implements CaseSource { +export class GeipanHttpDatasource extends GeipanDatasource { protected static readonly dateFormat = /(.+?)\s*\(([\d-AB]+)\)\s+(\d+)(?:.(\d+)(?:.(\d+))?)?/ protected readonly http = new HttpSource() diff --git a/time/datasource/geipan/GeipanRR0Mapping.ts b/time/datasource/geipan/GeipanRR0Mapping.ts index 4dfdaebf9c..3e54f92949 100644 --- a/time/datasource/geipan/GeipanRR0Mapping.ts +++ b/time/datasource/geipan/GeipanRR0Mapping.ts @@ -4,13 +4,14 @@ import { GeipanCaseSummary } from "./GeipanCaseSummary" import { GeipanCaseSummaryRR0Mapper } from "./GeipanCaseSummaryRR0Mapper" import { departmentService } from "../../../org/country/region/department/DepartmentService" import { GeipanFileDatasource } from "./GeipanFileDatasource" +import { regionService } from "../../../org/country/region/RegionService" export const geipanHttpDatasource = new GeipanHttpDatasource("https://geipan.fr", "fr/recherche/cas") export const geipanFileDatasource = new GeipanFileDatasource("time/datasource/geipan/export_cas_pub_20210219111412.csv") export const geipanRR0Mapper = new GeipanCaseSummaryRR0Mapper( - cityService, departmentService, - geipanHttpDatasource.baseUrl, geipanHttpDatasource.copyright, geipanHttpDatasource.author + cityService, departmentService, regionService, + geipanHttpDatasource.baseUrl, geipanHttpDatasource.copyright, geipanHttpDatasource.authors ) export const geipanRR0Mapping = {datasource: geipanFileDatasource, mapper: geipanRR0Mapper} diff --git a/time/datasource/nuforc/NuforcDatasource.ts b/time/datasource/nuforc/NuforcDatasource.ts index 28f3681b75..e9b953e973 100644 --- a/time/datasource/nuforc/NuforcDatasource.ts +++ b/time/datasource/nuforc/NuforcDatasource.ts @@ -1,7 +1,10 @@ import { NuforcCaseSummary } from "./NuforcCaseSummary" import { CaseSource } from "../CaseSource" +import { RR0SsgContext } from "../../../RR0SsgContext" -export abstract class NuforcHttpDatasource implements CaseSource { - readonly author = "NUFORC" +export abstract class NuforcDatasource implements CaseSource { + readonly authors = ["NUFORC"] readonly copyright = "Online Database" + + abstract getAll(context: RR0SsgContext): Promise } diff --git a/time/datasource/nuforc/NuforcHttpDatasource.ts b/time/datasource/nuforc/NuforcHttpDatasource.ts index 06e7be04c0..7ece35e0e6 100644 --- a/time/datasource/nuforc/NuforcHttpDatasource.ts +++ b/time/datasource/nuforc/NuforcHttpDatasource.ts @@ -9,6 +9,7 @@ import assert from "assert" import { TimeContext } from "../../TimeContext" import { NuforcCountry } from "./NuforcCountry" import { NuforcShape } from "./NuforcShape" +import { NuforcDatasource } from "./NuforcDatasource" interface QueryParameters { id: string diff --git a/time/datasource/nuforc/NuforcRR0Mapper.test.ts b/time/datasource/nuforc/NuforcRR0Mapper.test.ts index 1ac40cc952..3fdff78a27 100644 --- a/time/datasource/nuforc/NuforcRR0Mapper.test.ts +++ b/time/datasource/nuforc/NuforcRR0Mapper.test.ts @@ -16,7 +16,7 @@ import { bonneyLake } from "../../../org/us/region/wa/pierce/bonneylake/BonneyLa function expectedSource(datasource: NuforcHttpDatasource, dataDate: Date, caseNumber: number) { const url = new URL("sighting/?id=" + caseNumber, datasource.baseUrl) - return new OnlineSource(url, "cas n° " + caseNumber, [datasource.author], + return new OnlineSource(url, "cas n° " + caseNumber, datasource.authors, {publisher: datasource.copyright, time: dataDate.toLocaleString()}) } diff --git a/time/datasource/nuforc/NuforcRR0Mapper.ts b/time/datasource/nuforc/NuforcRR0Mapper.ts index 7f7356bf06..c6055a4088 100644 --- a/time/datasource/nuforc/NuforcRR0Mapper.ts +++ b/time/datasource/nuforc/NuforcRR0Mapper.ts @@ -3,7 +3,6 @@ import { NuforcCaseSummary } from "./NuforcCaseSummary" import { HtmlRR0SsgContext } from "../../../RR0SsgContext" import { OnlineSource } from "../../../source/OnlineSource" import { CityService } from "../../../org/country/region/department/city/CityService" -import { NamedPlace, RR0CaseSummary } from "../../RR0CaseSummary" import assert from "assert" import { CountryService } from "../../../org/country/CountryService" import { australia } from "../../../org/au/Australia" @@ -23,6 +22,7 @@ import { uk } from "../../../org/uk/Uk" import { colombia } from "../../../org/co/Colombia" import { NuforcShape } from "./NuforcShape" import { germany } from "../../../org/eu/de/Germany" +import { NamedPlace, RR0CaseSummary } from "../rr0/RR0CaseSummary" export class NuforcRR0Mapper implements CaseMapper { @@ -52,8 +52,7 @@ export class NuforcRR0Mapper implements CaseMapper { - constructor( - readonly baseUrl: string, readonly copyright: string, readonly author: string - ) { + constructor(readonly baseUrl: string, readonly copyright: string, readonly authors: string[]) { } map(context: HtmlRR0SsgContext, sourceCase: RR0CaseSummary, sourceTime: Date): RR0CaseSummary { diff --git a/time/datasource/rr0/RR0Datasource.ts b/time/datasource/rr0/RR0Datasource.ts index 6db625c59f..cb6ffa55e5 100644 --- a/time/datasource/rr0/RR0Datasource.ts +++ b/time/datasource/rr0/RR0Datasource.ts @@ -1,8 +1,10 @@ import { CaseSource } from "../CaseSource" -import { RR0CaseSummary } from "../../RR0CaseSummary" +import { RR0CaseSummary } from "./RR0CaseSummary" +import { RR0SsgContext } from "../../../RR0SsgContext" export abstract class RR0Datasource implements CaseSource { - readonly author = "Jérôme Beau" + readonly authors = ["Jérôme Beau"] readonly copyright = "RR0" + abstract getAll(context: RR0SsgContext): Promise } diff --git a/time/datasource/rr0/RR0HttpDatasource.ts b/time/datasource/rr0/RR0HttpDatasource.ts index e52846f6fa..e95e99eb6d 100644 --- a/time/datasource/rr0/RR0HttpDatasource.ts +++ b/time/datasource/rr0/RR0HttpDatasource.ts @@ -80,7 +80,7 @@ export class RR0HttpDatasource extends RR0Datasource { const sourceContent = sourceId.querySelector(".source-contents") const title = this.getDescription(sourceContent) sourceId.remove() - sources.push(new Source(title)) + sources.push(new Source(title, this.authors)) } return sources } @@ -115,7 +115,7 @@ export class RR0HttpDatasource extends RR0Datasource { return {name, place} } - protected getDescription(el: HTMLElement): string { + protected getDescription(el: Element): string { const notes = el.querySelectorAll(".note-id") for (const note of notes) { const noteContents = note.querySelector(".note-contents") diff --git a/time/datasource/rr0/RR0Mapping.ts b/time/datasource/rr0/RR0Mapping.ts index 8cff44c6da..f42295e0ac 100644 --- a/time/datasource/rr0/RR0Mapping.ts +++ b/time/datasource/rr0/RR0Mapping.ts @@ -1,13 +1,10 @@ -import { RR0HttpDatasource } from "./Rr0HttpDatasource" -import { cityService } from "../../../org/Cities" import { RR0CaseSummary } from "./RR0CaseSummary" import { RR0CaseSummaryMapper } from "./RR0CaseSummaryMapper" +import { RR0HttpDatasource } from "./RR0HttpDatasource" export const rr0Datasource = new RR0HttpDatasource() -export const rr0Mapper = new RR0CaseSummaryMapper(cityService, rr0Datasource.baseUrl, - rr0Datasource.copyright, - rr0Datasource.author) +export const rr0Mapper = new RR0CaseSummaryMapper(rr0Datasource.baseUrl, rr0Datasource.copyright, rr0Datasource.authors) export const rr0Mapping = {datasource: rr0Datasource, mapper: rr0Mapper} diff --git a/time/datasource/urecat/UrecatDatasource.ts b/time/datasource/urecat/UrecatDatasource.ts index 67d9edeca2..efd5731925 100644 --- a/time/datasource/urecat/UrecatDatasource.ts +++ b/time/datasource/urecat/UrecatDatasource.ts @@ -1,7 +1,10 @@ import { UrecatCase } from "./UrecatCase" import { CaseSource } from "../CaseSource" +import { RR0SsgContext } from "../../../RR0SsgContext" export abstract class UrecatDatasource implements CaseSource { - readonly author = "Gross, Patrick" + readonly authors = ["Gross, Patrick"] readonly copyright = "URECAT (Les ovnis vus de près)" + + abstract getAll(context: RR0SsgContext): Promise } diff --git a/time/datasource/urecat/UrecatRR0Mapper.ts b/time/datasource/urecat/UrecatRR0Mapper.ts index e2dd80cd2a..de7a40f97b 100644 --- a/time/datasource/urecat/UrecatRR0Mapper.ts +++ b/time/datasource/urecat/UrecatRR0Mapper.ts @@ -3,16 +3,15 @@ import { UrecatCase } from "./UrecatCase" import { HtmlRR0SsgContext } from "../../../RR0SsgContext" import { OnlineSource } from "../../../source/OnlineSource" import { CityService } from "../../../org/country/region/department/city/CityService" -import { NamedPlace, RR0CaseSummary } from "../../RR0CaseSummary" import assert from "assert" import { CountryService } from "../../../org/country/CountryService" +import { NamedPlace, RR0CaseSummary } from "../rr0/RR0CaseSummary" export class UrecatRR0Mapper implements CaseMapper { constructor( protected cityService: CityService, protected countryService: CountryService, - readonly baseUrl: string, - readonly copyright: string, readonly author: string + readonly baseUrl: string, readonly copyright: string, readonly authors: string[] ) { } @@ -23,7 +22,7 @@ export class UrecatRR0Mapper implements CaseMapper