Files
openstapps/src/things/abstract/creative-work.ts
2019-08-21 10:34:04 +02:00

135 lines
3.9 KiB
TypeScript

/*
* Copyright (C) 2019 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 <https://www.gnu.org/licenses/>.
*/
import {SCLanguage, SCMetaTranslations, SCTranslations} from '../../general/i18n';
import {SCISO8601Date} from '../../general/time';
import {SCOrganizationWithoutReferences} from '../organization';
import {SCPersonWithoutReferences} from '../person';
import {SCThingMeta, SCThingTranslatableProperties, SCThingWithoutReferences} from './thing';
import {
SCAcademicPriceGroup,
SCThingThatCanBeOffered,
SCThingThatCanBeOfferedMeta,
SCThingThatCanBeOfferedTranslatableProperties,
SCThingThatCanBeOfferedWithoutReferences,
} from './thing-that-can-be-offered';
/**
* A creative work without references
*/
export interface SCCreativeWorkWithoutReferences
extends SCThingWithoutReferences, SCThingThatCanBeOfferedWithoutReferences {
/**
* Date the creative work was published
*/
datePublished?: SCISO8601Date;
/**
* List of languages this creative work is written/recorded/... in
*/
inLanguages?: SCLanguage[];
/**
* Keywords of the creative work
*
* @aggregatable
* @filterable
* @keyword
*/
keywords?: string[];
/**
* Translated fields of the creative work
*/
translations?: SCTranslations<SCCreativeWorkTranslatableProperties>;
}
/**
* A creative work
*/
export interface SCCreativeWork
extends SCCreativeWorkWithoutReferences, SCThingThatCanBeOffered<SCAcademicPriceGroup> {
/**
* Authors of the creative work
*/
authors?: SCPersonWithoutReferences[];
/**
* List of publishers of the creative work
*/
publishers?: Array<SCPersonWithoutReferences | SCOrganizationWithoutReferences>;
/**
* Translated fields of the creative work
*/
translations?: SCTranslations<SCCreativeWorkTranslatableProperties>;
}
/**
* Translatable properties of creative works
*/
export interface SCCreativeWorkTranslatableProperties
extends SCThingTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
/**
* Translation of the keywords of the creative work
*
* @keyword
*/
keywords?: string[];
}
/**
* Meta information about creative works
*/
export class SCCreativeWorkMeta
extends SCThingMeta implements SCMetaTranslations<SCCreativeWork> {
/**
* Translations of fields
*/
fieldTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.de,
authors: 'Authoren',
datePublished: 'Veröffentlichungsdatum',
inLanguages: 'verfügbare Übersetzungen',
keywords: 'Schlagwörter',
publishers: 'Verleger',
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldTranslations.en,
authors: 'authors',
datePublished: 'release date',
inLanguages: 'available Languages',
keywords: 'keywords',
publishers: 'publishers',
},
};
/**
* Translations of values of fields
*/
fieldValueTranslations = {
de: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.de,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
},
en: {
...SCThingMeta.getInstance<SCThingMeta>().fieldValueTranslations.en,
...SCThingThatCanBeOfferedMeta.getInstance().fieldValueTranslations.en,
},
};
}