From 2dfb64bafd782b26c67a14d18ec3deaba478994a Mon Sep 17 00:00:00 2001 From: Rainer Killinger Date: Thu, 12 Aug 2021 12:41:03 +0000 Subject: [PATCH] refactor: remodel entities for library search and results --- src/meta.ts | 64 ++++++++----- src/things/abstract/creative-work.ts | 57 +++++++++-- src/things/abstract/thing.ts | 37 ++++++-- src/things/article.ts | 60 ++++++++---- src/things/book.ts | 120 +++++++++++++++++------ src/things/message.ts | 30 +++++- src/things/periodical.ts | 137 +++++++++++++++++++++++++++ src/things/person.ts | 4 +- src/things/publication-event.ts | 105 ++++++++++++++++++++ test/resources/Article.1.json | 2 +- test/resources/Article.2.json | 2 +- test/resources/Article.3.json | 36 +++++++ test/resources/Article.4.json | 36 +++++++ test/resources/Book.1.json | 9 +- test/resources/Book.2.json | 7 +- test/resources/Book.3.json | 40 ++++++++ test/resources/Book.4.json | 43 +++++++++ test/resources/Diff.1.json | 3 + test/resources/Diff.2.json | 3 + test/resources/Message.1.json | 3 + test/resources/Message.2.json | 3 + test/resources/Periodical.1.json | 35 +++++++ test/resources/Periodical.2.json | 32 +++++++ test/resources/Video.1.json | 2 +- test/resources/Video.2.json | 2 +- test/type.spec.ts | 24 +++++ 26 files changed, 791 insertions(+), 105 deletions(-) create mode 100644 src/things/periodical.ts create mode 100644 src/things/publication-event.ts create mode 100644 test/resources/Article.3.json create mode 100644 test/resources/Article.4.json create mode 100644 test/resources/Book.3.json create mode 100644 test/resources/Book.4.json create mode 100644 test/resources/Periodical.1.json create mode 100644 test/resources/Periodical.2.json diff --git a/src/meta.ts b/src/meta.ts index ef157104..28567046 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 StApps + * Copyright (C) 2019-2021 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -27,8 +27,14 @@ import {SCFavorite, SCFavoriteMeta, SCFavoriteWithoutReferences} from './things/ import {SCFloor, SCFloorMeta, SCFloorWithoutReferences} from './things/floor'; import {SCMessage, SCMessageMeta, SCMessageWithoutReferences} from './things/message'; import {SCOrganization, SCOrganizationMeta, SCOrganizationWithoutReferences} from './things/organization'; +import {SCPeriodical, SCPeriodicalMeta, SCPeriodicalWithoutReferences} from './things/periodical'; import {SCPerson, SCPersonMeta, SCPersonWithoutReferences} from './things/person'; import {SCPointOfInterest, SCPointOfInterestMeta, SCPointOfInterestWithoutReferences} from './things/point-of-interest'; +import { + SCPublicationEvent, + SCPublicationEventMeta, + SCPublicationEventWithoutReferences, +} from './things/publication-event'; import {SCRoom, SCRoomMeta, SCRoomWithoutReferences} from './things/room'; import {SCSemester, SCSemesterMeta, SCSemesterWithoutReferences} from './things/semester'; import {SCSetting, SCSettingMeta, SCSettingWithoutReferences} from './things/setting'; @@ -59,8 +65,10 @@ export const SCClasses: { [K in SCThingType]: object } = { 'floor': SCFloorMeta, 'message': SCMessageMeta, 'organization': SCOrganizationMeta, + 'periodical': SCPeriodicalMeta, 'person': SCPersonMeta, 'point of interest': SCPointOfInterestMeta, + 'publication event': SCPublicationEventMeta, 'room': SCRoomMeta, 'semester': SCSemesterMeta, 'setting': SCSettingMeta, @@ -85,8 +93,10 @@ export type SCIndexableThings = | SCFloor | SCMessage | SCOrganization + | SCPeriodical | SCPerson | SCPointOfInterest + | SCPublicationEvent | SCRoom | SCSemester | SCSportCourse @@ -126,18 +136,20 @@ export type SCAssociatedThingWithoutReferences = THING extends SCFloor ? SCFloorWithoutReferences : THING extends SCMessage ? SCMessageWithoutReferences : THING extends SCOrganization ? SCOrganizationWithoutReferences : - THING extends SCPerson ? SCPersonWithoutReferences : - THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences : - THING extends SCRoom ? SCRoomWithoutReferences : - THING extends SCSemester ? SCSemesterWithoutReferences : - THING extends SCSetting ? SCSettingWithoutReferences : - THING extends SCSportCourse ? SCSportCourseWithoutReferences : - THING extends SCStudyModule ? SCStudyModuleWithoutReferences : - THING extends SCTicket ? SCTicketWithoutReferences : - THING extends SCToDo ? SCToDoWithoutReferences : - THING extends SCTour ? SCTourWithoutReferences : - THING extends SCVideo ? SCVideoWithoutReferences : - never; + THING extends SCPeriodical ? SCPeriodicalWithoutReferences : + THING extends SCPerson ? SCPersonWithoutReferences : + THING extends SCPointOfInterest ? SCPointOfInterestWithoutReferences : + THING extends SCPublicationEvent ? SCPublicationEventWithoutReferences : + THING extends SCRoom ? SCRoomWithoutReferences : + THING extends SCSemester ? SCSemesterWithoutReferences : + THING extends SCSetting ? SCSettingWithoutReferences : + THING extends SCSportCourse ? SCSportCourseWithoutReferences : + THING extends SCStudyModule ? SCStudyModuleWithoutReferences : + THING extends SCTicket ? SCTicketWithoutReferences : + THING extends SCToDo ? SCToDoWithoutReferences : + THING extends SCTour ? SCTourWithoutReferences : + THING extends SCVideo ? SCVideoWithoutReferences : + never; /** * Thing for a thing without references @@ -157,15 +169,17 @@ export type SCAssociatedThing = THING extends SCFloorWithoutReferences ? SCFloor : THING extends SCMessageWithoutReferences ? SCMessage : THING extends SCOrganizationWithoutReferences ? SCOrganization : - THING extends SCPersonWithoutReferences ? SCPerson : - THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest : - THING extends SCRoomWithoutReferences ? SCRoom : - THING extends SCSemesterWithoutReferences ? SCSemester : - THING extends SCSettingWithoutReferences ? SCSetting : - THING extends SCSportCourseWithoutReferences ? SCSportCourse : - THING extends SCStudyModuleWithoutReferences ? SCStudyModule : - THING extends SCTicketWithoutReferences ? SCTicket : - THING extends SCToDoWithoutReferences ? SCToDo : - THING extends SCTourWithoutReferences ? SCTour : - THING extends SCVideoWithoutReferences ? SCVideo : - never; + THING extends SCPeriodicalWithoutReferences ? SCPeriodical : + THING extends SCPersonWithoutReferences ? SCPerson : + THING extends SCPointOfInterestWithoutReferences ? SCPointOfInterest : + THING extends SCPublicationEventWithoutReferences ? SCPublicationEvent : + THING extends SCRoomWithoutReferences ? SCRoom : + THING extends SCSemesterWithoutReferences ? SCSemester : + THING extends SCSettingWithoutReferences ? SCSetting : + THING extends SCSportCourseWithoutReferences ? SCSportCourse : + THING extends SCStudyModuleWithoutReferences ? SCStudyModule : + THING extends SCTicketWithoutReferences ? SCTicket : + THING extends SCToDoWithoutReferences ? SCToDo : + THING extends SCTourWithoutReferences ? SCTour : + THING extends SCVideoWithoutReferences ? SCVideo : + never; diff --git a/src/things/abstract/creative-work.ts b/src/things/abstract/creative-work.ts index b243dd21..65f07224 100644 --- a/src/things/abstract/creative-work.ts +++ b/src/things/abstract/creative-work.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 StApps + * Copyright (C) 2019-2021 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -16,11 +16,11 @@ import {SCLanguageCode, SCMetaTranslations, SCTranslations} from '../../general/ import {SCISO8601Date} from '../../general/time'; import {SCOrganizationWithoutReferences} from '../organization'; import {SCPersonWithoutReferences} from '../person'; +import {SCPublicationEventWithoutReferences} from '../publication-event'; import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing'; import { SCAcademicPriceGroup, - SCThingThatCanBeOffered, - SCThingThatCanBeOfferedMeta, + SCThingThatCanBeOffered, SCThingThatCanBeOfferedMeta, SCThingThatCanBeOfferedTranslatableProperties, SCThingThatCanBeOfferedWithoutReferences, } from './thing-that-can-be-offered'; @@ -38,11 +38,23 @@ export interface SCCreativeWorkWithoutReferences /** * Date the creative work was published - * - * @filterable */ datePublished?: SCISO8601Date; + /** + * Edition of a creative work (e.g. the book edition or edition of an article) + * + * @keyword + */ + edition?: string; + + /** + * Date (in text form) the creative work was published for the first time + * + * @keyword + */ + firstPublished?: string; + /** * Languages this creative work is written/recorded/... in * @@ -75,11 +87,26 @@ export interface SCCreativeWork */ authors?: SCPersonWithoutReferences[]; + /** + * A creative work to which the creative work belongs + */ + isPartOf?: SCCreativeWorkWithoutReferences; + + /** + * List of events at which the creative work was published + */ + publications?: SCPublicationEventWithoutReferences[]; + /** * List of publishers of the creative work */ publishers?: Array; + /** + * A text representing on organization on whose behalf the creator was working + */ + sourceOrganization?: string; + /** * Translated fields of the creative work */ @@ -111,22 +138,36 @@ export class SCCreativeWorkMeta de: { ...SCThingMeta.getInstance().fieldTranslations.de, ...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de, - authors: 'Autoren', + name: 'Titel', + authors: 'beteiligte Personen', availableLanguages: 'verfügbare Übersetzungen', datePublished: 'Veröffentlichungsdatum', + edition: 'Ausgabe', + firstPublished: 'erste Veröffentlichung', inLanguage: 'Inhaltssprache', + isPartOf: 'erschienen in', keywords: 'Schlagwörter', + lastPublished: 'aktuellste Veröffentlichung', publishers: 'Verleger', + publications: 'Veröffentlichungen', + sourceOrganization: 'Körperschaft', }, en: { ...SCThingMeta.getInstance().fieldTranslations.en, ...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en, - authors: 'authors', + name: 'title', + authors: 'involved persons', availableLanguages: 'available languages', datePublished: 'release date', + edition: 'edition', + firstPublished: 'first published', inLanguage: 'content language', + isPartOf: 'published in', keywords: 'keywords', + lastPublished: 'last published', publishers: 'publishers', + publications: 'publications', + sourceOrganization: 'corporation', }, }; @@ -136,7 +177,7 @@ export class SCCreativeWorkMeta fieldValueTranslations = { de: { ...SCThingMeta.getInstance().fieldValueTranslations.de, - ...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en, + ...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.de, }, en: { ...SCThingMeta.getInstance().fieldValueTranslations.en, diff --git a/src/things/abstract/thing.ts b/src/things/abstract/thing.ts index dd429389..fb0b427b 100644 --- a/src/things/abstract/thing.ts +++ b/src/things/abstract/thing.ts @@ -13,6 +13,7 @@ * this program. If not, see . */ import {SCMetaTranslations, SCTranslations} from '../../general/i18n'; +import {SCMap} from '../../general/map'; import {SCISO8601Date} from '../../general/time'; import {SCUuid} from '../../general/uuid'; import {SCOrganizationWithoutReferences} from '../organization'; @@ -25,6 +26,7 @@ export enum SCThingType { AcademicEvent = 'academic event', Article = 'article', Book = 'book', + Periodical = 'periodical', Building = 'building', Catalog = 'catalog', ContactPoint = 'contact point', @@ -38,6 +40,7 @@ export enum SCThingType { Organization = 'organization', Person = 'person', PointOfInterest = 'point of interest', + PublicationEvent = 'publication event', Room = 'room', Semester = 'semester', Setting = 'setting', @@ -60,6 +63,7 @@ export interface SCThingWithoutReferences { * @keyword */ alternateNames?: string[]; + /** * Description of the thing * @@ -67,12 +71,21 @@ export interface SCThingWithoutReferences { * @text */ description?: string; + + /** + * The identifier property represents any kind of additional identifier for any kind of SCThing + * + * E.g. GTIN codes, UUIDs, Database IDs etc. + */ + identifiers?: SCMap; + /** * URL of an image of the thing * * @keyword */ image?: string; + /** * Name of the thing * @@ -82,12 +95,21 @@ export interface SCThingWithoutReferences { * @text */ name: string; + + /** + * URL of a reference Web page that unambiguously indicates the item's identity + * + * E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website. + */ + sameAs?: string; + /** * Translations of specific values of the object * * Take precedence over "main" value for selected languages. */ translations?: SCTranslations; + /** * Type of the thing * @@ -96,16 +118,11 @@ export interface SCThingWithoutReferences { * @aggregatable global */ type: SCThingType; + /** * Universally unique identifier of the thing */ uid: SCUuid; - /** - * URL of the thing - * - * @filterable - */ - url?: string; } /** @@ -252,7 +269,7 @@ export interface SCThingTranslatablePropertyOrigin { */ export class SCThingMeta implements SCMetaTranslations { /** - * Set type definiton for singleton instance + * Set type definition for singleton instance */ protected static _instance = new Map(); @@ -263,24 +280,26 @@ export class SCThingMeta implements SCMetaTranslations { de: { alternateNames: 'alternative Namen', description: 'Beschreibung', + identifiers: 'Alternative Identifikation', image: 'Bild', name: 'Name', origin: 'Ursprung', + sameAs: 'ursprünglicher Link', translations: 'Übersetzungen', type: 'Typ', uid: 'Identifikation', - url: 'URL', }, en: { alternateNames: 'alternate names', description: 'description', + identifiers: 'alternative identification', image: 'image', name: 'name', origin: 'origin', + sameAs: 'original link', translations: 'translations', type: 'type', uid: 'identification', - url: 'URL', }, }; diff --git a/src/things/article.ts b/src/things/article.ts index 4839fcd6..bd65d278 100644 --- a/src/things/article.ts +++ b/src/things/article.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 StApps + * Copyright (C) 2019-2021 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -21,25 +21,37 @@ import { } from './abstract/creative-work'; import {SCThingMeta, SCThingType} from './abstract/thing'; import { - SCThingWithCategories, SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, } from './abstract/thing-with-categories'; +import {SCPeriodicalWithoutReferences} from './periodical'; + +/** + * Categories of an article + */ +export type SCArticleCategories = 'unipedia' + | 'article' + | 'eArticle'; /** * An article without references */ export interface SCArticleWithoutReferences extends SCCreativeWorkWithoutReferences, - SCThingWithCategoriesWithoutReferences { + SCThingWithCategoriesWithoutReferences { /** * Article itself as markdown * * @text */ - articleBody: string; + articleBody?: string; + + /** + * Categories of an article + */ + categories: SCArticleCategories[]; /** * Translated fields of an article @@ -59,8 +71,16 @@ export interface SCArticleWithoutReferences * @indexable */ export interface SCArticle - extends SCCreativeWork, SCArticleWithoutReferences, - SCThingWithCategories { + extends SCCreativeWork, SCArticleWithoutReferences { + /** + * A periodical to which this article belongs + */ + isPartOf?: SCPeriodicalWithoutReferences; + /** + * Additional information about how to find the article inside of its "parent" (which is provided in 'isPartOf') + * e.g. "40, 2011, S. 2-3" + */ + reference?: string; /** * Translated fields of an article */ @@ -73,12 +93,7 @@ export interface SCArticle } /** - * Categories of articles - */ -export type SCArticleCategories = 'unipedia'; - -/** - * Translatable properties of creative works + * Translatable properties of an article */ export interface SCArticleTranslatableProperties extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { @@ -103,14 +118,18 @@ export class SCArticleMeta ...SCCreativeWorkMeta.getInstance().fieldTranslations .de, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + SCThingWithCategoriesSpecificValues>().fieldTranslations.de, + categories: 'Format', + reference: 'Referenz', articleBody: 'Artikelinhalt', }, en: { ...SCCreativeWorkMeta.getInstance().fieldTranslations .en, ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + SCThingWithCategoriesSpecificValues>().fieldTranslations.en, + categories: 'format', + reference: 'reference', articleBody: 'article body', }, }; @@ -122,19 +141,22 @@ export class SCArticleMeta de: { ...SCCreativeWorkMeta.getInstance() .fieldValueTranslations.de, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, categories: { - 'unipedia': 'Unipedia', + article: 'Artikel', + eArticle: 'E-Aufsatz', + unipedia: 'Unipedia', }, type: 'Artikel', }, en: { ...SCCreativeWorkMeta.getInstance() .fieldValueTranslations.en, - ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Article, + categories: { + article: 'article', + eArticle: 'E-Article', + unipedia: 'unipedia', + }, }, }; } diff --git a/src/things/book.ts b/src/things/book.ts index 86434db9..dc9c36db 100644 --- a/src/things/book.ts +++ b/src/things/book.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 StApps + * Copyright (C) 2019-2021 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -20,29 +20,52 @@ import { SCCreativeWorkWithoutReferences, } from './abstract/creative-work'; import {SCThingMeta, SCThingType} from './abstract/thing'; -import {SCThingWithCategoriesTranslatableProperties} from './abstract/thing-with-categories'; -import {SCPersonWithoutReferences} from './person'; +import { + SCThingWithCategoriesSpecificValues, + SCThingWithCategoriesTranslatableProperties, + SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, +} from './abstract/thing-with-categories'; + +/** + * Categories of a book + */ +export type SCBookCategories = 'audio' + | 'book' + | 'cd' + | 'dvd' + | 'ePhoto' + | 'ebook' + | 'hierarchy' + | 'kit' + | 'manuscript' + | 'map' + | 'microfilm' + | 'musicalscore' + | 'photo' + | 'retro' + | 'sensorimage' + | 'unknown' + | 'video'; /** * A book without references */ export interface SCBookWithoutReferences - extends SCCreativeWorkWithoutReferences { + extends SCCreativeWorkWithoutReferences, + SCThingWithCategoriesWithoutReferences { /** - * Edition of a book - * - * @filterable - * @keyword + * Categories of a book */ - bookEdition?: string; + categories: SCBookCategories[]; /** - * ISBN of a book + * ISBNs of a book * * @filterable * @keyword */ - isbn?: string; + ISBNs?: string[]; /** * Number of pages of a book @@ -70,11 +93,6 @@ export interface SCBookWithoutReferences */ export interface SCBook extends SCCreativeWork, SCBookWithoutReferences { - /** - * Authors of the creative work - */ - authors: SCPersonWithoutReferences[]; - /** * Translated properties of a book */ @@ -91,12 +109,6 @@ export interface SCBook */ export interface SCBookTranslatableFields extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { - /** - * Translation of an edition of a book - * - * @keyword - */ - bookEdition?: string; } /** @@ -108,17 +120,19 @@ export class SCBookMeta extends SCThingMeta implements SCMetaTranslations().fieldTranslations - .de, - bookEdition: 'Buchausgabe', - isbn: 'ISBN', - numberOfPages: 'Seitenzahl', + ...SCCreativeWorkMeta.getInstance().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + categories: 'Format', + ISBNs: 'ISBN', + numberOfPages: 'Seitenanzahl', }, en: { - ...SCCreativeWorkMeta.getInstance().fieldTranslations - .en, - bookEdition: 'book edition', - isbn: 'ISBN', + ...SCCreativeWorkMeta.getInstance().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + categories: 'format', + ISBNs: 'ISBN', numberOfPages: 'number of pages', }, }; @@ -130,12 +144,56 @@ export class SCBookMeta extends SCThingMeta implements SCMetaTranslations() .fieldValueTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.de, + categories: { + audio: 'Tonträger', + book: 'Buch', + cd: 'CD', + dvd: 'DVD', + ePhoto: 'E-Photo', + ebook: 'E-Book', + hierarchy: 'mehrteiliges Werk', + kit: 'Medienkombination', + manuscript: 'Handschrift', + map: 'Karte', + microfilm: 'Mikrofilm, Mikrofiche', + musicalscore: 'Noten', + photo: 'Abbildung', + physicalobject: 'Objekt', + retro: 'Retro (Buch)', + sensorimage: 'Blindenschrift', + unknown: 'Unbekannt', + video: 'Film', + }, type: 'Buch', }, en: { ...SCCreativeWorkMeta.getInstance() .fieldValueTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldValueTranslations.en, type: SCThingType.Book, + categories: { + audio: 'audio material', + book: 'book', + cd: 'CD', + dvd: 'DVD', + ePhoto: 'E-Photo', + ebook: 'E-Book', + hierarchy: 'multipart item', + kit: 'media combination', + manuscript: 'manuscript', + map: 'map', + microfilm: 'microfilm, microfiche', + musicalscore: 'sheet music', + photo: 'illustration', + physicalobject: 'object', + retro: 'retro (book)', + sensorimage: 'braille', + unknown: 'unknown', + video: 'film', + }, }, }; } diff --git a/src/things/message.ts b/src/things/message.ts index cf4f6da8..a75ba961 100644 --- a/src/things/message.ts +++ b/src/things/message.ts @@ -22,14 +22,24 @@ import { } from './abstract/creative-work'; import {SCThingMeta, SCThingType} from './abstract/thing'; import {SCThingThatCanBeOfferedTranslatableProperties} from './abstract/thing-that-can-be-offered'; +import { + SCThingWithCategoriesSpecificValues, + SCThingWithCategoriesWithoutReferences, SCThingWithCategoriesWithoutReferencesMeta, +} from './abstract/thing-with-categories'; import {SCUserGroup} from './abstract/user-groups'; import {SCOrganizationWithoutReferences} from './organization'; +/** + * Categories of a message + */ +export type SCMessageCategories = 'news'; + /** * A message without references */ export interface SCMessageWithoutReferences - extends SCCreativeWorkWithoutReferences { + extends SCCreativeWorkWithoutReferences, + SCThingWithCategoriesWithoutReferences { /** * Organizational unit for which the message is intended */ @@ -42,6 +52,11 @@ export interface SCMessageWithoutReferences */ audiences: SCUserGroup[]; + /** + * Categories of a message + */ + categories: SCMessageCategories[]; + /** * When the message was created * @@ -117,6 +132,8 @@ export class SCMessageMeta de: { ...SCCreativeWorkMeta.getInstance().fieldTranslations .de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, audienceOrganizations: 'Zielgruppenorganisationen', audiences: 'Zielgruppen', dateCreated: 'Erstellungsdatum', @@ -126,6 +143,8 @@ export class SCMessageMeta en: { ...SCCreativeWorkMeta.getInstance().fieldTranslations .en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, audienceOrganizations: 'audience organizations', audiences: 'audiences', dateCreated: 'date created', @@ -142,9 +161,12 @@ export class SCMessageMeta ...SCCreativeWorkMeta.getInstance() .fieldValueTranslations.de, audiences: { - 'employees': 'Angestellte', - 'guests': 'Gäste', - 'students': 'Studenten', + employees: 'Angestellte', + guests: 'Gäste', + students: 'Studenten', + }, + categories: { + news: 'Neuigkeiten', }, type: 'Nachricht', }, diff --git a/src/things/periodical.ts b/src/things/periodical.ts new file mode 100644 index 00000000..c13c49c8 --- /dev/null +++ b/src/things/periodical.ts @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2021 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import { + SCCreativeWork, + SCCreativeWorkMeta, + SCCreativeWorkTranslatableProperties, + SCCreativeWorkWithoutReferences, +} from './abstract/creative-work'; +import {SCThingMeta, SCThingType} from './abstract/thing'; +import { + SCThingWithCategoriesSpecificValues, + SCThingWithCategoriesTranslatableProperties, + SCThingWithCategoriesWithoutReferences, + SCThingWithCategoriesWithoutReferencesMeta, +} from './abstract/thing-with-categories'; + +/** + * Categories of a periodical + */ +export type SCPeriodicalCategories = 'journal' | 'electronic'; + +/** + * A periodical without references + */ +export interface SCPeriodicalWithoutReferences + extends SCCreativeWorkWithoutReferences, + SCThingWithCategoriesWithoutReferences { + /** + * Categories of a periodical + */ + categories: SCPeriodicalCategories[]; + /** + * A list of ISSNs of a periodical + * + * @filterable + * @keyword + */ + ISSNs?: string[]; + + /** + * Translated properties of a periodical + */ + translations?: SCTranslations; + + /** + * Type of a periodical + */ + type: SCThingType.Periodical; +} + +/** + * A publication published at regular intervals (e.g. a magazine or newspaper) + * + * @validatable + * @indexable + */ +export interface SCPeriodical + extends SCCreativeWork, SCPeriodicalWithoutReferences { + /** + * Translated properties of a periodical + */ + translations?: SCTranslations; + + /** + * Type of a periodical + */ + type: SCThingType.Periodical; +} + +/** + * Translatable properties of a periodical + */ +export interface SCPeriodicalTranslatableFields + extends SCThingWithCategoriesTranslatableProperties, SCCreativeWorkTranslatableProperties { +} + +/** + * Meta information about a periodical + */ +export class SCPeriodicalMeta extends SCThingMeta implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ...SCCreativeWorkMeta.getInstance().fieldTranslations.de, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.de, + categories: 'Format', + ISSNs: 'ISSN', + }, + en: { + ...SCCreativeWorkMeta.getInstance().fieldTranslations.en, + ...SCThingWithCategoriesWithoutReferencesMeta.getInstance().fieldTranslations.en, + categories: 'format', + ISSNs: 'ISSN', + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ...SCCreativeWorkMeta.getInstance() + .fieldValueTranslations.de, + type: 'Periodikum', + categories: { + electronic: 'E-Journal', + journal: 'Zeitschrift', + }, + }, + en: { + ...SCCreativeWorkMeta.getInstance() + .fieldValueTranslations.en, + type: 'periodical', + categories: { + electronic: 'E-Journal', + journal: 'journal', + }, + }, + }; +} diff --git a/src/things/person.ts b/src/things/person.ts index 4543cdcb..f156de5f 100644 --- a/src/things/person.ts +++ b/src/things/person.ts @@ -57,7 +57,7 @@ export interface SCPersonWithoutReferences * @filterable * @keyword */ - familyName: string; + familyName?: string; /** * The private fax number of the person. @@ -80,7 +80,7 @@ export interface SCPersonWithoutReferences * @filterable * @keyword */ - givenName: string; + givenName?: string; /** * Honorific prefix of the person. diff --git a/src/things/publication-event.ts b/src/things/publication-event.ts new file mode 100644 index 00000000..41996e73 --- /dev/null +++ b/src/things/publication-event.ts @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2021 StApps + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import {SCMetaTranslations, SCTranslations} from '../general/i18n'; +import {SCEvent, SCEventMeta, SCEventWithoutReferences} from './abstract/event'; +import {SCThingMeta, SCThingTranslatableProperties, SCThingType} from './abstract/thing'; + +/** + * An publication event without references + */ +export interface SCPublicationEventWithoutReferences + extends SCEventWithoutReferences { + /** + * All the locations related to the event (e.g. where a creative work was published) + */ + locations?: string[]; + + /** + * An organization (or a person) that is publishing at the event + */ + publisher?: string; + + /** + * Translated fields of an publication event + */ + translations?: SCTranslations; + + /** + * Type of an publication event + */ + type: SCThingType.PublicationEvent; +} + +/** + * An publication event + * + * @validatable + * @indexable + */ +export interface SCPublicationEvent + extends SCEvent, SCPublicationEventWithoutReferences { + /** + * Translated fields of an publication event + */ + translations?: SCTranslations; + + /** + * Type of an publication event + */ + type: SCThingType.PublicationEvent; +} + +/** + * Translatable properties of an publication event + */ +export interface SCPublicationEventTranslatableProperties extends SCThingTranslatableProperties { +} + +/** + * Meta information about publication events + */ +export class SCPublicationEventMeta + extends SCThingMeta + implements SCMetaTranslations { + /** + * Translations of fields + */ + fieldTranslations = { + de: { + ...SCEventMeta.getInstance().fieldTranslations.de, + locations: 'Erscheinungsorte', + publisher: 'Verlag', + }, + en: { + ...SCEventMeta.getInstance().fieldTranslations.en, + locations: 'places of publication', + publisher: 'publisher', + }, + }; + + /** + * Translations of values of fields + */ + fieldValueTranslations = { + de: { + ...SCEventMeta.getInstance().fieldValueTranslations.de, + type: 'Veröffentlichung', + }, + en: { + ...SCEventMeta.getInstance().fieldValueTranslations.en, + type: 'publication event', + }, + }; +} diff --git a/test/resources/Article.1.json b/test/resources/Article.1.json index f42d52a0..21073595 100644 --- a/test/resources/Article.1.json +++ b/test/resources/Article.1.json @@ -6,7 +6,7 @@ "categories": [ "unipedia" ], - "url": "https://www.mydesk.tu-berlin.de/wiki/abk%C3%BCrzungen", + "sameAs": "https://www.mydesk.tu-berlin.de/wiki/abk%C3%BCrzungen", "name": "Abkürzungen", "keywords": [ "Abkürzungen", diff --git a/test/resources/Article.2.json b/test/resources/Article.2.json index 7752d6fa..b32e7fc3 100644 --- a/test/resources/Article.2.json +++ b/test/resources/Article.2.json @@ -6,7 +6,7 @@ "categories": [ "unipedia" ], - "url": "https://www.mydesk.tu-berlin.de/wiki/ag_ziethen", + "sameAs": "https://www.mydesk.tu-berlin.de/wiki/ag_ziethen", "name": "AG Ziethen", "keywords": [ "Bologna", diff --git a/test/resources/Article.3.json b/test/resources/Article.3.json new file mode 100644 index 00000000..fd52ab11 --- /dev/null +++ b/test/resources/Article.3.json @@ -0,0 +1,36 @@ +{ + "errorNames": [], + "instance": { + "type": "article", + "uid": "d541eda5-1542-59b2-969e-7dbbee0bd2a8", + "name": "Mozart und Frankfurt am Main : drei Generationen Mozart in Frankfurt am Main", + "description": "Ill.", + "categories": [ + "article" + ], + "authors": [ + { + "type": "person", + "uid": "56d46c9b-8ede-52ae-a40f-6800cff577e5", + "name": "Greve, Clemens" + } + ], + "firstPublished": "2008", + "sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB198305427", + "origin": { + "indexed": "2018-09-11T12:30:00Z", + "name": "HeBIS HDS", + "originalId": "HEB198305427", + "type": "remote", + "url": "https://hds2test.hebis.de/ubffm/" + }, + "isPartOf": { + "uid": "bc5e5399-a24c-5c01-9c1b-0c8b83272087", + "name": "Archiv für Frankfurts Geschichte und Kunst", + "type": "periodical", + "categories": [] + }, + "reference": "Band 71 (2008), Seite 27-40" + }, + "schema": "SCArticle" +} diff --git a/test/resources/Article.4.json b/test/resources/Article.4.json new file mode 100644 index 00000000..91b52c2a --- /dev/null +++ b/test/resources/Article.4.json @@ -0,0 +1,36 @@ +{ + "errorNames": [], + "instance": { + "type": "article", + "uid": "554a4a89-df73-5197-ac85-c8a5a3a9c5b0", + "name": "Ursula Janik : [Markthändlerin]", + "description": "Ill.", + "categories": [ + "article" + ], + "authors": [ + { + "type": "person", + "uid": "c6e44e1f-f76c-53f8-a18f-47fa54ae0e90", + "name": "Fröhlich, Ute B." + } + ], + "firstPublished": "2002", + "sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB107025590", + "origin": { + "indexed": "2018-09-11T12:30:00Z", + "name": "HeBIS HDS", + "originalId": "HEB107025590", + "type": "remote", + "url": "https://hds2test.hebis.de/ubffm/" + }, + "isPartOf": { + "uid": "f84c1851-042e-542f-ba7a-158b32dfb82f", + "name": "Frankfurter Allgemeine. R, Rhein-Main-Zeitung", + "type": "periodical", + "categories": [] + }, + "reference": "Heft 190 (17. 8 2002), Seite 62" + }, + "schema": "SCArticle" +} diff --git a/test/resources/Book.1.json b/test/resources/Book.1.json index 67a93484..758cadc8 100644 --- a/test/resources/Book.1.json +++ b/test/resources/Book.1.json @@ -22,9 +22,14 @@ } ], "inLanguage": "de", - "bookEdition": "2., überarb. u. erw. Aufl.", - "isbn": "3936608776", + "edition": "2., überarb. u. erw. Aufl.", + "ISBNs": [ + "3936608776" + ], "numberOfPages": 537, + "categories": [ + "book" + ], "origin": { "indexed": "2018-09-11T12:30:00Z", "name": "Dummy", diff --git a/test/resources/Book.2.json b/test/resources/Book.2.json index 0ac67b3a..73bfc225 100644 --- a/test/resources/Book.2.json +++ b/test/resources/Book.2.json @@ -4,6 +4,9 @@ "type": "book", "uid": "db47f7f4-7699-5a37-afcc-24beaa998d36", "name": "Minimal Book", + "categories": [ + "ebook" + ], "authors": [ { "type": "person", @@ -14,7 +17,9 @@ } ], "datePublished": "2007-08-01", - "isbn": "3936608776", + "ISBNs": [ + "3936608776" + ], "origin": { "indexed": "2018-09-11T12:30:00Z", "name": "Dummy", diff --git a/test/resources/Book.3.json b/test/resources/Book.3.json new file mode 100644 index 00000000..c97e1409 --- /dev/null +++ b/test/resources/Book.3.json @@ -0,0 +1,40 @@ +{ + "errorNames": [], + "instance": { + "type": "book", + "uid": "188cb2bd-724d-543d-97ac-9aa1dda68cb7", + "name": "Frauen im Ingenieurberuf : FIB ; 1. Gesamtdeutsches Symposium VDI-FIB 17. - 18. November 1990, Bad Homburg ; 1. überregionales Treffen VDI-FIB 11. - 12. November 1989, Düsseldorf", + "description": "47 S. : Ill., Kt.", + "categories": [ + "book" + ], + "authors": [ + { + "uid": "a276588c-ecee-5d2e-8b9c-73cb902bc165", + "name": "Saatweber, Jutta (Hrsg.)", + "type": "person" + } + ], + "firstPublished": "[ca. 1991]", + "publications": [ + { + "uid": "603a6574-8910-588a-9e83-cd26e6988c74", + "type": "publication event", + "locations": [ + "Frankfurt/M" + ], + "publisher": "VDI", + "name": "VDI" + } + ], + "sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB022992618", + "origin": { + "indexed": "2018-09-11T12:30:00Z", + "name": "HeBIS HDS", + "originalId": "HEB022992618", + "type": "remote", + "url": "https://hds2test.hebis.de/ubffm/" + } + }, + "schema": "SCBook" +} diff --git a/test/resources/Book.4.json b/test/resources/Book.4.json new file mode 100644 index 00000000..24778541 --- /dev/null +++ b/test/resources/Book.4.json @@ -0,0 +1,43 @@ +{ + "errorNames": [], + "instance": { + "type": "book", + "uid": "f6ee5744-a441-595d-9dae-a9f579c0660f", + "name": "Kant", + "description": "176 S.", + "categories": [ + "book" + ], + "authors": [ + { + "uid": "7e198ecf-966a-5f99-8a45-266243583023", + "name": "Thouard, Denis", + "type": "person" + } + ], + "firstPublished": "2001", + "publications": [ + { + "uid": "603a6574-8910-588a-9e83-cd26e6988c74", + "type": "publication event", + "locations": [ + "Paris" + ], + "publisher": "Belles Lettres", + "name": "Belles Lettres" + } + ], + "sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB102248788", + "ISBNs": [ + "2251760385" + ], + "origin": { + "indexed": "2018-09-11T12:30:00Z", + "name": "HeBIS HDS", + "originalId": "HEB102248788", + "type": "remote", + "url": "https://hds2test.hebis.de/ubffm/" + } + }, + "schema": "SCBook" +} diff --git a/test/resources/Diff.1.json b/test/resources/Diff.1.json index 4c989323..72e8fe11 100644 --- a/test/resources/Diff.1.json +++ b/test/resources/Diff.1.json @@ -21,6 +21,9 @@ "audiences": [ "students" ], + "categories": [ + "news" + ], "sequenceIndex": 1010, "origin": { "indexed": "2018-09-11T12:30:00Z", diff --git a/test/resources/Diff.2.json b/test/resources/Diff.2.json index 6993b93f..f2350c85 100644 --- a/test/resources/Diff.2.json +++ b/test/resources/Diff.2.json @@ -21,6 +21,9 @@ "audiences": [ "students" ], + "categories": [ + "news" + ], "sequenceIndex": 1020, "origin": { "indexed": "2018-09-11T12:30:00Z", diff --git a/test/resources/Message.1.json b/test/resources/Message.1.json index a5344e31..54babf20 100644 --- a/test/resources/Message.1.json +++ b/test/resources/Message.1.json @@ -9,6 +9,9 @@ "audiences": [ "students" ], + "categories": [ + "news" + ], "sequenceIndex": 1001, "origin": { "indexed": "2018-09-11T12:30:00Z", diff --git a/test/resources/Message.2.json b/test/resources/Message.2.json index 45df1e6b..b4398cb7 100644 --- a/test/resources/Message.2.json +++ b/test/resources/Message.2.json @@ -11,6 +11,9 @@ "audiences": [ "students" ], + "categories": [ + "news" + ], "sequenceIndex": 1004, "origin": { "indexed": "2018-09-11T12:30:00Z", diff --git a/test/resources/Periodical.1.json b/test/resources/Periodical.1.json new file mode 100644 index 00000000..3f2de198 --- /dev/null +++ b/test/resources/Periodical.1.json @@ -0,0 +1,35 @@ +{ + "errorNames": [], + "instance": { + "type": "periodical", + "uid": "d921479e-4d35-5cd1-b64a-939cbe40a5b0", + "name": "London magazine : a review of literature and the arts", + "categories": [ + "journal" + ], + "firstPublished": "1954", + "publications": [ + { + "uid": "603a6574-8910-588a-9e83-cd26e6988c74", + "type": "publication event", + "locations": [ + "London" + ], + "publisher": "London Magazine", + "name": "London Magazine" + } + ], + "ISSNs": [ + "0024-6085" + ], + "sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB046847146", + "origin": { + "indexed": "2018-09-11T12:30:00Z", + "name": "HeBIS HDS", + "originalId": "HEB046847146", + "type": "remote", + "url": "https://hds2test.hebis.de/ubffm/" + } + }, + "schema": "SCPeriodical" +} diff --git a/test/resources/Periodical.2.json b/test/resources/Periodical.2.json new file mode 100644 index 00000000..bc92a389 --- /dev/null +++ b/test/resources/Periodical.2.json @@ -0,0 +1,32 @@ +{ + "errorNames": [], + "instance": { + "type": "periodical", + "uid": "c8d7a4f7-88ac-5da3-86c7-32b93d16f00a", + "name": "[Frankfurter Allgemeine \/ R F A Z FAZ Republik Heroes], Frankfurter Allgemeine : Zeitung für Deutschland, R. Rhein-Main-Zeitung : Zeitung für Frankfurt", + "categories": [ + "journal" + ], + "firstPublished": "1988", + "publications": [ + { + "uid": "64829217-9eea-532f-8730-7e609efffbca", + "type": "publication event", + "locations": [ + "Frankfurt, M." + ], + "publisher": "Frankfurter Allg. Zeitung", + "name": "Frankfurter Allg. Zeitung" + } + ], + "sameAs": "https://hds2test.hebis.de/ubffm/Record/HEB048624853", + "origin": { + "indexed": "2018-09-11T12:30:00Z", + "name": "HeBIS HDS", + "originalId": "HEB048624853", + "type": "remote", + "url": "https://hds2test.hebis.de/ubffm/" + } + }, + "schema": "SCPeriodical" +} diff --git a/test/resources/Video.1.json b/test/resources/Video.1.json index 26e60b12..6dfd37f2 100644 --- a/test/resources/Video.1.json +++ b/test/resources/Video.1.json @@ -3,7 +3,7 @@ "instance": { "type": "video", "uid": "e274cc82-f51c-566b-b8da-85763ff375e8", - "url": "https://vimeo.com/1084537", + "sameAs": "https://vimeo.com/1084537", "name": "Big Buck Bunny", "origin": { "indexed": "2018-09-11T12:30:00Z", diff --git a/test/resources/Video.2.json b/test/resources/Video.2.json index 669007af..3110806b 100644 --- a/test/resources/Video.2.json +++ b/test/resources/Video.2.json @@ -3,7 +3,7 @@ "instance": { "type": "video", "uid": "2def52c8-f901-5b30-96fc-ba570a038508", - "url": "https://vimeo.com/1084537", + "sameAs": "https://vimeo.com/1084537", "name": "Big Buck Bunny", "sources": [ { diff --git a/test/type.spec.ts b/test/type.spec.ts index 090823e2..9fac9ccc 100644 --- a/test/type.spec.ts +++ b/test/type.spec.ts @@ -39,6 +39,8 @@ import {SCTicket, SCTicketWithoutReferences} from '../src/things/ticket'; import {SCToDo, SCToDoWithoutReferences} from '../src/things/todo'; import {SCTour, SCTourWithoutReferences} from '../src/things/tour'; import {SCVideo, SCVideoWithoutReferences} from '../src/things/video'; +import {SCPeriodical, SCPeriodicalWithoutReferences} from '../src/things/periodical'; +import {SCPublicationEvent, SCPublicationEventWithoutReferences} from '../src/things/publication-event'; // tslint:disable:no-any // tslint:disable:completed-docs @@ -226,6 +228,17 @@ assert>(false); assert>(false); assert>(true); +/** + * Types of properties of SCPeriodical + */ +type SCPeriodicalPropertyTypes = PropertyTypesNested; +assert>(false); +assert>(true); +assert>(true); +assert>(false); +assert>(false); +assert>(true); + /** * Types of properties of SCPerson */ @@ -248,6 +261,17 @@ assert>(false); assert>(false); assert>(true); +/** + * Types of properties of SCPublicationEvent + */ +type SCPublicationEventPropertyTypes = PropertyTypesNested; +assert>(false); +assert>(true); +assert>(true); +assert>(false); +assert>(false); +assert>(true); + /** * Types of properties of SCRoom */