.
This commit is contained in:
+74
-1
@@ -1,6 +1,12 @@
|
||||
use oxigraph::model::NamedNodeRef;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use oxigraph::model::{NamedNode, NamedNodeRef};
|
||||
use oxilangtag::LanguageTag;
|
||||
use gl_search::Schema;
|
||||
use crate::language::LanguageCondition;
|
||||
use crate::vocab;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Class {
|
||||
RdfProperty = 0,
|
||||
RdfsClass = 1,
|
||||
@@ -12,7 +18,33 @@ pub enum Class {
|
||||
Manifestation = 10007,
|
||||
}
|
||||
|
||||
impl Display for Class {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Class::RdfProperty => f.write_str("RDF Property"),
|
||||
Class::RdfsClass => f.write_str("RDFS Class"),
|
||||
Class::SkosConcept => f.write_str("SKOS Concept"),
|
||||
Class::Work => f.write_str("Work"),
|
||||
Class::Person => f.write_str("Person"),
|
||||
Class::CorporateBody => f.write_str("Corporate Body"),
|
||||
Class::Expression => f.write_str("Expression"),
|
||||
Class::Manifestation => f.write_str("Manifestation"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Class {
|
||||
pub const ALL: &[Class] = &[
|
||||
Class::RdfProperty,
|
||||
Class::RdfsClass,
|
||||
Class::SkosConcept,
|
||||
Class::Work,
|
||||
Class::Person,
|
||||
Class::CorporateBody,
|
||||
Class::Expression,
|
||||
Class::Manifestation,
|
||||
];
|
||||
|
||||
pub fn to_named_node(&self) -> NamedNodeRef<'_> {
|
||||
match self {
|
||||
Class::RdfProperty => vocab::rdf::PROPERTY,
|
||||
@@ -40,4 +72,45 @@ impl Class {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fields(&self, language: LanguageTag<&str>) -> Vec<(gl_search::Field, String)> {
|
||||
match self {
|
||||
Class::RdfProperty => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("label", Some(language.primary_language())), String::from("Label")),
|
||||
(Schema::field("definition", Some(language.primary_language())), String::from("Definition")),
|
||||
],
|
||||
Class::RdfsClass => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("label", Some(language.primary_language())), String::from("Label")),
|
||||
(Schema::field("definition", Some(language.primary_language())), String::from("Definition")),
|
||||
],
|
||||
Class::SkosConcept => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("label", Some(language.primary_language())), String::from("Label")),
|
||||
(Schema::field("definition", Some(language.primary_language())), String::from("Definition")),
|
||||
],
|
||||
Class::Work => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("title", Some(language.primary_language())), String::from("Title")),
|
||||
],
|
||||
Class::Person => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("given_name", Some(language.primary_language())), String::from("Given Name")),
|
||||
(Schema::field("surname", Some(language.primary_language())), String::from("Surname")),
|
||||
],
|
||||
Class::CorporateBody => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("corporate_body", Some(language.primary_language())), String::from("Corporate Body")),
|
||||
],
|
||||
Class::Expression => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("title", Some(language.primary_language())), String::from("Title")),
|
||||
],
|
||||
Class::Manifestation => vec![
|
||||
(Schema::curie_field(), String::from("CURIE")),
|
||||
(Schema::field("title", Some(language.primary_language())), String::from("Title")),
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user