greek-manifests/src/Metadata.js
2023-11-15 11:03:17 +01:00

73 lines
2.2 KiB
JavaScript

class ManifestMetadata {
papyrus = '';
author = '';
title = '';
edition = '';
technique = '';
pca = null;
date = '';
imageAuthor = '';
license = 'CC BY-NC-ND 4.0';
copyright = "Ministero della Cultura (Biblioteca Nazionale 'Vittorio Emanuele III' di Napoli)/CNR-Istituto di Scienze del Patrimonio Culturale";
/**
* @todo Maybe this doesn't make any sense??
* @param {
* {papyrus,
* author,
* title,
* edition,
* technique,
* pca,
* date,
* imageAuthor,
* license,
* copyright}
* } metadata
*/
constructor(metadata) {
this.papyrus = metadata.papyrus ?? this.papyrus;
this.author = metadata.author ?? this.author;
this.title = metadata.title ?? this.title;
this.edition = metadata.edition ?? this.edition;
// There should always be a technique value
// in the metadata param
this.technique = metadata.technique;
this.pca = metadata.pca ?? this.pca;
this.date = metadata.date ?? this.date;
this.imageAuthor = metadata.imageAuthor ?? this.imageAuthor
this.license = metadata.license ?? this.license;
this.copyright = metadata.copyright ?? this.copyright;
}
/**
* Returns an array of `label, value`
* pairs for all metadata
* @returns {Array<{label, value}>}
*/
toObject() {
let metadataObj = [
{label:"Papyrus", value: this.papyrus},
{label:"Author", value: this.author},
{label:"Title", value: this.title},
{label:"Reference edition", value: this.edition},
{label:"Technique", value: this.technique},
];
if (this.pca) {
metadataObj.push({label:"Principal Component Analysis",value: this.pca});
}
metadataObj = metadataObj.concat([
{label:"Date (Year)", value: this.date},
{label:"Image Author", value: this.imageAuthor},
{label:"License", value: this.license},
{label:"Copyright", value: this.copyright},
]);
return metadataObj;
}
}
export default ManifestMetadata;