.
This commit is contained in:
+25
-24
@@ -1,7 +1,7 @@
|
||||
use crate::rdf::ontology::{LabeledIri, Ontology};
|
||||
use crate::rdf::term_helper::{TermHelper, TermHelperMut};
|
||||
use crate::rdf::vocab::{gl, rda};
|
||||
use gl_search::{Schema, SearchDocument, SearchIndex, doc, NamedFieldDocument, OwnedValue};
|
||||
use gl_search::{Schema, SearchDocument, SearchIndex, NamedFieldDocument, OwnedValue, doc};
|
||||
use http::StatusCode;
|
||||
use iced::alignment::Horizontal;
|
||||
use iced::widget::button::Style;
|
||||
@@ -18,8 +18,8 @@ use ldp::traverse::Traverse;
|
||||
use ldp::{RdfSource, RdfSourceUpdateResponse, ResourceRequestBuilder, SerializationOptions};
|
||||
use oxigraph::io::RdfFormat;
|
||||
use oxigraph::model::vocab::{rdf, rdfs};
|
||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, NamedNodeRef, Quad, Term, TermRef};
|
||||
use tracing::{debug, error, info};
|
||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, Quad, Term, TermRef};
|
||||
use tracing::{debug, error, info, info_span, span, Level};
|
||||
use crate::widget::iri_input::iri_input;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -95,40 +95,41 @@ pub(crate) struct Publisher {
|
||||
|
||||
impl Publisher {
|
||||
pub(crate) fn new() -> (Self, Task<Message>) {
|
||||
let ontology = Ontology::builder()
|
||||
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/ontology")
|
||||
.build()
|
||||
.expect("Failed to build ontology");
|
||||
let ontology = info_span!("Ontology Creation").in_scope(|| {
|
||||
Ontology::builder()
|
||||
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/ontology")
|
||||
.build()
|
||||
.expect("Failed to build ontology")
|
||||
});
|
||||
|
||||
let mut index = SearchIndex::builder()
|
||||
.with_path("/home/alex/Documents/Index")
|
||||
.build()
|
||||
.expect("Failed to build search index");
|
||||
let index = info_span!("Ontology Indexing").in_scope(|| {
|
||||
let mut index = SearchIndex::builder()
|
||||
//.with_path("/home/alex/.local/share/org.graphofliberty.desktop/index")
|
||||
.build()
|
||||
.expect("Failed to build search index");
|
||||
|
||||
if let Some(id) = ontology.catalog_id(&rdf::PROPERTY.into_owned()) { index.remove_all_of_type(id); }
|
||||
if let Some(id) = ontology.catalog_id(&rdfs::CLASS.into_owned()) { index.remove_all_of_type(id); }
|
||||
if let Some(id) = ontology.catalog_id(&rdf::PROPERTY.into_owned()) { index.remove_all_of_type(id); }
|
||||
if let Some(id) = ontology.catalog_id(&rdfs::CLASS.into_owned()) { index.remove_all_of_type(id); }
|
||||
|
||||
/*for (iri, info) in ontology.iri_info() {
|
||||
if let Some(type_) = ontology.catalog_id(&info.type_) {
|
||||
for (iri, entity) in ontology.entities() {
|
||||
let mut document = doc!(
|
||||
Schema::type_field() => type_,
|
||||
Schema::type_field() => entity.catalog_id,
|
||||
Schema::iri_field() => iri.as_str(),
|
||||
);
|
||||
|
||||
if let Some(label) = &info.label &&
|
||||
let Some(field) = ontology.field_for_property(&rdfs::LABEL.into_owned()) {
|
||||
document.add_text(Schema::field(&field.name), label);
|
||||
if let Some(field) = ontology.field_for_property(&rdfs::LABEL.into_owned()) {
|
||||
document.add_text(Schema::field(&field.name), &entity.label);
|
||||
}
|
||||
|
||||
if let Some(comment) = &info.comment &&
|
||||
let Some(field) = ontology.field_for_property(&rdfs::COMMENT.into_owned()) {
|
||||
document.add_text(Schema::field(&field.name), comment);
|
||||
if let Some(field) = ontology.field_for_property(&rdfs::COMMENT.into_owned()) {
|
||||
document.add_text(Schema::field(&field.name), entity.comment.clone().unwrap_or(String::from("")));
|
||||
}
|
||||
|
||||
index.add(document).expect("Unable to add annotated IRI to search index");
|
||||
}
|
||||
}
|
||||
index.commit().expect("Unable to commit ontology to index");*/
|
||||
index.commit().expect("Unable to commit ontology to index");
|
||||
index
|
||||
});
|
||||
|
||||
let mut abbreviated_datatypes = ontology
|
||||
.datatypes()
|
||||
|
||||
Reference in New Issue
Block a user