From 22cf2376ad19c6a921415eca65aaacc4b785640b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Tue, 3 Sep 2024 09:36:38 +0200 Subject: [PATCH 01/12] Remove unused dsp-domain crate --- Cargo.lock | 29 +- Cargo.toml | 2 +- data/add_status.py | 79 ----- data/dokubib.hcl | 170 ----------- data/hdm.hcl | 173 ----------- data/incunabula.hcl | 256 ---------------- dsp-domain/src/error.rs | 16 - dsp-domain/src/lib.rs | 3 - dsp-domain/src/metadata/entity/dataset.rs | 32 -- dsp-domain/src/metadata/entity/grant.rs | 18 -- dsp-domain/src/metadata/entity/mod.rs | 6 - .../src/metadata/entity/organization.rs | 8 - dsp-domain/src/metadata/entity/person.rs | 8 - dsp-domain/src/metadata/entity/project.rs | 35 --- .../src/metadata/entity/project_metadata.rs | 19 -- dsp-domain/src/metadata/mod.rs | 2 - dsp-domain/src/metadata/value/abstract.rs | 26 -- dsp-domain/src/metadata/value/access.rs | 27 -- .../src/metadata/value/alternative_name.rs | 25 -- dsp-domain/src/metadata/value/attribution.rs | 28 -- dsp-domain/src/metadata/value/data_type.rs | 29 -- dsp-domain/src/metadata/value/description.rs | 26 -- dsp-domain/src/metadata/value/discipline.rs | 23 -- dsp-domain/src/metadata/value/funder.rs | 2 - dsp-domain/src/metadata/value/identifier.rs | 19 -- dsp-domain/src/metadata/value/iso_code.rs | 71 ----- dsp-domain/src/metadata/value/keyword.rs | 15 - .../src/metadata/value/lang_text_data.rs | 9 - dsp-domain/src/metadata/value/language.rs | 26 -- dsp-domain/src/metadata/value/license.rs | 58 ---- dsp-domain/src/metadata/value/mod.rs | 72 ----- dsp-domain/src/metadata/value/publication.rs | 8 - dsp-domain/src/metadata/value/ref_data.rs | 8 - .../src/metadata/value/simple_text_data.rs | 12 - .../src/metadata/value/spatial_coverage.rs | 6 - dsp-domain/src/metadata/value/status.rs | 25 -- .../src/metadata/value/temporal_coverage.rs | 9 - dsp-domain/src/metadata/value/url.rs | 39 --- dsp-domain/src/metadata/value/version.rs | 4 - dsp-domain/src/ontology/mod.rs | 236 --------------- dsp-meta/Cargo.toml | 5 - .../src/api/convert/hcl/dsp_meta_error.rs | 7 - .../dataset/extracted_dataset_attributes.rs | 253 ---------------- .../dataset/extracted_dataset_blocks.rs | 101 ------- .../src/api/convert/hcl/entity/dataset/mod.rs | 210 ------------- .../hcl/entity/grant/extracted_grant.rs | 228 -------------- .../src/api/convert/hcl/entity/grant/mod.rs | 113 ------- dsp-meta/src/api/convert/hcl/entity/mod.rs | 3 - .../project/extracted_project_attributes.rs | 211 ------------- .../project/extracted_project_blocks.rs | 271 ----------------- .../src/api/convert/hcl/entity/project/mod.rs | 281 ------------------ dsp-meta/src/api/convert/hcl/hcl_attribute.rs | 2 - dsp-meta/src/api/convert/hcl/hcl_block.rs | 1 - dsp-meta/src/api/convert/hcl/hcl_body.rs | 1 - dsp-meta/src/api/convert/hcl/mod.rs | 7 - .../src/api/convert/hcl/project_metadata.rs | 121 -------- .../src/api/convert/hcl/value/abstract.rs | 77 ----- .../api/convert/hcl/value/alternative_name.rs | 74 ----- .../src/api/convert/hcl/value/attribution.rs | 130 -------- .../src/api/convert/hcl/value/description.rs | 77 ----- .../src/api/convert/hcl/value/discipline.rs | 107 ------- dsp-meta/src/api/convert/hcl/value/keyword.rs | 76 ----- .../api/convert/hcl/value/lang_text_data.rs | 29 -- .../src/api/convert/hcl/value/language.rs | 78 ----- dsp-meta/src/api/convert/hcl/value/license.rs | 170 ----------- dsp-meta/src/api/convert/hcl/value/mod.rs | 16 - .../src/api/convert/hcl/value/publication.rs | 66 ---- .../src/api/convert/hcl/value/ref_data.rs | 88 ------ .../api/convert/hcl/value/simple_text_data.rs | 85 ------ .../api/convert/hcl/value/spatial_coverage.rs | 71 ----- .../convert/hcl/value/temporal_coverage.rs | 86 ------ dsp-meta/src/api/convert/hcl/value/url.rs | 121 -------- dsp-meta/src/api/convert/hcl/value/version.rs | 45 --- dsp-meta/src/api/convert/mod.rs | 2 - dsp-meta/src/api/convert/rdf/constance.rs | 7 - dsp-meta/src/api/convert/rdf/error.rs | 7 - dsp-meta/src/api/convert/rdf/mod.rs | 6 - dsp-meta/src/api/convert/rdf/project.rs | 39 --- .../src/api/convert/rdf/project_metadata.rs | 147 --------- dsp-meta/src/api/convert/rdf/triple.rs | 6 - dsp-meta/src/api/convert/rdf/value/mod.rs | 1 - .../src/api/convert/rdf/value/shortcode.rs | 26 -- dsp-meta/src/error.rs | 10 - dsp-meta/tests/common/mod.rs | 12 - dsp-meta/tests/integration_test.rs | 41 --- 85 files changed, 29 insertions(+), 5145 deletions(-) delete mode 100644 data/add_status.py delete mode 100644 data/dokubib.hcl delete mode 100644 data/hdm.hcl delete mode 100644 data/incunabula.hcl delete mode 100644 dsp-domain/src/error.rs delete mode 100644 dsp-domain/src/lib.rs delete mode 100644 dsp-domain/src/metadata/entity/dataset.rs delete mode 100644 dsp-domain/src/metadata/entity/grant.rs delete mode 100644 dsp-domain/src/metadata/entity/mod.rs delete mode 100644 dsp-domain/src/metadata/entity/organization.rs delete mode 100644 dsp-domain/src/metadata/entity/person.rs delete mode 100644 dsp-domain/src/metadata/entity/project.rs delete mode 100644 dsp-domain/src/metadata/entity/project_metadata.rs delete mode 100644 dsp-domain/src/metadata/mod.rs delete mode 100644 dsp-domain/src/metadata/value/abstract.rs delete mode 100644 dsp-domain/src/metadata/value/access.rs delete mode 100644 dsp-domain/src/metadata/value/alternative_name.rs delete mode 100644 dsp-domain/src/metadata/value/attribution.rs delete mode 100644 dsp-domain/src/metadata/value/data_type.rs delete mode 100644 dsp-domain/src/metadata/value/description.rs delete mode 100644 dsp-domain/src/metadata/value/discipline.rs delete mode 100644 dsp-domain/src/metadata/value/funder.rs delete mode 100644 dsp-domain/src/metadata/value/identifier.rs delete mode 100644 dsp-domain/src/metadata/value/iso_code.rs delete mode 100644 dsp-domain/src/metadata/value/keyword.rs delete mode 100644 dsp-domain/src/metadata/value/lang_text_data.rs delete mode 100644 dsp-domain/src/metadata/value/language.rs delete mode 100644 dsp-domain/src/metadata/value/license.rs delete mode 100644 dsp-domain/src/metadata/value/mod.rs delete mode 100644 dsp-domain/src/metadata/value/publication.rs delete mode 100644 dsp-domain/src/metadata/value/ref_data.rs delete mode 100644 dsp-domain/src/metadata/value/simple_text_data.rs delete mode 100644 dsp-domain/src/metadata/value/spatial_coverage.rs delete mode 100644 dsp-domain/src/metadata/value/status.rs delete mode 100644 dsp-domain/src/metadata/value/temporal_coverage.rs delete mode 100644 dsp-domain/src/metadata/value/url.rs delete mode 100644 dsp-domain/src/metadata/value/version.rs delete mode 100644 dsp-domain/src/ontology/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/dsp_meta_error.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_attributes.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_blocks.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/dataset/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/grant/extracted_grant.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/grant/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/project/extracted_project_attributes.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/project/extracted_project_blocks.rs delete mode 100644 dsp-meta/src/api/convert/hcl/entity/project/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/hcl_attribute.rs delete mode 100644 dsp-meta/src/api/convert/hcl/hcl_block.rs delete mode 100644 dsp-meta/src/api/convert/hcl/hcl_body.rs delete mode 100644 dsp-meta/src/api/convert/hcl/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/project_metadata.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/abstract.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/alternative_name.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/attribution.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/description.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/discipline.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/keyword.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/lang_text_data.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/language.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/license.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/mod.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/publication.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/ref_data.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/simple_text_data.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/spatial_coverage.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/temporal_coverage.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/url.rs delete mode 100644 dsp-meta/src/api/convert/hcl/value/version.rs delete mode 100644 dsp-meta/src/api/convert/rdf/constance.rs delete mode 100644 dsp-meta/src/api/convert/rdf/error.rs delete mode 100644 dsp-meta/src/api/convert/rdf/mod.rs delete mode 100644 dsp-meta/src/api/convert/rdf/project.rs delete mode 100644 dsp-meta/src/api/convert/rdf/project_metadata.rs delete mode 100644 dsp-meta/src/api/convert/rdf/triple.rs delete mode 100644 dsp-meta/src/api/convert/rdf/value/mod.rs delete mode 100644 dsp-meta/src/api/convert/rdf/value/shortcode.rs delete mode 100644 dsp-meta/tests/common/mod.rs delete mode 100644 dsp-meta/tests/integration_test.rs diff --git a/Cargo.lock b/Cargo.lock index 08a3f5f7..abeaaffe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -562,6 +562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] +<<<<<<< HEAD name = "dsp-domain" version = "2.2.0" dependencies = [ @@ -586,6 +587,33 @@ dependencies = [ ] [[package]] +||||||| parent of d2944c9 (Remove unused dsp-domain crate) +name = "dsp-domain" +version = "2.1.0" +dependencies = [ + "anyhow", + "assert_cmd", + "axum", + "axum-macros", + "clap", + "hcl-rs", + "hyper", + "log", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "tower-http", + "tracing", + "tracing-subscriber", + "tracing-test", + "url", +] + +[[package]] +======= +>>>>>>> d2944c9 (Remove unused dsp-domain crate) name = "dsp-meta" version = "2.2.0" dependencies = [ @@ -597,7 +625,6 @@ dependencies = [ "chrono", "clap", "config", - "dsp-domain", "fake", "hcl-rs", "http-body-util", diff --git a/Cargo.toml b/Cargo.toml index cbe1275f..513853dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["dsp-domain", "dsp-meta", "dsp-meta-cmd", "serde-rdf"] +members = ["dsp-meta", "dsp-meta-cmd", "serde-rdf"] resolver = "2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/data/add_status.py b/data/add_status.py deleted file mode 100644 index 78f690c6..00000000 --- a/data/add_status.py +++ /dev/null @@ -1,79 +0,0 @@ -import os -import json - -# List of ongoing shortcodes -ongoing_shortcodes = [ - "0102", - "0103", - "0105", - "0106", - "0107", - "0112", - "0114", - "0116", - "0118", - "0119", - "0121", - "0801", - "0804", - "0805", - "0806", - "0807", - "080C", - "080E", - "0810", - "0812", - "0813", - "0816", - "081B", - "0820", - "0827", - "082B", - "082C", - "0836", - "0838", - "083A", - "083B", - "083C", - "083E", - "0843", - "0844", - "0849", - "084A", - "084E" -] - -def update_json_files(folder_path): - print(ongoing_shortcodes) - # Iterate through all files in the given folder - for filename in os.listdir(folder_path): - # Check if the file is a JSON file - if filename.endswith(".json"): - file_path = os.path.join(folder_path, filename) - - # Read the JSON file - with open(file_path, 'r', encoding='utf-8') as file: - data = json.load(file) - - # Check if the "project" and "shortcode" keys exist - if "project" in data and "shortcode" in data["project"]: - shortcode = data["project"]["shortcode"] - - # Determine the status based on the shortcode - print (shortcode) - print (shortcode in ongoing_shortcodes) - if shortcode in ongoing_shortcodes: - status = "ongoing" - else: - status = "finished" - - # Add or update the "status" property - data["project"]["status"] = status - - # Write the updated JSON back to the file - with open(file_path, 'w', encoding='utf-8') as file: - json.dump(data, file, indent=4, ensure_ascii=False) - else: - print(f"File {filename} does not contain the expected structure.") - -update_json_files('./json/') \ No newline at end of file diff --git a/data/dokubib.hcl b/data/dokubib.hcl deleted file mode 100644 index 72a5adb7..00000000 --- a/data/dokubib.hcl +++ /dev/null @@ -1,170 +0,0 @@ -version = 1 - -project { - id = "http://ns.dasch.swiss/repository#dsp-0804-project" - created_at = 1630601300976368000 - created_by = "dsp-metadata-gui" - shortcode = "0804" - name = "Bilddatenbank Bibliothek St. Moritz" - - teaser_text = "Bibliothek St. Moritz Dokumentation is the local history archive of the community of St. Moritz, Switzerland." - - description { - en = "Bibliothek St. Moritz Dokumentation is the local history archive of the community of St. Moritz, Switzerland. It’s collection contains publications, manuscripts and audiovisual documents of the touristic development of St. Moritz" - } - - url { - href = "https://data.dasch.swiss/dokubib/" - label = "Project Website" - } - - how_to_cite = "Dokumentationsbibliothek St. Moritz" - start_date = "2021-01-01" - end_date = "2021-12-31" - - status = "Ongoing" - - keyword { - en = "local history" - de = "Lokalgeschichte" - } - keyword { - en = "regional history" - de = "Regionalgeschichte" - } - keyword { - en = "tourism" - de = "Tourismus" - } - keyword { - en = "St. Moritz" - de = "St. Moritz" - } - keyword { - en = "Switzerland" - de = "Schweiz" - } - - discipline skos { - ref_id = "https://skos.um.es/unesco6/5501" - description = "Local history" - url = "https://skos.um.es/unesco6/5501" - } - - spatial_coverage geonames { - ref_id = "https://www.geonames.org/2658822" - description = "St. Moritz" - url = "https://www.geonames.org/2658822" - } - temporal_coverage chronontology { - ref_id = "https://chronontology.dainst.org/period/INtagfT8h7Fs" - description = "20th and 21st Centuries" - url = "https://chronontology.dainst.org/period/INtagfT8h7Fs" - } - temporal_coverage chronontology { - ref_id = "https://chronontology.dainst.org/period/kqORhO4TGm4n" - description = "20th Century (1900 - 1999)" - url = "https://chronontology.dainst.org/period/kqORhO4TGm4n" - } - - publication { - text = "Bibliothek St. Moritz Dokumentation" - } - - // reference to person or organization (0-1) - contact_point = "gemeinde_st_moritz" - - // reference to datasets (1-n) - datasets = ["http://ns.dasch.swiss/repository#dsp-0804-dataset-000"] - - // reference to grants (0-n) - grants = ["http://ns.dasch.swiss/repository#dsp-0804-grant-000"] -} - -dataset { - id = "http://ns.dasch.swiss/repository#dsp-0804-dataset-000" - created_at = 1630601300976368000 - created_by = "dsp-metadata-gui" - title = "Dokumentationsbibliothek St. Moritz Bilddatenbank" - how_to_cite = "Dokumentationsbibliothek St. Moritz" - status = "Ongoing" - access_conditions = "Restricted" - date_published = 1630601300976368000 - type_of_data = ["Image", "Text"] - - abstract { - en = "Bilddatenbank makes accessible the collection of historic photographs and other graphical representation of St. Moritz Dokumentationsbibliothek" - } - - license { - type = "creative_commons" - href = "https://creativecommons.org/licenses/by-nc/4.0" - date = "2021-09-02" - label = "CC BY-NC 4.0" - } - - language { - de = "Deutsch" - } - language { - en = "German" - } - language { - fr = "Allemand" - } - - attribution { - agent = "http://ns.dasch.swiss/repository#dsp-0804-organization-001" - roles = [ - "Creator", - "Publisher" - ] - } -} - -dmp { - available = false -} - -grant { - id = "http://ns.dasch.swiss/repository#dsp-0804-grant-000" - created_at = 1630601300976368000 - created_by = "dsp-metadata-gui" - type = "Funding" - name = "Ordinary Budget" - funders = ["http://ns.dasch.swiss/repository#dsp-0804-organization-000"] // reference to person or organization -} - -organization { - id = "http://ns.dasch.swiss/repository#dsp-0804-organization-000" - created_at = "1630601301506212000" - created_by = "dsp-metadata-gui" - name = "Gemeinde St. Moritz" - - address { - street = "" - postal_code = "7500" - locality = "St. Moritz" - country = "Switzerland" - } -} - -organization "biblio_stmoritz" { - id = "http://ns.dasch.swiss/repository#dsp-0804-organization-001" - created_at = "1630601301561696000" - created_by = "dsp-metadata-gui" - email = "doku@biblio-stmoritz.ch" - name = "Dokumentationsbibliothek St. Moritz" - - url { - href = "https://www.biblio-stmoritz.ch" - label = "www.biblio-stmoritz.ch" - } - - address { - street = "Plazza da Scoula 14" - postal_code = "7500" - locality = "St. Moritz" - country = "Switzerland" - } -} diff --git a/data/hdm.hcl b/data/hdm.hcl deleted file mode 100644 index d4f103bb..00000000 --- a/data/hdm.hcl +++ /dev/null @@ -1,173 +0,0 @@ -version = 1 - -project { - id = "http://ns.dasch.swiss/repository#dsp-081C-project" - created_at = 1630601274523025000 - created_by = "dsp-metadata-gui" - shortcode = "081C" - name = "Hôtel de Musique Bern" - - teaser_text = "The database documents the different kinds of spectacles such as theatre plays, operas, ballets, or concerts that took place in the Hôtel de Musique in Bern between 1766 and 1905." - - description { - en = "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century." - } - - url { - href = "https://admin.dasch.swiss/project/081C" - label = "Discover Project Data" - } - - how_to_cite = "HdM-Bern" - start_date = "2009-04-01" - end_date = "2015-04-01" - - status = "Finished" - - keyword { - en = "19 Century" - } - keyword { - de = "Bern" - } - keyword { - en = "Concert" - } - keyword { - en = "Music" - } - keyword { - en = "Musicology" - } - keyword { - en = "Opera" - } - keyword { - en = "Spectales" - } - keyword { - en = "Switzerland" - } - keyword { - en = "Theater history" - } - keyword { - en = "Theatre" - } - - discipline snf { - ref_id = "10302" - description = "Schweizer Geschichte" - url = "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - } - discipline snf { - ref_id = "10405" - description = "Musikologie" - url = "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - } - discipline snf { - ref_id = "10406" - description = "Theater-und Filmwissenschaften" - url = "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - } - discipline snf { - ref_id = "10604" - description = "Musik und Theater" - url = "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - } - - spatial_coverage geonames { - ref_id = "https://www.geonames.org/2661552" - description = "Bern" - url = "https://www.geonames.org/2661552" - } - - temporal_coverage periodo { - ref_id = "https://n2t.net/ark:/99152/p06c6g3pvr5" - description = "Under Mediation act, 1803-1814" - url = "https://n2t.net/ark:/99152/p06c6g3pvr5" - } - temporal_coverage periodo { - ref_id = "https://n2t.net/ark:/99152/p06c6g3p4cf" - description = "Sonderbund, 1845-1847" - url = "https://n2t.net/ark:/99152/p06c6g3p4cf" - } - temporal_coverage periodo { - ref_id = "https://n2t.net/ark:/99152/p06c6g364np" - description = "Helvetic Republic, 1798-1803" - url = "https://n2t.net/ark:/99152/p06c6g364np" - } - temporal_coverage text { - de = "1766-1905" - en = "1766-1905" - fr = "1766-1905" - } - datasets = ["http://ns.dasch.swiss/repository#dsp-081C-dataset-000"] - - // reference to grants (0-n) - grants = ["http://ns.dasch.swiss/repository#dsp-081C-grant-000"] -} - -dataset { - id = "http://ns.dasch.swiss/repository#dsp-081C-dataset-000" - created_at = 1630601285266958000 - created_by = "dsp-metadata-gui" - title = "Hôtel de Musique Bern" - how_to_cite = "HdM-Bern" - status = "Finished" - access_conditions = "Open" - date_published = 1630601285266958000 - type_of_data = ["Text"] - - abstract { - en = "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century." - } - - license { - type = "creative_commons" - href = "https://creativecommons.org/licenses/by-nc/4.0" - date = "2021-09-02" - label = "CC BY-NC 4.0" - } - - language { - de = "Deutsch" - en = "German" - fr = "Allemand" - } - - // reference to person or organization - attribution { - agent = "http://ns.dasch.swiss/repository#dsp-081C-organization-000" // reference to person or organization - roles = ["Author"] - } -} - -grant { - id = "http://ns.dasch.swiss/repository#dsp-081C-grant-000" - created_at = 1630601285796580000 - created_by = "dsp-metadata-gui" - type = "funding" - name = "Hôtel de Musique Bern" - funders = ["http://ns.dasch.swiss/repository#dsp-081C-organization-000"] -} - -organization { - id = "http://ns.dasch.swiss/repository#dsp-081C-organization-000" - created_at = 1630601285796580000 - created_by = "dsp-metadata-gui" - name = "Institut für Musikwissenschaft der Universität Bern" - email = "urchueguia@musik.unibe.ch" - - url { - href = "https://www.musik.unibe.ch" - label = "https://www.musik.unibe.ch" - } - - address { - street = "Mittelstr. 43" - postal_code = "3011" - locality = "Bern" - country = "Switzerland" - } -} diff --git a/data/incunabula.hcl b/data/incunabula.hcl deleted file mode 100644 index 549d8710..00000000 --- a/data/incunabula.hcl +++ /dev/null @@ -1,256 +0,0 @@ -version = 1 - -project { - id = "http://ns.dasch.swiss/repository#dsp-0803-project" - created_at = 1637624150548721000 - created_by = "dsp-metadata-gui" - shortcode = "0803" - name = "Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre" - - alternative_name { - en = "Incunabula" - } - - teaser_text = "An art-scientific monograph of the richly illustrated early prints in Basel - the most important center of early letterpress printing in the territory of present-day Switzerland." - - description { - de = "Eine kunstwissenschaftliche Monographie der reich bebilderten Frühdrucke in Basel - dem wichtigsten Zentrum des frühen Buchdrucks auf dem Gebiet der heutigen Schweiz - wird im vorliegenden Projekt erstmals seit über einem Jahrhundert ins Auge gefasst. Im Zentrum stehen 18 Werke aus vier verschiedenen Offizinen, welche insgesamt über 1000 Holzschnitte enthalten, die bedeutendsten überlieferten Basler Bilderfolgen des Spätmittelalters nach den massiven Zerstörungen im Zuge der Reformation. Bei den Texten handelt es sich fast ausschliesslich um deutsche und lateinische Kompilationen religiösen, didaktischen Inhalts, darunter viele zeitgenössische und in Basel entstandene, neben Übersetzungen des 15. Jahrhunderts und vollständig überarbeiteten Ausgaben bereits verbreiteter Werke. Äusserst erfolgreiche Bücher wie das Narrenschiff oder der Heilsspiegel stehen neben kaum bekannten wie den seelsorgerischen Schriften des Kartäusers Ludwig Moser und des Franziskaners Johannes Meder. Die Analyse eines umfassenden Corpus bebilderter Frühdrucke fehlt in der neueren Forschung, welche sich bezüglich der Basler Produktion vorwiegend der Untersuchung der Produzentenkreise gewidmet, die Bilder dagegen - mit Ausnahme des Narrenschiffs - wenig beachtet hat. Sehr heterogen ist auch die Erforschung der Texte, von denen ein grosser Teil unediert geblieben ist, von anderen wiederum existieren ausführlich kommentierte Faksimileausgaben. Die bisherige Bild-Text-Forschung hat sich auf das Narrenschiff fokussiert.Neben der Quellenanalyse der Bilder und Texte strebt das Projekt eine umfassende Untersuchung der Bild-Text-Bezüge unter Berücksichtigung rezeptionsästethischer Fragestellungen an. Gefragt wird nach der Funktion der Bilder für die spätmittelalterlichen visuellen und auditiven Rezipienten. Dabei wird davon ausgegangen, dass es sich bei unseren Frühdrucken ausnahmslos um kalkulierte Bild-Text-Kompilationen handelt, welche einen reflektierten und kreativen Umgang ihrer Produzenten mit den drucktechnischen Möglichkeiten des neuen Mediums voraussetzen, wie z.B. mit der Möglichkeit der vielfältigen Kontextualisierung von Bildern. Die Analyse der Bild- und Textquellen liefert eine umfassende Fallstudie zum Medienwechsel zwischen Handschrift und Frühdruck, diejenige der Bild-Text-Bezüge im Spannungsfeld zwischen mündlicher Tradierung und schriftlicher Fixierung religiöser Didaxe eine Fallstudie zur spätmittelalterlichen Rezeptionsforschung.Methodisch knüpft das Projekt an rezeptionsästhetische Konzepte und Studien der jüngeren literaturwissenschaftlichen Forschung an, welche mit ikonographischen Analysen kombiniert werden. Durch diese Erweiterung textzentrierter methodischer Ansätze treten die Texte in Bezug auf die Bilder nicht mehr als übergeordnete, unabhängige Einheiten in den Blick, sondern die Konstruktion des Werksinnes erscheint im Wechselspiel der Medien. Der traditionelle Begriff der Buchillustration wird dadurch grundlegend revidiert.Neben mehreren Aufsätzen und einer Tagung sind eine Monographie in Buchform geplant, welche sich an die Fachwelt sowie an eine interessierte Öffentlichkeit wendet, ausserdem eine Internet-Publikation der Bild- und Textquellen im Rahmen der Zusammenarbeit mit der Basler Univeristätsbibliothek." - } - - url { - href = "https://admin.dasch.swiss/project/3ABR_2i8QYGSIDvmP9mlEw" - label = "Discover Project Data" - } - - how_to_cite = "Incunabula" - start_date = "2008-06-01" - end_date = "2012-08-31" - - status = "Finished" - - keyword { - de = "Basel" - } - keyword { - en = "Contextualisation of images" - } - keyword { - en = "Late Middle Ages" - } - keyword { - en = "Letterpress Printing" - } - - discipline snf { - ref_id = "10404" - description = "Visual arts and Art history" - url = "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - } - - publication { - text = "Graf Kathrin (2011), Klerikersatiren in Bild und Text. Zur Kompilationstechnik im Narrenschiff, in Krause Karin u. Schellewald Barbara (ed.), 205-227." - } - publication { - text = "Krause Karin u. Schellewald Barbara (ed.) (2011), Bild und Text im Mittelalter." - } - publication { - text = "Rosenthaler Lukas u. Ryf Patrick (2009), Incunabula Basilea: A Web 2.0 Application as Research Tool to Early Prints, in Archiving, 6, 175-177." - } - publication { - text = "Rosenthaler Lukas u. Schweizer Tobias (2012), SALSAH - eine webbasierte Forschungsplattform für die Geisteswissenschaften, in SAGW Bulletin, 32-33." - } - publication { - text = "Rosenthaler Lukas, Virtual Research Environments. A New Approach for Dealing with Digitized Sources in Research in Arts and Humanities, in Clivaz Claire (ed.), ebook auf der Plattform http://www.ppur.info/lire-demain.html, Lausanne, 661-670." - } - publication { - text = "Rosenthaler Lukas, Virtual Research Environments. A New Approach for Dealing with Digitized Sources in Research in Arts and Humanities, in Clivaz Claire (ed.), ebook auf der Plattform http://www.ppur.info/lire-demain.html, Lausanne, 661-670." - } - publication { - text = "Ryf Patrick u. Rosenthaler Lukas (2010), SALSAH: System for Annotation and Linkage of Sources in Arts and Humanities. Eine Web 2.0 Applikation zur wissenschaftlichen Betrachtung und Bearbeitung von historischem Bild- und Textmaterial, in Bienert Andreas u.a. (ed.), GFaI, Berlin, 123-126." - } - publication { - text = "Schmitt Lothar (2009), Sebastian Brant, Albrecht Dürer und das Narrenschiff, in Wolfenbütteler Abhandlungen zur Renaissanceforschung, 26, 347-412." - } - publication { - text = "Schmitt Lothar (2010), Mehr als Dürer. Die Ilustrationen in Friedrich Riederers \"Spiegel der wahren Rhetorik\", in Knape Joachim u. Luppold Stefanie (ed.), 191-216." - } - publication { - text = "Schweizer Tobias u. Rosenthaler Lukas (2011), SALSAH - eine virtuelle Forschungsumgebung für die Geisteswissenschaften, in Bienert Andreas u.a. (ed.), GFaI, Berlin, 147-153." - } - publication { - text = "Schweizer Tobias, Development of a Topographical Transcription Method, in Clivaz Claire u. a. (ed.), ebook, auf der Plattform http://www.ppur.info/lire-demain.html, Lausanne, 671-680." - } - datasets = ["http://ns.dasch.swiss/repository#dsp-0803-dataset-000"] - - grants = ["http://ns.dasch.swiss/repository#dsp-0803-grant-000"] -} - -dataset { - id = "http://ns.dasch.swiss/repository#dsp-0803-dataset-000" - created_at = 1637624150907146000 - created_by = "dsp-metadata-gui" - title = "Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre" - how_to_cite = "dokubib" - status = "Finished" - access_conditions = "Open" - date_published = 1630601285266958000 - type_of_data = ["Text", "Image"] - - abstract { - en = "The interdisciplinary research project \"The image sequences of Basel's early prints: Late Medieval didactic didactics as an image-text reading\" combines a comprehensive art scholarly analysis of the links between images and texts in the illustrated incunabula in Basel with the digitization of the holdings of the University Library and the development of an electronic edition in the form of a new kind of Web-0.2 application. The project is carried out by Kunsthistorische Seminar of the University of Basel (Prof. Dr. B. Schellewald) and Digital Humanities Lab of the University of Basel (Prof. Dr. L. Rosenthaler). The core of the digital edition consists of around twenty richly illustrated early prints from four different Basel officers. Many of them appeared in several editions before 1500, some of them in German and Latin at almost the same time. It is an extraordinarily varied production; in addition to the Mirror of Salvation, there is a novel, the Melusine, the travelogues of Jean de Mandeville, some prayer and edification books, theological writings, Lent sermons, the lives of Saints Fridolin and Meinrad, the famous ship of fools and the knight of Thurn. The Internet publication makes the digitized corpus of these early prints usable for the scientific edition as well as for the exploration of images and texts through the possibilities of non-linear linking and commenting on the images and texts. Existing and emerging online editions can also be linked to it, which optimises the use of databases from other institutions with regard to our corpus." - } - - license { - type = "creative_commons" - href = "https://creativecommons.org/licenses/by-nc/4.0" - date = "2021-09-02" - label = "CC BY-NC 4.0" - } - - language { - de = "Deutsch" - en = "German" - fr = "Allemand" - } - - // reference to person or organization - attribution { - agent = "katrin_graf_lamei" - roles = ["Employee"] - } - // reference to person or organization - attribution { - agent = "barbara_schellewald" - roles = ["Applicant"] - } - // reference to person or organization - attribution { - agent = "lothar_schmidt" - roles = ["Employee"] - } - // reference to person or organization - attribution { - agent = "hannes_hug" - roles = ["Co-Applicant"] - } - // reference to person or organization - attribution { - agent = "lukas_rosenthaler" - roles = ["Co-Applicant"] - } -} - -grant { - id = "http://ns.dasch.swiss/repository#dsp-0803-grant-000" - created_at = "1637624150958979000" - created_by = "dsp-metadata-gui" - type = "Project funding" - name = "Project funding" - number = "120378" - funders = ["http://ns.dasch.swiss/repository#dsp-0803-organization-003"] // reference to person or organization (1-n) - - url { - href = "https://data.snf.ch/grants/grant/120378" - label = "https://data.snf.ch/grants/grant/120378" - } -} - -person "barbara_schellewald" { - id = "http://ns.dasch.swiss/repository#dsp-0803-person-000" - created_at = "1637624150958979000" - created_by = "dsp-metadata-gui" - - family_name { - text = "Schellewald" - } - given_name { - text = "Barbara" - } - // reference to organization (1-n) - affiliation = ["kunst_seminar_unibas"] -} - -person "hannes_hug" { - id = "http://ns.dasch.swiss/repository#dsp-0803-person-001" - created_at = "1637624150959055000" - created_by = "dsp-metadata-gui" - - family_name { - text = "Hug" - } - given_name { - text = "Hannes" - } - // reference to organization (1-n) - affiliation = ["ub_unibas"] -} - -person "lukas_rosenthaler" { - id = "http://ns.dasch.swiss/repository#dsp-0803-person-002" - created_at = "1637624150959124000" - created_by = "dsp-metadata-gui" - - family_name { - text = "Rosenthaler" - } - given_name { - text = "Lukas" - } - // reference to organization (1-n) - affiliation = ["dhlab_basel"] -} - -person "lothar_schmitt" { - id = "http://ns.dasch.swiss/repository#dsp-0803-person-003" - created_at = "1637624150959191000" - created_by = "dsp-metadata-gui" - - family_name { - text = "Schmitt" - } - given_name { - text = "Lothar" - } - - // reference to organization (1-n) - affiliation = ["dhlab_basel"] -} - -person "katrin_graf_lamei" { - id = "http://ns.dasch.swiss/repository#dsp-0803-person-004" - created_at = "1637624150959244000" - created_by = "dsp-metadata-gui" - - family_name { - text = "Graf" - } - family_name { - text = "Lamei" - } - given_name { - text = "Katrin" - } - - // reference to organization (1-n) - affiliation = ["dhlab_basel"] -} - -organization "kunst_seminar_unibas" { - id = "http://ns.dasch.swiss/repository#dsp-0803-organization-000" - name = "Kunsthistorisches Seminar Universität Basel" -} - -organization "ub_unibas" { - id = "http://ns.dasch.swiss/repository#dsp-0803-organization-001" - name = "Universität Basel Universitätsbibliothek Sekretariat" -} - -organization "dhlab_basel" { - id = "http://ns.dasch.swiss/repository#dsp-0803-organization-002" - name = "Digital Humanities Lab Philosophisch-Historische Fakultät Universität Basel" -} - -organization { - id = "http://ns.dasch.swiss/repository#dsp-0803-organization-003" - name = "Swiss National Science Foundation (SNSF)" -} diff --git a/dsp-domain/src/error.rs b/dsp-domain/src/error.rs deleted file mode 100644 index 9fe8891d..00000000 --- a/dsp-domain/src/error.rs +++ /dev/null @@ -1,16 +0,0 @@ -use thiserror::Error; - -/// Type alias for `Result` with default error `DspDomainError`. -/// -/// Can be used like `std::result::Result` as well. -pub type Result = std::result::Result; - -/// This error is raised when a domain entity or value fails creation -/// at runtime. -#[derive(Debug, Error)] -pub enum DspDomainError { - #[error("Error creating value object: `{0}`")] - CreateValueObject(String), - #[error("Error creating domain object.")] - CreateDomainObject(String), -} diff --git a/dsp-domain/src/lib.rs b/dsp-domain/src/lib.rs deleted file mode 100644 index d19c750d..00000000 --- a/dsp-domain/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod error; -pub mod metadata; -mod ontology; diff --git a/dsp-domain/src/metadata/entity/dataset.rs b/dsp-domain/src/metadata/entity/dataset.rs deleted file mode 100644 index 19eed3cd..00000000 --- a/dsp-domain/src/metadata/entity/dataset.rs +++ /dev/null @@ -1,32 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::access::Access; -use crate::metadata::value::attribution::Attribution; -use crate::metadata::value::data_type::DataType; -use crate::metadata::value::identifier::DatasetId; -use crate::metadata::value::language::Language; -use crate::metadata::value::license::License; -use crate::metadata::value::r#abstract::Abstract; -use crate::metadata::value::status::Status; -use crate::metadata::value::url::Url; -use crate::metadata::value::{CreatedAt, CreatedBy, DatePublished, HowToCite, Title}; - -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct Dataset { - pub id: DatasetId, // (1) - pub created_at: CreatedAt, // (1) - pub created_by: CreatedBy, // (1) - pub title: Title, // (1) - pub status: Status, // (1) - pub access_conditions: Access, // (1) - pub how_to_cite: HowToCite, // (1) - pub date_published: Option, // (0-1) - pub type_of_data: Vec, // (1-n) - pub alternative_titles: Vec, // (0-n) - pub abstracts: Vec<Abstract>, // (1-n) - pub licenses: Vec<License>, // (1-n) - pub languages: Vec<Language>, // (1-n) - pub attributions: Vec<Attribution>, // (1-n) - - pub urls: Vec<Url>, // (0-n) -} diff --git a/dsp-domain/src/metadata/entity/grant.rs b/dsp-domain/src/metadata/entity/grant.rs deleted file mode 100644 index d1ce3e2b..00000000 --- a/dsp-domain/src/metadata/entity/grant.rs +++ /dev/null @@ -1,18 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::funder::Funder; -use crate::metadata::value::identifier::GrantId; -use crate::metadata::value::url::Url; -use crate::metadata::value::{CreatedAt, CreatedBy, GrantNumber, GrantType, Name}; - -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct Grant { - pub id: GrantId, // (1) - pub created_at: CreatedAt, // (1) - pub created_by: CreatedBy, // (1) - pub type_of_grant: GrantType, // (1) - pub name: Option<Name>, // (0-1) - pub number: Option<GrantNumber>, // (0-1) - pub url: Option<Url>, // (0-1) - pub funders: Vec<Funder>, // (1-n) -} diff --git a/dsp-domain/src/metadata/entity/mod.rs b/dsp-domain/src/metadata/entity/mod.rs deleted file mode 100644 index ec828f8d..00000000 --- a/dsp-domain/src/metadata/entity/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod dataset; -pub mod grant; -mod organization; -mod person; -pub mod project; -pub mod project_metadata; diff --git a/dsp-domain/src/metadata/entity/organization.rs b/dsp-domain/src/metadata/entity/organization.rs deleted file mode 100644 index b4df1037..00000000 --- a/dsp-domain/src/metadata/entity/organization.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::identifier::OrganizationId; - -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct Organization { - pub id: OrganizationId, -} diff --git a/dsp-domain/src/metadata/entity/person.rs b/dsp-domain/src/metadata/entity/person.rs deleted file mode 100644 index 7f693ace..00000000 --- a/dsp-domain/src/metadata/entity/person.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::identifier::PersonId; - -#[derive(Debug, Clone, Default, PartialEq, Serialize)] -pub struct Person { - pub id: PersonId, -} diff --git a/dsp-domain/src/metadata/entity/project.rs b/dsp-domain/src/metadata/entity/project.rs deleted file mode 100644 index ecd8fdc7..00000000 --- a/dsp-domain/src/metadata/entity/project.rs +++ /dev/null @@ -1,35 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::alternative_name::AlternativeName; -use crate::metadata::value::description::Description; -use crate::metadata::value::discipline::Discipline; -use crate::metadata::value::identifier::{DatasetId, ProjectId}; -use crate::metadata::value::keyword::Keyword; -use crate::metadata::value::publication::Publication; -use crate::metadata::value::status::Status; -use crate::metadata::value::url::Url; -use crate::metadata::value::{ - ContactPoint, CreatedAt, CreatedBy, EndDate, HowToCite, Name, Shortcode, StartDate, TeaserText, -}; - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct Project { - pub id: ProjectId, - pub created_at: CreatedAt, - pub created_by: CreatedBy, - pub shortcode: Shortcode, - pub name: Name, - pub alternative_names: Vec<AlternativeName>, - pub teaser_text: TeaserText, - pub description: Description, - pub url: Url, - pub how_to_cite: HowToCite, - pub start_date: StartDate, - pub end_date: Option<EndDate>, - pub status: Status, - pub contact_point: Option<ContactPoint>, - pub keywords: Vec<Keyword>, - pub disciplines: Vec<Discipline>, - pub publications: Vec<Publication>, - pub datasets: Vec<DatasetId>, -} diff --git a/dsp-domain/src/metadata/entity/project_metadata.rs b/dsp-domain/src/metadata/entity/project_metadata.rs deleted file mode 100644 index 315dc729..00000000 --- a/dsp-domain/src/metadata/entity/project_metadata.rs +++ /dev/null @@ -1,19 +0,0 @@ -use serde::Serialize; - -use crate::metadata::entity::dataset::Dataset; -use crate::metadata::entity::grant::Grant; -use crate::metadata::entity::organization::Organization; -use crate::metadata::entity::person::Person; -use crate::metadata::entity::project::Project; -use crate::metadata::value::version::Version; - -/// The Metadata struct represents the metadata of a DSP project. -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct ProjectMetadata { - pub version: Version, - pub project: Project, - pub datasets: Vec<Dataset>, - pub grants: Vec<Grant>, - pub organizations: Vec<Organization>, - pub persons: Vec<Person>, -} diff --git a/dsp-domain/src/metadata/mod.rs b/dsp-domain/src/metadata/mod.rs deleted file mode 100644 index 8b5893d0..00000000 --- a/dsp-domain/src/metadata/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod entity; -pub mod value; diff --git a/dsp-domain/src/metadata/value/abstract.rs b/dsp-domain/src/metadata/value/abstract.rs deleted file mode 100644 index fbc57458..00000000 --- a/dsp-domain/src/metadata/value/abstract.rs +++ /dev/null @@ -1,26 +0,0 @@ -use std::collections::HashMap; - -use serde::Serialize; - -use crate::metadata::value::iso_code::IsoCode; -use crate::metadata::value::lang_text_data::LangTextData; - -/// A set of abstracts in different languages. -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct Abstract(pub HashMap<IsoCode, String>); - -impl Default for Abstract { - fn default() -> Self { - let mut map: HashMap<IsoCode, String> = HashMap::new(); - map.insert(IsoCode::DE, String::from("Die Default-Auszug.")); - map.insert(IsoCode::EN, String::from("The default abstract.")); - map.insert(IsoCode::FR, String::from("Le standard abstract.")); - Self(map) - } -} - -impl From<LangTextData> for Abstract { - fn from(value: LangTextData) -> Self { - Abstract(value.0) - } -} diff --git a/dsp-domain/src/metadata/value/access.rs b/dsp-domain/src/metadata/value/access.rs deleted file mode 100644 index 7158bcd4..00000000 --- a/dsp-domain/src/metadata/value/access.rs +++ /dev/null @@ -1,27 +0,0 @@ -use serde::Serialize; - -use crate::error::DspDomainError; - -#[derive(Clone, Debug, Default, PartialEq, Serialize)] -pub enum Access { - #[default] - Open, - Restricted, - Closed, -} - -impl TryFrom<String> for Access { - type Error = DspDomainError; - - fn try_from(value: String) -> Result<Self, Self::Error> { - match value.as_str() { - "Open" => Ok(Access::Open), - "Restricted" => Ok(Access::Restricted), - "Closed" => Ok(Access::Closed), - _ => Err(DspDomainError::CreateValueObject(format!( - "Creating Access failed because provided value '{}' is not allowed.", - value - ))), - } - } -} diff --git a/dsp-domain/src/metadata/value/alternative_name.rs b/dsp-domain/src/metadata/value/alternative_name.rs deleted file mode 100644 index f058935e..00000000 --- a/dsp-domain/src/metadata/value/alternative_name.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::collections::HashMap; - -use serde::Serialize; - -use crate::metadata::value::iso_code::IsoCode; -use crate::metadata::value::lang_text_data::LangTextData; - -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct AlternativeName(pub HashMap<IsoCode, String>); - -impl Default for AlternativeName { - fn default() -> Self { - let mut map: HashMap<IsoCode, String> = HashMap::new(); - map.insert(IsoCode::DE, String::from("Der Default AlternativeName.")); - map.insert(IsoCode::EN, String::from("The default AlternativeName.")); - map.insert(IsoCode::FR, String::from("Le default AlternativeName.")); - Self(map) - } -} - -impl From<LangTextData> for AlternativeName { - fn from(value: LangTextData) -> Self { - AlternativeName(value.0) - } -} diff --git a/dsp-domain/src/metadata/value/attribution.rs b/dsp-domain/src/metadata/value/attribution.rs deleted file mode 100644 index af7ffe1d..00000000 --- a/dsp-domain/src/metadata/value/attribution.rs +++ /dev/null @@ -1,28 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::identifier::AgentId; - -/// Represents an HCL block which consists of attribute keys and a value expressions. -/// -/// In HCL syntax this is represented as: -/// -/// ```hcl -/// attribution { -/// agent = "identifier of the agent" -/// roles = ["role1", "role2"] -/// } -/// ``` -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -pub struct Attribution { - pub agent: AgentId, - pub roles: Vec<String>, -} - -impl Default for Attribution { - fn default() -> Self { - Attribution { - agent: AgentId("Default agent ID".to_string()), - roles: vec!["role1".to_string(), "role2".to_string()], - } - } -} diff --git a/dsp-domain/src/metadata/value/data_type.rs b/dsp-domain/src/metadata/value/data_type.rs deleted file mode 100644 index 5533ab44..00000000 --- a/dsp-domain/src/metadata/value/data_type.rs +++ /dev/null @@ -1,29 +0,0 @@ -use serde::Serialize; - -use crate::error::DspDomainError; - -#[derive(Clone, Debug, Default, PartialEq, Serialize)] -pub enum DataType { - #[default] - Text, - Image, - Audio, - Video, -} - -impl TryFrom<String> for DataType { - type Error = DspDomainError; - - fn try_from(value: String) -> Result<Self, Self::Error> { - match value.as_str() { - "Text" => Ok(DataType::Text), - "Image" => Ok(DataType::Image), - "Audio" => Ok(DataType::Audio), - "Video" => Ok(DataType::Video), - _ => Err(DspDomainError::CreateValueObject(format!( - "Creating Status failed because provided value '{}' is not allowed.", - value - ))), - } - } -} diff --git a/dsp-domain/src/metadata/value/description.rs b/dsp-domain/src/metadata/value/description.rs deleted file mode 100644 index 48fed13b..00000000 --- a/dsp-domain/src/metadata/value/description.rs +++ /dev/null @@ -1,26 +0,0 @@ -use std::collections::HashMap; - -use serde::Serialize; - -use crate::metadata::value::iso_code::IsoCode; -use crate::metadata::value::lang_text_data::LangTextData; - -/// A set of descriptions in different languages. -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct Description(pub HashMap<IsoCode, String>); - -impl Default for Description { - fn default() -> Self { - Description(HashMap::from_iter([ - (IsoCode::DE, String::from("Die Default-Beschreibung.")), - (IsoCode::EN, String::from("The default description.")), - (IsoCode::FR, String::from("Le standard description.")), - ])) - } -} - -impl From<LangTextData> for Description { - fn from(value: LangTextData) -> Self { - Description(value.0) - } -} diff --git a/dsp-domain/src/metadata/value/discipline.rs b/dsp-domain/src/metadata/value/discipline.rs deleted file mode 100644 index f14e37ec..00000000 --- a/dsp-domain/src/metadata/value/discipline.rs +++ /dev/null @@ -1,23 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::lang_text_data::LangTextData; -use crate::metadata::value::ref_data::RefData; - -/// The discipline of a project can be defined in two ways: -/// 1. A reference to a discipline defined in an external reference system (e.g. SNF or SKOS) -/// 2. A text description of the discipline -/// -/// Example: -/// ```hcl -/// discipline skos { -/// ref_id = "https://skos.um.es/unesco6/5501" -/// description = "Local history" -/// url = "https://skos.um.es/unesco6/5501" -/// } -/// ``` -#[derive(Debug, Clone, PartialEq, Serialize)] -pub enum Discipline { - Skos(RefData), - Snf(RefData), - Text(LangTextData), -} diff --git a/dsp-domain/src/metadata/value/funder.rs b/dsp-domain/src/metadata/value/funder.rs deleted file mode 100644 index b76c2e54..00000000 --- a/dsp-domain/src/metadata/value/funder.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize)] -pub struct Funder(pub String); diff --git a/dsp-domain/src/metadata/value/identifier.rs b/dsp-domain/src/metadata/value/identifier.rs deleted file mode 100644 index f5ca5070..00000000 --- a/dsp-domain/src/metadata/value/identifier.rs +++ /dev/null @@ -1,19 +0,0 @@ -use serde::Serialize; - -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -pub struct ProjectId(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -pub struct DatasetId(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -pub struct GrantId(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -pub struct OrganizationId(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -pub struct PersonId(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -pub struct AgentId(pub String); diff --git a/dsp-domain/src/metadata/value/iso_code.rs b/dsp-domain/src/metadata/value/iso_code.rs deleted file mode 100644 index 216812d4..00000000 --- a/dsp-domain/src/metadata/value/iso_code.rs +++ /dev/null @@ -1,71 +0,0 @@ -use std::fmt::{Display, Formatter}; - -use serde::Serialize; - -use crate::error::DspDomainError; - -/// Language codes according to ISO 639-1 -/// Not an exhaustive list. -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize)] -#[serde(rename_all(serialize = "lowercase"))] -pub enum IsoCode { - #[default] - DE, // German - EN, // English - FR, // French - IT, // Italian - ES, // Spanish - PT, // Portuguese - NL, // Dutch - PL, // Polish - RU, // Russian - JA, // Japanese - ZH, // Chinese - AR, // Arabic - FA, // Persian -} - -impl Display for IsoCode { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - IsoCode::DE => write!(f, "de"), - IsoCode::EN => write!(f, "en"), - IsoCode::FR => write!(f, "fr"), - IsoCode::IT => write!(f, "it"), - IsoCode::ES => write!(f, "es"), - IsoCode::PT => write!(f, "pt"), - IsoCode::NL => write!(f, "nl"), - IsoCode::PL => write!(f, "pl"), - IsoCode::RU => write!(f, "ru"), - IsoCode::JA => write!(f, "ja"), - IsoCode::ZH => write!(f, "zh"), - IsoCode::AR => write!(f, "ar"), - IsoCode::FA => write!(f, "fa"), - } - } -} - -impl TryFrom<&str> for IsoCode { - type Error = DspDomainError; - - fn try_from(value: &str) -> Result<Self, Self::Error> { - match value { - "de" => Ok(IsoCode::DE), - "en" => Ok(IsoCode::EN), - "fr" => Ok(IsoCode::FR), - "it" => Ok(IsoCode::IT), - "es" => Ok(IsoCode::ES), - "pt" => Ok(IsoCode::PT), - "nl" => Ok(IsoCode::NL), - "pl" => Ok(IsoCode::PL), - "ru" => Ok(IsoCode::RU), - "ja" => Ok(IsoCode::JA), - "zh" => Ok(IsoCode::ZH), - "ar" => Ok(IsoCode::AR), - "fa" => Ok(IsoCode::FA), - _ => Err(DspDomainError::CreateValueObject( - "Creating an IsoCode failed because provided value is not allowed.".to_string(), - )), - } - } -} diff --git a/dsp-domain/src/metadata/value/keyword.rs b/dsp-domain/src/metadata/value/keyword.rs deleted file mode 100644 index d63a4bb3..00000000 --- a/dsp-domain/src/metadata/value/keyword.rs +++ /dev/null @@ -1,15 +0,0 @@ -use std::collections::HashMap; - -use serde::Serialize; - -use crate::metadata::value::iso_code::IsoCode; -use crate::metadata::value::lang_text_data::LangTextData; - -#[derive(Clone, Debug, Default, PartialEq, Serialize)] -pub struct Keyword(pub HashMap<IsoCode, String>); - -impl From<LangTextData> for Keyword { - fn from(value: LangTextData) -> Self { - Keyword(value.0) - } -} diff --git a/dsp-domain/src/metadata/value/lang_text_data.rs b/dsp-domain/src/metadata/value/lang_text_data.rs deleted file mode 100644 index 8d83266b..00000000 --- a/dsp-domain/src/metadata/value/lang_text_data.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::collections::HashMap; - -use serde::Serialize; - -use crate::metadata::value::iso_code::IsoCode; - -/// Represents multiple strings in different languages. -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct LangTextData(pub HashMap<IsoCode, String>); diff --git a/dsp-domain/src/metadata/value/language.rs b/dsp-domain/src/metadata/value/language.rs deleted file mode 100644 index ea703fe6..00000000 --- a/dsp-domain/src/metadata/value/language.rs +++ /dev/null @@ -1,26 +0,0 @@ -use std::collections::HashMap; - -use serde::Serialize; - -use crate::metadata::value::iso_code::IsoCode; -use crate::metadata::value::lang_text_data::LangTextData; - -/// A set of abstracts in different languages. -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct Language(pub HashMap<IsoCode, String>); - -impl Default for Language { - fn default() -> Self { - let mut map: HashMap<IsoCode, String> = HashMap::new(); - map.insert(IsoCode::DE, String::from("Deutsch")); - map.insert(IsoCode::EN, String::from("German")); - map.insert(IsoCode::FR, String::from("Allemand")); - Self(map) - } -} - -impl From<LangTextData> for Language { - fn from(value: LangTextData) -> Self { - Language(value.0) - } -} diff --git a/dsp-domain/src/metadata/value/license.rs b/dsp-domain/src/metadata/value/license.rs deleted file mode 100644 index 19f0b4c5..00000000 --- a/dsp-domain/src/metadata/value/license.rs +++ /dev/null @@ -1,58 +0,0 @@ -use serde::Serialize; - -use crate::error::DspDomainError; -use crate::error::DspDomainError::CreateValueObject; - -/// Represents an HCL block which consists of attribute keys and a value expressions. -/// -/// In HCL syntax this is represented as: -/// -/// ```hcl -/// license { -/// type = "creative_commons" -/// href = "https://creativecommons.org/licenses/by-nc/4.0" -/// date = "2021-09-02" -/// label = "CC BY-NC 4.0" -/// } -/// ``` -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -pub struct License { - pub license_type: String, - pub href: url::Url, - pub date: String, - pub label: String, -} - -impl License { - pub fn new( - license_type: String, - url_string: String, - date: String, - label: String, - ) -> Result<Self, DspDomainError> { - let maybe_url = url::Url::try_from(url_string.as_str()); - match maybe_url { - Ok(href) => Ok(License { - license_type, - href, - date, - label, - }), - Err(_) => Err(CreateValueObject( - "Creating an UrlValue failed because provided value is not a valid URL." - .to_string(), - )), - } - } -} - -impl Default for License { - fn default() -> Self { - License { - license_type: "creative_commons".to_string(), - href: url::Url::try_from("https://default.xyz").unwrap(), - date: "2021-09-02".to_string(), - label: "Default license label".to_string(), - } - } -} diff --git a/dsp-domain/src/metadata/value/mod.rs b/dsp-domain/src/metadata/value/mod.rs deleted file mode 100644 index 6231d04e..00000000 --- a/dsp-domain/src/metadata/value/mod.rs +++ /dev/null @@ -1,72 +0,0 @@ -use serde::Serialize; - -pub mod r#abstract; -pub mod access; -pub mod alternative_name; -pub mod attribution; -pub mod data_type; -pub mod description; -pub mod discipline; -pub mod funder; -pub mod identifier; -pub mod iso_code; -pub mod keyword; -pub mod lang_text_data; -pub mod language; -pub mod license; -pub mod publication; -pub mod ref_data; -pub mod simple_text_data; -pub mod spatial_coverage; -pub mod status; -pub mod temporal_coverage; -pub mod url; -pub mod version; - -#[derive(Debug, Default, Clone, PartialEq)] -pub struct ID(String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct CreatedAt(pub u64); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct CreatedBy(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct Shortcode(pub String); - -impl Shortcode { - pub fn as_string(&self) -> String { - self.0.to_string() - } -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct Name(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct TeaserText(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct HowToCite(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct StartDate(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct EndDate(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct ContactPoint(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct Title(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct DatePublished(pub u64); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct GrantType(pub String); - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct GrantNumber(pub String); diff --git a/dsp-domain/src/metadata/value/publication.rs b/dsp-domain/src/metadata/value/publication.rs deleted file mode 100644 index 8f0d4cb2..00000000 --- a/dsp-domain/src/metadata/value/publication.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::simple_text_data::SimpleTextData; - -#[derive(Clone, Debug, PartialEq, Serialize)] -pub enum Publication { - SimpleText(SimpleTextData), -} diff --git a/dsp-domain/src/metadata/value/ref_data.rs b/dsp-domain/src/metadata/value/ref_data.rs deleted file mode 100644 index bb0e41c8..00000000 --- a/dsp-domain/src/metadata/value/ref_data.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::Serialize; - -#[derive(Debug, Clone, PartialEq, Serialize)] -pub struct RefData { - pub ref_id: String, - pub description: String, - pub url: url::Url, -} diff --git a/dsp-domain/src/metadata/value/simple_text_data.rs b/dsp-domain/src/metadata/value/simple_text_data.rs deleted file mode 100644 index b0d27939..00000000 --- a/dsp-domain/src/metadata/value/simple_text_data.rs +++ /dev/null @@ -1,12 +0,0 @@ -use serde::Serialize; - -use crate::metadata::value::publication::Publication; - -#[derive(Clone, Debug, PartialEq, Serialize)] -pub struct SimpleTextData(pub String); - -impl SimpleTextData { - pub fn to_simple_text(&self) -> Publication { - Publication::SimpleText(self.to_owned()) - } -} diff --git a/dsp-domain/src/metadata/value/spatial_coverage.rs b/dsp-domain/src/metadata/value/spatial_coverage.rs deleted file mode 100644 index 62079cc5..00000000 --- a/dsp-domain/src/metadata/value/spatial_coverage.rs +++ /dev/null @@ -1,6 +0,0 @@ -use crate::metadata::value::ref_data::RefData; - -#[derive(Debug, PartialEq)] -pub enum SpatialCoverage { - Geonames(RefData), -} diff --git a/dsp-domain/src/metadata/value/status.rs b/dsp-domain/src/metadata/value/status.rs deleted file mode 100644 index a48873c5..00000000 --- a/dsp-domain/src/metadata/value/status.rs +++ /dev/null @@ -1,25 +0,0 @@ -use serde::Serialize; - -use crate::error::DspDomainError; - -#[derive(Clone, Debug, Default, PartialEq, Serialize)] -pub enum Status { - #[default] - Ongoing, - Finished, -} - -impl TryFrom<String> for Status { - type Error = DspDomainError; - - fn try_from(value: String) -> Result<Self, Self::Error> { - match value.as_str() { - "Ongoing" => Ok(Status::Ongoing), - "Finished" => Ok(Status::Finished), - _ => Err(DspDomainError::CreateValueObject(format!( - "Creating Status failed because provided value '{}' is not allowed.", - value - ))), - } - } -} diff --git a/dsp-domain/src/metadata/value/temporal_coverage.rs b/dsp-domain/src/metadata/value/temporal_coverage.rs deleted file mode 100644 index 436438ce..00000000 --- a/dsp-domain/src/metadata/value/temporal_coverage.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::metadata::value::lang_text_data::LangTextData; -use crate::metadata::value::ref_data::RefData; - -#[derive(Debug, PartialEq)] -pub enum TemporalCoverage { - Chronontology(RefData), - Periodo(RefData), - Text(LangTextData), -} diff --git a/dsp-domain/src/metadata/value/url.rs b/dsp-domain/src/metadata/value/url.rs deleted file mode 100644 index 8e05a0bd..00000000 --- a/dsp-domain/src/metadata/value/url.rs +++ /dev/null @@ -1,39 +0,0 @@ -use serde::Serialize; - -/// Represents an HCL block which consists of attribute keys and a value expressions. -/// -/// In HCL syntax this is represented as: -/// -/// ```hcl -/// url { -/// href = "https://www.google.com" -/// label = "text describing the link" -/// } -/// ``` -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -pub struct Url { - pub href: url::Url, - pub label: String, -} - -impl Url { - pub fn new(url_string: String, label: String) -> Result<Self, String> { - let maybe_url = url::Url::try_from(url_string.as_str()); - match maybe_url { - Ok(href) => Ok(Url { href, label }), - Err(_) => Err( - "Creating an UrlValue failed because provided value is not a valid URL." - .to_string(), - ), - } - } -} - -impl Default for Url { - fn default() -> Self { - Url { - href: url::Url::try_from("https://default.xyz").unwrap(), - label: "Default URL description".to_string(), - } - } -} diff --git a/dsp-domain/src/metadata/value/version.rs b/dsp-domain/src/metadata/value/version.rs deleted file mode 100644 index f08b832c..00000000 --- a/dsp-domain/src/metadata/value/version.rs +++ /dev/null @@ -1,4 +0,0 @@ -use serde::Serialize; - -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct Version(pub u64); diff --git a/dsp-domain/src/ontology/mod.rs b/dsp-domain/src/ontology/mod.rs deleted file mode 100644 index 7a38e13e..00000000 --- a/dsp-domain/src/ontology/mod.rs +++ /dev/null @@ -1,236 +0,0 @@ -#![allow(dead_code)] - -// Functional domain for ontologies. -// - -use std::cell::RefCell; -use std::collections::{HashMap, HashSet}; - -use crate::error::DspDomainError; - -type Iri = String; - -#[derive(Debug, PartialEq)] -pub struct Identified(pub Iri); - -#[derive(Debug, PartialEq)] -struct UnIdentified; - -#[derive(Debug, PartialEq)] -struct WithOntologyInfo { - label: String, - project_iri: Iri, - comment: String, -} - -#[derive(Debug, PartialEq)] -struct NoOntologyInfo; - -/// Used to track defined classes inside the ontology -struct DefinedClasses(RefCell<HashSet<Iri>>); - -#[derive(Debug, Clone, PartialEq)] -struct OntologyClass { - id: Iri, // only one per ontology - label: String, - comment: String, -} - -#[derive(Debug, PartialEq)] -struct OntologyProperty { - name: Iri, // only one per ontology - label: String, - comment: String, - range: String, // what type is allowed in object position: subject / predicate / object -} - -#[derive(Debug, PartialEq)] -struct Cardinality { - ontology_class: OntologyClass, - ontology_property: OntologyProperty, - cardinality_type: CardinalityType, -} - -#[derive(Debug, PartialEq)] -enum CardinalityType { - MaxCardinalityOne, - MinCardinalityOne, - MinCardinalityZero, -} - -pub struct Ontology { - id: Iri, - label: String, - project_iri: Iri, - comment: String, -} - -#[derive(Debug, PartialEq)] -struct OntologyBuilder<ID, INFO> { - id: ID, - info: INFO, - classes: HashMap<Iri, OntologyClass>, -} - -/// gives us an empty ontology builder -impl OntologyBuilder<UnIdentified, NoOntologyInfo> { - fn default() -> Self { - Self { - id: UnIdentified, - info: NoOntologyInfo, - classes: HashMap::new(), - } - } -} - -/// we always allow setting the id and info -impl<T> OntologyBuilder<UnIdentified, T> { - fn id(self, iri: Iri) -> OntologyBuilder<Identified, T> { - OntologyBuilder { - id: Identified(iri), - info: self.info, - classes: self.classes, - } - } -} - -impl<T> OntologyBuilder<T, NoOntologyInfo> { - fn info( - self, - label: String, - project_iri: Iri, - comment: String, - ) -> OntologyBuilder<T, WithOntologyInfo> { - OntologyBuilder { - id: self.id, - info: WithOntologyInfo { - label, - project_iri, - comment, - }, - classes: self.classes, - } - } -} - -impl<T, S> OntologyBuilder<T, S> { - fn add_class(mut self, clazz: OntologyClass) -> Result<OntologyBuilder<T, S>, DspDomainError> { - if self.classes.contains_key(&clazz.id) { - return Err(DspDomainError::CreateDomainObject( - "The ontology already contains a class with the same id.".to_string(), - )); - } - let id = clazz.id.clone(); - self.classes.insert(id, clazz); - Ok(self) - } -} - -/// we can only construct the ontology once all needed information is set -impl OntologyBuilder<Identified, WithOntologyInfo> { - fn into_ontology(self) -> Ontology { - Ontology { - id: self.id.0, - label: self.info.label, - project_iri: self.info.project_iri, - comment: self.info.comment, - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn create_empty_ontology() { - let empty = OntologyBuilder::default(); - assert_eq!(empty.id, UnIdentified); - assert_eq!(empty.info, NoOntologyInfo); - } - - #[test] - fn ontology_with_id() { - let empty = OntologyBuilder::default(); - let with_id = empty.id("https:://example.com/example".to_owned()); - assert_eq!( - with_id.id, - Identified("https:://example.com/example".to_owned()) - ); - assert_eq!(with_id.info, NoOntologyInfo); - } - - #[test] - fn ontology_with_info() { - let empty = OntologyBuilder::default(); - - let with_id = empty.id("https:://example.com/example".to_owned()); - let with_info = with_id.info("label".to_owned(), "iri".to_owned(), "comment".to_owned()); - assert_eq!( - with_info.id, - Identified("https:://example.com/example".to_owned()) - ); - assert_eq!( - with_info.info, - WithOntologyInfo { - label: "label".to_owned(), - project_iri: "iri".to_owned(), - comment: "comment".to_owned(), - } - ) - } - - #[test] - fn ontology_with_info_1() { - let empty = OntologyBuilder::default(); - let with_info = empty.info("label".to_owned(), "iri".to_owned(), "comment".to_owned()); - let with_id = with_info.id("https:://example.com/example".to_owned()); - - assert_eq!( - with_id.id, - Identified("https:://example.com/example".to_owned()) - ); - assert_eq!( - with_id.info, - WithOntologyInfo { - label: "label".to_owned(), - project_iri: "iri".to_owned(), - comment: "comment".to_owned(), - } - ) - } - - #[test] - fn ontology_with_class() { - let empty = OntologyBuilder::default(); - let actual = empty - .info("label".to_owned(), "iri".to_owned(), "comment".to_owned()) - .id("https:://example.com/example".to_owned()) - .add_class(OntologyClass { - id: "something".to_string(), - label: "".to_string(), - comment: "".to_string(), - }); - - assert!(actual.unwrap().classes.contains_key("something")); - } - - #[test] - fn error_adding_duplicate_class() { - let empty = OntologyBuilder::default(); - let actual = empty - .add_class(OntologyClass { - id: "something".to_string(), - label: "".to_string(), - comment: "".to_string(), - }) - .unwrap() - .add_class(OntologyClass { - id: "something".to_string(), - label: "".to_string(), - comment: "".to_string(), - }); - - assert!(actual.is_err()); - } -} diff --git a/dsp-meta/Cargo.toml b/dsp-meta/Cargo.toml index e460a1f2..8b781e62 100644 --- a/dsp-meta/Cargo.toml +++ b/dsp-meta/Cargo.toml @@ -13,7 +13,6 @@ authors.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dsp-domain = { path = "../dsp-domain" } anyhow.workspace = true axum.workspace = true axum-macros.workspace = true @@ -46,7 +45,3 @@ chrono.workspace = true assert_cmd = "2.0.16" axum-test = "15.3.0" fake = "2.9.2" - -[[test]] -name = "integration_test" -test = true diff --git a/dsp-meta/src/api/convert/hcl/dsp_meta_error.rs b/dsp-meta/src/api/convert/hcl/dsp_meta_error.rs deleted file mode 100644 index 193124ab..00000000 --- a/dsp-meta/src/api/convert/hcl/dsp_meta_error.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::error::DspMetaError; - -impl From<hcl::Error> for DspMetaError { - fn from(error: hcl::Error) -> Self { - DspMetaError::ParseHcl(error.to_string()) - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_attributes.rs b/dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_attributes.rs deleted file mode 100644 index 82156ad2..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_attributes.rs +++ /dev/null @@ -1,253 +0,0 @@ -use std::cell::OnceCell; - -use dsp_domain::metadata::value::access::Access; -use dsp_domain::metadata::value::data_type::DataType; -use dsp_domain::metadata::value::identifier::DatasetId; -use dsp_domain::metadata::value::status::Status; -use dsp_domain::metadata::value::{CreatedAt, CreatedBy, DatePublished, HowToCite, Title}; -use hcl::Expression; -use tracing::warn; - -use crate::error::DspMetaError; - -pub struct ExtractedDatasetAttributes { - pub id: OnceCell<DatasetId>, // (1) - pub created_at: OnceCell<CreatedAt>, // (1) - pub created_by: OnceCell<CreatedBy>, // (1) - pub title: OnceCell<Title>, // (1) - pub status: OnceCell<Status>, // (1) - pub access_conditions: OnceCell<Access>, // (1) - pub how_to_cite: OnceCell<HowToCite>, // (1) - pub date_published: OnceCell<DatePublished>, // (0-1) - pub type_of_data: Vec<DataType>, // (1-n) - pub alternative_titles: Vec<Title>, // (0-n) -} - -impl TryFrom<Vec<&hcl::Attribute>> for ExtractedDatasetAttributes { - type Error = DspMetaError; - - fn try_from(attributes: Vec<&hcl::Attribute>) -> Result<Self, Self::Error> { - let id: OnceCell<DatasetId> = OnceCell::new(); - let created_at: OnceCell<CreatedAt> = OnceCell::new(); - let created_by: OnceCell<CreatedBy> = OnceCell::new(); - let title: OnceCell<Title> = OnceCell::new(); - let status: OnceCell<Status> = OnceCell::new(); - let access_conditions: OnceCell<Access> = OnceCell::new(); - let how_to_cite: OnceCell<HowToCite> = OnceCell::new(); - let date_published: OnceCell<DatePublished> = OnceCell::new(); - let mut type_of_data: Vec<DataType> = vec![]; - let mut alternative_titles: Vec<Title> = vec![]; - - for attribute in attributes { - match attribute.key() { - "id" => { - let extracted_id = match attribute.expr() { - Expression::String(value) => Ok(DatasetId(value.to_owned())), - _ => Err(DspMetaError::ParseDataset( - "Parse error: id needs to be a string.".to_string(), - )), - }?; - id.set(extracted_id).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: id needs to be unique.".to_string(), - ) - })?; - } - "created_at" => { - let extracted_created_at = match attribute.expr() { - Expression::Number(value) => Ok(CreatedAt(value.as_u64().unwrap())), /* FIXME: get rid of unwrap */ - _ => Err(DspMetaError::ParseDataset( - "Parse error: created_at needs to be a number.".to_string(), - )), - }?; - created_at.set(extracted_created_at).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: created_at needs to be unique.".to_string(), - ) - })?; - } - "created_by" => { - let extracted_created_by = match attribute.expr() { - Expression::String(value) => Ok(CreatedBy(value.to_owned())), - _ => Err(DspMetaError::ParseDataset( - "Parse error: created_by needs to be a string.".to_string(), - )), - }?; - created_by.set(extracted_created_by).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: created_by needs to be unique.".to_string(), - ) - })?; - } - "title" => { - let extracted_title = match attribute.expr() { - Expression::String(value) => Ok(Title(value.to_owned())), - _ => Err(DspMetaError::ParseDataset( - "Parse error: title needs to be a string.".to_string(), - )), - }?; - title.set(extracted_title).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: title needs to be unique.".to_string(), - ) - })?; - } - "status" => { - let extracted_status = match attribute.expr() { - Expression::String(value) => Ok(Status::try_from(value.to_owned())?), - _ => Err(DspMetaError::ParseDataset( - "Parse error: status needs to be a string.".to_string(), - )), - }?; - status.set(extracted_status).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: status needs to be unique.".to_string(), - ) - })?; - } - "access_conditions" => { - let extracted_access_conditions = match attribute.expr() { - Expression::String(value) => Ok(Access::try_from(value.to_owned())?), - _ => Err(DspMetaError::ParseDataset( - "Parse error: access_conditions needs to be a string.".to_string(), - )), - }?; - access_conditions - .set(extracted_access_conditions) - .map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: access_conditions needs to be unique.".to_string(), - ) - })?; - } - "how_to_cite" => { - let extracted_how_to_cite = match attribute.expr() { - Expression::String(value) => Ok(HowToCite(value.to_owned())), - _ => Err(DspMetaError::ParseDataset( - "Parse error: how_to_cite needs to be a string.".to_string(), - )), - }?; - how_to_cite.set(extracted_how_to_cite).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: how_to_cite needs to be unique.".to_string(), - ) - })?; - } - "date_published" => { - let extracted_date_published = match attribute.expr() { - Expression::Number(value) => Ok(DatePublished(value.as_u64().unwrap())), - _ => Err(DspMetaError::ParseDataset( - "Parse error: date_published needs to be a string.".to_string(), - )), - }?; - date_published.set(extracted_date_published).map_err(|_| { - DspMetaError::ParseDataset( - "Parse error: date_published needs to be unique.".to_string(), - ) - })?; - } - "type_of_data" => { - type_of_data = match attribute.expr() { - Expression::Array(values) => { - let mut data_types = vec![]; - for value in values { - match value { - Expression::String(value) => { - data_types.push(DataType::try_from(value.to_owned())?) - } - _ => { - return Err(DspMetaError::ParseDataset( - "Parse error: type_of_data value needs to be a string." - .to_string(), - )) - } - } - } - Ok(data_types) - } - _ => Err(DspMetaError::ParseDataset( - "Parse error: type_of_data needs to be a list of strings.".to_string(), - )), - }?; - } - "alternative_titles" => { - alternative_titles = match attribute.expr() { - Expression::Array(values) => { - let mut titles = vec![]; - for value in values { - match value { - Expression::String(value) => { - titles.push(Title(value.to_owned())) - } - _ => { - return Err(DspMetaError::ParseDataset( - "Parse error: alternative_titles value needs to be a string." - .to_string(), - )) - } - } - } - Ok(titles) - } - _ => Err(DspMetaError::ParseDataset( - "Parse error: alternative_titles needs to be a list of strings." - .to_string(), - )), - }?; - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - Ok(ExtractedDatasetAttributes { - id, - created_at, - created_by, - title, - status, - access_conditions, - how_to_cite, - date_published, - type_of_data, - alternative_titles, - }) - } -} - -#[cfg(test)] -mod tests { - use hcl::Number; - use tracing_test::traced_test; - - use super::*; - - #[test] - fn extract_created_at() { - let attribute = hcl::Attribute::new("created_at", Number::from(1u64)); - let attributes = vec![&attribute]; - let mut result = ExtractedDatasetAttributes::try_from(attributes).unwrap(); - assert_eq!(result.created_at.take().unwrap(), CreatedAt(1)); - } - - #[test] - fn extract_created_by() { - let attribute = hcl::Attribute::new("created_by", "someone"); - let attributes = vec![&attribute]; - let mut result = ExtractedDatasetAttributes::try_from(attributes).unwrap(); - assert_eq!( - result.created_by.take().unwrap(), - CreatedBy("someone".to_string()) - ); - } - - #[traced_test] - #[test] - fn warn_on_unknown_attribute() { - let attribute = hcl::Attribute::new("gugus", "something"); - let attributes = vec![&attribute]; - let _ = ExtractedDatasetAttributes::try_from(attributes); - - assert!(logs_contain("Parse error: unknown attribute 'gugus'")); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_blocks.rs b/dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_blocks.rs deleted file mode 100644 index 94d8f2b8..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/dataset/extracted_dataset_blocks.rs +++ /dev/null @@ -1,101 +0,0 @@ -use dsp_domain::metadata::value::attribution::Attribution; -use dsp_domain::metadata::value::language::Language; -use dsp_domain::metadata::value::license::License; -use dsp_domain::metadata::value::r#abstract::Abstract; -use dsp_domain::metadata::value::url::Url; -use tracing::warn; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const ABSTRACT_BLOCK: &str = "abstract"; -const LICENSE_BLOCK: &str = "license"; -const LANGUAGE_BLOCK: &str = "language"; -const ATTRIBUTION_BLOCK: &str = "attribution"; -const URL_BLOCK: &str = "url"; - -#[derive(Debug, Default, PartialEq)] -pub struct ExtractedDatasetBlocks { - pub abstracts: Vec<Abstract>, - pub licenses: Vec<License>, - pub languages: Vec<Language>, - pub attributions: Vec<Attribution>, - pub urls: Vec<Url>, -} - -impl TryFrom<Vec<&hcl::Block>> for ExtractedDatasetBlocks { - type Error = DspMetaError; - - fn try_from(blocks: Vec<&hcl::Block>) -> Result<Self, Self::Error> { - let mut abstracts: Vec<Abstract> = vec![]; - let mut licenses: Vec<License> = vec![]; - let mut languages: Vec<Language> = vec![]; - let mut attributions: Vec<Attribution> = vec![]; - let mut urls: Vec<Url> = vec![]; - - for block in blocks { - match block.identifier.as_str() { - ABSTRACT_BLOCK => abstracts.push(HclBlock(block).try_into()?), - LICENSE_BLOCK => licenses.push(HclBlock(block).try_into()?), - LANGUAGE_BLOCK => languages.push(HclBlock(block).try_into()?), - ATTRIBUTION_BLOCK => attributions.push(HclBlock(block).try_into()?), - URL_BLOCK => urls.push(HclBlock(block).try_into()?), - _ => { - // catch all - warn!( - "Parse error: unknown or not implemented block '{}'.", - block.identifier - ); - } - } - } - Ok(ExtractedDatasetBlocks { - abstracts, - licenses, - languages, - attributions, - urls, - }) - } -} - -#[cfg(test)] -mod tests { - use hcl::{block, Identifier}; - use tracing_test::traced_test; - - use crate::api::convert::hcl::entity::dataset::extracted_dataset_blocks::ExtractedDatasetBlocks; - - #[test] - fn extract_abstracts() { - let input1 = block!( - abstract { - de = "abstract1_de" - en = "abstract1_en" - fr = "abstract1_fr" - } - ); - let input2 = block!( - abstract { - de = "abstract2_de" - en = "abstract2_en" - fr = "abstract2_fr" - } - ); - let blocks = vec![&input1, &input2]; - let result = ExtractedDatasetBlocks::try_from(blocks).unwrap(); - assert_eq!(result.abstracts.len(), 2); - } - - #[traced_test] - #[test] - fn warn_on_unknown_block() { - let block = hcl::Block::new(Identifier::new("gugus").unwrap()); - let blocks = vec![&block]; - let _ = ExtractedDatasetBlocks::try_from(blocks); - - assert!(logs_contain( - " Parse error: unknown or not implemented block 'gugus'" - )); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/dataset/mod.rs b/dsp-meta/src/api/convert/hcl/entity/dataset/mod.rs deleted file mode 100644 index eafccba6..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/dataset/mod.rs +++ /dev/null @@ -1,210 +0,0 @@ -use dsp_domain::metadata::entity::dataset::Dataset; -use extracted_dataset_attributes::ExtractedDatasetAttributes; -use extracted_dataset_blocks::ExtractedDatasetBlocks; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -pub(crate) mod extracted_dataset_attributes; -pub(crate) mod extracted_dataset_blocks; - -impl<'a> TryInto<Dataset> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Dataset, Self::Error> { - if self.0.identifier.as_str() != "dataset" { - return Err(DspMetaError::ParseDataset( - format!( - "Parse error: dataset block needs to be named 'dataset', however got '{}' instead.", - self.0.identifier.as_str() - ) - .to_string(), - )); - } - - // extract the dataset attributes - // id (1), created_at (1), created_by (1), title (1), status (1), access_conditions (1), - // how_to_cite (1), date_published (0-1), type_of_data (1-n), alternative_titles (0-n), - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - let mut extracted_attributes = ExtractedDatasetAttributes::try_from(attributes)?; - - let id = extracted_attributes.id.take().ok_or_else(|| { - DspMetaError::ParseDataset("Parse error: project needs to have an id.".to_string()) - })?; - - let created_at = extracted_attributes.created_at.take().ok_or_else(|| { - DspMetaError::ParseDataset( - "Parse error: project needs to have a created_at value.".to_string(), - ) - })?; - - let created_by = extracted_attributes.created_by.take().ok_or_else(|| { - DspMetaError::ParseDataset( - "Parse error: project needs to have a created_by value.".to_string(), - ) - })?; - - let title = extracted_attributes.title.take().ok_or_else(|| { - DspMetaError::ParseDataset("Parse error: dataset needs to have a title.".to_string()) - })?; - - let status = extracted_attributes.status.take().ok_or_else(|| { - DspMetaError::ParseDataset("Parse error: dataset needs to have a status".to_string()) - })?; - - let access_conditions = extracted_attributes - .access_conditions - .take() - .ok_or_else(|| { - DspMetaError::ParseDataset( - "Parse error: dataset needs to have a access_condition".to_string(), - ) - })?; - - let how_to_cite = extracted_attributes.how_to_cite.take().ok_or_else(|| { - DspMetaError::ParseDataset("Parse error: dataset needs to have how_to_cite".to_string()) - })?; - - let date_published = extracted_attributes.date_published.take(); - - let type_of_data = if !extracted_attributes.type_of_data.is_empty() { - Ok(extracted_attributes.type_of_data) - } else { - Err(DspMetaError::ParseDataset( - "Parse dataset: there needs to be at least one type_of_data.".to_string(), - )) - }?; - - let alternative_titles = extracted_attributes.alternative_titles; - - // extract the dataset blocks - // abstracts (1-n), licenses (1-n), languages (1-n), attributions (1-n), - // urls (0-n), - - let blocks: Vec<&hcl::Block> = self.0.body.blocks().collect(); - let extracted_blocks = ExtractedDatasetBlocks::try_from(blocks)?; - - let abstracts = if !extracted_blocks.abstracts.is_empty() { - Ok(extracted_blocks.abstracts) - } else { - Err(DspMetaError::ParseDataset( - "Parse dataset: there needs to be at least one abstract.".to_string(), - )) - }?; - - let licenses = if !extracted_blocks.licenses.is_empty() { - Ok(extracted_blocks.licenses) - } else { - Err(DspMetaError::ParseDataset( - "Parse dataset: there needs to be at least one license.".to_string(), - )) - }?; - - let languages = if !extracted_blocks.languages.is_empty() { - Ok(extracted_blocks.languages) - } else { - Err(DspMetaError::ParseDataset( - "Parse dataset: there needs to be at least one language.".to_string(), - )) - }?; - - let attributions = if !extracted_blocks.attributions.is_empty() { - Ok(extracted_blocks.attributions) - } else { - Err(DspMetaError::ParseDataset( - "Parse dataset: there needs to be at least one attribution.".to_string(), - )) - }?; - let urls = extracted_blocks.urls; - - Ok(Dataset { - id, - created_at, - created_by, - title, - status, - access_conditions, - how_to_cite, - date_published, - type_of_data, - alternative_titles, - abstracts, - licenses, - languages, - attributions, - urls, - }) - } -} - -#[cfg(test)] -mod tests { - use dsp_domain::metadata::value::access::Access; - use dsp_domain::metadata::value::data_type::DataType; - use dsp_domain::metadata::value::identifier::DatasetId; - use dsp_domain::metadata::value::status::Status; - use dsp_domain::metadata::value::{CreatedAt, CreatedBy, DatePublished, HowToCite, Title}; - use hcl::block; - use tracing_test::traced_test; - - use super::*; - - #[traced_test] - #[test] - fn test_convert_dataset_block() { - let input_dataset_block = block!( - dataset { - id = "d1" - created_at = 1630601274523025000u64 // FIXME: is there a more readable way to write an i64? - created_by = "dsp-metadata-gui" - title = "The German Family Panel (pairfam)" - how_to_cite = "pairfam" - status = "Ongoing" - access_conditions = "Open" - date_published = 1630601274523025000u64 - type_of_data = ["Image", "Text"] - abstract { - en = "The interdisciplinary research project \"The image sequences of Basel's early prints: Late Medieval didactic didactics as an image-text reading\" combines a comprehensive art scholarly analysis of the links between images and texts in the illustrated incunabula in Basel with the digitization of the holdings of the University Library and the development of an electronic edition in the form of a new kind of Web-0.2 application. The project is carried out by Kunsthistorische Seminar of the University of Basel (Prof. Dr. B. Schellewald) and Digital Humanities Lab of the University of Basel (Prof. Dr. L. Rosenthaler). The core of the digital edition consists of around twenty richly illustrated early prints from four different Basel officers. Many of them appeared in several editions before 1500, some of them in German and Latin at almost the same time. It is an extraordinarily varied production; in addition to the Mirror of Salvation, there is a novel, the Melusine, the travelogues of Jean de Mandeville, some prayer and edification books, theological writings, Lent sermons, the lives of Saints Fridolin and Meinrad, the famous ship of fools and the knight of Thurn. The Internet publication makes the digitized corpus of these early prints usable for the scientific edition as well as for the exploration of images and texts through the possibilities of non-linear linking and commenting on the images and texts. Existing and emerging online editions can also be linked to it, which optimises the use of databases from other institutions with regard to our corpus." - } - license { - type = "creative_commons" - href = "https://creativecommons.org/licenses/by-nc/4.0" - date = "2021-09-02" - label = "CC BY-NC 4.0" - } - language { - de = "Deutsch" - en = "German" - fr = "Allemand" - } - - // reference to person or organization - attribution { - agent = "http://ns.dasch.swiss/repository#dsp-081C-organization-000" // reference to person or organization - roles = ["Author"] - } - } - ); - let dataset: Dataset = HclBlock(&input_dataset_block).try_into().unwrap(); - assert_eq!(dataset.id, DatasetId(String::from("d1"))); - assert_eq!(dataset.created_at, CreatedAt(1630601274523025000)); - assert_eq!( - dataset.created_by, - CreatedBy(String::from("dsp-metadata-gui")) - ); - assert_eq!( - dataset.title, - Title(String::from("The German Family Panel (pairfam)")) - ); - assert_eq!(dataset.how_to_cite, HowToCite("pairfam".to_string())); - assert_eq!(dataset.status, Status::Ongoing); - assert_eq!(dataset.access_conditions, Access::Open); - assert_eq!( - dataset.date_published, - Some(DatePublished(1630601274523025000u64)) - ); - assert_eq!(dataset.type_of_data, vec![DataType::Image, DataType::Text]); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/grant/extracted_grant.rs b/dsp-meta/src/api/convert/hcl/entity/grant/extracted_grant.rs deleted file mode 100644 index 2adba635..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/grant/extracted_grant.rs +++ /dev/null @@ -1,228 +0,0 @@ -use dsp_domain::metadata::value::funder::Funder; -use dsp_domain::metadata::value::identifier::GrantId; -use dsp_domain::metadata::value::url::Url; -use dsp_domain::metadata::value::{CreatedAt, CreatedBy, GrantNumber, GrantType, Name}; -use hcl::Expression; -use log::warn; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -pub struct ExtractedGrant { - pub id: Option<GrantId>, - pub created_at: Option<CreatedAt>, - pub created_by: Option<CreatedBy>, - pub type_of_grant: Option<GrantType>, - pub name: Option<Name>, - pub number: Option<GrantNumber>, - pub url: Option<Url>, - pub funders: Vec<Funder>, -} - -impl<'a> TryFrom<HclBlock<'a>> for ExtractedGrant { - type Error = DspMetaError; - - fn try_from(hcl_block: HclBlock<'a>) -> Result<Self, Self::Error> { - let mut id: Option<GrantId> = None; - let mut created_at: Option<CreatedAt> = None; - let mut created_by: Option<CreatedBy> = None; - let mut type_of_grant: Option<GrantType> = None; - let mut name: Option<Name> = None; - let mut number: Option<GrantNumber> = None; - let mut url: Option<Url> = None; - let mut funders: Vec<Funder> = Vec::new(); - - // check if the block is named grant - if hcl_block.0.identifier.as_str() != "grant" { - return Err(DspMetaError::ParseGrant( - format!( - "Parse error: grant block needs to be named 'grant', however got '{}' instead.", - hcl_block.0.identifier.as_str() - ) - .to_string(), - )); - } - - // extract the attributes - // id (1), created_at (1), created_by (1), type_of_grant (1), - // name (0-1), number (0-1), funders (1-n), - - let attributes: Vec<&hcl::Attribute> = hcl_block.0.body.attributes().collect(); - - for attribute in attributes { - match attribute.key() { - "id" => { - if id.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one id.".to_string(), - )); - } - id = match attribute.expr() { - hcl::Expression::String(value) => Some(GrantId(value.to_string())), - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant id needs to be a string.".to_string(), - )) - } - }; - } - "created_at" => { - if created_at.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one created_at value." - .to_string(), - )); - } - created_at = match attribute.expr() { - hcl::Expression::Number(value) => Some(CreatedAt(value.as_u64().unwrap())), - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant created_at needs to be a number.".to_string(), - )) - } - } - } - "created_by" => { - if created_by.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one created_by value." - .to_string(), - )); - } - created_by = match attribute.expr() { - hcl::Expression::String(value) => Some(CreatedBy(value.to_string())), - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant created_by needs to be a string.".to_string(), - )) - } - } - } - "type_of_grant" => { - if type_of_grant.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one type_of_grant value." - .to_string(), - )); - } - type_of_grant = match attribute.expr() { - hcl::Expression::String(value) => Some(GrantType(value.to_string())), - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant type_of_grant needs to be a string." - .to_string(), - )) - } - } - } - "name" => { - if name.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one name value.".to_string(), - )); - } - name = match attribute.expr() { - hcl::Expression::String(value) => Some(Name(value.to_string())), - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant name needs to be a string.".to_string(), - )) - } - } - } - "number" => { - if number.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one number value.".to_string(), - )); - } - number = match attribute.expr() { - hcl::Expression::String(value) => Some(GrantNumber(value.to_string())), - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant number needs to be a string.".to_string(), - )) - } - } - } - "funders" => { - match attribute.expr() { - Expression::Array(values) => { - for value in values { - match value { - Expression::String(value) => { - // pushing the value to the vector - funders.push(Funder(value.to_string())) - } - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant funder needs to be a string." - .to_string(), - )) - } - } - } - } - _ => { - return Err(DspMetaError::ParseGrant( - "Parse error: grant funder needs to be an array.".to_string(), - )) - } - } - } - _ => warn!("Parse error: unknown attribute '{}'.", attribute.key()), - } - } - - // extract the blocks - // url (0-1), - - let blocks: Vec<&hcl::Block> = hcl_block.0.body.blocks().collect(); - - for block in blocks { - match block.identifier.as_str() { - "url" => { - if url.is_some() { - return Err(DspMetaError::ParseGrant( - "Parse error: grant needs to have only one url.".to_string(), - )); - } - url = Some(HclBlock(block).try_into()?) - } - _ => warn!( - "Parse error: unknown or not implemented block '{}'.", - block.identifier - ), - } - } - - Ok(Self { - id, - created_at, - created_by, - type_of_grant, - name, - number, - url, - funders, - }) - } -} - -#[cfg(test)] -mod tests { - use hcl::block; - - use super::*; - - #[test] - fn extract_id() { - let hcl = block!( - grant { - id = "grant-1" - } - ); - let extracted = ExtractedGrant::try_from(HclBlock(&hcl)).unwrap(); - assert_eq!(extracted.id, Some(GrantId("grant-1".to_string()))); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/grant/mod.rs b/dsp-meta/src/api/convert/hcl/entity/grant/mod.rs deleted file mode 100644 index d953fbd1..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/grant/mod.rs +++ /dev/null @@ -1,113 +0,0 @@ -use dsp_domain::metadata::entity::grant::Grant; - -use crate::api::convert::hcl::entity::grant::extracted_grant::ExtractedGrant; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -mod extracted_grant; - -impl<'a> TryInto<Grant> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Grant, Self::Error> { - let mut extracted = ExtractedGrant::try_from(self)?; - - // id (1), created_at (1), created_by (1), type_of_grant (1), - // name (0-1), number (0-1), url (0-1), funders (1-n), - - let id = extracted.id.take().ok_or_else(|| { - DspMetaError::ParseGrant("Parse error: Grant needs to have an id.".to_string()) - })?; - - let created_at = extracted.created_at.take().ok_or_else(|| { - DspMetaError::ParseGrant( - "Parse error: grant needs to have a created_at value.".to_string(), - ) - })?; - - let created_by = extracted.created_by.take().ok_or_else(|| { - DspMetaError::ParseGrant( - "Parse error: grant needs to have a created_by value.".to_string(), - ) - })?; - - let type_of_grant = extracted.type_of_grant.ok_or(DspMetaError::ParseGrant( - "Parse error: grant needs to have a type.".to_string(), - ))?; - - let name = extracted.name; - - let number = extracted.number; - - let url = extracted.url; - - let funders = if !extracted.funders.is_empty() { - Ok(extracted.funders) - } else { - Err(DspMetaError::ParseGrant( - "Parse grant: there needs to be at least one funder.".to_string(), - )) - }?; - - Ok(Grant { - id, - created_at, - created_by, - type_of_grant, - name, - number, - url, - funders, - }) - } -} - -#[cfg(test)] -mod tests { - use dsp_domain::metadata::value::identifier::GrantId; - use dsp_domain::metadata::value::url::Url; - use hcl::block; - use tracing_test::traced_test; - - use super::*; - - #[traced_test] - #[test] - fn test_convert_grant_block() { - let input_block = block!( - grant { - id = "g1" - created_at = 1630601300976368000u64 - created_by = "dsp-metadata-gui" - type_of_grant = "funding" - name = "The German Family Panel (pairfam)" - number = "01US1706A" - url { - href = "https://data.snf.ch/grants/grant/120378" - label = "https://data.snf.ch/grants/grant/120378" - } - funders = ["f1"] - } - ); - let grant: Grant = HclBlock(&input_block).try_into().unwrap(); - assert_eq!(grant.id, GrantId("g1".to_string())); - assert_eq!(grant.created_at.0, 1630601300976368000u64); - assert_eq!(grant.created_by.0, "dsp-metadata-gui".to_string()); - assert_eq!(grant.type_of_grant.0, "funding".to_string()); - assert_eq!( - grant.name.unwrap().0, - "The German Family Panel (pairfam)".to_string() - ); - assert_eq!(grant.number.unwrap().0, "01US1706A".to_string()); - assert_eq!( - grant.url, - Some( - Url::new( - "https://data.snf.ch/grants/grant/120378".to_string(), - "https://data.snf.ch/grants/grant/120378".to_string() - ) - .unwrap() - ) - ); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/mod.rs b/dsp-meta/src/api/convert/hcl/entity/mod.rs deleted file mode 100644 index 53c9ffed..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub(crate) mod dataset; -pub(crate) mod grant; -pub(crate) mod project; diff --git a/dsp-meta/src/api/convert/hcl/entity/project/extracted_project_attributes.rs b/dsp-meta/src/api/convert/hcl/entity/project/extracted_project_attributes.rs deleted file mode 100644 index 8d74f6db..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/project/extracted_project_attributes.rs +++ /dev/null @@ -1,211 +0,0 @@ -use dsp_domain::metadata::value::identifier::{DatasetId, ProjectId}; -use dsp_domain::metadata::value::status::Status; -use dsp_domain::metadata::value::{ - ContactPoint, CreatedAt, CreatedBy, EndDate, HowToCite, Name, Shortcode, StartDate, TeaserText, -}; -use hcl::Expression; -use tracing::warn; - -use crate::error::DspMetaError; - -pub struct ExtractedProjectAttributes { - pub id: Option<ProjectId>, - pub created_at: Option<CreatedAt>, - pub created_by: Option<CreatedBy>, - pub shortcode: Option<Shortcode>, - pub name: Option<Name>, - pub teaser_text: Option<TeaserText>, - pub how_to_cite: Option<HowToCite>, - pub start_date: Option<StartDate>, - pub end_date: Option<EndDate>, - pub status: Option<Status>, - pub contact_point: Option<ContactPoint>, - pub datasets: Vec<DatasetId>, -} - -impl TryFrom<Vec<&hcl::Attribute>> for ExtractedProjectAttributes { - type Error = DspMetaError; - - fn try_from(attributes: Vec<&hcl::Attribute>) -> Result<Self, Self::Error> { - let mut id: Option<ProjectId> = None; - let mut created_at: Option<CreatedAt> = None; - let mut created_by: Option<CreatedBy> = None; - let mut shortcode: Option<Shortcode> = None; - let mut name: Option<Name> = None; - let mut teaser_text: Option<TeaserText> = None; - let mut how_to_cite: Option<HowToCite> = None; - let mut start_date: Option<StartDate> = None; - let mut end_date: Option<EndDate> = None; - let mut status: Option<Status> = None; - let mut contact_point: Option<ContactPoint> = None; - let mut datasets: Vec<DatasetId> = vec![]; - - // FIXME: throw error on duplicate attributes - for attribute in attributes { - match attribute.key() { - "id" => { - id = match attribute.expr() { - Expression::String(value) => Ok(Some(ProjectId(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: id needs to be a string.".to_string(), - )), - }?; - } - "created_at" => { - created_at = match attribute.expr() { - Expression::Number(value) => Ok(Some(CreatedAt(value.as_u64().unwrap()))), /* FIXME: get rid of unwrap */ - _ => Err(DspMetaError::ParseProject( - "Parse error: created_at needs to be a number.".to_string(), - )), - }? - } - "created_by" => { - created_by = match attribute.expr() { - Expression::String(value) => Ok(Some(CreatedBy(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: created_by needs to be a string.".to_string(), - )), - }? - } - "shortcode" => { - shortcode = match attribute.expr() { - Expression::String(value) => Ok(Some(Shortcode(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: shortcode needs to be a string.".to_string(), - )), - }?; - } - "name" => { - name = match attribute.expr() { - Expression::String(value) => Ok(Some(Name(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: name needs to be a string.".to_string(), - )), - }?; - } - "teaser_text" => { - teaser_text = match attribute.expr() { - Expression::String(value) => Ok(Some(TeaserText(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: teaser_text needs to be a string.".to_string(), - )), - }?; - } - "how_to_cite" => { - how_to_cite = match attribute.expr() { - Expression::String(value) => Ok(Some(HowToCite(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: how_to_cite needs to be a string.".to_string(), - )), - }?; - } - "start_date" => { - start_date = match attribute.expr() { - Expression::String(value) => Ok(Some(StartDate(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: start_date needs to be a string.".to_string(), - )), - }?; - } - "end_date" => { - end_date = match attribute.expr() { - Expression::String(value) => Ok(Some(EndDate(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: end_date needs to be a string.".to_string(), - )), - }?; - } - "status" => { - status = match attribute.expr() { - Expression::String(value) => Ok(Some(Status::try_from(value.to_owned())?)), - _ => Err(DspMetaError::ParseProject( - "Parse error: end_date needs to be a string.".to_string(), - )), - }?; - } - "contact_point" => { - contact_point = match attribute.expr() { - Expression::String(value) => Ok(Some(ContactPoint(value.to_owned()))), - _ => Err(DspMetaError::ParseProject( - "Parse error: contact_point needs to be a string.".to_string(), - )), - }?; - } - "datasets" => { - datasets = - match attribute.expr() { - Expression::Array(values) => { - let mut dataset_ids = vec![]; - for value in values { - match value { - Expression::String(value) => { - dataset_ids.push(DatasetId(value.to_owned())) - } - _ => return Err(DspMetaError::ParseProject( - "Parse error: datasets needs to be a list of strings." - .to_string(), - )), - } - } - Ok(dataset_ids) - } - _ => Err(DspMetaError::ParseProject( - "Parse error: datasets needs to be a list of strings.".to_string(), - )), - }?; - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - Ok(ExtractedProjectAttributes { - id, - created_at, - created_by, - shortcode, - name, - teaser_text, - how_to_cite, - start_date, - end_date, - status, - contact_point, - datasets, - }) - } -} - -#[cfg(test)] -mod tests { - use hcl::Number; - use tracing_test::traced_test; - - use super::*; - - #[test] - fn extract_created_at() { - let attribute = hcl::Attribute::new("created_at", Number::from(1u64)); - let attributes = vec![&attribute]; - let result = ExtractedProjectAttributes::try_from(attributes).unwrap(); - assert_eq!(result.created_at.unwrap(), CreatedAt(1)); - } - - #[test] - fn extract_created_by() { - let attribute = hcl::Attribute::new("created_by", "someone"); - let attributes = vec![&attribute]; - let result = ExtractedProjectAttributes::try_from(attributes).unwrap(); - assert_eq!(result.created_by.unwrap(), CreatedBy("someone".to_owned())); - } - - #[traced_test] - #[test] - fn warn_on_unknown_attribute() { - let attribute = hcl::Attribute::new("gugus", "something"); - let attributes = vec![&attribute]; - let _ = ExtractedProjectAttributes::try_from(attributes); - - assert!(logs_contain("Parse error: unknown attribute 'gugus'")); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/project/extracted_project_blocks.rs b/dsp-meta/src/api/convert/hcl/entity/project/extracted_project_blocks.rs deleted file mode 100644 index a67a6ecb..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/project/extracted_project_blocks.rs +++ /dev/null @@ -1,271 +0,0 @@ -use dsp_domain::metadata::value::alternative_name::AlternativeName; -use dsp_domain::metadata::value::description::Description; -use dsp_domain::metadata::value::discipline::Discipline; -use dsp_domain::metadata::value::keyword::Keyword; -use dsp_domain::metadata::value::publication::Publication; -use dsp_domain::metadata::value::spatial_coverage::SpatialCoverage; -use dsp_domain::metadata::value::temporal_coverage::TemporalCoverage; -use dsp_domain::metadata::value::url::Url; -use tracing::warn; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const ALTERNATIVE_NAME_BLOCK: &str = "alternative_name"; -const DESCRIPTION_BLOCK: &str = "description"; -const URL_BLOCK: &str = "url"; -const KEYWORD_BLOCK: &str = "keyword"; -const DISCIPLINE_BLOCK: &str = "discipline"; -const SPATIAL_COVERAGE_BLOCK: &str = "spatial_coverage"; -const TEMPORAL_COVERAGE_BLOCK: &str = "temporal_coverage"; -const PUBLICATION_BLOCK: &str = "publication"; - -#[derive(Debug, Default, PartialEq)] -pub struct ExtractedProjectBlocks { - pub alternative_names: Vec<AlternativeName>, - pub description: Option<Description>, - pub url: Option<Url>, - pub keywords: Vec<Keyword>, - pub disciplines: Vec<Discipline>, - pub spatial_coverages: Vec<SpatialCoverage>, - pub temporal_coverages: Vec<TemporalCoverage>, - pub publications: Vec<Publication>, -} - -impl TryFrom<Vec<&hcl::Block>> for ExtractedProjectBlocks { - type Error = DspMetaError; - - fn try_from(blocks: Vec<&hcl::Block>) -> Result<Self, Self::Error> { - let mut alternative_names: Vec<AlternativeName> = vec![]; - let mut description: Option<Description> = None; - let mut url: Option<Url> = None; - let mut keywords: Vec<Keyword> = vec![]; - let mut disciplines: Vec<Discipline> = vec![]; - let mut spatial_coverages: Vec<SpatialCoverage> = vec![]; - let mut temporal_coverages: Vec<TemporalCoverage> = vec![]; - let mut publications: Vec<Publication> = vec![]; - - for block in blocks { - match block.identifier.as_str() { - ALTERNATIVE_NAME_BLOCK => alternative_names.push(HclBlock(block).try_into()?), - DESCRIPTION_BLOCK => { - if description.is_some() { - return Err(DspMetaError::ParseProject( - "Only one 'description' block allowed.".to_string(), - )); - } - description = Some(HclBlock(block).try_into()?) - } - URL_BLOCK => { - if url.is_some() { - return Err(DspMetaError::ParseProject( - "Only one 'url' block allowed.".to_string(), - )); - } - url = Some(HclBlock(block).try_into()?) - } - KEYWORD_BLOCK => keywords.push(HclBlock(block).try_into()?), - DISCIPLINE_BLOCK => disciplines.push(HclBlock(block).try_into()?), - SPATIAL_COVERAGE_BLOCK => spatial_coverages.push(HclBlock(block).try_into()?), - TEMPORAL_COVERAGE_BLOCK => temporal_coverages.push(HclBlock(block).try_into()?), - PUBLICATION_BLOCK => publications.push(HclBlock(block).try_into()?), - _ => { - // catch all - warn!("Parse error: unknown block '{}'.", block.identifier); - } - } - } - Ok(ExtractedProjectBlocks { - alternative_names, - description, - url, - keywords, - disciplines, - spatial_coverages, - temporal_coverages, - publications, - }) - } -} - -#[cfg(test)] -mod tests { - use hcl::{block, Identifier}; - use tracing_test::traced_test; - - use crate::api::convert::hcl::entity::project::extracted_project_blocks::ExtractedProjectBlocks; - - #[test] - fn extract_alternative_names() { - let input1 = block!( - alternative_name { - de = "name1_de" - en = "name1_en" - fr = "name1_fr" - } - ); - let input2 = block!( - alternative_name { - de = "name2_de" - en = "name2_en" - fr = "name2_fr" - } - ); - let blocks = vec![&input1, &input2]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert_eq!(result.alternative_names.len(), 2); - } - - #[test] - fn extract_description() { - let input = block!( - description { - de = "descr_de" - en = "descr_en" - fr = "descr_fr" - } - ); - let blocks = vec![&input]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert!(result.description.is_some()); - } - - #[test] - fn error_on_multiple_description_blocks() { - let input1 = block!( - description { - de = "descr_de" - en = "descr_en" - fr = "descr_fr" - } - ); - let input2 = block!( - description { - de = "descr_de" - en = "descr_en" - fr = "descr_fr" - } - ); - let blocks = vec![&input1, &input2]; - let result = ExtractedProjectBlocks::try_from(blocks); - assert!(result.is_err()); - } - - #[test] - fn extract_single_url() { - let input = block!( - url { - href = "https://data.dasch.swiss/dokubib/" - label = "Project Website" - } - ); - let blocks = vec![&input]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert!(result.url.is_some()); - } - - #[test] - fn error_on_multiple_url_blocks() { - let input1 = block!( - url { - href = "https://data.dasch.swiss/dokubib/" - label = "Project Website" - } - ); - let input2 = block!( - url { - href = "https://data.dasch.swiss/dokubib/" - label = "Project Website" - } - ); - let blocks = vec![&input1, &input2]; - let result = ExtractedProjectBlocks::try_from(blocks); - assert!(result.is_err()); - } - - #[test] - fn extract_keywords() { - let input1 = block!( - keyword { - de = "keyword1_de" - en = "keyword1_en" - fr = "keyword1_fr" - } - - ); - let input2 = block!( - keyword { - de = "keyword2_de" - en = "keyword2_en" - fr = "keyword2_fr" - } - ); - let blocks = vec![&input1, &input2]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert_eq!(result.keywords.len(), 2); - } - - #[test] - fn extract_disciplines() { - let input1 = block!( - discipline skos { - ref_id = "https://skos.um.es/unesco6/5501" - description = "Local history" - url = "https://skos.um.es/unesco6/5501" - } - ); - let blocks = vec![&input1]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert_eq!(result.disciplines.len(), 1); - } - - #[test] - fn extract_spatial_coverages() { - let input1 = block!( - spatial_coverage geonames { - ref_id = "1234" - description = "A description" - url = "https://geonames.org/1234" - } - ); - let blocks = vec![&input1]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert_eq!(result.spatial_coverages.len(), 1); - } - - #[test] - fn extract_temporal_coverage() { - let input1 = block!( - temporal_coverage chronontology { - ref_id = "https://chronontology.dainst.org/period/INtagfT8h7Fs" - description = "20th and 21st Centuries" - url = "https://chronontology.dainst.org/period/INtagfT8h7Fs" - } - ); - let blocks = vec![&input1]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert_eq!(result.temporal_coverages.len(), 1); - } - - #[test] - fn extract_publications() { - let input1 = block!( - publication { - text = "A publication" - } - ); - let blocks = vec![&input1]; - let result = ExtractedProjectBlocks::try_from(blocks).unwrap(); - assert_eq!(result.publications.len(), 1); - } - - #[traced_test] - #[test] - fn warn_on_unknown_block() { - let block = hcl::Block::new(Identifier::new("gugus").unwrap()); - let blocks = vec![&block]; - let _ = ExtractedProjectBlocks::try_from(blocks); - - assert!(logs_contain("Parse error: unknown block 'gugus'")); - } -} diff --git a/dsp-meta/src/api/convert/hcl/entity/project/mod.rs b/dsp-meta/src/api/convert/hcl/entity/project/mod.rs deleted file mode 100644 index 3c24bc6b..00000000 --- a/dsp-meta/src/api/convert/hcl/entity/project/mod.rs +++ /dev/null @@ -1,281 +0,0 @@ -use dsp_domain::metadata::entity::project::Project; -use extracted_project_attributes::ExtractedProjectAttributes; -use extracted_project_blocks::ExtractedProjectBlocks; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -pub(crate) mod extracted_project_attributes; -pub(crate) mod extracted_project_blocks; - -impl<'a> TryInto<Project> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Project, Self::Error> { - if self.0.identifier.as_str() != "project" { - return Err(DspMetaError::ParseProject( - format!( - "Parse error: project block needs to be named 'project', however got '{}' instead.", - self.0.identifier.as_str() - ) - .to_string(), - )); - } - - // extract the project attributes - // created_at, created_by, shortcode, name, teaser_text, how_to_cite, start_date, end_date, - // datasets (1-n), funders, grants - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - let extracted_attributes = ExtractedProjectAttributes::try_from(attributes)?; - - let id = extracted_attributes.id.ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have an id.".to_string(), - ))?; - - let created_at = extracted_attributes - .created_at - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a created_at value.".to_string(), - ))?; - - let created_by = extracted_attributes - .created_by - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a created_by value.".to_string(), - ))?; - - let shortcode = extracted_attributes - .shortcode - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a shortcode.".to_string(), - ))?; - - let name = extracted_attributes.name.ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a name.".to_string(), - ))?; - - let teaser_text = extracted_attributes - .teaser_text - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a teaser_text.".to_string(), - ))?; - - let how_to_cite = extracted_attributes - .how_to_cite - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a how_to_cite.".to_string(), - ))?; - - let start_date = extracted_attributes - .start_date - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a start_date.".to_string(), - ))?; - - let end_date = extracted_attributes.end_date; - - let status = extracted_attributes - .status - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a status.".to_string(), - ))?; - - let contact_point = extracted_attributes.contact_point; - - let datasets = extracted_attributes.datasets; - - // extract the project blocks - // alternative_names (0-n), description (1), url (1), keywords (1-n), disciplines (1-n), - // publications (0-n) - - let blocks: Vec<&hcl::Block> = self.0.body.blocks().collect(); - let extracted_blocks = ExtractedProjectBlocks::try_from(blocks)?; - - let alternative_names = extracted_blocks.alternative_names; - let description = extracted_blocks - .description - .ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a description.".to_string(), - ))?; - let url = extracted_blocks.url.ok_or(DspMetaError::ParseProject( - "Parse error: project needs to have a url.".to_string(), - ))?; - let keywords = if !extracted_blocks.keywords.is_empty() { - Ok(extracted_blocks.keywords) - } else { - Err(DspMetaError::ParseProject( - "Parse error: project needs to have at least one keyword.".to_string(), - )) - }?; - let disciplines = if !extracted_blocks.disciplines.is_empty() { - Ok(extracted_blocks.disciplines) - } else { - Err(DspMetaError::ParseProject( - "Parse error: project needs to have at least one discipline.".to_string(), - )) - }?; - let publications = extracted_blocks.publications; - - let project = Project { - id, - created_at, - created_by, - shortcode, - name, - alternative_names, - teaser_text, - description, - url, - how_to_cite, - start_date, - end_date, - status, - contact_point, - keywords, - disciplines, - publications, - datasets, - }; - - Ok(project) - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use dsp_domain::metadata::entity::project::Project; - use dsp_domain::metadata::value::description::Description; - use dsp_domain::metadata::value::discipline::Discipline; - use dsp_domain::metadata::value::identifier::{DatasetId, ProjectId}; - use dsp_domain::metadata::value::iso_code::IsoCode; - use dsp_domain::metadata::value::keyword::Keyword; - use dsp_domain::metadata::value::ref_data::RefData; - use dsp_domain::metadata::value::url::Url; - use dsp_domain::metadata::value::{ - ContactPoint, CreatedAt, CreatedBy, EndDate, HowToCite, Name, Shortcode, StartDate, - TeaserText, - }; - use hcl::block; - use tracing_test::traced_test; - - use crate::api::convert::hcl::hcl_block::HclBlock; - - #[traced_test] - #[test] - fn test_convert_project_block() { - let input_project_block = block!( - project { - id = "p1" - created_at = 1630601274523025000u64 // FIXME: is there a more readable way to write an i64? - created_by = "dsp-metadata-gui" - shortcode = "0803" - name = "The German Family Panel (pairfam)" - alternative_name "1" { - de = "Der deutsche Familienpanel (pairfam)" - en = "The German Family Panel (pairfam)" - } - teaser_text = "The German Family Panel (pairfam) is a multidisciplinary, longitudinal study." - description { - de = "Der deutsche Familienpanel (pairfam) ist eine multidisziplinäre, längsschnittliche Studie." - en = "The German Family Panel (pairfam) is a multidisciplinary, longitudinal study." - } - url { - href = "https://admin.dasch.swiss/project/081C" - label = "Discover Project Data" - } - how_to_cite = "Huinink, Johannes; Schröder, Carolin; Castiglioni, Laura; Feldhaus, Michael" - start_date = "2009-04-01" - end_date = "2012-03-31" - status = "Ongoing" - keyword { - en = "Bern" - } - discipline snf { - ref_id = "10302" - description = "Schweizer Geschichte" - url = "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - } - contact_point = "project_organization" - datasets = ["ds1", "ds2"] - } - ); - let project: Project = HclBlock(&input_project_block).try_into().unwrap(); - assert_eq!(project.id, ProjectId(String::from("p1"))); - assert_eq!(project.created_at, CreatedAt(1630601274523025000)); - assert_eq!( - project.created_by, - CreatedBy(String::from("dsp-metadata-gui")) - ); - assert_eq!(project.shortcode, Shortcode(String::from("0803"))); - assert_eq!( - project.name, - Name(String::from("The German Family Panel (pairfam)")) - ); - assert_eq!( - project.teaser_text, - TeaserText(String::from( - "The German Family Panel (pairfam) is a multidisciplinary, longitudinal study." - )) - ); - assert_eq!( - project.description, - Description( - HashMap::from_iter( - [ - (IsoCode::DE, "Der deutsche Familienpanel (pairfam) ist eine multidisziplinäre, längsschnittliche Studie.".to_string()), - (IsoCode::EN, "The German Family Panel (pairfam) is a multidisciplinary, longitudinal study.".to_string()) - ] - ) - ) - ); - assert_eq!( - project.url, - Url { - href: url::Url::parse("https://admin.dasch.swiss/project/081C").unwrap(), - label: "Discover Project Data".to_string() - } - ); - assert_eq!( - project.how_to_cite, - HowToCite(String::from( - "Huinink, Johannes; Schröder, Carolin; Castiglioni, Laura; Feldhaus, Michael" - )) - ); - assert_eq!(project.start_date, StartDate(String::from("2009-04-01"))); - assert_eq!(project.end_date, Some(EndDate(String::from("2012-03-31")))); - assert_eq!( - project.status, - dsp_domain::metadata::value::status::Status::Ongoing - ); - assert_eq!( - project.keywords, - vec![Keyword(HashMap::from_iter([( - IsoCode::EN, - "Bern".to_string() - )]))] - ); - assert_eq!( - project.disciplines, - vec![Discipline::Snf(RefData { - ref_id: "10302".to_string(), - description: "Schweizer Geschichte".to_string(), - url: url::Url::parse( - "https://www.snf.ch/SiteCollectionDocuments/allg_disziplinenliste.pdf" - ) - .unwrap() - })] - ); - assert_eq!( - project.contact_point, - Some(ContactPoint(String::from("project_organization"))) - ); - assert_eq!( - project.datasets, - vec![DatasetId("ds1".to_string()), DatasetId("ds2".to_string())] - ); - } -} diff --git a/dsp-meta/src/api/convert/hcl/hcl_attribute.rs b/dsp-meta/src/api/convert/hcl/hcl_attribute.rs deleted file mode 100644 index ec18163b..00000000 --- a/dsp-meta/src/api/convert/hcl/hcl_attribute.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub struct HclAttribute<'a>(pub &'a hcl::Attribute); -pub struct HclAttributes<'a>(pub Vec<&'a hcl::Attribute>); diff --git a/dsp-meta/src/api/convert/hcl/hcl_block.rs b/dsp-meta/src/api/convert/hcl/hcl_block.rs deleted file mode 100644 index d68a9fbb..00000000 --- a/dsp-meta/src/api/convert/hcl/hcl_block.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct HclBlock<'a>(pub &'a hcl::Block); diff --git a/dsp-meta/src/api/convert/hcl/hcl_body.rs b/dsp-meta/src/api/convert/hcl/hcl_body.rs deleted file mode 100644 index 86062da7..00000000 --- a/dsp-meta/src/api/convert/hcl/hcl_body.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct HclBody<'a>(pub &'a hcl::Body); diff --git a/dsp-meta/src/api/convert/hcl/mod.rs b/dsp-meta/src/api/convert/hcl/mod.rs deleted file mode 100644 index 6a837de2..00000000 --- a/dsp-meta/src/api/convert/hcl/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod dsp_meta_error; -mod entity; -pub mod hcl_attribute; -pub mod hcl_block; -pub mod hcl_body; -pub(crate) mod project_metadata; -mod value; diff --git a/dsp-meta/src/api/convert/hcl/project_metadata.rs b/dsp-meta/src/api/convert/hcl/project_metadata.rs deleted file mode 100644 index 5e51888c..00000000 --- a/dsp-meta/src/api/convert/hcl/project_metadata.rs +++ /dev/null @@ -1,121 +0,0 @@ -use dsp_domain::metadata::entity::dataset::Dataset; -use dsp_domain::metadata::entity::project::Project; -use dsp_domain::metadata::entity::project_metadata::ProjectMetadata; -use dsp_domain::metadata::value::version::Version; - -use crate::api::convert::hcl::hcl_attribute::HclAttribute; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::api::convert::hcl::hcl_body::HclBody; -use crate::error::DspMetaError; - -impl<'a> TryInto<ProjectMetadata> for HclBody<'a> { - type Error = DspMetaError; - - /// Converts an `hcl::Body` into `ProjectMetadata` by consuming the - /// input. This operation can fail. - fn try_into(self) -> Result<ProjectMetadata, Self::Error> { - let mut maybe_version: Option<Version> = None; - let mut maybe_project: Option<Project> = None; - let mut maybe_datasets: Vec<Dataset> = vec![]; - - let attributes: Vec<&hcl::Attribute> = self.0.attributes().collect(); - for attribute in attributes { - match attribute.key() { - "version" => maybe_version = Some(HclAttribute(attribute).try_into()?), - _ => { - continue; - } - } - } - - let blocks: Vec<&hcl::Block> = self.0.blocks().collect(); - for block in blocks { - match block.identifier() { - "project" => { - if maybe_project.is_some() { - return Err(DspMetaError::ParseProject( - "Only one project block allowed.".to_string(), - )); - } else { - maybe_project = Some(HclBlock(block).try_into()?) - } - } - "dataset" => maybe_datasets.push(HclBlock(block).try_into()?), - _ => { - continue; - } - } - } - - // Validate that the version is provided - let version = maybe_version.ok_or_else(|| { - DspMetaError::ParseVersion("Version attribute is not provided.".to_string()) - })?; - - // Validate that the project is provided - let project = maybe_project.ok_or_else(|| { - DspMetaError::ParseProject("Project block is not provided.".to_string()) - })?; - - // Validate that at least one dataset is provided - let datasets = if !maybe_datasets.is_empty() { - maybe_datasets - } else { - return Err(DspMetaError::ParseProject( - "At least one dataset block needs to be provided.".to_string(), - )); - }; - - // Validate that all referenced datasets exist - for dataset in &project.datasets { - if !datasets.iter().any(|d| d.id == *dataset) { - return Err(DspMetaError::ParseProject(format!( - "Dataset with id '{:?}' referenced in project block does not exist.", - dataset - ))); - } - } - - let metadata = ProjectMetadata { - version, - project, - datasets, - grants: Vec::new(), - organizations: Vec::new(), - persons: Vec::new(), - }; - Ok(metadata) - } -} - -#[cfg(test)] -mod tests { - use dsp_domain::metadata::entity::project_metadata::ProjectMetadata; - use hcl::body; - - use crate::api::convert::hcl::hcl_body::HclBody; - use crate::error::DspMetaError; - - #[test] - fn try_from_multiple_projects_error() { - let input = body!( - project { - shortcode = "0803" - } - project { - shortcode = "0804" - } - ); - - let project: Result<ProjectMetadata, DspMetaError> = HclBody(&input).try_into(); - assert!(project.is_err()); - } - - #[test] - fn try_from_no_project_error() { - let input = body!(); - - let project: Result<ProjectMetadata, DspMetaError> = HclBody(&input).try_into(); - assert!(project.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/abstract.rs b/dsp-meta/src/api/convert/hcl/value/abstract.rs deleted file mode 100644 index edaa4daa..00000000 --- a/dsp-meta/src/api/convert/hcl/value/abstract.rs +++ /dev/null @@ -1,77 +0,0 @@ -use dsp_domain::metadata::value::lang_text_data::LangTextData; -use dsp_domain::metadata::value::r#abstract::Abstract; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const ABSTRACT_BLOCK_IDENTIFIER: &str = "abstract"; - -impl<'a> TryInto<Abstract> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Abstract, Self::Error> { - if self.0.identifier.as_str() != ABSTRACT_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - ABSTRACT_BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - // FIXME: improve API - let lang_text_data: Result<LangTextData, DspMetaError> = - HclAttributes(attributes).try_into(); - lang_text_data.map(|l| l.into()) - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use dsp_domain::metadata::value::iso_code::IsoCode; - use dsp_domain::metadata::value::r#abstract::Abstract; - - use crate::api::convert::hcl::hcl_block::HclBlock; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - abstract { - de = "Die Zusammenfassung" - en = "The abstract" - fr = "Le résumé" - } - ); - - let result: Abstract = HclBlock(&block).try_into().unwrap(); - - let mut map = HashMap::new(); - map.insert(IsoCode::DE, String::from("Die Zusammenfassung")); - map.insert(IsoCode::EN, String::from("The abstract")); - map.insert(IsoCode::FR, String::from("Le résumé")); - let expected = Abstract(map); - - assert_eq!(result, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - other_block_name { - de = "Die Zusammenfassung" - en = "The abstract" - fr = "Le résumé" - } - ); - - let result: Result<Abstract, DspMetaError> = HclBlock(&block).try_into(); - - assert!(result.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/alternative_name.rs b/dsp-meta/src/api/convert/hcl/value/alternative_name.rs deleted file mode 100644 index effddfa0..00000000 --- a/dsp-meta/src/api/convert/hcl/value/alternative_name.rs +++ /dev/null @@ -1,74 +0,0 @@ -use dsp_domain::metadata::value::alternative_name::AlternativeName; -use dsp_domain::metadata::value::lang_text_data::LangTextData; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const ALTERNATIVE_NAME_BLOCK_IDENTIFIER: &str = "alternative_name"; - -impl<'a> TryInto<AlternativeName> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<AlternativeName, Self::Error> { - if self.0.identifier.as_str() != ALTERNATIVE_NAME_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - ALTERNATIVE_NAME_BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - // FIXME: improve API - let lang_text_data: Result<LangTextData, DspMetaError> = - HclAttributes(attributes).try_into(); - lang_text_data.map(|l| l.into()) - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use dsp_domain::metadata::value::iso_code::IsoCode; - - use super::*; - - #[test] - fn test_try_into_from_correct_block() { - let block = hcl::block!( - alternative_name { - de = "Der alternative Name" - en = "The alternative name" - fr = "Le alternative name" - } - ); - - let alternative_name: AlternativeName = HclBlock(&block).try_into().unwrap(); - let mut map: HashMap<IsoCode, String> = HashMap::new(); - map.insert(IsoCode::DE, String::from("Der alternative Name")); - map.insert(IsoCode::EN, String::from("The alternative name")); - map.insert(IsoCode::FR, String::from("Le alternative name")); - let expected = AlternativeName(map); - - assert_eq!(alternative_name, expected); - } - - #[test] - fn test_try_into_from_incorrect_block() { - let block = hcl::block!( - alternative_name_other { - de = "Der alternative Name" - en = "The alternative name" - fr = "Le alternative name" - } - ); - - let alternative_name: Result<AlternativeName, DspMetaError> = HclBlock(&block).try_into(); - - assert!(alternative_name.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/attribution.rs b/dsp-meta/src/api/convert/hcl/value/attribution.rs deleted file mode 100644 index 321d2739..00000000 --- a/dsp-meta/src/api/convert/hcl/value/attribution.rs +++ /dev/null @@ -1,130 +0,0 @@ -use dsp_domain::metadata::value::attribution::Attribution; -use dsp_domain::metadata::value::identifier::AgentId; -use tracing::warn; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const BLOCK_IDENTIFIER: &str = "attribution"; -const AGENT_ATTRIBUTE_KEY: &str = "agent"; -const ROLES_ATTRIBUTE_KEY: &str = "roles"; - -impl<'a> TryInto<Attribution> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Attribution, Self::Error> { - if self.0.identifier.as_str() != BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let mut maybe_agent: Option<AgentId> = None; - let mut maybe_roles: Vec<String> = vec![]; - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - for attribute in attributes { - match attribute.key() { - AGENT_ATTRIBUTE_KEY => { - if maybe_agent.is_some() { - return Err(DspMetaError::CreateValueObject( - format!("The passed {BLOCK_IDENTIFIER} block contains multiple {AGENT_ATTRIBUTE_KEY} attributes.") - .to_string(), - )); - } - maybe_agent = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(AgentId(value.to_owned()))), - _ => Err(DspMetaError::CreateValueObject( - format!("The passed {BLOCK_IDENTIFIER} block {AGENT_ATTRIBUTE_KEY} attribute is not of String type.").to_string(), - )), - }?; - }, - ROLES_ATTRIBUTE_KEY => { - match attribute.expr() { - hcl::Expression::Array(values) => { - for value in values { - match value { - hcl::Expression::String(value) => maybe_roles.push(value.to_owned()), - _ => { - return Err(DspMetaError::CreateValueObject( - format!("The passed {BLOCK_IDENTIFIER} block {ROLES_ATTRIBUTE_KEY} attribute is not of String type.").to_string(), - )) - } - } - } - } - _ => { - return Err(DspMetaError::CreateValueObject( - format!("The passed {BLOCK_IDENTIFIER} block {ROLES_ATTRIBUTE_KEY} attribute is not of List type.").to_string(), - )) - } - } - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - - let agent = maybe_agent.ok_or( - DspMetaError::CreateValueObject( - format!("The passed {BLOCK_IDENTIFIER} block does not contain a {AGENT_ATTRIBUTE_KEY} attribute.") - .to_string(), - ) - )?; - - let roles = if !maybe_roles.is_empty() { - Ok(maybe_roles) - } else { - Err(DspMetaError::CreateValueObject( - format!("The passed {BLOCK_IDENTIFIER} block does not contain a {ROLES_ATTRIBUTE_KEY} attribute.") - .to_string(), - )) - }?; - - Ok(Attribution { agent, roles }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - attribution { - agent = "http://ns.dasch.swiss/repository#dsp-081C-organization-000" // reference to person or organization - roles = ["Author"] - } - ); - - let result: Attribution = HclBlock(&block).try_into().unwrap(); - - let expected = Attribution { - agent: AgentId(String::from( - "http://ns.dasch.swiss/repository#dsp-081C-organization-000", - )), - roles: vec![String::from("Author")], - }; - - assert_eq!(result, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - other_block { - agent = "http://ns.dasch.swiss/repository#dsp-081C-organization-000" // reference to person or organization - roles = ["Author"] - } - ); - - let result: Result<Attribution, DspMetaError> = HclBlock(&block).try_into(); - - assert!(result.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/description.rs b/dsp-meta/src/api/convert/hcl/value/description.rs deleted file mode 100644 index 5af3fcc3..00000000 --- a/dsp-meta/src/api/convert/hcl/value/description.rs +++ /dev/null @@ -1,77 +0,0 @@ -use dsp_domain::metadata::value::description::Description; -use dsp_domain::metadata::value::lang_text_data::LangTextData; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const DESCRIPTION_BLOCK_IDENTIFIER: &str = "description"; - -impl<'a> TryInto<Description> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Description, Self::Error> { - if self.0.identifier.as_str() != DESCRIPTION_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - DESCRIPTION_BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - // FIXME: improve API - let lang_text_data: Result<LangTextData, DspMetaError> = - HclAttributes(attributes).try_into(); - lang_text_data.map(|l| l.into()) - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use dsp_domain::metadata::value::description::*; - use dsp_domain::metadata::value::iso_code::IsoCode; - - use crate::api::convert::hcl::hcl_block::HclBlock; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - description { - de = "Die Beschreibung" - en = "The description" - fr = "La description" - } - ); - - let description: Description = HclBlock(&block).try_into().unwrap(); - - let mut map = HashMap::new(); - map.insert(IsoCode::DE, String::from("Die Beschreibung")); - map.insert(IsoCode::EN, String::from("The description")); - map.insert(IsoCode::FR, String::from("La description")); - let expected = Description(map); - - assert_eq!(description, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - description_other { - de = "Die Beschreibung" - en = "The description" - fr = "La description" - } - ); - - let description: Result<Description, DspMetaError> = HclBlock(&block).try_into(); - - assert!(description.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/discipline.rs b/dsp-meta/src/api/convert/hcl/value/discipline.rs deleted file mode 100644 index ca00950b..00000000 --- a/dsp-meta/src/api/convert/hcl/value/discipline.rs +++ /dev/null @@ -1,107 +0,0 @@ -use dsp_domain::metadata::value::discipline::Discipline; -use dsp_domain::metadata::value::lang_text_data::LangTextData; -use dsp_domain::metadata::value::ref_data::RefData; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -impl<'a> TryInto<Discipline> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Discipline, Self::Error> { - if self.0.identifier.as_str() != "discipline" { - let msg = format!( - "The passed block is not named correctly. Expected 'discipline', however got '{}' instead.", - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - if self.0.labels.len() != 1 { - return Err(DspMetaError::CreateValueObject("The passed number of block labels is not correct. Expected '1', namely 'reference data type' (e.g., 'skos').".to_string())); - } - - let reference_data_type = self.0.labels.first().ok_or_else(|| { - DspMetaError::CreateValueObject( - "The passed discipline block is missing the reference data type label.".to_string(), - ) - })?; - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - match reference_data_type.as_str() { - "skos" => { - let ref_data: RefData = HclAttributes(attributes).try_into()?; - Ok(Discipline::Skos(ref_data)) - } - "snf" => { - let ref_data: RefData = HclAttributes(attributes).try_into()?; - Ok(Discipline::Snf(ref_data)) - } - "text" => { - let text_data: LangTextData = HclAttributes(attributes).try_into()?; - Ok(Discipline::Text(text_data)) - } - _ => { - Err(DspMetaError::CreateValueObject("The passed discipline block is missing the correct reference data type label: 'skos', 'snf', or 'text'.".to_string())) - } - } - } -} - -#[cfg(test)] -mod tests { - - use dsp_domain::metadata::value::discipline::*; - use dsp_domain::metadata::value::iso_code::IsoCode; - use tracing_test::traced_test; - - use super::*; - - #[test] - #[traced_test] - fn test_try_from_block_with_skos() { - let block = hcl::block!( - discipline skos { - ref_id = "https://skos.um.es/unesco6/5501" - description = "Local history" - url = "https://skos.um.es/unesco6/5501" - } - ); - - let input: Discipline = HclBlock(&block).try_into().unwrap(); - let expected = Discipline::Skos(RefData { - ref_id: "https://skos.um.es/unesco6/5501".to_string(), - description: "Local history".to_string(), - url: url::Url::parse("https://skos.um.es/unesco6/5501").unwrap(), - }); - - assert_eq!(input, expected); - } - - #[test] - #[traced_test] - fn test_try_from_block_with_text() { - let block = hcl::block!( - discipline text { - de = "Lokalgeschichte" - en = "Local history" - fr = "Histoire locale" - } - ); - - let input: Discipline = HclBlock(&block).try_into().unwrap(); - let expected = Discipline::Text(LangTextData( - vec![ - (IsoCode::DE, "Lokalgeschichte".to_string()), - (IsoCode::EN, "Local history".to_string()), - (IsoCode::FR, "Histoire locale".to_string()), - ] - .into_iter() - .collect(), - )); - - assert_eq!(input, expected); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/keyword.rs b/dsp-meta/src/api/convert/hcl/value/keyword.rs deleted file mode 100644 index ebd1f2b5..00000000 --- a/dsp-meta/src/api/convert/hcl/value/keyword.rs +++ /dev/null @@ -1,76 +0,0 @@ -use dsp_domain::metadata::value::keyword::Keyword; -use dsp_domain::metadata::value::lang_text_data::LangTextData; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const KEYWORD_BLOCK_IDENTIFIER: &str = "keyword"; - -impl<'a> TryInto<Keyword> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Keyword, Self::Error> { - if self.0.identifier.as_str() != KEYWORD_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - KEYWORD_BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - // FIXME: improve API - let lang_text_data: Result<LangTextData, DspMetaError> = - HclAttributes(attributes).try_into(); - lang_text_data.map(|l| l.into()) - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use dsp_domain::metadata::value::iso_code::IsoCode; - use dsp_domain::metadata::value::keyword::*; - - use crate::api::convert::hcl::hcl_block::HclBlock; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - keyword { - de = "Der keyword" - en = "The keyword" - fr = "Le keyword" - } - ); - - let keyword: Keyword = HclBlock(&block).try_into().unwrap(); - - let mut map: HashMap<IsoCode, String> = HashMap::new(); - map.insert(IsoCode::DE, String::from("Der keyword")); - map.insert(IsoCode::EN, String::from("The keyword")); - map.insert(IsoCode::FR, String::from("Le keyword")); - let expected = Keyword(map); - - assert_eq!(keyword, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - keyword_other { - de = "Der keyword" - en = "The keyword" - fr = "Le keyword" - } - ); - - let keyword: Result<Keyword, DspMetaError> = HclBlock(&block).try_into(); - - assert!(keyword.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/lang_text_data.rs b/dsp-meta/src/api/convert/hcl/value/lang_text_data.rs deleted file mode 100644 index 5b05d9dd..00000000 --- a/dsp-meta/src/api/convert/hcl/value/lang_text_data.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::collections::HashMap; - -use dsp_domain::metadata::value::iso_code::IsoCode; -use dsp_domain::metadata::value::lang_text_data::LangTextData; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::error::DspMetaError; - -impl<'a> TryInto<LangTextData> for HclAttributes<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<LangTextData, Self::Error> { - let mut text_data: HashMap<IsoCode, String> = HashMap::new(); - - for attribute in self.0 { - let iso_code = IsoCode::try_from(attribute.key())?; - let text = match attribute.expr() { - hcl::Expression::String(value) => Ok(value.to_owned()), - _ => Err(DspMetaError::CreateValueObject( - "The attribute value is not of String type.".to_string(), - )), - }?; - - text_data.insert(iso_code, text); - } - - Ok(LangTextData(text_data)) - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/language.rs b/dsp-meta/src/api/convert/hcl/value/language.rs deleted file mode 100644 index edaed62a..00000000 --- a/dsp-meta/src/api/convert/hcl/value/language.rs +++ /dev/null @@ -1,78 +0,0 @@ -use dsp_domain::metadata::value::lang_text_data::LangTextData; -use dsp_domain::metadata::value::language::Language; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const BLOCK_IDENTIFIER: &str = "language"; - -impl<'a> TryInto<Language> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Language, Self::Error> { - if self.0.identifier.as_str() != BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - // FIXME: improve API - let lang_text_data: Result<LangTextData, DspMetaError> = - HclAttributes(attributes).try_into(); - lang_text_data.map(|l| l.into()) - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use dsp_domain::metadata::value::description::*; - use dsp_domain::metadata::value::iso_code::IsoCode; - use dsp_domain::metadata::value::language::Language; - - use crate::api::convert::hcl::hcl_block::HclBlock; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - language { - de = "Deutsch" - en = "German" - fr = "Allemand" - } - ); - - let result: Language = HclBlock(&block).try_into().unwrap(); - - let mut map = HashMap::new(); - map.insert(IsoCode::DE, String::from("Deutsch")); - map.insert(IsoCode::EN, String::from("German")); - map.insert(IsoCode::FR, String::from("Allemand")); - let expected = Language(map); - - assert_eq!(result, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - other_block { - de = "Deutsch" - en = "German" - fr = "Allemand" - } - ); - - let result: Result<Description, DspMetaError> = HclBlock(&block).try_into(); - - assert!(result.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/license.rs b/dsp-meta/src/api/convert/hcl/value/license.rs deleted file mode 100644 index 256a7841..00000000 --- a/dsp-meta/src/api/convert/hcl/value/license.rs +++ /dev/null @@ -1,170 +0,0 @@ -use dsp_domain::metadata::value::license::License; -use tracing::warn; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const LICENSE_BLOCK_IDENTIFIER: &str = "license"; -const TYPE_ATTRIBUTE_KEY: &str = "type"; -const HREF_ATTRIBUTE_KEY: &str = "href"; -const DATE_ATTRIBUTE_KEY: &str = "date"; -const LABEL_ATTRIBUTE_KEY: &str = "label"; - -impl<'a> TryInto<License> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<License, Self::Error> { - if self.0.identifier.as_str() != LICENSE_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - LICENSE_BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let mut type_: Option<String> = None; - let mut href: Option<url::Url> = None; - let mut date: Option<String> = None; - let mut label: Option<String> = None; - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - for attribute in attributes { - match attribute.key() { - TYPE_ATTRIBUTE_KEY => { - if type_.is_some() { - return Err(DspMetaError::CreateValueObject( - format!("The passed {LICENSE_BLOCK_IDENTIFIER} block contains multiple {TYPE_ATTRIBUTE_KEY} attributes.") - .to_string(), - )); - } - type_ = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - format!("The passed {LICENSE_BLOCK_IDENTIFIER} block {TYPE_ATTRIBUTE_KEY} attribute is not of String type.").to_string(), - )), - }?; - } - HREF_ATTRIBUTE_KEY => { - if href.is_some() { - return Err(DspMetaError::CreateValueObject( - format!("Multiple {TYPE_ATTRIBUTE_KEY} attributes not allowed.") - .to_string(), - )); - } - href = match attribute.expr() { - hcl::Expression::String(value) => { - Ok(Some(url::Url::parse(value).map_err(|_| { - DspMetaError::CreateValueObject( - format!("The passed {LICENSE_BLOCK_IDENTIFIER} block {TYPE_ATTRIBUTE_KEY} attribute is not a valid URL.") - .to_string(), - ) - })?)) - } - _ => Err(DspMetaError::CreateValueObject( - "The value for the href attribute is not of String type.".to_string(), - )), - }?; - } - DATE_ATTRIBUTE_KEY => { - if date.is_some() { - return Err(DspMetaError::CreateValueObject( - format!("Multiple {DATE_ATTRIBUTE_KEY} attributes not allowed.") - .to_string(), - )); - } - date = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - format!("The passed {LICENSE_BLOCK_IDENTIFIER} block {DATE_ATTRIBUTE_KEY} attribute is not of String type.").to_string(), - )), - }?; - } - LABEL_ATTRIBUTE_KEY => { - if label.is_some() { - return Err(DspMetaError::CreateValueObject( - format!("The passed {LICENSE_BLOCK_IDENTIFIER} block contains multiple {LABEL_ATTRIBUTE_KEY} attributes.") - .to_string(), - )); - } - label = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - format!("The passed {LICENSE_BLOCK_IDENTIFIER} block {LABEL_ATTRIBUTE_KEY} attribute is not of String type.").to_string(), - )), - }?; - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - - Ok(License { - license_type: type_.ok_or_else(|| { - DspMetaError::CreateDomainObject( - "The required href attribute is missing.".to_string(), - ) - })?, - href: href.ok_or_else(|| { - DspMetaError::CreateDomainObject( - "The required href attribute is missing.".to_string(), - ) - })?, - date: date.ok_or_else(|| { - DspMetaError::CreateDomainObject( - "The required date attribute is missing.".to_string(), - ) - })?, - label: label.ok_or_else(|| { - DspMetaError::CreateDomainObject( - "The required label attribute is missing.".to_string(), - ) - })?, - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - license { - type = "creative_commons" - href = "https://www.google.com" - date = "2021-09-02" - label = "CC BY-NC 4.0" - } - ); - - let result: License = HclBlock(&block).try_into().unwrap(); - - let expected = License { - license_type: "creative_commons".to_string(), - href: url::Url::try_from("https://www.google.com").unwrap(), - date: "2021-09-02".to_string(), - label: "CC BY-NC 4.0".to_string(), - }; - - assert_eq!(result, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - other_block { - type = "creative_commons" - href = "https://www.google.com" - date = "2021-09-02" - label = "CC BY-NC 4.0" - } - ); - - let result: Result<License, DspMetaError> = HclBlock(&block).try_into(); - - assert!(result.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/mod.rs b/dsp-meta/src/api/convert/hcl/value/mod.rs deleted file mode 100644 index f04cdd97..00000000 --- a/dsp-meta/src/api/convert/hcl/value/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -mod r#abstract; -mod alternative_name; -mod attribution; -mod description; -mod discipline; -mod keyword; -mod lang_text_data; -mod language; -mod license; -mod publication; -mod ref_data; -mod simple_text_data; -mod spatial_coverage; -mod temporal_coverage; -mod url; -mod version; diff --git a/dsp-meta/src/api/convert/hcl/value/publication.rs b/dsp-meta/src/api/convert/hcl/value/publication.rs deleted file mode 100644 index 0c1caae5..00000000 --- a/dsp-meta/src/api/convert/hcl/value/publication.rs +++ /dev/null @@ -1,66 +0,0 @@ -use dsp_domain::metadata::value::publication::Publication; -use dsp_domain::metadata::value::simple_text_data::SimpleTextData; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const PUBLICATION_BLOCK_IDENTIFIER: &str = "publication"; - -impl<'a> TryInto<Publication> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Publication, Self::Error> { - if self.0.identifier.as_str() != PUBLICATION_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected 'publication', however got '{}' instead.", - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - let simple_text_data: Result<SimpleTextData, DspMetaError> = - HclAttributes(attributes).try_into(); - simple_text_data.map(|s| s.to_simple_text()) - } -} - -#[cfg(test)] -mod tests { - use dsp_domain::metadata::value::publication::*; - use dsp_domain::metadata::value::simple_text_data::SimpleTextData; - - use crate::api::convert::hcl::hcl_block::HclBlock; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - publication { - text = "A publication" - } - ); - - let publication: Publication = HclBlock(&block).try_into().unwrap(); - - match publication { - Publication::SimpleText(data) => { - assert_eq!(data, SimpleTextData("A publication".to_string())); - } - } - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - publication_other { - text = "A publication" - } - ); - - let publication: Result<Publication, DspMetaError> = HclBlock(&block).try_into(); - - assert!(publication.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/ref_data.rs b/dsp-meta/src/api/convert/hcl/value/ref_data.rs deleted file mode 100644 index f32b32a6..00000000 --- a/dsp-meta/src/api/convert/hcl/value/ref_data.rs +++ /dev/null @@ -1,88 +0,0 @@ -use dsp_domain::metadata::value::ref_data::RefData; -use tracing::warn; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::error::DspMetaError; - -/// Reference to a discipline defined in an external reference system (e.g. SNF or SKOS) -/// FIXME: Move to the API layer where the service adapter is implemented -impl<'a> TryInto<RefData> for HclAttributes<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<RefData, Self::Error> { - let mut ref_id: Option<String> = None; - let mut description: Option<String> = None; - let mut url: Option<url::Url> = None; - - for attribute in self.0 { - match attribute.key() { - "ref_id" => { - if ref_id.is_some() { - return Err(DspMetaError::CreateValueObject( - "The passed discipline block contains multiple ref_id attributes." - .to_string(), - )); - } - ref_id = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - "The passed discipline block ref_id attribute is not of String type." - .to_string(), - )), - }?; - } - "description" => { - if description.is_some() { - return Err(DspMetaError::CreateValueObject( - "The passed discipline block contains multiple description attributes." - .to_string(), - )); - } - description = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - "The passed discipline block description attribute is not of String type.".to_string(), - )), - }?; - } - "url" => { - if url.is_some() { - return Err(DspMetaError::CreateValueObject( - "The passed discipline block contains multiple url attributes." - .to_string(), - )); - } - url = match attribute.expr() { - hcl::Expression::String(value) => { - Ok(Some(url::Url::parse(value).map_err(|_| { - DspMetaError::CreateValueObject( - "The passed discipline block url attribute is not a valid url." - .to_string(), - ) - })?)) - } - _ => Err(DspMetaError::CreateValueObject( - "The passed discipline block url attribute is not of String type." - .to_string(), - )), - }?; - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - - Ok(RefData { - ref_id: ref_id.ok_or(DspMetaError::CreateValueObject( - "The passed discipline block does not contain a ref_id attribute.".to_string(), - ))?, - description: description.ok_or(DspMetaError::CreateValueObject( - "The passed discipline block does not contain a description attribute.".to_string(), - ))?, - url: url.ok_or(DspMetaError::CreateValueObject( - "The passed discipline block does not contain a url attribute.".to_string(), - ))?, - }) - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/simple_text_data.rs b/dsp-meta/src/api/convert/hcl/value/simple_text_data.rs deleted file mode 100644 index b3b1def1..00000000 --- a/dsp-meta/src/api/convert/hcl/value/simple_text_data.rs +++ /dev/null @@ -1,85 +0,0 @@ -use dsp_domain::metadata::value::simple_text_data::SimpleTextData; -use tracing::warn; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::error::DspMetaError; - -const TEXT_ATTRIBUTE_IDENTIFIER: &str = "text"; - -impl<'a> TryInto<SimpleTextData> for HclAttributes<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<SimpleTextData, Self::Error> { - let mut text_attribute_value: Option<String> = None; - - for attribute in self.0 { - match attribute.key() { - TEXT_ATTRIBUTE_IDENTIFIER => { - if text_attribute_value.is_some() { - return Err(DspMetaError::CreateValueObject( - "Multiple text attributes are not allowed.".to_string(), - )); - } - text_attribute_value = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - "The attribute value is not of String type.".to_string(), - )), - }?; - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - Ok(SimpleTextData(text_attribute_value.ok_or_else(|| { - DspMetaError::CreateValueObject("Missing text attribute.".to_string()) - })?)) - } -} - -#[cfg(test)] -mod tests { - - use dsp_domain::metadata::value::simple_text_data::*; - use tracing_test::traced_test; - - use crate::api::convert::hcl::hcl_attribute::HclAttributes; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_attributes() { - let attribute = hcl::Attribute::new("text", "some text"); - let text_data: SimpleTextData = HclAttributes(vec![&attribute]).try_into().unwrap(); - assert_eq!(text_data, SimpleTextData("some text".to_string())); - } - - #[traced_test] - #[test] - fn test_try_from_attributes_missing_text() { - let attribute = hcl::Attribute::new("some_other_attribute", "some text"); - let text_data: Result<SimpleTextData, DspMetaError> = - HclAttributes(vec![&attribute]).try_into(); - assert!(text_data.is_err()); - assert!(logs_contain( - "Parse error: unknown attribute 'some_other_attribute'" - )); - } - - #[test] - fn test_try_from_attributes_multiple_text() { - let attribute = hcl::Attribute::new("text", "some text"); - let attribute2 = hcl::Attribute::new("text", "some text"); - let text_data: Result<SimpleTextData, DspMetaError> = - HclAttributes(vec![&attribute, &attribute2]).try_into(); - assert!(text_data.is_err()); - } - - #[test] - fn test_try_from_attributes_wrong_type() { - let attribute = hcl::Attribute::new("text", 1); - let text_data: Result<SimpleTextData, DspMetaError> = - HclAttributes(vec![&attribute]).try_into(); - assert!(text_data.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/spatial_coverage.rs b/dsp-meta/src/api/convert/hcl/value/spatial_coverage.rs deleted file mode 100644 index bf833d2e..00000000 --- a/dsp-meta/src/api/convert/hcl/value/spatial_coverage.rs +++ /dev/null @@ -1,71 +0,0 @@ -use dsp_domain::metadata::value::ref_data::RefData; -use dsp_domain::metadata::value::spatial_coverage::SpatialCoverage; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const SPATIAL_COVERAGE: &str = "spatial_coverage"; -const GEONAMES: &str = "geonames"; - -impl<'a> TryInto<SpatialCoverage> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<SpatialCoverage, Self::Error> { - if self.0.identifier.as_str() != SPATIAL_COVERAGE { - let msg = format!( - "The passed block is not named correctly. Expected 'spatial_coverage', however got '{}' instead.", - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - if self.0.labels.len() != 1 { - return Err(DspMetaError::CreateValueObject("The passed number of block labels is not correct. Expected '1', namely 'reference data type' (e.g., 'geonames').".to_string())); - } - - let reference_data_type = self.0.labels.first().ok_or_else(|| { - DspMetaError::CreateValueObject( - "The passed spacial_coverage block is missing the reference data type label." - .to_string(), - ) - })?; - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - match reference_data_type.as_str() { - GEONAMES => { - let ref_data: RefData = HclAttributes(attributes).try_into()?; - Ok(SpatialCoverage::Geonames(ref_data)) - } - _ => { - Err(DspMetaError::CreateValueObject("The passed spacial_coverage block is missing the correct reference data type label: 'geonames'.".to_string())) - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_try_from_block_with_geonames() { - let block = hcl::block!( - spatial_coverage geonames { - ref_id = "1234" - description = "A description" - url = "https://geonames.org/1234" - } - ); - - let input: SpatialCoverage = HclBlock(&block).try_into().unwrap(); - let expected = SpatialCoverage::Geonames(RefData { - ref_id: "1234".to_string(), - description: "A description".to_string(), - url: "https://geonames.org/1234".parse().unwrap(), - }); - - assert_eq!(input, expected); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/temporal_coverage.rs b/dsp-meta/src/api/convert/hcl/value/temporal_coverage.rs deleted file mode 100644 index 9522bd7e..00000000 --- a/dsp-meta/src/api/convert/hcl/value/temporal_coverage.rs +++ /dev/null @@ -1,86 +0,0 @@ -use dsp_domain::metadata::value::lang_text_data::LangTextData; -use dsp_domain::metadata::value::ref_data::RefData; -use dsp_domain::metadata::value::temporal_coverage::TemporalCoverage; - -use crate::api::convert::hcl::hcl_attribute::HclAttributes; -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const TEMPORAL_COVERAGE: &str = "temporal_coverage"; -const CHRONONTOLOGY: &str = "chronontology"; -const PERIODO: &str = "periodo"; - -const TEXT: &str = "text"; - -impl<'a> TryInto<TemporalCoverage> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<TemporalCoverage, Self::Error> { - if self.0.identifier.as_str() != TEMPORAL_COVERAGE { - let msg = format!( - "The passed block is not named correctly. Expected 'temporal_coverage', however got '{}' instead.", - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - if self.0.labels.len() != 1 { - return Err(DspMetaError::CreateValueObject("The passed number of block labels is not correct. Expected '1', namely 'reference data type' (e.g., 'chronontology, periodo').".to_string())); - } - - let reference_data_type = self.0.labels.first().ok_or_else(|| { - DspMetaError::CreateValueObject( - "The passed spacial_coverage block is missing the reference data type label." - .to_string(), - ) - })?; - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - - match reference_data_type.as_str() { - CHRONONTOLOGY => { - let ref_data: RefData = HclAttributes(attributes).try_into()?; - Ok(TemporalCoverage::Chronontology(ref_data)) - } - PERIODO => { - let ref_data: RefData = HclAttributes(attributes).try_into()?; - Ok(TemporalCoverage::Periodo(ref_data)) - } - TEXT => { - let text_data: LangTextData = HclAttributes(attributes).try_into()?; - Ok(TemporalCoverage::Text(text_data)) - } - _ => { - let msg = format!("The passed temporal_coverage block is missing the correct reference data type label. Expected one of '{}', '{}' or '{}'. Got '{}'.", CHRONONTOLOGY, PERIODO, TEXT, reference_data_type.as_str()); - Err(DspMetaError::CreateValueObject(msg)) - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_try_from_block_with_chonontology() { - let block = hcl::block!( - temporal_coverage chronontology { - ref_id = "https://chronontology.dainst.org/period/INtagfT8h7Fs" - description = "20th and 21st Centuries" - url = "https://chronontology.dainst.org/period/INtagfT8h7Fs" - } - ); - - let input: TemporalCoverage = HclBlock(&block).try_into().unwrap(); - let expected = TemporalCoverage::Chronontology(RefData { - ref_id: "https://chronontology.dainst.org/period/INtagfT8h7Fs".to_string(), - description: "20th and 21st Centuries".to_string(), - url: "https://chronontology.dainst.org/period/INtagfT8h7Fs" - .parse() - .unwrap(), - }); - - assert_eq!(input, expected); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/url.rs b/dsp-meta/src/api/convert/hcl/value/url.rs deleted file mode 100644 index c48e2b40..00000000 --- a/dsp-meta/src/api/convert/hcl/value/url.rs +++ /dev/null @@ -1,121 +0,0 @@ -use dsp_domain::metadata::value::url::Url; -use tracing::warn; - -use crate::api::convert::hcl::hcl_block::HclBlock; -use crate::error::DspMetaError; - -const URL_BLOCK_IDENTIFIER: &str = "url"; -const HREF_ATTRIBUTE_KEY: &str = "href"; -const LABEL_ATTRIBUTE_KEY: &str = "label"; - -impl<'a> TryInto<Url> for HclBlock<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Url, Self::Error> { - if self.0.identifier.as_str() != URL_BLOCK_IDENTIFIER { - let msg = format!( - "The passed block is not named correctly. Expected '{}', however got '{}' instead.", - URL_BLOCK_IDENTIFIER, - self.0.identifier.as_str() - ); - return Err(DspMetaError::CreateValueObject(msg)); - } - - let mut href: Option<url::Url> = None; - let mut label: Option<String> = None; - - let attributes: Vec<&hcl::Attribute> = self.0.body.attributes().collect(); - for attribute in attributes { - match attribute.key() { - LABEL_ATTRIBUTE_KEY => { - if label.is_some() { - return Err(DspMetaError::CreateValueObject( - "The passed discipline block contains multiple description attributes." - .to_string(), - )); - } - label = match attribute.expr() { - hcl::Expression::String(value) => Ok(Some(value.to_owned())), - _ => Err(DspMetaError::CreateValueObject( - "The passed discipline block description attribute is not of String type.".to_string(), - )), - }?; - } - HREF_ATTRIBUTE_KEY => { - if href.is_some() { - return Err(DspMetaError::CreateValueObject( - "Multiple href attributes not allowed.".to_string(), - )); - } - href = match attribute.expr() { - hcl::Expression::String(value) => { - Ok(Some(url::Url::parse(value).map_err(|_| { - DspMetaError::CreateValueObject( - "The passed discipline block url attribute is not a valid url." - .to_string(), - ) - })?)) - } - _ => Err(DspMetaError::CreateValueObject( - "The value for the href attribute is not of String type.".to_string(), - )), - }?; - } - _ => { - warn!("Parse error: unknown attribute '{}'.", attribute.key()); - } - } - } - - Ok(Url { - href: href.ok_or(DspMetaError::CreateValueObject( - "The required href attribute is missing.".to_string(), - ))?, - label: label.ok_or(DspMetaError::CreateValueObject( - "The required label attribute is missing.".to_string(), - ))?, - }) - } -} - -#[cfg(test)] -mod tests { - - use dsp_domain::metadata::value::url::*; - - use crate::api::convert::hcl::hcl_block::HclBlock; - use crate::error::DspMetaError; - - #[test] - fn test_try_from_correct_block() { - let block = hcl::block!( - url { - href = "https://www.google.com" - label = "Google" - } - ); - - let url: Url = HclBlock(&block).try_into().unwrap(); - - let expected = Url { - href: url::Url::try_from("https://www.google.com").unwrap(), - label: "Google".to_string(), - }; - - assert_eq!(url, expected); - } - - #[test] - fn test_try_from_incorrect_block() { - let block = hcl::block!( - url_other { - href = "https://www.google.com" - label = "Google" - } - ); - - let url: Result<Url, DspMetaError> = HclBlock(&block).try_into(); - - assert!(url.is_err()); - } -} diff --git a/dsp-meta/src/api/convert/hcl/value/version.rs b/dsp-meta/src/api/convert/hcl/value/version.rs deleted file mode 100644 index a6316e1a..00000000 --- a/dsp-meta/src/api/convert/hcl/value/version.rs +++ /dev/null @@ -1,45 +0,0 @@ -use dsp_domain::metadata::value::version::Version; -use hcl::Expression; - -use crate::api::convert::hcl::hcl_attribute::HclAttribute; -use crate::error::DspMetaError; - -/// Given a list of attributes, try to extract the version. -impl<'a> TryInto<Version> for HclAttribute<'a> { - type Error = DspMetaError; - - fn try_into(self) -> Result<Version, Self::Error> { - type Error = crate::error::DspMetaError; - - let mut result: Result<Version, Self::Error> = Err(Error::ParseVersion( - "Version attribute is not provided.".to_string(), - )); - - if self.0.key() == "version" { - result = match self.0.expr() { - Expression::Number(value) => Ok(Version(value.as_u64().ok_or_else(|| { - Error::ParseVersion("Version needs to be a non-negative number.".to_string()) - })?)), - _ => Err(Error::ParseVersion( - "Version needs to be a non-negative number.".to_string(), - )), - } - } - - result - } -} - -#[cfg(test)] -mod tests { - use dsp_domain::metadata::value::version::*; - - use crate::api::convert::hcl::hcl_attribute::HclAttribute; - - #[test] - fn test_try_from_attributes() { - let attribute = hcl::Attribute::new("version", 1u64); - let version: Version = HclAttribute(&attribute).try_into().unwrap(); - assert_eq!(version, Version(1)); - } -} diff --git a/dsp-meta/src/api/convert/mod.rs b/dsp-meta/src/api/convert/mod.rs index 9c49a5a8..e2d4eff1 100644 --- a/dsp-meta/src/api/convert/mod.rs +++ b/dsp-meta/src/api/convert/mod.rs @@ -1,3 +1 @@ pub(crate) mod axum; -pub mod hcl; -pub(crate) mod rdf; diff --git a/dsp-meta/src/api/convert/rdf/constance.rs b/dsp-meta/src/api/convert/rdf/constance.rs deleted file mode 100644 index ddf62807..00000000 --- a/dsp-meta/src/api/convert/rdf/constance.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(dead_code)] -pub const RDF_NAMESPACE_STRING: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; -pub const RDFS_NAMESPACE_STRING: &str = "http://www.w3.org/2000/01/rdf-schema#"; -pub const XSD_NAMESPACE_STRING: &str = "http://www.w3.org/2001/XMLSchema#"; -pub const DSP_NAMESPACE_STRING: &str = "http://ns.dasch.swiss/repository#"; -pub const PROV_NAMESPACE_STRING: &str = "http://www.w3.org/ns/prov#"; -pub const SCHEMA_NAMESPACE_STRING: &str = "https://schema.org/"; diff --git a/dsp-meta/src/api/convert/rdf/error.rs b/dsp-meta/src/api/convert/rdf/error.rs deleted file mode 100644 index bd014cc4..00000000 --- a/dsp-meta/src/api/convert/rdf/error.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::error::DspMetaError; - -impl From<sophia::iri::InvalidIri> for DspMetaError { - fn from(error: sophia::iri::InvalidIri) -> Self { - DspMetaError::SerializeToRdf(error.0) - } -} diff --git a/dsp-meta/src/api/convert/rdf/mod.rs b/dsp-meta/src/api/convert/rdf/mod.rs deleted file mode 100644 index 01176117..00000000 --- a/dsp-meta/src/api/convert/rdf/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod constance; -mod error; -mod project; -pub(crate) mod project_metadata; -mod triple; -pub mod value; diff --git a/dsp-meta/src/api/convert/rdf/project.rs b/dsp-meta/src/api/convert/rdf/project.rs deleted file mode 100644 index 45481f90..00000000 --- a/dsp-meta/src/api/convert/rdf/project.rs +++ /dev/null @@ -1,39 +0,0 @@ -// placeholder for project - -use dsp_domain::metadata::entity::project::Project; -use sophia::api::graph::{Graph, MutableGraph}; -use sophia::api::ns::{rdf, Namespace}; -use sophia::inmem::graph::LightGraph; -use sophia::iri::Iri; - -use crate::api::convert::rdf::constance::DSP_NAMESPACE_STRING; -use crate::api::convert::rdf::value::shortcode::ShortcodeGraphDto; - -pub struct ProjectGraphDto(pub Project); -impl ProjectGraphDto { - pub(crate) fn to_graph(&self) -> LightGraph { - let mut graph = LightGraph::new(); - - // http://ns.dasch.swiss/repository#dsp-081C-project a http://ns.dasch.swiss/repository#Project - let ns = Namespace::new_unchecked(DSP_NAMESPACE_STRING); - - let project_iri = ns - .get(format!("{}dsp-{}-project", ns.as_str(), self.0.shortcode.0).as_str()) - .expect("project_iri creation failed.") - .to_string(); - let project_iri = Iri::new(project_iri).expect("project_iri creation failed."); - - let project_class = ns.get("Project").expect("project_class creation failed."); - - graph - .insert(&project_iri, rdf::type_, project_class) - .expect("insert of project triples into graph failed."); - - let shortcode_graph = ShortcodeGraphDto(&self.0.shortcode).to_graph(&project_iri); - graph - .insert_all(shortcode_graph.triples()) - .expect("insert of project triples into graph failed."); - - graph - } -} diff --git a/dsp-meta/src/api/convert/rdf/project_metadata.rs b/dsp-meta/src/api/convert/rdf/project_metadata.rs deleted file mode 100644 index f5dbfe4b..00000000 --- a/dsp-meta/src/api/convert/rdf/project_metadata.rs +++ /dev/null @@ -1,147 +0,0 @@ -use dsp_domain::metadata::entity::project_metadata::ProjectMetadata; -use sophia::api::ns::Namespace; -use sophia::api::prefix::{Prefix, PrefixMapPair}; -use sophia::api::prelude::Stringifier; -use sophia::api::serializer::TripleSerializer; -use sophia::inmem::graph::LightGraph; -use sophia::iri::Iri; -use sophia::turtle::serializer::turtle::{TurtleConfig, TurtleSerializer}; -use tracing::trace; - -use crate::api::convert::rdf::constance::{ - DSP_NAMESPACE_STRING, PROV_NAMESPACE_STRING, SCHEMA_NAMESPACE_STRING, XSD_NAMESPACE_STRING, -}; -use crate::api::convert::rdf::project::ProjectGraphDto; -pub struct ProjectMetadataGraph { - graph: LightGraph, -} - -impl ProjectMetadataGraph { - /// Serialize the graph to a turtle string. - /// - /// Example output: - /// ```turtle - /// @prefix dsp: <http://ns.dasch.swiss/repository#> . - /// @prefix prov: <http://www.w3.org/ns/prov#> . - /// @prefix sdo: <https://schema.org/> . - /// @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . - /// - /// dsp:dsp-081C-project a dsp:Project ; - /// dsp:hasDataset dsp:dsp-081C-dataset-000 ; - /// dsp:hasDescription "The database documents the events that took place in the Hôtel de Musique - /// in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles - /// like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences - /// or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th - /// Century."@en ; dsp:hasDiscipline "10302 Schweizer Geschichte"@de, - /// "10405 Musikologie"@de, - /// "10406 Theater-und Filmwissenschaften"@de, - /// "10604 Musik und Theater"@de ; - /// dsp:hasFunder dsp:dsp-081C-organization-000 ; - /// dsp:hasHowToCite "HdM-Bern"^^xsd:string ; - /// dsp:hasKeyword "Bern"@de, - /// "19 Century"@en, - /// "Concert"@en, - /// "Music"@en, - /// "Musicology"@en, - /// "Opera"@en, - /// "Spectales"@en, - /// "Switzerland"@en, - /// "Theater history"@en, - /// "Theatre"@en ; - /// dsp:hasName "Hôtel de Musique Bern"^^xsd:string ; - /// dsp:hasShortcode "081C"^^xsd:string ; - /// dsp:hasSpatialCoverage [ a sdo:URL ; - /// sdo:propertyID [ a sdo:PropertyValue ; - /// sdo:propertyID "Bern" ] ; - /// sdo:url "https://www.geonames.org/2661552" ] ; - /// dsp:hasStartDate "2009-04-01"^^xsd:date ; - /// dsp:hasTeaser "The database documents the different kinds of spectacles such as theatre - /// plays, operas, ballets, or concerts that took place in the Hôtel de Musique in Bern between 1766 - /// and 1905."^^xsd:string ; dsp:hasTemporalCoverage [ a sdo:URL ; - /// sdo:propertyID [ a sdo:PropertyValue ; - /// sdo:propertyID "Sonderbund, 1845-1847" ] ; - /// sdo:url "http://n2t.net/ark:/99152/p06c6g3p4cf" ], - /// [ a sdo:URL ; - /// sdo:propertyID [ a sdo:PropertyValue ; - /// sdo:propertyID "Under Mediation act, 1803-1814" ] ; - /// sdo:url "http://n2t.net/ark:/99152/p06c6g3pvr5" ], - /// [ a sdo:URL ; - /// sdo:propertyID [ a sdo:PropertyValue ; - /// sdo:propertyID "Helvetic Republic, 1798-1803" ] ; - /// sdo:url "http://n2t.net/ark:/99152/p06c6g364np" ], - /// "1766-1905"@de, - /// "1766-1905"@en, - /// "1766-1905"@fr ; - /// dsp:hasURL [ a sdo:URL ; - /// sdo:propertyID [ a sdo:PropertyValue ; - /// sdo:propertyID "Discover Project Data" ] ; - /// sdo:url "https://admin.dasch.swiss/project/081C" ] . - /// ``` - pub fn to_turtle_string(&self) -> String { - let prefix_map: Vec<PrefixMapPair> = vec![ - ( - Prefix::new_unchecked("dsp".into()), - Iri::new_unchecked("http://ns.dasch.swiss/repository#".into()), - ), - ( - Prefix::new_unchecked("prov".into()), - Iri::new_unchecked("http://www.w3.org/ns/prov#".into()), - ), - ( - Prefix::new_unchecked("sdo".into()), - Iri::new_unchecked("https://schema.org/".into()), - ), - ( - Prefix::new_unchecked("rdf".into()), - Iri::new_unchecked("http://www.w3.org/1999/02/22-rdf-syntax-ns#".into()), - ), - ( - Prefix::new_unchecked("rdfs".into()), - Iri::new_unchecked("http://www.w3.org/2000/01/rdf-schema#".into()), - ), - ( - Prefix::new_unchecked("xsd".into()), - Iri::new_unchecked("http://www.w3.org/2001/XMLSchema#".into()), - ), - ]; - - let config = TurtleConfig::new() - .with_pretty(true) - .with_own_prefix_map(prefix_map); - let mut serializer = TurtleSerializer::new_stringifier_with_config(config); - let out = serializer - .serialize_graph(&self.graph) - .expect("Error serializing graph to turtle.") - .to_string(); - out - } -} - -/// A wrapper around an optional ProjectMetadata. -pub struct ProjectMetadataGraphWrapper(pub ProjectMetadata); - -/// Convert a `ProjectMetadataGraphDto` into a `ProjectMetadataGraph`. -/// -/// The underlying graph implementation is a `LightGraph` (in contrast to FastGraph) which is a -/// simple in-memory graph graph implementation with a low memory footprint, without indexing, -/// thus fast to build but slow to query. Since we are only interested in building the graph and -/// immediately serializing it, this is the better choice (supported by benchmarking results). -impl From<ProjectMetadataGraphWrapper> for ProjectMetadataGraph { - fn from(value: ProjectMetadataGraphWrapper) -> ProjectMetadataGraph { - trace!("entered ProjectMetadataGraph::from()"); - let _dsp = Namespace::new_unchecked(DSP_NAMESPACE_STRING); - - let _prov = Namespace::new_unchecked(PROV_NAMESPACE_STRING); - - let _sdo = Namespace::new_unchecked(SCHEMA_NAMESPACE_STRING); - - let _xsd = Namespace::new_unchecked(XSD_NAMESPACE_STRING); - - let graph = ProjectGraphDto(value.0.project).to_graph(); - let result = ProjectMetadataGraph { graph }; - - trace!("The resulting graph\n{}", result.to_turtle_string()); - - result - } -} diff --git a/dsp-meta/src/api/convert/rdf/triple.rs b/dsp-meta/src/api/convert/rdf/triple.rs deleted file mode 100644 index 0b672c22..00000000 --- a/dsp-meta/src/api/convert/rdf/triple.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(dead_code)] -struct Triple { - subject: String, - predicate: String, - object: String, -} diff --git a/dsp-meta/src/api/convert/rdf/value/mod.rs b/dsp-meta/src/api/convert/rdf/value/mod.rs deleted file mode 100644 index 708ab009..00000000 --- a/dsp-meta/src/api/convert/rdf/value/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod shortcode; diff --git a/dsp-meta/src/api/convert/rdf/value/shortcode.rs b/dsp-meta/src/api/convert/rdf/value/shortcode.rs deleted file mode 100644 index 6823004c..00000000 --- a/dsp-meta/src/api/convert/rdf/value/shortcode.rs +++ /dev/null @@ -1,26 +0,0 @@ -use dsp_domain::metadata::value::Shortcode; -use sophia::api::graph::MutableGraph; -use sophia::api::ns::Namespace; -use sophia::inmem::graph::LightGraph; -use sophia::iri::Iri; - -pub(crate) struct ShortcodeGraphDto<'a>(pub &'a Shortcode); - -impl<'a> ShortcodeGraphDto<'a> { - pub fn to_graph(&self, project_iri: &Iri<String>) -> LightGraph { - // http://ns.dasch.swiss/repository#dsp-081C-project http://ns.dasch.swiss/repository#hasShortcode "081C"^^http://www.w3.org/2001/XMLSchema#string - let dsp = Namespace::new_unchecked("http://ns.dasch.swiss/repository#"); - - let has_shortcode = dsp - .get("hasShortcode") - .expect("has_shortcode_property creation failed."); - - // mutating the graph - let mut graph: LightGraph = LightGraph::new(); - - graph - .insert(project_iri, has_shortcode, self.0.as_string().as_str()) - .expect("triple inserted"); - graph - } -} diff --git a/dsp-meta/src/error.rs b/dsp-meta/src/error.rs index af3b80a5..f6183a4f 100644 --- a/dsp-meta/src/error.rs +++ b/dsp-meta/src/error.rs @@ -1,6 +1,5 @@ use std::io; -use dsp_domain::error::DspDomainError; use serde::Serialize; use serde_json::Error; use thiserror::Error; @@ -45,15 +44,6 @@ impl From<io::Error> for DspMetaError { } } -impl From<DspDomainError> for DspMetaError { - fn from(value: DspDomainError) -> Self { - match value { - DspDomainError::CreateValueObject(err) => DspMetaError::CreateValueObject(err), - DspDomainError::CreateDomainObject(err) => DspMetaError::CreateDomainObject(err), - } - } -} - impl From<serde_json::Error> for DspMetaError { fn from(value: Error) -> Self { DspMetaError::JsonSerialization(value.to_string()) diff --git a/dsp-meta/tests/common/mod.rs b/dsp-meta/tests/common/mod.rs deleted file mode 100644 index 8fd6b940..00000000 --- a/dsp-meta/tests/common/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::path::Path; - -use dsp_domain::metadata::entity::project_metadata::ProjectMetadata; -use dsp_meta::api::convert::hcl::hcl_body::HclBody; -use dsp_meta::error::DspMetaError; - -pub fn load<P: AsRef<Path>>(path: P) -> Result<ProjectMetadata, DspMetaError> { - let input = std::fs::read_to_string(path)?; - let body: hcl::Body = hcl::from_str(&input)?; - let entity: ProjectMetadata = HclBody(&body).try_into()?; - Ok(entity) -} diff --git a/dsp-meta/tests/integration_test.rs b/dsp-meta/tests/integration_test.rs deleted file mode 100644 index 1237a7ec..00000000 --- a/dsp-meta/tests/integration_test.rs +++ /dev/null @@ -1,41 +0,0 @@ -mod common; - -use std::env; - -use common::load; - -#[test] -fn load_dokubib_config() { - let file = env::current_dir() - .unwrap() - .parent() - .unwrap() - .join("data") - .join("dokubib.hcl"); - let metadata = load(file).unwrap(); - assert_eq!(metadata.version.0, 1); -} - -#[test] -fn load_hdm_config() { - let file = env::current_dir() - .unwrap() - .parent() - .unwrap() - .join("data") - .join("hdm.hcl"); - let metadata = load(file).unwrap(); - assert_eq!(metadata.version.0, 1); -} - -#[test] -fn load_incunabula_config() { - let file = env::current_dir() - .unwrap() - .parent() - .unwrap() - .join("data") - .join("incunabula.hcl"); - let metadata = load(file).unwrap(); - assert_eq!(metadata.version.0, 1); -} From 40fb15d51f2cfce7ade343d8c7c8979533d0b6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 10:20:28 +0200 Subject: [PATCH 02/12] merge crates --- dsp-meta/CHANGELOG.md => CHANGELOG.md | 0 Cargo.lock | 482 ++++++------ Cargo.toml | 29 +- Dockerfile | 2 +- benches/rdf_bench.rs | 14 - example_output_formats/dokubib.json | 154 ---- example_output_formats/hdm.json | 180 ----- example_output_formats/hdm.jsonld | 468 ------------ example_output_formats/hdm.ttl | 84 --- example_output_formats/hdm.xml | 137 ---- example_output_formats/incunabula.json | 240 ------ justfile | 6 +- .../schema-metadata-draft.json | 0 .../schema-metadata-final.json | 0 serde-rdf/Cargo.toml | 27 - serde-rdf/examples/deserialize.rs | 56 -- serde-rdf/examples/serialize.rs | 71 -- serde-rdf/src/de.rs | 274 ------- serde-rdf/src/error.rs | 64 -- serde-rdf/src/lib.rs | 13 - serde-rdf/src/ser.rs | 704 ------------------ serde-rdf/src/structure.rs | 46 -- {dsp-meta/src => src}/api/convert/axum/mod.rs | 0 .../src => src}/api/convert/axum/responses.rs | 0 {dsp-meta/src => src}/api/convert/mod.rs | 0 {dsp-meta/src => src}/api/handler/health.rs | 0 {dsp-meta/src => src}/api/handler/mod.rs | 0 .../src => src}/api/handler/robots_txt.rs | 0 .../src => src}/api/handler/sitemap_xml.rs | 0 {dsp-meta/src => src}/api/handler/v1/mod.rs | 0 .../api/handler/v1/projects/handlers.rs | 0 .../api/handler/v1/projects/mod.rs | 0 .../api/handler/v1/projects/responses.rs | 0 {dsp-meta/src => src}/api/mod.rs | 0 {dsp-meta/src => src}/api/router.rs | 4 +- {dsp-meta/src => src}/app_state.rs | 0 {dsp-meta-cmd/src => src}/cli.rs | 0 .../src => src}/domain/metadata_repository.rs | 2 +- .../src => src}/domain/metadata_service.rs | 0 {dsp-meta/src => src}/domain/mod.rs | 0 .../src => src}/domain/model/draft_model.rs | 0 {dsp-meta/src => src}/domain/model/error.rs | 0 .../domain/model/json_schema_validator.rs | 0 {dsp-meta/src => src}/domain/model/mod.rs | 0 {dsp-meta/src => src}/error.rs | 0 {dsp-meta/src => src}/infrastructure/mod.rs | 0 {dsp-meta/src => src}/lib.rs | 0 {dsp-meta-cmd/src => src}/main-server.rs | 1 + {dsp-meta-cmd/src => src}/main-validator.rs | 0 {dsp-meta/tests => tests}/api_tests.rs | 0 .../tests => tests}/draft_schema_test.rs | 5 +- 51 files changed, 292 insertions(+), 2771 deletions(-) rename dsp-meta/CHANGELOG.md => CHANGELOG.md (100%) delete mode 100644 benches/rdf_bench.rs delete mode 100755 example_output_formats/dokubib.json delete mode 100755 example_output_formats/hdm.json delete mode 100755 example_output_formats/hdm.jsonld delete mode 100755 example_output_formats/hdm.ttl delete mode 100755 example_output_formats/hdm.xml delete mode 100755 example_output_formats/incunabula.json rename {dsp-meta/resources => resources}/schema-metadata-draft.json (100%) rename {dsp-meta/resources => resources}/schema-metadata-final.json (100%) delete mode 100644 serde-rdf/Cargo.toml delete mode 100644 serde-rdf/examples/deserialize.rs delete mode 100644 serde-rdf/examples/serialize.rs delete mode 100644 serde-rdf/src/de.rs delete mode 100644 serde-rdf/src/error.rs delete mode 100644 serde-rdf/src/lib.rs delete mode 100644 serde-rdf/src/ser.rs delete mode 100644 serde-rdf/src/structure.rs rename {dsp-meta/src => src}/api/convert/axum/mod.rs (100%) rename {dsp-meta/src => src}/api/convert/axum/responses.rs (100%) rename {dsp-meta/src => src}/api/convert/mod.rs (100%) rename {dsp-meta/src => src}/api/handler/health.rs (100%) rename {dsp-meta/src => src}/api/handler/mod.rs (100%) rename {dsp-meta/src => src}/api/handler/robots_txt.rs (100%) rename {dsp-meta/src => src}/api/handler/sitemap_xml.rs (100%) rename {dsp-meta/src => src}/api/handler/v1/mod.rs (100%) rename {dsp-meta/src => src}/api/handler/v1/projects/handlers.rs (100%) rename {dsp-meta/src => src}/api/handler/v1/projects/mod.rs (100%) rename {dsp-meta/src => src}/api/handler/v1/projects/responses.rs (100%) rename {dsp-meta/src => src}/api/mod.rs (100%) rename {dsp-meta/src => src}/api/router.rs (97%) rename {dsp-meta/src => src}/app_state.rs (100%) rename {dsp-meta-cmd/src => src}/cli.rs (100%) rename {dsp-meta/src => src}/domain/metadata_repository.rs (98%) rename {dsp-meta/src => src}/domain/metadata_service.rs (100%) rename {dsp-meta/src => src}/domain/mod.rs (100%) rename {dsp-meta/src => src}/domain/model/draft_model.rs (100%) rename {dsp-meta/src => src}/domain/model/error.rs (100%) rename {dsp-meta/src => src}/domain/model/json_schema_validator.rs (100%) rename {dsp-meta/src => src}/domain/model/mod.rs (100%) rename {dsp-meta/src => src}/error.rs (100%) rename {dsp-meta/src => src}/infrastructure/mod.rs (100%) rename {dsp-meta/src => src}/lib.rs (100%) rename {dsp-meta-cmd/src => src}/main-server.rs (98%) rename {dsp-meta-cmd/src => src}/main-validator.rs (100%) rename {dsp-meta/tests => tests}/api_tests.rs (100%) rename {dsp-meta/tests => tests}/draft_schema_test.rs (96%) diff --git a/dsp-meta/CHANGELOG.md b/CHANGELOG.md similarity index 100% rename from dsp-meta/CHANGELOG.md rename to CHANGELOG.md diff --git a/Cargo.lock b/Cargo.lock index abeaaffe..7aba7f0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -108,7 +108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -133,6 +133,28 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-trait" version = "0.1.81" @@ -367,7 +389,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -435,6 +457,19 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + [[package]] name = "cookie" version = "0.18.1" @@ -543,6 +578,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "dlv-list" version = "0.3.0" @@ -593,6 +649,7 @@ version = "2.1.0" dependencies = [ "anyhow", "assert_cmd", + "async-trait", "axum", "axum-macros", "clap", @@ -625,20 +682,24 @@ dependencies = [ "chrono", "clap", "config", + "dirs", "fake", "hcl-rs", "http-body-util", "hyper", + "indicatif", "log", "nonempty", + "once_cell", + "pid1", "regex", "serde", "serde_json", "serde_with", "serde_yaml", - "sophia", "thiserror", "tokio", + "tokio-test", "toml 0.8.19", "tower", "tower-http", @@ -650,6 +711,7 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "dsp-meta-cmd" version = "2.2.0" dependencies = [ @@ -674,6 +736,37 @@ dependencies = [ "tracing-test", "url", ] +||||||| parent of e0a64d7 (merge crates) +name = "dsp-meta-cmd" +version = "2.1.0" +dependencies = [ + "anyhow", + "assert_cmd", + "axum", + "axum-macros", + "clap", + "config", + "dsp-meta", + "hcl-rs", + "hyper", + "log", + "pid1", + "serde", + "serde_json", + "tokio", + "tower", + "tower-http", + "tracing", + "tracing-subscriber", + "tracing-test", + "url", +] +======= +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +>>>>>>> e0a64d7 (merge crates) [[package]] name = "equivalent" @@ -1042,6 +1135,28 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1115,6 +1230,16 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1188,15 +1313,9 @@ dependencies = [ "hermit-abi", "libc", "wasi", - "windows-sys", + "windows-sys 0.52.0", ] -[[package]] -name = "mownstr" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc45ce96192b5d8b20cffb10ccd85cc431c283a7d171a0d843ac0bd7d444598" - [[package]] name = "nix" version = "0.27.1" @@ -1252,6 +1371,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.36.2" @@ -1267,6 +1392,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "ordered-multimap" version = "0.4.3" @@ -1283,21 +1414,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "oxilangtag" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23f3f87617a86af77fa3691e6350483e7154c2ead9f1261b75130e21ca0f8acb" -dependencies = [ - "serde", -] - -[[package]] -name = "oxiri" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05417ee46e2eb40dd9d590b4d67fc2408208b3a48a6b7f71d2bc1d7ce12a3e0" - [[package]] name = "pathdiff" version = "0.2.1" @@ -1436,6 +1552,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "portable-atomic" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" + [[package]] name = "powerfmt" version = "0.2.0" @@ -1509,15 +1631,6 @@ version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" -[[package]] -name = "quick-xml" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" -dependencies = [ - "memchr", -] - [[package]] name = "quote" version = "1.0.36" @@ -1557,6 +1670,17 @@ dependencies = [ "getrandom", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + [[package]] name = "regex" version = "1.10.6" @@ -1611,41 +1735,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "resiter" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc95d56eb1865f69288945759cc0879d60ee68168dce676730275804ad2b276" - -[[package]] -name = "rio_api" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61d0c76ddf8b00cbb4d2c5932d067d49245c2f1f651809bde3cf265033ddb1af" - -[[package]] -name = "rio_turtle" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f351b77353c7c896f0cd5ced2a25a7e95b5360cb68d1d7c16682ee096d7f40" -dependencies = [ - "oxilangtag", - "oxiri", - "rio_api", -] - -[[package]] -name = "rio_xml" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abd3384ae785ed3b0159607adc08adef580a28e277fbfa375c42d162e9da93b1" -dependencies = [ - "oxilangtag", - "oxiri", - "quick-xml", - "rio_api", -] - [[package]] name = "ron" version = "0.7.1" @@ -1710,16 +1799,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-rdf" -version = "2.0.0" -dependencies = [ - "rio_api", - "rio_turtle", - "rio_xml", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.209" @@ -1884,132 +1963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys", -] - -[[package]] -name = "sophia" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d9d3e79754eeda3fc7e3610afcc492613fa0a5581d286d7545094e3e7ce1608" -dependencies = [ - "sophia_api", - "sophia_c14n", - "sophia_inmem", - "sophia_iri", - "sophia_isomorphism", - "sophia_resource", - "sophia_rio", - "sophia_term", - "sophia_turtle", -] - -[[package]] -name = "sophia_api" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e41b1197b9dbd2e5e2a7d8dc62fd6bab001724576463831920b13567bde2a4c" -dependencies = [ - "lazy_static", - "mownstr", - "regex", - "resiter", - "serde", - "sophia_iri", - "thiserror", -] - -[[package]] -name = "sophia_c14n" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e4ebf65104879fc9f3f1f54224b42ad1f9e40b6a5dc26c5a17bf43846d6a1d" -dependencies = [ - "sha2", - "sophia_api", - "sophia_iri", - "thiserror", -] - -[[package]] -name = "sophia_inmem" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3f836b898bbd5d5a73a977995e1d5dab8e2cf96a017890954864ece18b1e8c" -dependencies = [ - "sophia_api", - "thiserror", -] - -[[package]] -name = "sophia_iri" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb62d2fcd10fc3a44b646b1893ad478df0cb771f7ceb0331a5f3cee25f37ba7e" -dependencies = [ - "lazy_static", - "oxiri", - "regex", - "serde", - "thiserror", -] - -[[package]] -name = "sophia_isomorphism" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b3876c71756d3dd94590c51090a036298a983f6b1e5c316f9eca514b2f6a5e" -dependencies = [ - "sophia_api", - "sophia_iri", -] - -[[package]] -name = "sophia_resource" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "807253d3a4144e1f3eacf6976849dab04cbd493ff568414df07c33fd10886ce2" -dependencies = [ - "sophia_api", - "sophia_iri", - "sophia_turtle", - "thiserror", -] - -[[package]] -name = "sophia_rio" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e107086ca2b3e329dbe0f85f9ce504b1fbb478c85341338942b9dff613d4d8" -dependencies = [ - "rio_api", - "sophia_api", - "sophia_iri", -] - -[[package]] -name = "sophia_term" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3a77f8523038dc1204a59dd461f27322cbe14bea3da873d41b6cc40c3e63e9" -dependencies = [ - "lazy_static", - "sophia_api", -] - -[[package]] -name = "sophia_turtle" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a7b7ce7aeb34f55867599544622420b2a6b6488b16811e06fd3755fc9cae4d0" -dependencies = [ - "lazy_static", - "oxiri", - "regex", - "rio_turtle", - "sophia_api", - "sophia_iri", - "sophia_rio", + "windows-sys 0.52.0", ] [[package]] @@ -2142,7 +2096,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2156,6 +2110,30 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-test" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2468baabc3311435b55dd935f702f42cd1b8abb7e754fb7dfb16bd36aa88f9f7" +dependencies = [ + "async-stream", + "bytes", + "futures-core", + "tokio", + "tokio-stream", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -2409,6 +2387,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -2602,7 +2586,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -2611,7 +2604,22 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -2620,28 +2628,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2654,24 +2680,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index 513853dd..8750c7ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,16 @@ -[workspace] -members = ["dsp-meta", "dsp-meta-cmd", "serde-rdf"] -resolver = "2" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[workspace.package] -version = "2.0.3" +[package] +name = "dsp-meta" +version = "2.1.0" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/dasch-swiss/dsp-meta" repository = "https://github.com/dasch-swiss/dsp-meta" documentation = "https://github.com/dasch-swiss/dsp-meta" readme = "README.md" -description = "The DSP Metadata Command Line Tool providing transformation, validation and serving of research project's metadata." +description = "DSP-META is a service that provides metadata for the Digital and Semantic Publishing Platform (DSP)." authors = ["DaSCH - Swiss National Data and Service Center for the Humanities"] -[workspace.dependencies] +[dependencies] anyhow = "1" async-trait = "0.1.81" axum = "0.7.2" # web framework @@ -54,3 +49,17 @@ tracing-subscriber = { version = "0.3", features = [ tracing-test = "0.2" url = { version = "2", features = ["serde"] } toml = "0.8.19" + +[dev-dependencies] +assert_cmd = "2.0.16" +axum-test = "15.3.0" +fake = "2.9.2" + + +[[bin]] +name = "dsp-meta-server" +path = "src/main-server.rs" + +[[bin]] +name = "dsp-meta-validator" +path = "src/main-validator.rs" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7296910b..8e7fb5ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM rust:1-slim-bookworm AS builder-rs WORKDIR /dsp-meta COPY . . -RUN cargo install --path ./dsp-meta-cmd +RUN cargo install --path ./ FROM node:21-bookworm-slim AS builder-node WORKDIR /dsp-meta diff --git a/benches/rdf_bench.rs b/benches/rdf_bench.rs deleted file mode 100644 index 318ee5ab..00000000 --- a/benches/rdf_bench.rs +++ /dev/null @@ -1,14 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; -use dsp_meta::domain::model::entity::project_metadata::ProjectMetadata; -use sophia::graph::inmem::LightGraph; - -fn serialize() { - let _: LightGraph = ProjectMetadata::default().try_into().unwrap(); -} - -fn rdf_serialization_benchmark(c: &mut Criterion) { - c.bench_function("serialize project metadata to RDF", |b| b.iter(serialize)); -} - -criterion_group!(benches, rdf_serialization_benchmark); -criterion_main!(benches); diff --git a/example_output_formats/dokubib.json b/example_output_formats/dokubib.json deleted file mode 100755 index 8b27fd5a..00000000 --- a/example_output_formats/dokubib.json +++ /dev/null @@ -1,154 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dasch-swiss/dsp-meta-svc/main/docs/services/metadata/schema-metadata.json", - "project": { - "__id": "http://ns.dasch.swiss/repository#dsp-0804-project", - "__type": "Project", - "__createdAt": "1630601297599944000", - "__createdBy": "dsp-metadata-gui", - "howToCite": "Dokumentationsbibliothek St. Moritz", - "teaserText": "Bibliothek St. Moritz Dokumentation is the local history archive of the community of St. Moritz, Switzerland.", - "datasets": [ - "http://ns.dasch.swiss/repository#dsp-0804-dataset-000" - ], - "description": { - "en": "Bibliothek St. Moritz Dokumentation is the local history archive of the community of St. Moritz, Switzerland. It’s collection contains publications, manuscripts and audiovisual documents of the touristic development of St. Moritz" - }, - "disciplines": [ - { - "__type": "URL", - "type": "Skos", - "url": "http://skos.um.es/unesco6/550301", - "text": "Local history" - } - ], - "funders": [ - "http://ns.dasch.swiss/repository#dsp-0804-organization-001" - ], - "keywords": [ - { - "en": "Historic photograph" - }, - { - "en": "Local history" - }, - { - "en": "St. Moritz" - }, - { - "fr": "Touristic development" - } - ], - "name": "Bilddatenbank Bibliothek St. Moritz", - "shortcode": "0804", - "spatialCoverage": [ - { - "__type": "URL", - "type": "Geonames", - "url": "https://geonames.org/2658813", - "text": "Saint Moritz" - } - ], - "startDate": "1980-04-01", - "temporalCoverage": [ - { - "__type": "URL", - "type": "Chronontology", - "url": "http://chronontology.dainst.org/period/mvhEZ4S2qWEa", - "text": "19th Century (1800 - 1899)" - }, - { - "__type": "URL", - "type": "Chronontology", - "url": "http://chronontology.dainst.org/period/INtagfT8h7Fs", - "text": "20th and 21st Centuries" - }, - { - "__type": "URL", - "type": "Chronontology", - "url": "http://chronontology.dainst.org/period/kqORhO4TGm4n", - "text": "20th Century (1900 - 1999)" - } - ], - "url": { - "__type": "URL", - "type": "URL", - "url": "https://data.dasch.swiss/dokubib/", - "text": "Project Website" - } - }, - "datasets": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-0804-dataset-000", - "__type": "Dataset", - "__createdAt": "1630601300976368000", - "__createdBy": "dsp-metadata-gui", - "abstracts": [ - { - "en": "Bilddatenbank makes accessible the collection of historic photographs and other graphical representation of St. Moritz Dokumentationsbibliothek" - } - ], - "accessConditions": "restricted", - "howToCite": "Dokumentationsbibliothek St. Moritz", - "languages": [ - { - "de": "Deutsch", - "en": "German", - "fr": "allemand" - } - ], - "attributions": [ - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-0804-organization-000", - "roles": [ - "creator", - "publisher" - ] - } - ], - "status": "Ongoing", - "title": "Dokumentationsbibliothek St. Moritz Bilddatenbank", - "typeOfData": [ - "Image", - "Text" - ] - } - ], - "organizations": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-0804-organization-001", - "__type": "Organization", - "__createdAt": "1630601301506212000", - "__createdBy": "dsp-metadata-gui", - "address": { - "__type": "Address", - "street": "", - "postalCode": "7500", - "locality": "St. Moritz", - "country": "Switzerland" - }, - "name": "Gemeinde St. Moritz" - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0804-organization-000", - "__type": "Organization", - "__createdAt": "1630601301561696000", - "__createdBy": "dsp-metadata-gui", - "address": { - "__type": "Address", - "street": "Plazza da Scoula 14", - "postalCode": "7500", - "locality": "St. Moritz", - "country": "Switzerland" - }, - "email": "doku@biblio-stmoritz.ch", - "name": "Dokumentationsbibliothek St. Moritz", - "url": { - "__type": "URL", - "type": "URL", - "url": "http://www.biblio-stmoritz.ch", - "text": "www.biblio-stmoritz.ch" - } - } - ] -} diff --git a/example_output_formats/hdm.json b/example_output_formats/hdm.json deleted file mode 100755 index 543752ac..00000000 --- a/example_output_formats/hdm.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dasch-swiss/dsp-meta-svc/main/docs/services/metadata/schema-metadata.json", - "project": { - "__id": "http://ns.dasch.swiss/repository#dsp-081C-project", - "__type": "Project", - "__createdAt": "1630601274523025000", - "__createdBy": "dsp-metadata-gui", - "howToCite": "HdM-Bern", - "teaserText": "The database documents the different kinds of spectacles such as theatre plays, operas, ballets, or concerts that took place in the Hôtel de Musique in Bern between 1766 and 1905.", - "datasets": [ - "http://ns.dasch.swiss/repository#dsp-081C-dataset-000" - ], - "description": { - "en": "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century." - }, - "disciplines": [ - { - "de": "10302 Schweizer Geschichte" - }, - { - "de": "10405 Musikologie" - }, - { - "de": "10406 Theater-und Filmwissenschaften" - }, - { - "de": "10604 Musik und Theater" - } - ], - "funders": [ - "http://ns.dasch.swiss/repository#dsp-081C-organization-000" - ], - "keywords": [ - { - "en": "19 Century" - }, - { - "de": "Bern" - }, - { - "en": "Concert" - }, - { - "en": "Music" - }, - { - "en": "Musicology" - }, - { - "en": "Opera" - }, - { - "en": "Spectales" - }, - { - "en": "Switzerland" - }, - { - "en": "Theater history" - }, - { - "en": "Theatre" - } - ], - "name": "Hôtel de Musique Bern", - "shortcode": "081C", - "spatialCoverage": [ - { - "__type": "URL", - "type": "Geonames", - "url": "https://www.geonames.org/2661552", - "text": "Bern" - } - ], - "startDate": "2009-04-01", - "temporalCoverage": [ - { - "__type": "URL", - "type": "Periodo", - "url": "http://n2t.net/ark:/99152/p06c6g3pvr5", - "text": "Under Mediation act, 1803-1814" - }, - { - "__type": "URL", - "type": "Periodo", - "url": "http://n2t.net/ark:/99152/p06c6g3p4cf", - "text": "Sonderbund, 1845-1847" - }, - { - "__type": "URL", - "type": "Periodo", - "url": "http://n2t.net/ark:/99152/p06c6g364np", - "text": "Helvetic Republic, 1798-1803" - }, - { - "de": "1766-1905", - "en": "1766-1905", - "fr": "1766-1905" - } - ], - "url": { - "__type": "URL", - "type": "URL", - "url": "https://admin.dasch.swiss/project/081C", - "text": "Discover Project Data" - } - }, - "datasets": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-081C-dataset-000", - "__type": "Dataset", - "__createdAt": "1630601285266958000", - "__createdBy": "dsp-metadata-gui", - "abstracts": [ - { - "en": "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century." - } - ], - "accessConditions": "open", - "datePublished": "2015-04-01", - "howToCite": "HdM-Bern", - "languages": [ - { - "de": "Deutsch", - "en": "German", - "fr": "allemand" - } - ], - "licenses": [ - { - "__type": "License", - "date": "2021-09-02", - "license": { - "__type": "URL", - "type": "Creative Commons", - "url": "https://creativecommons.org/licenses/by-nc/4.0", - "text": "CC BY-NC 4.0" - } - } - ], - "attributions": [ - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-081C-organization-000", - "roles": [ - "author" - ] - } - ], - "status": "Finished", - "title": "Hôtel de Musique Bern", - "typeOfData": [ - "Text" - ] - } - ], - "organizations": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-081C-organization-000", - "__type": "Organization", - "__createdAt": "1630601285796580000", - "__createdBy": "dsp-metadata-gui", - "address": { - "__type": "Address", - "street": "Mittelstr. 43", - "postalCode": "3011", - "locality": "Bern", - "country": "Switzerland" - }, - "email": "urchueguia@musik.unibe.ch", - "name": "Institut für Musikwissenschaft der Universität Bern", - "url": { - "__type": "URL", - "type": "URL", - "url": "https://www.musik.unibe.ch/index_ger.html", - "text": "https://www.musik.unibe.ch/index_ger.html" - } - } - ] -} diff --git a/example_output_formats/hdm.jsonld b/example_output_formats/hdm.jsonld deleted file mode 100755 index 6d99a4bb..00000000 --- a/example_output_formats/hdm.jsonld +++ /dev/null @@ -1,468 +0,0 @@ -[ - { - "@id": "http://ns.dasch.swiss/repository#dsp-081C-dataset-000", - "@type": [ - "http://ns.dasch.swiss/repository#Dataset" - ], - "http://ns.dasch.swiss/repository#hasAbstract": [ - { - "@language": "en", - "@value": "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century." - } - ], - "http://ns.dasch.swiss/repository#hasAccessConditions": [ - { - "@value": "open" - } - ], - "http://ns.dasch.swiss/repository#hasDatePublished": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#date", - "@value": "2015-04-01" - } - ], - "http://ns.dasch.swiss/repository#hasHowToCite": [ - { - "@value": "HdM-Bern" - } - ], - "http://ns.dasch.swiss/repository#hasLanguage": [ - { - "@language": "de", - "@value": "Deutsch" - }, - { - "@language": "en", - "@value": "German" - }, - { - "@language": "fr", - "@value": "allemand" - } - ], - "http://ns.dasch.swiss/repository#hasLicense": [ - { - "@id": "_:N6179e73d6f4041709c76b78e04c21860" - } - ], - "http://ns.dasch.swiss/repository#hasQualifiedAttribution": [ - { - "@id": "_:N33910fc7e18e43aebfb4eca5660903c3" - } - ], - "http://ns.dasch.swiss/repository#hasStatus": [ - { - "@value": "Finished" - } - ], - "http://ns.dasch.swiss/repository#hasTitle": [ - { - "@value": "Hôtel de Musique Bern" - } - ], - "http://ns.dasch.swiss/repository#hasTypeOfData": [ - { - "@value": "Text" - } - ] - }, - { - "@id": "_:N6179e73d6f4041709c76b78e04c21860", - "@type": [ - "http://ns.dasch.swiss/repository#License" - ], - "http://ns.dasch.swiss/repository#hasDate": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#date", - "@value": "2021-09-02" - } - ], - "http://ns.dasch.swiss/repository#hasURL": [ - { - "@id": "_:N83807eac0cad4a78ad09e8ade88b4003" - } - ] - }, - { - "@id": "_:N83807eac0cad4a78ad09e8ade88b4003", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/propertyID": [ - { - "@id": "_:N703fb05b1e524a388180a06010edcf37" - } - ], - "http://schema.org/url": [ - { - "@value": "https://creativecommons.org/licenses/by-nc/4.0" - } - ] - }, - { - "@id": "_:N703fb05b1e524a388180a06010edcf37", - "@type": [ - "http://schema.org/PropertyValue" - ], - "http://schema.org/propertyID": [ - { - "@value": "CC BY-NC 4.0" - } - ] - }, - { - "@id": "_:N33910fc7e18e43aebfb4eca5660903c3", - "@type": [ - "http://www.w3.org/ns/prov#Attribution" - ], - "http://ns.dasch.swiss/repository#hasRole": [ - { - "@value": "author" - } - ], - "http://www.w3.org/ns/prov#agent": [ - { - "@id": "http://ns.dasch.swiss/repository#dsp-081C-organization-000" - } - ] - }, - { - "@id": "http://ns.dasch.swiss/repository#dsp-081C-organization-000", - "@type": [ - "http://ns.dasch.swiss/repository#Organization" - ], - "http://ns.dasch.swiss/repository#hasAddress": [ - { - "@id": "_:N344ffc44be544d39a2f0fa3d11490dfa" - } - ], - "http://ns.dasch.swiss/repository#hasEmail": [ - { - "@value": "urchueguia@musik.unibe.ch" - } - ], - "http://ns.dasch.swiss/repository#hasName": [ - { - "@value": "Institut für Musikwissenschaft der Universität Bern" - } - ], - "http://ns.dasch.swiss/repository#hasURL": [ - { - "@id": "_:N80088fb73216490fa26e41fe717b56d2" - } - ] - }, - { - "@id": "_:N80088fb73216490fa26e41fe717b56d2", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/url": [ - { - "@value": "https://www.musik.unibe.ch/index_ger.html" - } - ] - }, - { - "@id": "_:N344ffc44be544d39a2f0fa3d11490dfa", - "@type": [ - "http://schema.org/PostalAddress" - ], - "http://schema.org/addressCountry": [ - { - "@value": "Switzerland" - } - ], - "http://schema.org/addressLocality": [ - { - "@value": "Bern" - } - ], - "http://schema.org/postalCode": [ - { - "@value": "3011" - } - ], - "http://schema.org/streetAddress": [ - { - "@value": "Mittelstr. 43" - } - ] - }, - { - "@id": "http://ns.dasch.swiss/repository#dsp-081C-project", - "@type": [ - "http://ns.dasch.swiss/repository#Project" - ], - "http://ns.dasch.swiss/repository#hasDataset": [ - { - "@id": "http://ns.dasch.swiss/repository#dsp-081C-dataset-000" - } - ], - "http://ns.dasch.swiss/repository#hasDescription": [ - { - "@language": "en", - "@value": "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century." - } - ], - "http://ns.dasch.swiss/repository#hasDiscipline": [ - { - "@language": "de", - "@value": "10302 Schweizer Geschichte" - }, - { - "@language": "de", - "@value": "10405 Musikologie" - }, - { - "@language": "de", - "@value": "10406 Theater-und Filmwissenschaften" - }, - { - "@language": "de", - "@value": "10604 Musik und Theater" - } - ], - "http://ns.dasch.swiss/repository#hasFunder": [ - { - "@id": "http://ns.dasch.swiss/repository#dsp-081C-organization-000" - } - ], - "http://ns.dasch.swiss/repository#hasHowToCite": [ - { - "@value": "HdM-Bern" - } - ], - "http://ns.dasch.swiss/repository#hasKeyword": [ - { - "@language": "en", - "@value": "19 Century" - }, - { - "@language": "de", - "@value": "Bern" - }, - { - "@language": "en", - "@value": "Concert" - }, - { - "@language": "en", - "@value": "Music" - }, - { - "@language": "en", - "@value": "Musicology" - }, - { - "@language": "en", - "@value": "Opera" - }, - { - "@language": "en", - "@value": "Spectales" - }, - { - "@language": "en", - "@value": "Switzerland" - }, - { - "@language": "en", - "@value": "Theater history" - }, - { - "@language": "en", - "@value": "Theatre" - } - ], - "http://ns.dasch.swiss/repository#hasName": [ - { - "@value": "Hôtel de Musique Bern" - } - ], - "http://ns.dasch.swiss/repository#hasShortcode": [ - { - "@value": "081C" - } - ], - "http://ns.dasch.swiss/repository#hasSpatialCoverage": [ - { - "@id": "_:Nc470ba6dcff74c70bbbe6ea552176a18" - } - ], - "http://ns.dasch.swiss/repository#hasStartDate": [ - { - "@type": "http://www.w3.org/2001/XMLSchema#date", - "@value": "2009-04-01" - } - ], - "http://ns.dasch.swiss/repository#hasTeaser": [ - { - "@value": "The database documents the different kinds of spectacles such as theatre plays, operas, ballets, or concerts that took place in the Hôtel de Musique in Bern between 1766 and 1905." - } - ], - "http://ns.dasch.swiss/repository#hasTemporalCoverage": [ - { - "@id": "_:Nadc74cc5fa1c449f9a0d98423b5d349d" - }, - { - "@id": "_:N151b811550c74e76964ace35f52774c7" - }, - { - "@id": "_:Nd8f9750f59d04e1da1fa6fbccbf698dd" - }, - { - "@language": "de", - "@value": "1766-1905" - }, - { - "@language": "en", - "@value": "1766-1905" - }, - { - "@language": "fr", - "@value": "1766-1905" - } - ], - "http://ns.dasch.swiss/repository#hasURL": [ - { - "@id": "_:N6eba7cdfdfd84735b88288227698d702" - } - ] - }, - { - "@id": "_:Nadc74cc5fa1c449f9a0d98423b5d349d", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/propertyID": [ - { - "@id": "_:N117f4478986f4a51bba1b00524b37508" - } - ], - "http://schema.org/url": [ - { - "@value": "http://n2t.net/ark:/99152/p06c6g3pvr5" - } - ] - }, - { - "@id": "_:N117f4478986f4a51bba1b00524b37508", - "@type": [ - "http://schema.org/PropertyValue" - ], - "http://schema.org/propertyID": [ - { - "@value": "Under Mediation act, 1803-1814" - } - ] - }, - { - "@id": "_:N151b811550c74e76964ace35f52774c7", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/propertyID": [ - { - "@id": "_:N0c2c9ab6dc0747cb8a67e21292a95901" - } - ], - "http://schema.org/url": [ - { - "@value": "http://n2t.net/ark:/99152/p06c6g3p4cf" - } - ] - }, - { - "@id": "_:N0c2c9ab6dc0747cb8a67e21292a95901", - "@type": [ - "http://schema.org/PropertyValue" - ], - "http://schema.org/propertyID": [ - { - "@value": "Sonderbund, 1845-1847" - } - ] - }, - { - "@id": "_:Nd8f9750f59d04e1da1fa6fbccbf698dd", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/propertyID": [ - { - "@id": "_:N25015d996444461392f9f4f0d4468360" - } - ], - "http://schema.org/url": [ - { - "@value": "http://n2t.net/ark:/99152/p06c6g364np" - } - ] - }, - { - "@id": "_:N25015d996444461392f9f4f0d4468360", - "@type": [ - "http://schema.org/PropertyValue" - ], - "http://schema.org/propertyID": [ - { - "@value": "Helvetic Republic, 1798-1803" - } - ] - }, - { - "@id": "_:Nc470ba6dcff74c70bbbe6ea552176a18", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/propertyID": [ - { - "@id": "_:Naf9b30cd99c140e7bb4b20bd5dc72050" - } - ], - "http://schema.org/url": [ - { - "@value": "https://www.geonames.org/2661552" - } - ] - }, - { - "@id": "_:Naf9b30cd99c140e7bb4b20bd5dc72050", - "@type": [ - "http://schema.org/PropertyValue" - ], - "http://schema.org/propertyID": [ - { - "@value": "Bern" - } - ] - }, - { - "@id": "_:N6eba7cdfdfd84735b88288227698d702", - "@type": [ - "http://schema.org/URL" - ], - "http://schema.org/propertyID": [ - { - "@id": "_:Nd79fd9c0dc2843d4845fa22e9cc68af1" - } - ], - "http://schema.org/url": [ - { - "@value": "https://admin.dasch.swiss/project/081C" - } - ] - }, - { - "@id": "_:Nd79fd9c0dc2843d4845fa22e9cc68af1", - "@type": [ - "http://schema.org/PropertyValue" - ], - "http://schema.org/propertyID": [ - { - "@value": "Discover Project Data" - } - ] - } -] \ No newline at end of file diff --git a/example_output_formats/hdm.ttl b/example_output_formats/hdm.ttl deleted file mode 100755 index fb691a4d..00000000 --- a/example_output_formats/hdm.ttl +++ /dev/null @@ -1,84 +0,0 @@ -@prefix dsp: <http://ns.dasch.swiss/repository#> . -@prefix prov: <http://www.w3.org/ns/prov#> . -@prefix sdo: <https://schema.org/> . -@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . - -dsp:dsp-081C-project a dsp:Project ; - dsp:hasDataset dsp:dsp-081C-dataset-000 ; - dsp:hasDescription "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century."@en ; - dsp:hasDiscipline "10302 Schweizer Geschichte"@de, - "10405 Musikologie"@de, - "10406 Theater-und Filmwissenschaften"@de, - "10604 Musik und Theater"@de ; - dsp:hasFunder dsp:dsp-081C-organization-000 ; - dsp:hasHowToCite "HdM-Bern"^^xsd:string ; - dsp:hasKeyword "Bern"@de, - "19 Century"@en, - "Concert"@en, - "Music"@en, - "Musicology"@en, - "Opera"@en, - "Spectales"@en, - "Switzerland"@en, - "Theater history"@en, - "Theatre"@en ; - dsp:hasName "Hôtel de Musique Bern"^^xsd:string ; - dsp:hasShortcode "081C"^^xsd:string ; - dsp:hasSpatialCoverage [ a sdo:URL ; - sdo:propertyID [ a sdo:PropertyValue ; - sdo:propertyID "Bern" ] ; - sdo:url "https://www.geonames.org/2661552" ] ; - dsp:hasStartDate "2009-04-01"^^xsd:date ; - dsp:hasTeaser "The database documents the different kinds of spectacles such as theatre plays, operas, ballets, or concerts that took place in the Hôtel de Musique in Bern between 1766 and 1905."^^xsd:string ; - dsp:hasTemporalCoverage [ a sdo:URL ; - sdo:propertyID [ a sdo:PropertyValue ; - sdo:propertyID "Sonderbund, 1845-1847" ] ; - sdo:url "http://n2t.net/ark:/99152/p06c6g3p4cf" ], - [ a sdo:URL ; - sdo:propertyID [ a sdo:PropertyValue ; - sdo:propertyID "Under Mediation act, 1803-1814" ] ; - sdo:url "http://n2t.net/ark:/99152/p06c6g3pvr5" ], - [ a sdo:URL ; - sdo:propertyID [ a sdo:PropertyValue ; - sdo:propertyID "Helvetic Republic, 1798-1803" ] ; - sdo:url "http://n2t.net/ark:/99152/p06c6g364np" ], - "1766-1905"@de, - "1766-1905"@en, - "1766-1905"@fr ; - dsp:hasURL [ a sdo:URL ; - sdo:propertyID [ a sdo:PropertyValue ; - sdo:propertyID "Discover Project Data" ] ; - sdo:url "https://admin.dasch.swiss/project/081C" ] . - -dsp:dsp-081C-dataset-000 a dsp:Dataset ; - dsp:hasAbstract "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century."@en ; - dsp:hasAccessConditions "open"^^xsd:string ; - dsp:hasDatePublished "2015-04-01"^^xsd:date ; - dsp:hasHowToCite "HdM-Bern"^^xsd:string ; - dsp:hasLanguage "Deutsch"@de, - "German"@en, - "allemand"@fr ; - dsp:hasLicense [ a dsp:License ; - dsp:hasDate "2021-09-02"^^xsd:date ; - dsp:hasURL [ a sdo:URL ; - sdo:propertyID [ a sdo:PropertyValue ; - sdo:propertyID "CC BY-NC 4.0" ] ; - sdo:url "https://creativecommons.org/licenses/by-nc/4.0" ] ] ; - dsp:hasQualifiedAttribution [ a prov:Attribution ; - dsp:hasRole "author"^^xsd:string ; - prov:agent dsp:dsp-081C-organization-000 ] ; - dsp:hasStatus "Finished"^^xsd:string ; - dsp:hasTitle "Hôtel de Musique Bern"^^xsd:string ; - dsp:hasTypeOfData "Text"^^xsd:string . - -dsp:dsp-081C-organization-000 a dsp:Organization ; - dsp:hasAddress [ a sdo:PostalAddress ; - sdo:addressCountry "Switzerland"^^xsd:string ; - sdo:addressLocality "Bern"^^xsd:string ; - sdo:postalCode "3011"^^xsd:string ; - sdo:streetAddress "Mittelstr. 43"^^xsd:string ] ; - dsp:hasEmail "urchueguia@musik.unibe.ch"^^xsd:string ; - dsp:hasName "Institut für Musikwissenschaft der Universität Bern"^^xsd:string ; - dsp:hasURL [ a sdo:URL ; - sdo:url "https://www.musik.unibe.ch/index_ger.html" ] . - diff --git a/example_output_formats/hdm.xml b/example_output_formats/hdm.xml deleted file mode 100755 index 7c83b2b9..00000000 --- a/example_output_formats/hdm.xml +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<rdf:RDF - xmlns:dsp="http://ns.dasch.swiss/repository#" - xmlns:sdo="https://schema.org/" - xmlns:prov="http://www.w3.org/ns/prov#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" -> - <dsp:Project rdf:about="http://ns.dasch.swiss/repository#dsp-081C-project"> - <dsp:hasShortcode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">081C</dsp:hasShortcode> - <dsp:hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Hôtel de Musique Bern</dsp:hasName> - <dsp:hasHowToCite rdf:datatype="http://www.w3.org/2001/XMLSchema#string">HdM-Bern</dsp:hasHowToCite> - <dsp:hasDescription xml:lang="en">The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century.</dsp:hasDescription> - <dsp:hasStartDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2009-04-01</dsp:hasStartDate> - <dsp:hasTeaser rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The database documents the different kinds of spectacles such as theatre plays, operas, ballets, or concerts that took place in the Hôtel de Musique in Bern between 1766 and 1905.</dsp:hasTeaser> - <dsp:hasDataset> - <dsp:Dataset rdf:about="http://ns.dasch.swiss/repository#dsp-081C-dataset-000"> - <dsp:hasTitle rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Hôtel de Musique Bern</dsp:hasTitle> - <dsp:hasAccessConditions rdf:datatype="http://www.w3.org/2001/XMLSchema#string">open</dsp:hasAccessConditions> - <dsp:hasHowToCite rdf:datatype="http://www.w3.org/2001/XMLSchema#string">HdM-Bern</dsp:hasHowToCite> - <dsp:hasStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Finished</dsp:hasStatus> - <dsp:hasAbstract xml:lang="en">The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century.</dsp:hasAbstract> - <dsp:hasTypeOfData rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Text</dsp:hasTypeOfData> - <dsp:hasLicense> - <dsp:License rdf:nodeID="N6179e73d6f4041709c76b78e04c21860"> - <dsp:hasURL> - <sdo:URL rdf:nodeID="N83807eac0cad4a78ad09e8ade88b4003"> - <sdo:url>https://creativecommons.org/licenses/by-nc/4.0</sdo:url> - <sdo:propertyID> - <sdo:PropertyValue rdf:nodeID="N703fb05b1e524a388180a06010edcf37"> - <sdo:propertyID>CC BY-NC 4.0</sdo:propertyID> - </sdo:PropertyValue> - </sdo:propertyID> - </sdo:URL> - </dsp:hasURL> - <dsp:hasDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2021-09-02</dsp:hasDate> - </dsp:License> - </dsp:hasLicense> - <dsp:hasLanguage xml:lang="de">Deutsch</dsp:hasLanguage> - <dsp:hasLanguage xml:lang="en">German</dsp:hasLanguage> - <dsp:hasLanguage xml:lang="fr">allemand</dsp:hasLanguage> - <dsp:hasQualifiedAttribution> - <prov:Attribution rdf:nodeID="N33910fc7e18e43aebfb4eca5660903c3"> - <prov:agent rdf:resource="http://ns.dasch.swiss/repository#dsp-081C-organization-000"/> - <dsp:hasRole rdf:datatype="http://www.w3.org/2001/XMLSchema#string">author</dsp:hasRole> - </prov:Attribution> - </dsp:hasQualifiedAttribution> - <dsp:hasDatePublished rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2015-04-01</dsp:hasDatePublished> - </dsp:Dataset> - </dsp:hasDataset> - <dsp:hasKeyword xml:lang="en">19 Century</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="de">Bern</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Concert</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Music</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Musicology</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Opera</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Spectales</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Switzerland</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Theater history</dsp:hasKeyword> - <dsp:hasKeyword xml:lang="en">Theatre</dsp:hasKeyword> - <dsp:hasDiscipline xml:lang="de">10302 Schweizer Geschichte</dsp:hasDiscipline> - <dsp:hasDiscipline xml:lang="de">10405 Musikologie</dsp:hasDiscipline> - <dsp:hasDiscipline xml:lang="de">10406 Theater-und Filmwissenschaften</dsp:hasDiscipline> - <dsp:hasDiscipline xml:lang="de">10604 Musik und Theater</dsp:hasDiscipline> - <dsp:hasTemporalCoverage> - <sdo:URL rdf:nodeID="Nadc74cc5fa1c449f9a0d98423b5d349d"> - <sdo:url>http://n2t.net/ark:/99152/p06c6g3pvr5</sdo:url> - <sdo:propertyID> - <sdo:PropertyValue rdf:nodeID="N117f4478986f4a51bba1b00524b37508"> - <sdo:propertyID>Under Mediation act, 1803-1814</sdo:propertyID> - </sdo:PropertyValue> - </sdo:propertyID> - </sdo:URL> - </dsp:hasTemporalCoverage> - <dsp:hasTemporalCoverage> - <sdo:URL rdf:nodeID="N151b811550c74e76964ace35f52774c7"> - <sdo:url>http://n2t.net/ark:/99152/p06c6g3p4cf</sdo:url> - <sdo:propertyID> - <sdo:PropertyValue rdf:nodeID="N0c2c9ab6dc0747cb8a67e21292a95901"> - <sdo:propertyID>Sonderbund, 1845-1847</sdo:propertyID> - </sdo:PropertyValue> - </sdo:propertyID> - </sdo:URL> - </dsp:hasTemporalCoverage> - <dsp:hasTemporalCoverage> - <sdo:URL rdf:nodeID="Nd8f9750f59d04e1da1fa6fbccbf698dd"> - <sdo:url>http://n2t.net/ark:/99152/p06c6g364np</sdo:url> - <sdo:propertyID> - <sdo:PropertyValue rdf:nodeID="N25015d996444461392f9f4f0d4468360"> - <sdo:propertyID>Helvetic Republic, 1798-1803</sdo:propertyID> - </sdo:PropertyValue> - </sdo:propertyID> - </sdo:URL> - </dsp:hasTemporalCoverage> - <dsp:hasTemporalCoverage xml:lang="de">1766-1905</dsp:hasTemporalCoverage> - <dsp:hasTemporalCoverage xml:lang="en">1766-1905</dsp:hasTemporalCoverage> - <dsp:hasTemporalCoverage xml:lang="fr">1766-1905</dsp:hasTemporalCoverage> - <dsp:hasSpatialCoverage> - <sdo:URL rdf:nodeID="Nc470ba6dcff74c70bbbe6ea552176a18"> - <sdo:url>https://www.geonames.org/2661552</sdo:url> - <sdo:propertyID> - <sdo:PropertyValue rdf:nodeID="Naf9b30cd99c140e7bb4b20bd5dc72050"> - <sdo:propertyID>Bern</sdo:propertyID> - </sdo:PropertyValue> - </sdo:propertyID> - </sdo:URL> - </dsp:hasSpatialCoverage> - <dsp:hasFunder> - <dsp:Organization rdf:about="http://ns.dasch.swiss/repository#dsp-081C-organization-000"> - <dsp:hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Institut für Musikwissenschaft der Universität Bern</dsp:hasName> - <dsp:hasURL> - <sdo:URL rdf:nodeID="N80088fb73216490fa26e41fe717b56d2"> - <sdo:url>https://www.musik.unibe.ch/index_ger.html</sdo:url> - </sdo:URL> - </dsp:hasURL> - <dsp:hasAddress> - <sdo:PostalAddress rdf:nodeID="N344ffc44be544d39a2f0fa3d11490dfa"> - <sdo:streetAddress rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Mittelstr. 43</sdo:streetAddress> - <sdo:postalCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">3011</sdo:postalCode> - <sdo:addressLocality rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Bern</sdo:addressLocality> - <sdo:addressCountry rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Switzerland</sdo:addressCountry> - </sdo:PostalAddress> - </dsp:hasAddress> - <dsp:hasEmail rdf:datatype="http://www.w3.org/2001/XMLSchema#string">urchueguia@musik.unibe.ch</dsp:hasEmail> - </dsp:Organization> - </dsp:hasFunder> - <dsp:hasURL> - <sdo:URL rdf:nodeID="N6eba7cdfdfd84735b88288227698d702"> - <sdo:url>https://admin.dasch.swiss/project/081C</sdo:url> - <sdo:propertyID> - <sdo:PropertyValue rdf:nodeID="Nd79fd9c0dc2843d4845fa22e9cc68af1"> - <sdo:propertyID>Discover Project Data</sdo:propertyID> - </sdo:PropertyValue> - </sdo:propertyID> - </sdo:URL> - </dsp:hasURL> - </dsp:Project> -</rdf:RDF> diff --git a/example_output_formats/incunabula.json b/example_output_formats/incunabula.json deleted file mode 100755 index 3e65bbea..00000000 --- a/example_output_formats/incunabula.json +++ /dev/null @@ -1,240 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dasch-swiss/dsp-meta-svc/main/docs/services/metadata/schema-metadata.json", - "project": { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-project", - "__type": "Project", - "__createdAt": "1637624150548721000", - "__createdBy": "dsp-metadata-gui", - "teaserText": "An art-scientific monograph of the richly illustrated early prints in Basel - the most important center of early letterpress printing in the territory of present-day Switzerland.", - "datasets": [ - "http://ns.dasch.swiss/repository#dsp-0803-dataset-000" - ], - "alternativeNames": [ - { - "en": "Incunabula" - } - ], - "description": { - "de": "Eine kunstwissenschaftliche Monographie der reich bebilderten Frühdrucke in Basel - dem wichtigsten Zentrum des frühen Buchdrucks auf dem Gebiet der heutigen Schweiz - wird im vorliegenden Projekt erstmals seit über einem Jahrhundert ins Auge gefasst. Im Zentrum stehen 18 Werke aus vier verschiedenen Offizinen, welche insgesamt über 1000 Holzschnitte enthalten, die bedeutendsten überlieferten Basler Bilderfolgen des Spätmittelalters nach den massiven Zerstörungen im Zuge der Reformation. Bei den Texten handelt es sich fast ausschliesslich um deutsche und lateinische Kompilationen religiösen, didaktischen Inhalts, darunter viele zeitgenössische und in Basel entstandene, neben Übersetzungen des 15. Jahrhunderts und vollständig überarbeiteten Ausgaben bereits verbreiteter Werke. Äusserst erfolgreiche Bücher wie das Narrenschiff oder der Heilsspiegel stehen neben kaum bekannten wie den seelsorgerischen Schriften des Kartäusers Ludwig Moser und des Franziskaners Johannes Meder. Die Analyse eines umfassenden Corpus bebilderter Frühdrucke fehlt in der neueren Forschung, welche sich bezüglich der Basler Produktion vorwiegend der Untersuchung der Produzentenkreise gewidmet, die Bilder dagegen - mit Ausnahme des Narrenschiffs - wenig beachtet hat. Sehr heterogen ist auch die Erforschung der Texte, von denen ein grosser Teil unediert geblieben ist, von anderen wiederum existieren ausführlich kommentierte Faksimileausgaben. Die bisherige Bild-Text-Forschung hat sich auf das Narrenschiff fokussiert.Neben der Quellenanalyse der Bilder und Texte strebt das Projekt eine umfassende Untersuchung der Bild-Text-Bezüge unter Berücksichtigung rezeptionsästethischer Fragestellungen an. Gefragt wird nach der Funktion der Bilder für die spätmittelalterlichen visuellen und auditiven Rezipienten. Dabei wird davon ausgegangen, dass es sich bei unseren Frühdrucken ausnahmslos um kalkulierte Bild-Text-Kompilationen handelt, welche einen reflektierten und kreativen Umgang ihrer Produzenten mit den drucktechnischen Möglichkeiten des neuen Mediums voraussetzen, wie z.B. mit der Möglichkeit der vielfältigen Kontextualisierung von Bildern. Die Analyse der Bild- und Textquellen liefert eine umfassende Fallstudie zum Medienwechsel zwischen Handschrift und Frühdruck, diejenige der Bild-Text-Bezüge im Spannungsfeld zwischen mündlicher Tradierung und schriftlicher Fixierung religiöser Didaxe eine Fallstudie zur spätmittelalterlichen Rezeptionsforschung.Methodisch knüpft das Projekt an rezeptionsästhetische Konzepte und Studien der jüngeren literaturwissenschaftlichen Forschung an, welche mit ikonographischen Analysen kombiniert werden. Durch diese Erweiterung textzentrierter methodischer Ansätze treten die Texte in Bezug auf die Bilder nicht mehr als übergeordnete, unabhängige Einheiten in den Blick, sondern die Konstruktion des Werksinnes erscheint im Wechselspiel der Medien. Der traditionelle Begriff der Buchillustration wird dadurch grundlegend revidiert.Neben mehreren Aufsätzen und einer Tagung sind eine Monographie in Buchform geplant, welche sich an die Fachwelt sowie an eine interessierte Öffentlichkeit wendet, ausserdem eine Internet-Publikation der Bild- und Textquellen im Rahmen der Zusammenarbeit mit der Basler Univeristätsbibliothek." - }, - "disciplines": [ - { - "en": "10404 Visual arts and Art history" - } - ], - "endDate": "2012-08-31", - "funders": [ - "http://ns.dasch.swiss/repository#dsp-0803-organization-000" - ], - "grants": [ - "http://ns.dasch.swiss/repository#dsp-0803-grant-000" - ], - "keywords": [ - { - "de": "Basel" - }, - { - "en": "Contectualisation of images" - }, - { - "en": "Late Middle Ages" - }, - { - "en": "Letterpress Printing" - } - ], - "name": "Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre", - "publications": [ - "Graf Kathrin (2011), Klerikersatiren in Bild und Text. Zur Kompilationstechnik im Narrenschiff, in Krause Karin u. Schellewald Barbara (ed.), 205-227.", - "Krause Karin u. Schellewald Barbara (ed.) (2011), Bild und Text im Mittelalter.", - "Rosenthaler Lukas u. Ryf Patrick (2009), Incunabula Basilea: A Web 2.0 Application as Research Tool to Early Prints, in Archiving, 6, 175-177.", - "Rosenthaler Lukas u. Schweizer Tobias (2012), SALSAH - eine webbasierte Forschungsplattform für die Geisteswissenschaften, in SAGW Bulletin, 32-33.", - "Rosenthaler Lukas, Virtual Research Environments. A New Approach for Dealing with Digitized Sources in Research in Arts and Humanities, in Clivaz Claire (ed.), ebook auf der Plattform http://www.ppur.info/lire-demain.html, Lausanne, 661-670.", - "Ryf Patrick u. Rosenthaler Lukas (2010), SALSAH: System for Annotation and Linkage of Sources in Arts and Humanities. Eine Web 2.0 Applikation zur wissenschaftlichen Betrachtung und Bearbeitung von historischem Bild- und Textmaterial, in Bienert Andreas u.a. (ed.), GFaI, Berlin, 123-126.", - "Schmitt Lothar (2009), Sebastian Brant, Albrecht Dürer und das Narrenschiff, in Wolfenbütteler Abhandlungen zur Renaissanceforschung, 26, 347-412.", - "Schmitt Lothar (2010), Mehr als Dürer. Die Ilustrationen in Friedrich Riederers \"Spiegel der wahren Rhetorik\", in Knape Joachim u. Luppold Stefanie (ed.), 191-216.", - "Schweizer Tobias u. Rosenthaler Lukas (2011), SALSAH - eine virtuelle Forschungsumgebung für die Geisteswissenschaften, in Bienert Andreas u.a. (ed.), GFaI, Berlin, 147-153.", - "Schweizer Tobias, Development of a Topographical Transcription Method, in Clivaz Claire u. a. (ed.), ebook, auf der Plattform http://www.ppur.info/lire-demain.html, Lausanne, 671-680." - ], - "url": { - "__type": "URL", - "type": "URL", - "url": "https://admin.dasch.swiss/project/3ABR_2i8QYGSIDvmP9mlEw", - "text": "Discover Project Data" - }, - "shortcode": "0803", - "startDate": "2008-06-01" - }, - "datasets": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-dataset-000", - "__type": "Dataset", - "__createdAt": "1637624150907146000", - "__createdBy": "dsp-metadata-gui", - "abstracts": [ - { - "en": "The interdisciplinary research project \"The image sequences of Basel's early prints: Late Medieval didactic didactics as an image-text reading\" combines a comprehensive art scholarly analysis of the links between images and texts in the illustrated incunabula in Basel with the digitization of the holdings of the University Library and the development of an electronic edition in the form of a new kind of Web-0.2 application. The project is carried out by Kunsthistorische Seminar of the University of Basel (Prof. B. Schellewald) and Digital Humanities Lab of the University of Basel (Prof. Dr. L. Rosenthaler). The core of the digital edition consists of around twenty richly illustrated early prints from four different Basel officers. Many of them appeared in several editions before 1500, some of them in German and Latin at almost the same time. It is an extraordinarily varied production; in addition to the Mirror of Salvation, there is a novel, the Melusine, the travelogues of Jean de Mandeville, some prayer and edification books, theological writings, Lent sermons, the lives of Saints Fridolin and Meinrad, the famous ship of fools and the knight of Thurn. The Internet publication makes the digitized corpus of these early prints usable for the scientific edition as well as for the exploration of images and texts through the possibilities of non-linear linking and commenting on the images and texts. Existing and emerging online editions can also be linked to it, which optimises the use of databases from other institutions with regard to our corpus." - } - ], - "attributions": [ - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-0803-person-004", - "roles": [ - "Employee" - ] - }, - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-0803-person-000", - "roles": [ - "Applicant" - ] - }, - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-0803-person-003", - "roles": [ - "Employee" - ] - }, - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-0803-person-001", - "roles": [ - "Co-applicant" - ] - }, - { - "__type": "Attribution", - "agent": "http://ns.dasch.swiss/repository#dsp-0803-person-002", - "roles": [ - "Co-applicant" - ] - } - ], - "status": "Finished", - "title": "Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre" - } - ], - "persons": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-person-000", - "__type": "Person", - "__createdAt": "1637624150958979000", - "__createdBy": "dsp-metadata-gui", - "familyNames": [ - "Schellewald" - ], - "givenNames": [ - "Barbara" - ], - "affiliation": [ - "http://ns.dasch.swiss/repository#dsp-0803-organization-001" - ] - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-person-001", - "__type": "Person", - "__createdAt": "1637624150959055000", - "__createdBy": "dsp-metadata-gui", - "familyNames": [ - "Hug" - ], - "givenNames": [ - "Hannes" - ], - "affiliation": [ - "http://ns.dasch.swiss/repository#dsp-0803-organization-002" - ] - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-person-002", - "__type": "Person", - "__createdAt": "1637624150959124000", - "__createdBy": "dsp-metadata-gui", - "familyNames": [ - "Rosenthaler" - ], - "givenNames": [ - "Lukas" - ], - "affiliation": [ - "http://ns.dasch.swiss/repository#dsp-0803-organization-003" - ] - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-person-003", - "__type": "Person", - "__createdAt": "1637624150959191000", - "__createdBy": "dsp-metadata-gui", - "familyNames": [ - "Schmitt" - ], - "givenNames": [ - "Lothar" - ] - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-person-004", - "__type": "Person", - "__createdAt": "1637624150959244000", - "__createdBy": "dsp-metadata-gui", - "familyNames": [ - "Graf Lamei" - ], - "givenNames": [ - "Katrin" - ] - } - ], - "organizations": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-organization-001", - "__type": "Organization", - "__createdAt": "1637624150959319000", - "__createdBy": "dsp-metadata-gui", - "name": "Kunsthistorisches Seminar Universität Basel" - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-organization-002", - "__type": "Organization", - "__createdAt": "1637624150959357000", - "__createdBy": "dsp-metadata-gui", - "name": "Universität Basel Universitätsbibliothek Sekretariat" - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-organization-003", - "__type": "Organization", - "__createdAt": "1637624150959391000", - "__createdBy": "dsp-metadata-gui", - "name": "Digital Humanities Lab Philosophisch-Historische Fakultät Universität Basel" - }, - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-organization-000", - "__type": "Organization", - "__createdAt": "1637624150959423000", - "__createdBy": "dsp-metadata-gui", - "name": "Swiss National Science Foundation (SNSF)" - } - ], - "grants": [ - { - "__id": "http://ns.dasch.swiss/repository#dsp-0803-grant-000", - "__type": "Grant", - "__createdAt": "1637624150959473000", - "__createdBy": "dsp-metadata-gui", - "funders": [ - "http://ns.dasch.swiss/repository#dsp-0803-organization-000" - ], - "name": "Project funding", - "number": "120378", - "url": { - "__type": "URL", - "type": "URL", - "url": "https://data.snf.ch/grants/grant/120378", - "text": "https://data.snf.ch/grants/grant/120378" - } - } - ] -} diff --git a/justfile b/justfile index 4674bf45..6cfb9e8e 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ DOCKER_REPO := "daschswiss/dsp-meta-server" -CARGO_VERSION := `cargo metadata --format-version=1 --no-deps | jq --raw-output '.packages[] | select(.name == "dsp-meta-cmd") | .version'` +CARGO_VERSION := `cargo metadata --format-version=1 --no-deps | jq --raw-output '.packages[].version'` COMMIT_HASH := `git log --pretty=format:'%h' -n 1` IMAGE_TAG := CARGO_VERSION + "-" + COMMIT_HASH DOCKER_IMAGE := DOCKER_REPO + ":" + IMAGE_TAG @@ -51,10 +51,6 @@ serve-dev: serve-frontend: cd web-frontend && yarn run dev -# Run dsp-meta-validator validating all hcl documents under ./data -validate: - export DSP_META_DATA_DIR=${PWD}/data && cargo run --bin dsp-meta-validator - # Build linux/amd64 Docker image locally docker-build-amd64: docker buildx build --platform linux/amd64 -t {{ DOCKER_IMAGE }}-amd64 --load . diff --git a/dsp-meta/resources/schema-metadata-draft.json b/resources/schema-metadata-draft.json similarity index 100% rename from dsp-meta/resources/schema-metadata-draft.json rename to resources/schema-metadata-draft.json diff --git a/dsp-meta/resources/schema-metadata-final.json b/resources/schema-metadata-final.json similarity index 100% rename from dsp-meta/resources/schema-metadata-final.json rename to resources/schema-metadata-final.json diff --git a/serde-rdf/Cargo.toml b/serde-rdf/Cargo.toml deleted file mode 100644 index a0b54894..00000000 --- a/serde-rdf/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "serde-rdf" -version = "2.0.0" -edition.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -documentation.workspace = true -readme.workspace = true -description.workspace = true -authors.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde.workspace = true -rio_api = { version = "0.8.5", features = [] } -rio_turtle = { version = "0.8.5", features = [] } -rio_xml = { version = "0.8.5", features = [] } - -[[example]] -name = "serialize" -test = true - -[[example]] -name = "deserialize" -test = true diff --git a/serde-rdf/examples/deserialize.rs b/serde-rdf/examples/deserialize.rs deleted file mode 100644 index fca3485a..00000000 --- a/serde-rdf/examples/deserialize.rs +++ /dev/null @@ -1,56 +0,0 @@ -#![allow(unused_variables, unused_imports, dead_code)] - -use std::collections::HashMap; - -use serde::Deserialize; - -#[derive(Debug, Deserialize)] -struct Project { - id: Iri, - name: String, - description: LangString, - shortcode: String, - datasets: Vec<Dataset>, -} - -#[derive(Debug, Deserialize)] -struct Dataset { - id: Iri, - name: String, -} - -type Iri = String; - -#[derive(Debug, Deserialize)] -pub struct LangString(pub HashMap<IsoCode, String>); - -#[derive(Debug, Default, Deserialize, Hash, Eq, PartialEq)] -pub enum IsoCode { - #[default] - DE, // German - EN, // English - FR, // French - IT, // Italian - ES, // Spanish - PT, // Portuguese - NL, // Dutch - PL, // Polish - RU, // Russian - JA, // Japanese - ZH, // Chinese - AR, // Arabic - FA, // Persian -} - -fn main() { - let project_ttl = r#" - <https://ark.dasch.swiss/ark:/72163/1/081C> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ns.dasch.swiss/repository#Project> ; - <https://ns.dasch.swiss/repository#hasName> "Hôtel de Musique Bern"^^xsd:string ; - <https://ns.dasch.swiss/repository#hasDescription> "The database documents the events that took place in the Hôtel de Musique in Bern between 1766 and 1905. The repertoire was constituted by different kinds of spectacles like theatre plays, operas, ballets, concerts, dance parties, acrobatic performances, conferences or magicians. The list reconstructs the lifely and colourful theatre culture of Bern in the 19th Century."@en ; - - <https://ns.dasch.swiss/repository#hasShortcode> "081C"^^xsd:string ; - <https://ns.dasch.swiss/repository#hasDataset> <dataset-0> ; - "#; - - let _project: Project = serde_rdf::from_str(project_ttl).unwrap(); -} diff --git a/serde-rdf/examples/serialize.rs b/serde-rdf/examples/serialize.rs deleted file mode 100644 index 9a44ea5a..00000000 --- a/serde-rdf/examples/serialize.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![allow(dead_code)] - -use std::collections::HashMap; - -use serde::*; -use serde_rdf::{SerializerConfig, SubjectConfig}; - -#[derive(Debug, Serialize)] -struct Project { - id: Iri, - name: String, - description: LangString, - shortcode: String, - datasets: Vec<Dataset>, -} - -#[derive(Debug, Serialize)] -struct Dataset { - id: Iri, -} - -type Iri = String; - -#[derive(Debug, Serialize)] -pub struct LangString(pub HashMap<IsoCode, String>); - -#[derive(Debug, Default, Serialize, PartialEq, Eq, Hash)] -pub enum IsoCode { - #[default] - DE, // German - EN, // English - FR, // French - IT, // Italian - ES, // Spanish - PT, // Portuguese - NL, // Dutch - PL, // Polish - RU, // Russian - JA, // Japanese - ZH, // Chinese - AR, // Arabic - FA, // Persian -} - -fn main() { - let mut name = HashMap::<IsoCode, String>::new(); - name.insert(IsoCode::EN, "Hôtel de Musique Bern".to_string()); - - let dataset = Dataset { - id: "dataset-0".to_string(), - }; - - let config = SerializerConfig { - base_iri: "".to_string(), - namespaces: Default::default(), - subjects: HashMap::from([( - "Dataset".to_string(), - SubjectConfig { - struct_name: "Dataset".to_string(), - rdf_type: "https://example.org/ns#Test".to_string(), - identifier_field: "id".to_string(), - identifier_prefix: "https://ark.dasch.swiss/ark:/72163/1/".to_string(), - properties: Vec::new(), - }, - )]), - }; - - let project_ttl = serde_rdf::to_string(&dataset, config).unwrap(); - - dbg!(project_ttl); -} diff --git a/serde-rdf/src/de.rs b/serde-rdf/src/de.rs deleted file mode 100644 index 6d2f95fe..00000000 --- a/serde-rdf/src/de.rs +++ /dev/null @@ -1,274 +0,0 @@ -#![allow(unused_variables, unused_imports, dead_code)] - -//! Deserialize RDF data to a Rust data structure. - -use serde::de::{self, Visitor}; - -use crate::{Error, Result}; - -/// A structure that deserializes RDF into Rust values. -pub struct Deserializer { - statements: String, -} - -impl Deserializer { - /// Creates a RDF deserializer from a `&str`. - /// - /// # Errors - /// - /// An [`Error`][Error] is returned when the input is not valid HCL. - pub fn from_raw_str(input: &str) -> Result<Self> { - // FIXME: parse the input into a list of statements - // let statements = parser::parse(input)?; - Ok(Deserializer { - statements: input.to_string(), - }) - } -} - -/// Deserialize an instance of type `T` from a string of RDF text. -/// -/// By default, the deserialization will follow the [Turtle Specification][turtle-spec]. -/// -/// [turtle-spec]: https://www.w3.org/TR/turtle/ -/// -/// # Errors -/// -/// This functions fails with an error if the data does not match the structure of `T`. -pub fn from_str<'de, T>(s: &'de str) -> Result<T> -where - T: de::Deserialize<'de>, -{ - let deserializer = Deserializer::from_raw_str(s)?; - T::deserialize(deserializer) -} - -impl<'de> de::Deserializer<'de> for Deserializer { - type Error = Error; - - fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_bool<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_i8<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_i16<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_i32<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_i64<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_u8<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_u16<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_u32<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_u64<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_f32<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_f64<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_char<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_str<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_string<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_option<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_unit<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_unit_struct<V>( - self, - _name: &'static str, - _visitor: V, - ) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_newtype_struct<V>( - self, - _name: &'static str, - _visitor: V, - ) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_seq<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_tuple_struct<V>( - self, - _name: &'static str, - _len: usize, - _visitor: V, - ) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_map<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_struct<V>( - self, - _name: &'static str, - _fields: &'static [&'static str], - _visitor: V, - ) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_enum<V>( - self, - _name: &'static str, - _variants: &'static [&'static str], - _visitor: V, - ) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_identifier<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } - - fn deserialize_ignored_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error> - where - V: Visitor<'de>, - { - todo!() - } -} diff --git a/serde-rdf/src/error.rs b/serde-rdf/src/error.rs deleted file mode 100644 index bb0bac62..00000000 --- a/serde-rdf/src/error.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! The `Error` and `Result` types used by this crate. - -use std::fmt::{Display, Formatter}; -use std::io; -use std::str::Utf8Error; - -use serde::{de, ser}; - -/// The result type used by this crate. -pub type Result<T, E = Error> = std::result::Result<T, E>; - -/// The error type used by this crate. -#[derive(Debug)] -#[non_exhaustive] -pub enum Error { - /// Represents a generic error message. - Message(String), - /// Represents an error that resulted from invalid UTF8 input. - Utf8(Utf8Error), - /// Represents generic IO errors. - Io(io::Error), - /// Represents an error during serialization. - CannotSerializePrimitive(&'static str), -} - -impl Error { - pub(crate) fn new<T>(msg: T) -> Error - where - T: Display, - { - Error::Message(msg.to_string()) - } -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Error::Message(msg) => write!(f, "{msg}"), - Error::Utf8(err) => write!(f, "{err}"), - Error::Io(err) => write!(f, "{err}"), - Error::CannotSerializePrimitive(msg) => write!(f, "{msg}"), - } - } -} - -impl From<io::Error> for Error { - fn from(value: io::Error) -> Self { - Error::Io(value) - } -} - -impl std::error::Error for Error {} - -impl ser::Error for Error { - fn custom<T: Display>(msg: T) -> Self { - Error::new(msg) - } -} - -impl de::Error for Error { - fn custom<T: Display>(msg: T) -> Self { - Error::new(msg) - } -} diff --git a/serde-rdf/src/lib.rs b/serde-rdf/src/lib.rs deleted file mode 100644 index 77bdbf2b..00000000 --- a/serde-rdf/src/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -mod de; -mod error; -mod ser; -mod structure; - -#[doc(inline)] -pub use de::{from_str, Deserializer}; -#[doc(inline)] -pub use error::{Error, Result}; -#[doc(inline)] -pub use ser::{to_string, Serializer}; -#[doc(inline)] -pub use structure::{PropertyConfig, SerializerConfig, SubjectConfig}; diff --git a/serde-rdf/src/ser.rs b/serde-rdf/src/ser.rs deleted file mode 100644 index 2b6a8a7b..00000000 --- a/serde-rdf/src/ser.rs +++ /dev/null @@ -1,704 +0,0 @@ -#![allow(unused_variables, unused_imports, dead_code)] - -//! Serialize a Rust data structure into RDF data. - -use std::io; - -use rio_api::formatter::TriplesFormatter; -use rio_api::model::{NamedNode as RioNamedNode, Triple}; -use rio_turtle::TurtleFormatter; -use serde::ser::{self, Serialize}; - -use crate::error::{Error, Result}; -use crate::structure::SerializerConfig; - -/// Serializer mapping configuration containing mappings aka instructions on how -/// to serialize a type. There are three possible options: -/// (1) one IRI: this denotes the name of the field containing the identifier. Further, it provides -/// the prefix to the identifier used to build the IRI. -/// (2) one Clazz: this denotes the name of the struct and to what RDF class it should be typed -/// (3) one or more Property: this denotes the name of the field, it's property IRI, and the -/// literal xsd:type (`XsdType`) it should be serialized into, if it is a literal, or (`Subject`) -/// denoting that it is a struct that needs to be serialized as a separate subject. -/// -/// Example: -/// ``` -/// use std::collections::HashMap; -/// use serde_rdf::{SerializerConfig, SubjectConfig, PropertyConfig}; -/// let _config = SerializerConfig{ -/// base_iri: "".to_string(), -/// namespaces: Default::default(), -/// subjects: HashMap::from([ -/// ("Project".to_string(), SubjectConfig{ -/// struct_name: "Project".to_string(), -/// rdf_type: "https://ns.dasch.swiss/repository#Project".to_string(), -/// identifier_field: "id".to_string(), -/// identifier_prefix: "https://ark.dasch.swiss/ark:/72163/1/".to_string(), -/// properties: vec!( -/// PropertyConfig{struct_field: "name".to_string(), rdf_property: "https://ns.dasch.swiss/repository#hasName".to_string()}, -/// PropertyConfig{struct_field: "description".to_string(), rdf_property: "https://ns.dasch.swiss/repository#hasDescription".to_string()}, -/// PropertyConfig{struct_field: "shortcode".to_string(), rdf_property: "https://ns.dasch.swiss/repository#hasShortcode".to_string()}, -/// PropertyConfig{struct_field: "datasets".to_string(), rdf_property: "https://ns.dasch.swiss/repository#hasDataset".to_string()}, -/// ), -/// }), -/// ("Dataset".to_string(), SubjectConfig{ -/// struct_name: "Dataset".to_string(), -/// rdf_type: "https://ns.dasch.swiss/repository#Dataset".to_string(), -/// identifier_field: "id".to_string(), -/// identifier_prefix: "https://ark.dasch.swiss/ark:/72163/1/".to_string(), -/// properties: vec!( -/// PropertyConfig{struct_field: "title".to_string(), rdf_property: "https://ns.dasch.swiss/repository#hasTitle".to_string()} -/// ), -/// })]) -/// }; -/// ``` - -#[derive(Eq, PartialEq, Debug, Clone, Hash)] -pub enum Literal<'a> { - /// A [simple literal](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) without datatype or language form. - Simple { - /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). - value: String, - }, - /// A [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string) - LanguageTaggedString { - /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). - value: String, - /// The [language tag](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag). - language: String, - }, - /// A literal with an explicit datatype - Typed { - /// The [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form). - value: String, - /// The [datatype IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri). - datatype: RioNamedNode<'a>, - }, -} - -impl Literal<'_> { - /// Return the lexical form of the literal. - pub fn value(&self) -> &str { - match self { - Literal::Simple { value } => value, - Literal::LanguageTaggedString { value, .. } => value, - Literal::Typed { value, .. } => value, - } - } -} - -#[derive(Debug)] -struct Loc { - id: String, - type_name: String, -} -/// Need a structure inside the serializer to hold the components of triples as they are -/// gathered: -/// - one IRI field holding the IRI of the subject -/// - one field with Vec holding tuples with the predicate and literal. -/// -/// The struct that we want to serialize, needs to be prepared: -/// - those fields of a struct that contain a Vec of literals need to be flattened `serde(flatten)` -/// - those fields of a struct that contain a Vec of structs should **not** be flattened -/// -pub struct Serializer<'a, W: io::Write> { - stack: Vec<Loc>, - last_subject: &'a str, - last_key: &'a str, - last_literal: Option<Literal<'a>>, - output: String, - mapping: SerializerConfig, - formatter: TurtleFormatter<W>, -} - -impl<'a, W> Serializer<'a, W> -where - W: io::Write, -{ - fn new(mapping: SerializerConfig, writer: W) -> Serializer<'a, W> { - Serializer::with_formatter(mapping, TurtleFormatter::new(writer)) - } - - fn with_formatter( - mapping: SerializerConfig, - formatter: TurtleFormatter<W>, - ) -> Serializer<'a, W> { - Serializer { - stack: Vec::new(), - last_subject: "", - last_key: "", - last_literal: None, - output: String::new(), - mapping, - formatter, - } - } -} - -/// Serialize the given value as an RDF string. -/// -/// # Errors -/// -/// Serialization fails if the type cannot be represented as RDF. -pub fn to_string<T>(value: &T, config: SerializerConfig) -> Result<String> -where - T: ?Sized + Serialize, -{ - let mut serializer = Serializer::new(config, Vec::default()); - value.serialize(&mut serializer)?; - let bytes = serializer.formatter.finish()?; - - // SAFETY: The `Formatter` never emits invalid UTF-8. - Ok(unsafe { String::from_utf8_unchecked(bytes) }) -} - -impl<'a, W> ser::Serializer for &mut Serializer<'a, W> -where - W: io::Write, -{ - // The output type produced by this `Serializer` during successful - // serialization. Most serializers that produce text or binary output should - // set `Ok = ()` and serialize into an `io::Write` or buffer contained - // within the `Serializer` instance, as happens here. Serializers that build - // in-memory data structures may be simplified by using `Ok` to propagate - // the data structure around. - type Ok = (); - - // The error type when some error occurs during serialization. - type Error = Error; - - // Associated types for keeping track of additional state while serializing - // compound data structures like sequences and maps. In this case no - // additional state is required beyond what is already stored in the - // Serializer struct. - type SerializeSeq = Self; - type SerializeTuple = Self; - type SerializeTupleStruct = Self; - type SerializeTupleVariant = Self; - type SerializeMap = Self; - type SerializeStruct = Self; - type SerializeStructVariant = Self; - - // Here we go with the simple methods. The following 12 methods receive one - // of the primitive types of the data model and map it to JSON by appending - // into the output string. - fn serialize_bool(self, v: bool) -> Result<()> { - use crate::ser::Literal::Typed; - - if v { - self.last_literal = Some(Typed { - value: "true".to_owned(), - datatype: RioNamedNode { iri: "xsd:boolean" }, - }); - } else { - self.last_literal = Some(Typed { - value: "false".to_owned(), - datatype: RioNamedNode { iri: "xsd:boolean" }, - }); - } - Ok(()) - } - - // JSON does not distinguish between different sizes of integers, so all - // signed integers will be serialized the same and all unsigned integers - // will be serialized the same. Other formats, especially compact binary - // formats, may need independent logic for the different sizes. - fn serialize_i8(self, v: i8) -> Result<Self::Ok> { - self.serialize_i64(i64::from(v)) - } - - fn serialize_i16(self, v: i16) -> Result<Self::Ok> { - self.serialize_i64(i64::from(v)) - } - - fn serialize_i32(self, v: i32) -> Result<Self::Ok> { - self.serialize_i64(i64::from(v)) - } - - // Not particularly efficient but this is example code anyway. A more - // performant approach would be to use the `itoa` crate. - fn serialize_i64(self, v: i64) -> Result<Self::Ok> { - self.output += &v.to_string(); - Ok(()) - } - - fn serialize_u8(self, v: u8) -> Result<Self::Ok> { - self.serialize_u64(u64::from(v)) - } - - fn serialize_u16(self, v: u16) -> Result<Self::Ok> { - self.serialize_u64(u64::from(v)) - } - - fn serialize_u32(self, v: u32) -> Result<Self::Ok> { - self.serialize_u64(u64::from(v)) - } - - fn serialize_u64(self, v: u64) -> Result<Self::Ok> { - self.output += &v.to_string(); - Ok(()) - } - - fn serialize_f32(self, v: f32) -> Result<Self::Ok> { - self.serialize_f64(f64::from(v)) - } - - fn serialize_f64(self, v: f64) -> Result<Self::Ok> { - self.output += &v.to_string(); - Ok(()) - } - - // Serialize a char as a single-character string. Other formats may - // represent this differently. - fn serialize_char(self, v: char) -> Result<Self::Ok> { - self.serialize_str(&v.to_string()) - } - - // This only works for strings that don't require escape sequences but you - // get the idea. For example it would emit invalid JSON if the input string - // contains a '"' character. - fn serialize_str(self, v: &str) -> Result<Self::Ok> { - println!("serialize_str"); - - use crate::ser::Literal::Typed; - - self.last_literal = Some(Typed { - value: v.to_owned(), - datatype: RioNamedNode { iri: "xsd:string" }, - }); - - Ok(()) - } - - // Serialize a byte array as an array of bytes. Could also use a base64 - // string here. Binary formats will typically represent byte arrays more - // compactly. - fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> { - use serde::ser::SerializeSeq; - let mut seq = self.serialize_seq(Some(v.len()))?; - for byte in v { - seq.serialize_element(byte)?; - } - seq.end() - } - - // An absent optional is represented as the JSON `null`. - fn serialize_none(self) -> Result<Self::Ok> { - self.serialize_unit() - } - - // A present optional is represented as just the contained value. Note that - // this is a lossy representation. For example the values `Some(())` and - // `None` both serialize as just `null`. Unfortunately this is typically - // what people expect when working with JSON. Other formats are encouraged - // to behave more intelligently if possible. - fn serialize_some<T>(self, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - value.serialize(self) - } - - // In Serde, unit means an anonymous value containing no data. Map this to - // JSON as `null`. - fn serialize_unit(self) -> Result<Self::Ok> { - self.output += "null"; - Ok(()) - } - - // Unit struct means a named value containing no data. Again, since there is - // no data, map this to JSON as `null`. There is no need to serialize the - // name in most formats. - fn serialize_unit_struct(self, name: &'static str) -> Result<Self::Ok> { - self.serialize_unit() - } - - // When serializing a unit variant (or any other kind of variant), formats - // can choose whether to keep track of it by index or by name. Binary - // formats typically use the index of the variant and human-readable formats - // typically use the name. - fn serialize_unit_variant( - self, - name: &'static str, - variant_index: u32, - variant: &'static str, - ) -> Result<Self::Ok, Self::Error> { - self.serialize_str(variant) - } - - // As is done here, serializers are encouraged to treat newtype structs as - // insignificant wrappers around the data they contain. - fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - value.serialize(self) - } - - // Note that newtype variant (and all of the other variant serialization - // methods) refer exclusively to the "externally tagged" enum - // representation. - // - // Serialize this to JSON in externally tagged form as `{ NAME: VALUE }`. - fn serialize_newtype_variant<T>( - self, - name: &'static str, - variant_index: u32, - variant: &'static str, - value: &T, - ) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - self.output += "{"; - variant.serialize(&mut *self)?; - self.output += ":"; - value.serialize(&mut *self)?; - self.output += "}"; - Ok(()) - } - - // Now we get to the serialization of compound types. - // - // The start of the sequence, each value, and the end are three separate - // method calls. This one is responsible only for serializing the start, - // which in JSON is `[`. - // - // The length of the sequence may or may not be known ahead of time. This - // doesn't make a difference in JSON because the length is not represented - // explicitly in the serialized form. Some serializers may only be able to - // support sequences for which the length is known up front. - fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq> { - self.output += "["; - Ok(self) - } - - // Tuples look just like sequences in JSON. Some formats may be able to - // represent tuples more efficiently by omitting the length, since tuple - // means that the corresponding `Deserialize implementation will know the - // length without needing to look at the serialized data. - fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, Self::Error> { - self.serialize_seq(Some(len)) - } - - // Tuple structs look just like sequences in JSON. - fn serialize_tuple_struct( - self, - name: &'static str, - len: usize, - ) -> Result<Self::SerializeTupleStruct, Self::Error> { - self.serialize_seq(Some(len)) - } - - // Tuple variants are represented in JSON as `{ NAME: [DATA...] }`. Again - // this method is only responsible for the externally tagged representation. - fn serialize_tuple_variant( - self, - name: &'static str, - variant_index: u32, - variant: &'static str, - len: usize, - ) -> Result<Self::SerializeTupleVariant, Self::Error> { - self.output += "{"; - variant.serialize(&mut *self)?; - self.output += ":["; - Ok(self) - } - - // Maps are represented in JSON as `{ K: V, K: V, ... }`. - fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap> { - self.output += "{"; - Ok(self) - } - - // Structs represent subjects, where the name is the "type". - fn serialize_struct(self, name: &'static str, len: usize) -> Result<Self::SerializeStruct> { - println!("serialize_struct"); - println!("name: {}", name); - self.last_subject = name; - Ok(self) - } - - // Struct variants are represented in JSON as `{ NAME: { K: V, ... } }`. - // This is the externally tagged representation. - fn serialize_struct_variant( - self, - name: &'static str, - variant_index: u32, - variant: &'static str, - len: usize, - ) -> Result<Self::SerializeStructVariant> { - self.output += "{"; - variant.serialize(&mut *self)?; - self.output += ":{"; - Ok(self) - } -} - -// The following 7 impls deal with the serialization of compound types like -// sequences and maps. Serialization of such types is begun by a Serializer -// method and followed by zero or more calls to serialize individual elements of -// the compound type and one call to end the compound type. -// -// This impl is SerializeSeq so these methods are called after `serialize_seq` -// is called on the Serializer. -impl<'a, W: io::Write> ser::SerializeSeq for &mut Serializer<'a, W> { - // Must match the `Ok` type of the serializer. - type Ok = (); - // Must match the `Error` type of the serializer. - type Error = Error; - - // Serialize a single element of the sequence. - fn serialize_element<T>(&mut self, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - if !self.output.ends_with('[') { - self.output += ","; - } - value.serialize(&mut **self) - } - - // Close the sequence. - fn end(self) -> Result<Self::Ok> { - self.output += "]"; - Ok(()) - } -} - -// Same thing but for tuples. -impl<'a, W: io::Write> ser::SerializeTuple for &mut Serializer<'a, W> { - type Ok = (); - type Error = Error; - - fn serialize_element<T>(&mut self, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - if !self.output.ends_with('[') { - self.output += ","; - } - value.serialize(&mut **self) - } - - fn end(self) -> Result<()> { - self.output += "]"; - Ok(()) - } -} - -// Same thing but for tuple structs. -impl<'a, W: io::Write> ser::SerializeTupleStruct for &mut Serializer<'a, W> { - type Ok = (); - type Error = Error; - - fn serialize_field<T>(&mut self, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - if !self.output.ends_with('[') { - self.output += ","; - } - value.serialize(&mut **self) - } - - fn end(self) -> Result<()> { - self.output += "]"; - Ok(()) - } -} - -// Tuple variants are a little different. Refer back to the -// `serialize_tuple_variant` method above: -// -// self.output += "{"; -// variant.serialize(&mut *self)?; -// self.output += ":["; -// -// So the `end` method in this impl is responsible for closing both the `]` and -// the `}`. -impl<'a, W: io::Write> ser::SerializeTupleVariant for &mut Serializer<'a, W> { - type Ok = (); - type Error = Error; - - fn serialize_field<T>(&mut self, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - if !self.output.ends_with('[') { - self.output += ","; - } - value.serialize(&mut **self) - } - - fn end(self) -> Result<()> { - self.output += "]}"; - Ok(()) - } -} - -// Some `Serialize` types are not able to hold a key and value in memory at the -// same time so `SerializeMap` implementations are required to support -// `serialize_key` and `serialize_value` individually. -// -// There is a third optional method on the `SerializeMap` trait. The -// `serialize_entry` method allows serializers to optimize for the case where -// key and value are both available simultaneously. In JSON it doesn't make a -// difference so the default behavior for `serialize_entry` is fine. -impl<'a, W: io::Write> ser::SerializeMap for &mut Serializer<'a, W> { - type Ok = (); - type Error = Error; - - // The Serde data model allows map keys to be any serializable type. JSON - // only allows string keys so the implementation below will produce invalid - // JSON if the key serializes as something other than a string. - // - // A real JSON serializer would need to validate that map keys are strings. - // This can be done by using a different Serializer to serialize the key - // (instead of `&mut **self`) and having that other serializer only - // implement `serialize_str` and return an error on any other data type. - fn serialize_key<T>(&mut self, key: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - if !self.output.ends_with('{') { - self.output += ","; - } - key.serialize(&mut **self) - } - - // It doesn't make a difference whether the colon is printed at the end of - // `serialize_key` or at the beginning of `serialize_value`. In this case - // the code is a bit simpler having it here. - fn serialize_value<T>(&mut self, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - self.output += ":"; - value.serialize(&mut **self) - } - - fn end(self) -> Result<()> { - self.output += "}"; - Ok(()) - } -} - -// Structs are like maps in which the keys are constrained to be compile-time -// constant strings. -impl<'a, W: io::Write> ser::SerializeStruct for &mut Serializer<'a, W> { - type Ok = (); - type Error = Error; - - fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - println!("serialize_struct -> serialize_field"); - - value.serialize(&mut **self)?; - - let subject = self.mapping.subjects.get(self.last_subject).unwrap(); - - if subject.identifier_field == key { - println!( - "serialize_struct -> serialize_field -> identifier_field: {}", - key - ); - } - - let value = match self.last_literal.take() { - Some(v) => v, - None => { - return Err(Error::Message(format!( - "serialize_struct -> serialize_field -> no value found for key: {}", - key - ))) - } - }; - - self.formatter.format(&Triple { - subject: RioNamedNode { - iri: format!("{}{}", &subject.identifier_prefix, value.value()).as_str(), - } - .into(), - predicate: RioNamedNode { - iri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", - }, - object: RioNamedNode { - iri: subject.rdf_type.as_str(), - } - .into(), - })?; - Ok(()) - } - - fn end(self) -> Result<()> { - println!("serialize_struct -> end"); - Ok(()) - } -} - -// Similar to `SerializeTupleVariant`, here the `end` method is responsible for -// closing both of the curly braces opened by `serialize_struct_variant`. -impl<'a, W: io::Write> ser::SerializeStructVariant for &mut Serializer<'a, W> { - type Ok = (); - type Error = Error; - - fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<Self::Ok> - where - T: ?Sized + Serialize, - { - if !self.output.ends_with('{') { - self.output += ","; - } - key.serialize(&mut **self)?; - self.output += ":"; - value.serialize(&mut **self) - } - - fn end(self) -> Result<()> { - self.output += "}}"; - Ok(()) - } -} - -//////////////////////////////////////////////////////////////////////////////// - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use serde::Serialize; - - use crate::{to_string, SerializerConfig, SubjectConfig}; - - #[test] - fn test_simple_struct() { - #[derive(Serialize)] - struct Test { - id: String, - } - - let config = SerializerConfig { - base_iri: "".to_string(), - namespaces: Default::default(), - subjects: HashMap::from([( - "Test".to_string(), - SubjectConfig { - struct_name: "Test".to_string(), - rdf_type: "https://example.org/ns#Test".to_string(), - identifier_field: "id".to_string(), - identifier_prefix: "https://ark.dasch.swiss/ark:/72163/1/".to_string(), - properties: Vec::new(), - }, - )]), - }; - - let test = Test { - id: "my-id".to_string(), - }; - let expected = "<https://ark.dasch.swiss/ark:/72163/1/my-id> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/ns#Test> .\n"; - assert_eq!(to_string(&test, config).unwrap(), expected); - } -} diff --git a/serde-rdf/src/structure.rs b/serde-rdf/src/structure.rs deleted file mode 100644 index 4fbef2c3..00000000 --- a/serde-rdf/src/structure.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![allow(unused_variables, unused_imports, dead_code)] - -use std::collections::HashMap; - -use rio_api::model::NamedNode; - -pub enum Term { - Literal(String), - Subject(String), -} - -/// A subject holds additional information for the serializer -/// to further configure how a specific rust struct should be serialized. -#[derive(Debug)] -pub struct SubjectConfig { - pub struct_name: String, - pub rdf_type: String, - pub identifier_field: String, - pub identifier_prefix: String, - pub properties: Vec<PropertyConfig>, -} - -#[derive(Debug)] -pub struct PropertyConfig { - pub struct_field: String, - pub rdf_property: String, -} - -/// Serializer configuration containing mappings / instructions on how to -/// serialize rust structs into RDF. The config contains one ore more -/// `Subject`s. -#[derive(Debug)] -pub struct SerializerConfig { - pub base_iri: String, - pub namespaces: HashMap<String, String>, - pub subjects: HashMap<String, SubjectConfig>, -} - -#[derive(Debug)] -pub struct SubjectBuilder { - struct_name: String, - rdf_type: String, - identifier_field: String, - identifier_prefix: String, - properties: Vec<PropertyConfig>, -} diff --git a/dsp-meta/src/api/convert/axum/mod.rs b/src/api/convert/axum/mod.rs similarity index 100% rename from dsp-meta/src/api/convert/axum/mod.rs rename to src/api/convert/axum/mod.rs diff --git a/dsp-meta/src/api/convert/axum/responses.rs b/src/api/convert/axum/responses.rs similarity index 100% rename from dsp-meta/src/api/convert/axum/responses.rs rename to src/api/convert/axum/responses.rs diff --git a/dsp-meta/src/api/convert/mod.rs b/src/api/convert/mod.rs similarity index 100% rename from dsp-meta/src/api/convert/mod.rs rename to src/api/convert/mod.rs diff --git a/dsp-meta/src/api/handler/health.rs b/src/api/handler/health.rs similarity index 100% rename from dsp-meta/src/api/handler/health.rs rename to src/api/handler/health.rs diff --git a/dsp-meta/src/api/handler/mod.rs b/src/api/handler/mod.rs similarity index 100% rename from dsp-meta/src/api/handler/mod.rs rename to src/api/handler/mod.rs diff --git a/dsp-meta/src/api/handler/robots_txt.rs b/src/api/handler/robots_txt.rs similarity index 100% rename from dsp-meta/src/api/handler/robots_txt.rs rename to src/api/handler/robots_txt.rs diff --git a/dsp-meta/src/api/handler/sitemap_xml.rs b/src/api/handler/sitemap_xml.rs similarity index 100% rename from dsp-meta/src/api/handler/sitemap_xml.rs rename to src/api/handler/sitemap_xml.rs diff --git a/dsp-meta/src/api/handler/v1/mod.rs b/src/api/handler/v1/mod.rs similarity index 100% rename from dsp-meta/src/api/handler/v1/mod.rs rename to src/api/handler/v1/mod.rs diff --git a/dsp-meta/src/api/handler/v1/projects/handlers.rs b/src/api/handler/v1/projects/handlers.rs similarity index 100% rename from dsp-meta/src/api/handler/v1/projects/handlers.rs rename to src/api/handler/v1/projects/handlers.rs diff --git a/dsp-meta/src/api/handler/v1/projects/mod.rs b/src/api/handler/v1/projects/mod.rs similarity index 100% rename from dsp-meta/src/api/handler/v1/projects/mod.rs rename to src/api/handler/v1/projects/mod.rs diff --git a/dsp-meta/src/api/handler/v1/projects/responses.rs b/src/api/handler/v1/projects/responses.rs similarity index 100% rename from dsp-meta/src/api/handler/v1/projects/responses.rs rename to src/api/handler/v1/projects/responses.rs diff --git a/dsp-meta/src/api/mod.rs b/src/api/mod.rs similarity index 100% rename from dsp-meta/src/api/mod.rs rename to src/api/mod.rs diff --git a/dsp-meta/src/api/router.rs b/src/api/router.rs similarity index 97% rename from dsp-meta/src/api/router.rs rename to src/api/router.rs index e6ef50c5..3dca26e2 100644 --- a/dsp-meta/src/api/router.rs +++ b/src/api/router.rs @@ -98,7 +98,7 @@ mod tests { #[tokio::test] async fn test_health_route() { - let data_dir = env::current_dir().unwrap().parent().unwrap().join("data"); + let data_dir = env::current_dir().unwrap().join("data"); let shared_state = Arc::new(AppState { metadata_service: MetadataService::new(MetadataRepository::from_path( @@ -131,7 +131,7 @@ mod tests { #[tokio::test] async fn test_not_found_project() { - let data_dir = env::current_dir().unwrap().parent().unwrap().join("data"); + let data_dir = env::current_dir().unwrap().join("data"); let shared_state = Arc::new(AppState { metadata_service: MetadataService::new(MetadataRepository::from_path( diff --git a/dsp-meta/src/app_state.rs b/src/app_state.rs similarity index 100% rename from dsp-meta/src/app_state.rs rename to src/app_state.rs diff --git a/dsp-meta-cmd/src/cli.rs b/src/cli.rs similarity index 100% rename from dsp-meta-cmd/src/cli.rs rename to src/cli.rs diff --git a/dsp-meta/src/domain/metadata_repository.rs b/src/domain/metadata_repository.rs similarity index 98% rename from dsp-meta/src/domain/metadata_repository.rs rename to src/domain/metadata_repository.rs index 04497591..eb3c2da7 100644 --- a/dsp-meta/src/domain/metadata_repository.rs +++ b/src/domain/metadata_repository.rs @@ -161,7 +161,7 @@ mod tests { #[test] fn successfully_load_all_metadata_files() { - let data_dir = env::current_dir().unwrap().parent().unwrap().join("data"); + let data_dir = env::current_dir().unwrap().join("data"); dbg!(&data_dir); let files = load_json_file_paths(&data_dir); diff --git a/dsp-meta/src/domain/metadata_service.rs b/src/domain/metadata_service.rs similarity index 100% rename from dsp-meta/src/domain/metadata_service.rs rename to src/domain/metadata_service.rs diff --git a/dsp-meta/src/domain/mod.rs b/src/domain/mod.rs similarity index 100% rename from dsp-meta/src/domain/mod.rs rename to src/domain/mod.rs diff --git a/dsp-meta/src/domain/model/draft_model.rs b/src/domain/model/draft_model.rs similarity index 100% rename from dsp-meta/src/domain/model/draft_model.rs rename to src/domain/model/draft_model.rs diff --git a/dsp-meta/src/domain/model/error.rs b/src/domain/model/error.rs similarity index 100% rename from dsp-meta/src/domain/model/error.rs rename to src/domain/model/error.rs diff --git a/dsp-meta/src/domain/model/json_schema_validator.rs b/src/domain/model/json_schema_validator.rs similarity index 100% rename from dsp-meta/src/domain/model/json_schema_validator.rs rename to src/domain/model/json_schema_validator.rs diff --git a/dsp-meta/src/domain/model/mod.rs b/src/domain/model/mod.rs similarity index 100% rename from dsp-meta/src/domain/model/mod.rs rename to src/domain/model/mod.rs diff --git a/dsp-meta/src/error.rs b/src/error.rs similarity index 100% rename from dsp-meta/src/error.rs rename to src/error.rs diff --git a/dsp-meta/src/infrastructure/mod.rs b/src/infrastructure/mod.rs similarity index 100% rename from dsp-meta/src/infrastructure/mod.rs rename to src/infrastructure/mod.rs diff --git a/dsp-meta/src/lib.rs b/src/lib.rs similarity index 100% rename from dsp-meta/src/lib.rs rename to src/lib.rs diff --git a/dsp-meta-cmd/src/main-server.rs b/src/main-server.rs similarity index 98% rename from dsp-meta-cmd/src/main-server.rs rename to src/main-server.rs index a24afb59..cb352727 100644 --- a/dsp-meta-cmd/src/main-server.rs +++ b/src/main-server.rs @@ -78,6 +78,7 @@ async fn init_server() { // start the server let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap(); + dbg!("Starting up on http://0.0.0.0:3000"); axum::serve(listener, dsp_meta::api::router::router(shared_state)) .await .unwrap(); diff --git a/dsp-meta-cmd/src/main-validator.rs b/src/main-validator.rs similarity index 100% rename from dsp-meta-cmd/src/main-validator.rs rename to src/main-validator.rs diff --git a/dsp-meta/tests/api_tests.rs b/tests/api_tests.rs similarity index 100% rename from dsp-meta/tests/api_tests.rs rename to tests/api_tests.rs diff --git a/dsp-meta/tests/draft_schema_test.rs b/tests/draft_schema_test.rs similarity index 96% rename from dsp-meta/tests/draft_schema_test.rs rename to tests/draft_schema_test.rs index 05d223ee..5d6a464f 100644 --- a/dsp-meta/tests/draft_schema_test.rs +++ b/tests/draft_schema_test.rs @@ -65,10 +65,7 @@ fn test_deserialization_all_json_data() { } fn data_dir() -> PathBuf { - let mut current_dir = env::current_dir() - .ok() - .and_then(|e| e.parent().map(|p| p.to_path_buf())) - .expect("Project root dir"); + let mut current_dir = env::current_dir().expect("Project root dir"); current_dir.push("data"); current_dir } From 000a7c2b9a141df4514bfff775d47a82dd753cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 10:15:39 +0200 Subject: [PATCH 03/12] rm unused dependencies --- Cargo.lock | 140 +------------------------------------ Cargo.toml | 3 - tests/draft_schema_test.rs | 23 ------ 3 files changed, 1 insertion(+), 165 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7aba7f0c..fe8f4d03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -453,7 +453,7 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml 0.5.11", + "toml", "yaml-rust", ] @@ -684,7 +684,6 @@ dependencies = [ "config", "dirs", "fake", - "hcl-rs", "http-body-util", "hyper", "indicatif", @@ -696,11 +695,9 @@ dependencies = [ "serde", "serde_json", "serde_with", - "serde_yaml", "thiserror", "tokio", "tokio-test", - "toml 0.8.19", "tower", "tower-http", "tracing", @@ -908,45 +905,6 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -[[package]] -name = "hcl-edit" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191e0335c5fda9cb8a028af95a73635e781970f2af1df55d9f49b4331dfc4315" -dependencies = [ - "fnv", - "hcl-primitives", - "vecmap-rs", - "winnow", -] - -[[package]] -name = "hcl-primitives" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaef0959c97781fc9aba104a08e513a14f995b7c12fdcf940d94252d2e4fa884" -dependencies = [ - "itoa", - "kstring", - "ryu", - "serde", - "unicode-ident", -] - -[[package]] -name = "hcl-rs" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a53aa7b895ddc4bf4eeb6502bc4db0256897ae7cfede76155ddd29352518dfee" -dependencies = [ - "hcl-edit", - "hcl-primitives", - "indexmap 2.2.6", - "itoa", - "serde", - "vecmap-rs", -] - [[package]] name = "heck" version = "0.4.1" @@ -1208,16 +1166,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "kstring" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1" -dependencies = [ - "serde", - "static_assertions", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -1832,15 +1780,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1883,19 +1822,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" -dependencies = [ - "indexmap 2.2.6", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - [[package]] name = "sha2" version = "0.10.8" @@ -1966,12 +1892,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.11.1" @@ -2156,40 +2076,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" -dependencies = [ - "indexmap 2.2.6", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tower" version = "0.4.13" @@ -2393,12 +2279,6 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - [[package]] name = "uritemplate-next" version = "0.2.0" @@ -2465,15 +2345,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vecmap-rs" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78fc839a22ab6c4e2f48cf5b935064188148258d467f49323134d503dd08294" -dependencies = [ - "serde", -] - [[package]] name = "version_check" version = "0.9.5" @@ -2728,15 +2599,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" -dependencies = [ - "memchr", -] - [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index 8750c7ee..cf494575 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ clap = { version = "4.5.16", features = ["derive"] } # command-line parser config = "0.13.1" # Layered configuration with strong support for 12-factor applications chrono = { version = "0.4.38", features = ["serde"] } dirs = "5.0.1" # provides platform-specific locations for storing user configuration -hcl-rs = "0.16.7" # HCL converter http-body-util = "0.1.0" indicatif = "0.17.0" # prograss bars and spinners log = "0.4.22" # logging facade @@ -28,7 +27,6 @@ pid1 = "0.1.1" serde = { version = "1", features = ["derive"] } serde_with = "3.9.0" serde_json = "1" # JSON serialization -serde_yaml = "0.9" nonempty = { version = "0.10.0", features = ["serialize"] } valico = "4.0.0" tokio = { version = "1", features = ["rt", "macros", "rt-multi-thread"] } @@ -48,7 +46,6 @@ tracing-subscriber = { version = "0.3", features = [ ] } tracing-test = "0.2" url = { version = "2", features = ["serde"] } -toml = "0.8.19" [dev-dependencies] assert_cmd = "2.0.16" diff --git a/tests/draft_schema_test.rs b/tests/draft_schema_test.rs index 5d6a464f..28710e67 100644 --- a/tests/draft_schema_test.rs +++ b/tests/draft_schema_test.rs @@ -7,29 +7,6 @@ use dsp_meta::domain::model::draft_model::*; use dsp_meta::domain::model::json_schema_validator::{validate_files, SchemaVersion}; use dsp_meta::infrastructure::load_json_file_paths; -#[test] -fn test_json_and_yaml_serialization_are_equal() { - let mut sgv_json = data_dir(); - sgv_json.push("json"); - sgv_json.push("sgv.json"); - let contents_json = fs::read_to_string(sgv_json).expect("Read JSON"); - let metadata_json = serde_json::from_str::<DraftMetadata>(&*contents_json).expect("From JSON"); - let contents_yaml = serde_yaml::to_string(&metadata_json).expect("To YAML"); - let metadata_yaml = serde_yaml::from_str(&*contents_yaml).expect("From YAML"); - assert_eq!(metadata_json, metadata_yaml); -} - -#[test] -fn test_json_and_toml_serialization_are_equal() { - let mut sgv_json = data_dir(); - sgv_json.push("json"); - sgv_json.push("sgv.json"); - let contents_json = fs::read_to_string(sgv_json).expect("Read JSON"); - let metadata_json = serde_json::from_str::<DraftMetadata>(&*contents_json).expect("From JSON"); - let contents_toml = toml::to_string(&metadata_json).expect("To TOML"); - let metadata_toml = toml::from_str::<DraftMetadata>(&*contents_toml).expect("From TOML"); - assert_eq!(metadata_json, metadata_toml); -} #[test] fn test_deserialization_all_json_data() { From 010094cda45988b33f27579f8d6dc8b64ce4e597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 10:17:57 +0200 Subject: [PATCH 04/12] fmt --- Cargo.toml | 1 - tests/draft_schema_test.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf494575..1378ee00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,6 @@ assert_cmd = "2.0.16" axum-test = "15.3.0" fake = "2.9.2" - [[bin]] name = "dsp-meta-server" path = "src/main-server.rs" diff --git a/tests/draft_schema_test.rs b/tests/draft_schema_test.rs index 28710e67..da38efbd 100644 --- a/tests/draft_schema_test.rs +++ b/tests/draft_schema_test.rs @@ -7,7 +7,6 @@ use dsp_meta::domain::model::draft_model::*; use dsp_meta::domain::model::json_schema_validator::{validate_files, SchemaVersion}; use dsp_meta::infrastructure::load_json_file_paths; - #[test] fn test_deserialization_all_json_data() { let json_file_paths = load_json_file_paths(&data_dir()); From a2a540f3ea436a8ee11c47a639986609b656d3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 10:21:33 +0200 Subject: [PATCH 05/12] update Cargo.lock --- Cargo.lock | 263 ++++++++++++++++++++++------------------------------- 1 file changed, 107 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe8f4d03..9d6b63b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", @@ -206,7 +206,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "axum-test" -version = "15.3.0" +version = "15.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cd2b6c11bc5e65ec121543c5049b7e07be9e7b5a515df79d01f74a72c6a15f0" +checksum = "6e1c84a9311539c426a1cb95137308aaa847baedfe6f3d049d57bdefedd8107e" dependencies = [ "anyhow", "auto-future", @@ -269,7 +269,7 @@ dependencies = [ "serde_urlencoded", "smallvec", "tokio", - "tower", + "tower 0.5.0", "url", ] @@ -359,17 +359,26 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.7" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -482,15 +491,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -618,33 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] -<<<<<<< HEAD -name = "dsp-domain" -version = "2.2.0" -dependencies = [ - "anyhow", - "assert_cmd", - "axum", - "axum-macros", - "clap", - "hcl-rs", - "hyper", - "log", - "serde", - "serde_json", - "thiserror", - "tokio", - "tower", - "tower-http", - "tracing", - "tracing-subscriber", - "tracing-test", - "url", -] - -[[package]] -||||||| parent of d2944c9 (Remove unused dsp-domain crate) -name = "dsp-domain" +name = "dsp-meta" version = "2.1.0" dependencies = [ "anyhow", @@ -652,32 +635,6 @@ dependencies = [ "async-trait", "axum", "axum-macros", - "clap", - "hcl-rs", - "hyper", - "log", - "serde", - "serde_json", - "thiserror", - "tokio", - "tower", - "tower-http", - "tracing", - "tracing-subscriber", - "tracing-test", - "url", -] - -[[package]] -======= ->>>>>>> d2944c9 (Remove unused dsp-domain crate) -name = "dsp-meta" -version = "2.2.0" -dependencies = [ - "anyhow", - "assert_cmd", - "axum", - "axum-macros", "axum-test", "chrono", "clap", @@ -698,7 +655,7 @@ dependencies = [ "thiserror", "tokio", "tokio-test", - "tower", + "tower 0.4.13", "tower-http", "tracing", "tracing-subscriber", @@ -708,62 +665,10 @@ dependencies = [ ] [[package]] -<<<<<<< HEAD -name = "dsp-meta-cmd" -version = "2.2.0" -dependencies = [ - "anyhow", - "assert_cmd", - "axum", - "axum-macros", - "clap", - "config", - "dsp-meta", - "hcl-rs", - "hyper", - "log", - "pid1", - "serde", - "serde_json", - "tokio", - "tower", - "tower-http", - "tracing", - "tracing-subscriber", - "tracing-test", - "url", -] -||||||| parent of e0a64d7 (merge crates) -name = "dsp-meta-cmd" -version = "2.1.0" -dependencies = [ - "anyhow", - "assert_cmd", - "axum", - "axum-macros", - "clap", - "config", - "dsp-meta", - "hcl-rs", - "hyper", - "log", - "pid1", - "serde", - "serde_json", - "tokio", - "tower", - "tower-http", - "tracing", - "tracing-subscriber", - "tracing-test", - "url", -] -======= name = "encode_unicode" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" ->>>>>>> e0a64d7 (merge crates) [[package]] name = "equivalent" @@ -1014,9 +919,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", @@ -1027,7 +932,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", + "tower 0.4.13", "tower-service", "tracing", ] @@ -1084,9 +989,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1129,9 +1034,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -1174,9 +1079,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libredox" @@ -1254,9 +1159,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", @@ -1327,9 +1232,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -1514,9 +1419,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "predicates" @@ -1581,9 +1489,9 @@ checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1802,7 +1710,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.5.0", "serde", "serde_derive", "serde_json", @@ -1842,6 +1750,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -1900,9 +1814,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -2005,9 +1919,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -2092,6 +2006,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36b837f86b25d7c0d7988f00a54e74739be6477f2aac6201b8f429a7569991b7" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-http" version = "0.5.2" @@ -2119,15 +2048,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -2377,19 +2306,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -2402,9 +2332,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2412,9 +2342,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -2425,9 +2355,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "winapi" @@ -2613,3 +2543,24 @@ name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] From 70bb6f599ca3da82c75142f224aa60ac295dffe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 11:37:25 +0200 Subject: [PATCH 06/12] Update release-please --- .github/release-please/config.json | 20 +++++++------------- .github/release-please/manifest.json | 4 +--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/release-please/config.json b/.github/release-please/config.json index a170605a..ccb99d58 100644 --- a/.github/release-please/config.json +++ b/.github/release-please/config.json @@ -1,7 +1,5 @@ { "release-type": "rust", - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": true, "changelog-sections": [ { "type": "feat", @@ -52,17 +50,13 @@ } ], "packages": { - "dsp-domain": { - "component": "dsp-domain", - "release-type": "rust" - }, - "dsp-meta": { - "component": "dsp-meta", - "release-type": "rust" - }, - "dsp-meta-cmd": { - "component": "dsp-meta-cmd", - "release-type": "rust" + ".": { + "changelog-path": "CHANGELOG.md", + "release-type": "rust", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "draft": true, + "prerelease": false } }, "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json index 069ae25d..a5d1cf28 100644 --- a/.github/release-please/manifest.json +++ b/.github/release-please/manifest.json @@ -1,5 +1,3 @@ { - "dsp-domain": "2.2.0", - "dsp-meta": "2.2.0", - "dsp-meta-cmd": "2.2.0" + ".": "2.2.0" } From b278e4234f91b2efacaae23d6f46fb6fc60b0cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 11:51:23 +0200 Subject: [PATCH 07/12] logging --- src/main-server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main-server.rs b/src/main-server.rs index cb352727..f652c2d4 100644 --- a/src/main-server.rs +++ b/src/main-server.rs @@ -78,7 +78,7 @@ async fn init_server() { // start the server let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap(); - dbg!("Starting up on http://0.0.0.0:3000"); + dbg!("Starting up: http://localhost:3000"); axum::serve(listener, dsp_meta::api::router::router(shared_state)) .await .unwrap(); From 8c05001a9fa7088d486ccc89e49db9d0425faab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 11:51:47 +0200 Subject: [PATCH 08/12] Remove remaining unused folders --- dsp-domain/CHANGELOG.md | 71 --------------------------------------- dsp-domain/Cargo.toml | 35 ------------------- dsp-meta-cmd/CHANGELOG.md | 54 ----------------------------- dsp-meta-cmd/Cargo.toml | 45 ------------------------- dsp-meta/Cargo.toml | 47 -------------------------- 5 files changed, 252 deletions(-) delete mode 100644 dsp-domain/CHANGELOG.md delete mode 100644 dsp-domain/Cargo.toml delete mode 100644 dsp-meta-cmd/CHANGELOG.md delete mode 100644 dsp-meta-cmd/Cargo.toml delete mode 100644 dsp-meta/Cargo.toml diff --git a/dsp-domain/CHANGELOG.md b/dsp-domain/CHANGELOG.md deleted file mode 100644 index 039bdbba..00000000 --- a/dsp-domain/CHANGELOG.md +++ /dev/null @@ -1,71 +0,0 @@ -# Changelog - -## [2.2.0](https://github.com/dasch-swiss/dsp-meta/compare/dsp-domain-v2.1.0...dsp-domain-v2.2.0) (2024-09-03) - - -### Maintenance - -* Force release 2.1.0 ([ba11ab5](https://github.com/dasch-swiss/dsp-meta/commit/ba11ab500b66e3d7d75c15c61a1819a6b5eaa167)) -* Force release 2.2.0 ([d5d098d](https://github.com/dasch-swiss/dsp-meta/commit/d5d098d24cb35ce7fdfc9100f11b49a2e4d86a19)) - -## [2.1.0](https://github.com/dasch-swiss/dsp-meta/compare/dsp-domain-v2.0.3...dsp-domain-v2.1.0) (2024-08-28) - - -### Enhancements - -* Add draft json schema validation and serde model ([#144](https://github.com/dasch-swiss/dsp-meta/issues/144)) ([df7948b](https://github.com/dasch-swiss/dsp-meta/commit/df7948b1fc5a411f064dbaa9657875405a551706)) -* Add grant domain model and deserialization ([#121](https://github.com/dasch-swiss/dsp-meta/issues/121)) ([f4a6162](https://github.com/dasch-swiss/dsp-meta/commit/f4a61623b3b640f8a8b1bd85969ea01ab9b3b056)) -* **dsp-domain:** Add ontology domain model ([#61](https://github.com/dasch-swiss/dsp-meta/issues/61)) ([c80cd83](https://github.com/dasch-swiss/dsp-meta/commit/c80cd83a5b9b749a00c84a5da5a1b4af606dbdc9)) -* Extend dataset domain model and a bit of deserialization (ongoing) ([#113](https://github.com/dasch-swiss/dsp-meta/issues/113)) ([070a729](https://github.com/dasch-swiss/dsp-meta/commit/070a7290a65a266e8d9c7284b7af3733c64cd490)) -* Extend dataset domain model and deserialization (ongoing) ([#115](https://github.com/dasch-swiss/dsp-meta/issues/115)) ([4264c72](https://github.com/dasch-swiss/dsp-meta/commit/4264c721cd80c889175331263b591a94c999b465)) - - -### Maintenance - -* Add version for each crate ([#162](https://github.com/dasch-swiss/dsp-meta/issues/162)) ([825a282](https://github.com/dasch-swiss/dsp-meta/commit/825a282bd0828eba40cec6e2038176bf0c6ab768)) -* Attempt to fix release-please ([#186](https://github.com/dasch-swiss/dsp-meta/issues/186)) ([ab7ca21](https://github.com/dasch-swiss/dsp-meta/commit/ab7ca21a31993c2f4e51447ce25232084771fcf8)) -* Change towards single version ([#80](https://github.com/dasch-swiss/dsp-meta/issues/80)) ([564736a](https://github.com/dasch-swiss/dsp-meta/commit/564736a398750aed47bdad704aa715a4a4252f62)) -* Change towards single version ([#82](https://github.com/dasch-swiss/dsp-meta/issues/82)) ([2f41c23](https://github.com/dasch-swiss/dsp-meta/commit/2f41c236d40792165255f3d21addf60d6c87424f)) -* **deps:** Bump assert_cmd from 2.0.15 to 2.0.16 ([#184](https://github.com/dasch-swiss/dsp-meta/issues/184)) ([b8dbfa5](https://github.com/dasch-swiss/dsp-meta/commit/b8dbfa5ca727e272fd8f6ac9bfe9dd5543aa62bf)) -* **deps:** Bump thiserror from 1.0.50 to 1.0.56 ([#109](https://github.com/dasch-swiss/dsp-meta/issues/109)) ([8c6ad74](https://github.com/dasch-swiss/dsp-meta/commit/8c6ad740fe228423ecc3fa07f265cbdf55dd1da8)) -* Force release 2.0.3 ([c622a06](https://github.com/dasch-swiss/dsp-meta/commit/c622a06c8f4e04d99d8f0b23cf46e7d2c0209805)) -* Force release 2.1.0 ([fc6a297](https://github.com/dasch-swiss/dsp-meta/commit/fc6a297805dda80e656ec923a0ccc37348813830)) -* Release 2.0.0 ([#154](https://github.com/dasch-swiss/dsp-meta/issues/154)) ([3d5d1ca](https://github.com/dasch-swiss/dsp-meta/commit/3d5d1ca63d85737ce21b3cd4c6eee0525f9146b0)) -* Release 2.0.0 ([#155](https://github.com/dasch-swiss/dsp-meta/issues/155)) ([fef0913](https://github.com/dasch-swiss/dsp-meta/commit/fef0913bfc2fd49c8057d31a4bad4a44ec1c5cc3)) -* Release main ([#163](https://github.com/dasch-swiss/dsp-meta/issues/163)) ([2cd272d](https://github.com/dasch-swiss/dsp-meta/commit/2cd272d02ab0c378dc661869f01cccca0a36ffdf)) -* Release main ([#164](https://github.com/dasch-swiss/dsp-meta/issues/164)) ([41b71e8](https://github.com/dasch-swiss/dsp-meta/commit/41b71e8d5e5a0a8703de0b154c3e8ae0f698b9d4)) -* Release main ([#75](https://github.com/dasch-swiss/dsp-meta/issues/75)) ([03cfae7](https://github.com/dasch-swiss/dsp-meta/commit/03cfae719eb5363677eacc7c9d488c014ea5ff3d)) -* Release main ([#83](https://github.com/dasch-swiss/dsp-meta/issues/83)) ([dae1280](https://github.com/dasch-swiss/dsp-meta/commit/dae12802411e6d4ec87d1c5016f788f0300c4e26)) - -## [0.1.0](https://github.com/dasch-swiss/dsp-meta/compare/dsp-domain-v0.1.4...dsp-domain-v0.1.0) (2024-07-31) - - -### Miscellaneous Chores - -* **dsp-domain:** Synchronize dsp-meta versions - -## [0.1.4](https://github.com/dasch-swiss/dsp-meta/compare/dsp-domain-v0.1.3...dsp-domain-v0.1.4) (2024-07-30) - - -### Features - -* Add and serve old frontend ([#92](https://github.com/dasch-swiss/dsp-meta/issues/92)) ([00fd892](https://github.com/dasch-swiss/dsp-meta/commit/00fd892d4d1553e29c274d83c6bdc06b0e249253)) -* Add draft json schema validation and serde model ([#144](https://github.com/dasch-swiss/dsp-meta/issues/144)) ([df7948b](https://github.com/dasch-swiss/dsp-meta/commit/df7948b1fc5a411f064dbaa9657875405a551706)) -* Add grant domain model and deserialization ([#121](https://github.com/dasch-swiss/dsp-meta/issues/121)) ([f4a6162](https://github.com/dasch-swiss/dsp-meta/commit/f4a61623b3b640f8a8b1bd85969ea01ab9b3b056)) -* Extend dataset domain model ([#85](https://github.com/dasch-swiss/dsp-meta/issues/85)) ([f564ff6](https://github.com/dasch-swiss/dsp-meta/commit/f564ff6a5dedd2a4a4e464c568b7acb2eba15033)) -* Extend dataset domain model and a bit of deserialization (ongoing) ([#113](https://github.com/dasch-swiss/dsp-meta/issues/113)) ([070a729](https://github.com/dasch-swiss/dsp-meta/commit/070a7290a65a266e8d9c7284b7af3733c64cd490)) -* Extend dataset domain model and deserialization (ongoing) ([#115](https://github.com/dasch-swiss/dsp-meta/issues/115)) ([4264c72](https://github.com/dasch-swiss/dsp-meta/commit/4264c721cd80c889175331263b591a94c999b465)) - -## [0.1.3](https://github.com/dasch-swiss/dsp-meta/compare/dsp-domain-v0.1.2...dsp-domain-v0.1.3) (2023-12-04) - - -### Features - -* **dsp-domain:** Add ontology domain model ([#61](https://github.com/dasch-swiss/dsp-meta/issues/61)) ([c80cd83](https://github.com/dasch-swiss/dsp-meta/commit/c80cd83a5b9b749a00c84a5da5a1b4af606dbdc9)) - -## [0.0.2](https://github.com/dasch-swiss/dsp-meta/compare/dsp-domain-v0.0.1...dsp-domain-v0.0.2) (2023-12-04) - - -### Features - -* **dsp-domain:** Add ontology domain model ([#61](https://github.com/dasch-swiss/dsp-meta/issues/61)) ([c80cd83](https://github.com/dasch-swiss/dsp-meta/commit/c80cd83a5b9b749a00c84a5da5a1b4af606dbdc9)) diff --git a/dsp-domain/Cargo.toml b/dsp-domain/Cargo.toml deleted file mode 100644 index 2de8eb77..00000000 --- a/dsp-domain/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "dsp-domain" -version = "2.2.0" -edition.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -documentation.workspace = true -readme.workspace = true -description.workspace = true -authors.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow.workspace = true -axum.workspace = true -axum-macros.workspace = true -clap.workspace = true -hcl-rs.workspace = true -hyper.workspace = true -log.workspace = true -serde.workspace = true -serde_json.workspace = true -tokio.workspace = true -tower.workspace = true -tower-http.workspace = true -tracing.workspace = true -tracing-subscriber.workspace = true -tracing-test.workspace = true -url.workspace = true -thiserror.workspace = true - -[dev-dependencies] -assert_cmd = "2.0.16" diff --git a/dsp-meta-cmd/CHANGELOG.md b/dsp-meta-cmd/CHANGELOG.md deleted file mode 100644 index cd242379..00000000 --- a/dsp-meta-cmd/CHANGELOG.md +++ /dev/null @@ -1,54 +0,0 @@ -# Changelog - - - - - -## [2.2.0](https://github.com/dasch-swiss/dsp-meta/compare/dsp-meta-cmd-v2.1.0...dsp-meta-cmd-v2.2.0) (2024-09-03) - - -### Maintenance - -* Force release 2.1.0 ([ba11ab5](https://github.com/dasch-swiss/dsp-meta/commit/ba11ab500b66e3d7d75c15c61a1819a6b5eaa167)) -* Force release 2.2.0 ([d5d098d](https://github.com/dasch-swiss/dsp-meta/commit/d5d098d24cb35ce7fdfc9100f11b49a2e4d86a19)) - -## [2.1.0](https://github.com/dasch-swiss/dsp-meta/compare/dsp-meta-cmd-v2.0.3...dsp-meta-cmd-v2.1.0) (2024-08-28) - - -### Enhancements - -* Add draft json schema validation and serde model ([#144](https://github.com/dasch-swiss/dsp-meta/issues/144)) ([df7948b](https://github.com/dasch-swiss/dsp-meta/commit/df7948b1fc5a411f064dbaa9657875405a551706)) -* Add robots.txt and sitemap.xml (DEV-3931) ([#152](https://github.com/dasch-swiss/dsp-meta/issues/152)) ([6dceb9e](https://github.com/dasch-swiss/dsp-meta/commit/6dceb9e32776f1678bfb10c144b87d1bba25c0ea)) -* Make service work with json (DEV-3930) ([#146](https://github.com/dasch-swiss/dsp-meta/issues/146)) ([184c710](https://github.com/dasch-swiss/dsp-meta/commit/184c71031595885389cd045375213b81ac09b00b)) - - -### Maintenance - -* Add version for each crate ([#162](https://github.com/dasch-swiss/dsp-meta/issues/162)) ([825a282](https://github.com/dasch-swiss/dsp-meta/commit/825a282bd0828eba40cec6e2038176bf0c6ab768)) -* Attempt to fix release-please ([#186](https://github.com/dasch-swiss/dsp-meta/issues/186)) ([ab7ca21](https://github.com/dasch-swiss/dsp-meta/commit/ab7ca21a31993c2f4e51447ce25232084771fcf8)) -* Bump axum to 0.7 ([#97](https://github.com/dasch-swiss/dsp-meta/issues/97)) ([a12d77b](https://github.com/dasch-swiss/dsp-meta/commit/a12d77b5f156afa9ba4adbbac58e040a4e7e5711)) -* Cleanup logging ([#94](https://github.com/dasch-swiss/dsp-meta/issues/94)) ([ff5f9d4](https://github.com/dasch-swiss/dsp-meta/commit/ff5f9d438e96aed9deb2e8d891e286217aa5d608)) -* Cleanup logging ([#95](https://github.com/dasch-swiss/dsp-meta/issues/95)) ([524cb33](https://github.com/dasch-swiss/dsp-meta/commit/524cb3307c3262171f00a5e02a7501c8a5769753)) -* Cleanup logging ([#96](https://github.com/dasch-swiss/dsp-meta/issues/96)) ([457da25](https://github.com/dasch-swiss/dsp-meta/commit/457da25c6c3a6b65cb7644d2abd33f53aef23508)) -* **deps:** Bump assert_cmd from 2.0.15 to 2.0.16 ([#184](https://github.com/dasch-swiss/dsp-meta/issues/184)) ([b8dbfa5](https://github.com/dasch-swiss/dsp-meta/commit/b8dbfa5ca727e272fd8f6ac9bfe9dd5543aa62bf)) -* Fix publishing of the docker image under multiple tags ([#89](https://github.com/dasch-swiss/dsp-meta/issues/89)) ([8b28c3f](https://github.com/dasch-swiss/dsp-meta/commit/8b28c3f584d3cdf81c41878e6cd45b1988018ec7)) -* Force release 2.0.3 ([c622a06](https://github.com/dasch-swiss/dsp-meta/commit/c622a06c8f4e04d99d8f0b23cf46e7d2c0209805)) -* Force release 2.1.0 ([fc6a297](https://github.com/dasch-swiss/dsp-meta/commit/fc6a297805dda80e656ec923a0ccc37348813830)) -* Release 2.0.0 ([#154](https://github.com/dasch-swiss/dsp-meta/issues/154)) ([3d5d1ca](https://github.com/dasch-swiss/dsp-meta/commit/3d5d1ca63d85737ce21b3cd4c6eee0525f9146b0)) -* Release 2.0.0 ([#155](https://github.com/dasch-swiss/dsp-meta/issues/155)) ([fef0913](https://github.com/dasch-swiss/dsp-meta/commit/fef0913bfc2fd49c8057d31a4bad4a44ec1c5cc3)) -* Release main ([#163](https://github.com/dasch-swiss/dsp-meta/issues/163)) ([2cd272d](https://github.com/dasch-swiss/dsp-meta/commit/2cd272d02ab0c378dc661869f01cccca0a36ffdf)) -* Release main ([#164](https://github.com/dasch-swiss/dsp-meta/issues/164)) ([41b71e8](https://github.com/dasch-swiss/dsp-meta/commit/41b71e8d5e5a0a8703de0b154c3e8ae0f698b9d4)) - -## [0.1.3](https://github.com/dasch-swiss/dsp-meta/compare/dsp-meta-cli-v0.1.2...dsp-meta-cli-v0.1.3) (2023-12-04) - - -### Miscellaneous Chores - -* **dsp-meta-cli:** Synchronize dsp-meta versions - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * dsp-meta bumped from 0.1.2 to 0.1.3 diff --git a/dsp-meta-cmd/Cargo.toml b/dsp-meta-cmd/Cargo.toml deleted file mode 100644 index ed67acfb..00000000 --- a/dsp-meta-cmd/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[package] -name = "dsp-meta-cmd" -version = "2.2.0" -edition.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -documentation.workspace = true -readme.workspace = true -description.workspace = true -authors.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -dsp-meta = { path = "../dsp-meta" } -anyhow.workspace = true -axum.workspace = true -axum-macros.workspace = true -clap.workspace = true -config.workspace = true -hcl-rs.workspace = true -hyper.workspace = true -log.workspace = true -pid1.workspace = true -serde.workspace = true -serde_json.workspace = true -tokio.workspace = true -tower.workspace = true -tower-http.workspace = true -tracing.workspace = true -tracing-subscriber.workspace = true -tracing-test.workspace = true -url.workspace = true - -[dev-dependencies] -assert_cmd = "2.0.16" - -[[bin]] -name = "dsp-meta-server" -path = "src/main-server.rs" - -[[bin]] -name = "dsp-meta-validator" -path = "src/main-validator.rs" diff --git a/dsp-meta/Cargo.toml b/dsp-meta/Cargo.toml deleted file mode 100644 index 8b781e62..00000000 --- a/dsp-meta/Cargo.toml +++ /dev/null @@ -1,47 +0,0 @@ -[package] -name = "dsp-meta" -version = "2.2.0" -edition.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -documentation.workspace = true -readme.workspace = true -description.workspace = true -authors.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow.workspace = true -axum.workspace = true -axum-macros.workspace = true -clap.workspace = true -config.workspace = true -hcl-rs.workspace = true -toml.workspace = true -http-body-util.workspace = true -hyper.workspace = true -log.workspace = true -serde.workspace = true -serde_with.workspace = true -serde_json.workspace = true -serde_yaml.workspace = true -nonempty.workspace = true -valico.workspace = true -regex.workspace = true -sophia = "0.8.0" -tokio.workspace = true -tower.workspace = true -tower-http.workspace = true -tracing.workspace = true -tracing-subscriber.workspace = true -tracing-test.workspace = true -url.workspace = true -thiserror.workspace = true -chrono.workspace = true - -[dev-dependencies] -assert_cmd = "2.0.16" -axum-test = "15.3.0" -fake = "2.9.2" From 2cb3f83fee352e3a2afd734d18bdb70ed5db6125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 11:55:34 +0200 Subject: [PATCH 09/12] update broken symlink --- docs/domain_model/schema-metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/domain_model/schema-metadata.json b/docs/domain_model/schema-metadata.json index f807c81d..5c52941d 120000 --- a/docs/domain_model/schema-metadata.json +++ b/docs/domain_model/schema-metadata.json @@ -1 +1 @@ -../../dsp-meta/resources/schema-metadata-final.json \ No newline at end of file +../../resources/schema-metadata-final.json \ No newline at end of file From 48098bb32cf309d8b184ea2fdc5941778c3188d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <seakayone@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:10:02 +0200 Subject: [PATCH 10/12] Update Cargo.toml Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1378ee00..20d3713f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ homepage = "https://github.com/dasch-swiss/dsp-meta" repository = "https://github.com/dasch-swiss/dsp-meta" documentation = "https://github.com/dasch-swiss/dsp-meta" readme = "README.md" -description = "DSP-META is a service that provides metadata for the Digital and Semantic Publishing Platform (DSP)." +description = "DSP-META is a service that provides metadata for the DaSCH Service Platform (DSP)." authors = ["DaSCH - Swiss National Data and Service Center for the Humanities"] [dependencies] From ba4d6280f808c0303b5e39246e1819961ba22857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <seakayone@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:11:21 +0200 Subject: [PATCH 11/12] Update Cargo.toml Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 20d3713f..b0a193fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dsp-meta" -version = "2.1.0" +version = "2.2.0" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/dasch-swiss/dsp-meta" From 70848d3c826820e0f19c0c4bc1785ecaf33558b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= <christian.kleinboelting@dasch.swiss> Date: Tue, 3 Sep 2024 13:13:36 +0200 Subject: [PATCH 12/12] update Cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 9d6b63b3..2a84a372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -628,7 +628,7 @@ checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dsp-meta" -version = "2.1.0" +version = "2.2.0" dependencies = [ "anyhow", "assert_cmd",