-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
use crate::error::DspMetaError; | ||
|
||
impl From<sophia::iri::error::InvalidIri> for DspMetaError { | ||
fn from(error: sophia::iri::error::InvalidIri) -> Self { | ||
impl From<sophia::iri::InvalidIri> for DspMetaError { | ||
fn from(error: sophia::iri::InvalidIri) -> Self { | ||
DspMetaError::SerializeToRdf(error.0) | ||
} | ||
} | ||
|
||
impl From<sophia::term::TermError> for DspMetaError { | ||
fn from(error: sophia::term::TermError) -> Self { | ||
DspMetaError::SerializeToRdf(error.to_string()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
use dsp_domain::metadata::value::Shortcode; | ||
use sophia::graph::inmem::LightGraph; | ||
use sophia::graph::MutableGraph; | ||
use sophia::ns::Namespace; | ||
use sophia::term::literal::Literal; | ||
use sophia::term::SimpleIri; | ||
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: &SimpleIri) -> LightGraph { | ||
let mut graph: LightGraph = LightGraph::new(); | ||
|
||
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_property = SimpleIri::new_unchecked(dsp.as_ref(), Some("hasShortcode")); | ||
|
||
graph | ||
.insert( | ||
project_iri, | ||
&has_shortcode_property, | ||
&Literal::<String>::new_lang_unchecked(&self.0.as_string(), "en"), | ||
) | ||
.expect("insert of shortcode triples into graph failed."); | ||
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 | ||
} | ||
} |