WIP JSON patch > SPARQL

refactor
Laurin Weger 2 days ago
parent 197e010034
commit 318fcf5624
No known key found for this signature in database
GPG Key ID: 9B372BB0B792770F
  1. 18
      engine/net/src/orm.rs
  2. 10
      engine/verifier/src/orm/add_remove_triples.rs
  3. 225
      engine/verifier/src/orm/handle_frontend_update.rs
  4. 2
      engine/verifier/src/orm/materialize.rs
  5. 29
      engine/verifier/src/orm/query.rs
  6. 12
      engine/verifier/src/orm/shape_validation.rs
  7. 50
      engine/verifier/src/orm/utils.rs
  8. 88
      sdk/rust/src/tests/orm_creation.rs
  9. 38
      sdk/rust/src/tests/orm_patches.rs

@ -24,7 +24,7 @@ pub struct OrmShapeType {
}
/* == Diff Types == */
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[allow(non_camel_case_types)]
pub enum OrmDiffOpType {
add,
@ -66,7 +66,7 @@ pub struct OrmSchemaShape {
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[allow(non_camel_case_types)]
pub enum OrmSchemaLiteralType {
pub enum OrmSchemaValType {
number,
string,
boolean,
@ -85,7 +85,7 @@ pub enum BasicType {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct OrmSchemaDataType {
pub valType: OrmSchemaLiteralType,
pub valType: OrmSchemaValType,
pub literals: Option<Vec<BasicType>>,
pub shape: Option<String>,
}
@ -100,13 +100,23 @@ pub struct OrmSchemaPredicate {
pub minCardinality: i32,
pub extra: Option<bool>,
}
impl OrmSchemaPredicate {
pub fn is_multi(&self) -> bool {
self.maxCardinality > 1 || self.maxCardinality == -1
}
pub fn is_object(&self) -> bool {
self.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaValType::shape)
}
}
impl Default for OrmSchemaDataType {
fn default() -> Self {
Self {
literals: None,
shape: None,
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
}
}
}

@ -109,7 +109,7 @@ pub fn add_remove_triples(
.schema
.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaLiteralType::literal)
.any(|dt| dt.valType == OrmSchemaValType::literal)
{
match &mut tracked_predicate.current_literals {
Some(lits) => lits.push(obj_term.clone()),
@ -122,7 +122,7 @@ pub fn add_remove_triples(
// If predicate is of type shape, register
// "parent (predicate) -> child subject" and `child_subject.parents`.
for shape_iri in predicate_schema.dataTypes.iter().filter_map(|dt| {
if dt.valType == OrmSchemaLiteralType::shape {
if dt.valType == OrmSchemaValType::shape {
dt.shape.clone()
} else {
None
@ -200,7 +200,7 @@ pub fn add_remove_triples(
.schema
.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaLiteralType::literal)
.any(|dt| dt.valType == OrmSchemaValType::literal)
{
if let Some(current_literals) = &mut tracked_predicate.current_literals {
// Remove obj_val from current_literals in-place
@ -212,7 +212,7 @@ pub fn add_remove_triples(
.schema
.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaLiteralType::shape)
.any(|dt| dt.valType == OrmSchemaValType::shape)
{
// Remove parent from child and child from tracked children.
// If predicate is of type shape, register (parent -> child) links so that
@ -222,7 +222,7 @@ pub fn add_remove_triples(
.dataTypes
.iter()
.filter_map(|dt| {
if dt.valType == OrmSchemaLiteralType::shape {
if dt.valType == OrmSchemaValType::shape {
dt.shape.clone()
} else {
None

@ -7,9 +7,13 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
use ng_net::orm::{OrmDiffOp, OrmDiffOpType, OrmDiffType, OrmSchemaPredicate, OrmSchemaShape};
use ng_oxigraph::oxrdf::Quad;
use ng_repo::errors::VerifierError;
use std::cmp::Ordering;
use std::fmt::format;
use std::sync::{Arc, RwLock};
use std::u64;
use futures::SinkExt;
@ -18,6 +22,7 @@ pub use ng_net::orm::{OrmDiff, OrmShapeType};
use ng_repo::log::*;
use crate::orm::types::*;
use crate::orm::utils::{decode_json_pointer, json_to_sparql_val};
use crate::verifier::*;
impl Verifier {
@ -73,11 +78,10 @@ impl Verifier {
let (doc_nuri, sparql_update) = {
let orm_subscription =
self.get_first_orm_subscription_for(scope, Some(&shape_iri), Some(&session_id));
let doc_nuri = orm_subscription.nuri.clone();
let sparql_update = create_sparql_update_query_for_diff(orm_subscription, diff);
// use orm_subscription as needed
// do the magic, then, find the doc where the query should start and generate the sparql update
let doc_nuri = NuriV0::new_empty();
let sparql_update: String = String::new();
(doc_nuri, sparql_update)
};
@ -113,3 +117,216 @@ impl Verifier {
}
}
}
fn create_sparql_update_query_for_diff(
orm_subscription: &OrmSubscription,
diff: OrmDiff,
) -> String {
// First sort patches.
// - Process delete patches first.
// - Process object creation add operations before rest, to ensure potential blank nodes are created.
let mut delete_patches: Vec<_> = diff
.iter()
.filter(|patch| patch.op == OrmDiffOpType::remove)
.collect();
let mut add_patches: Vec<_> = diff
.iter()
.filter(|patch| patch.op == OrmDiffOpType::add)
.collect();
// Put Object creations first and...
add_patches.sort_by(|patch1, patch2| match patch1.valType {
Some(OrmDiffType::object) => Ordering::Less,
_ => Ordering::Equal,
});
// ...shorter paths first
add_patches.sort_by(|patch1, patch2| {
patch1
.path
.split("/")
.count()
.cmp(&patch2.path.split("/").count())
});
// Use a counter to generate unique variable names.
fn get_new_var_name(counter: &mut i32) -> String {
let name = format!("v{}", counter);
*counter += 1;
name
}
// For each diff op, we create a separate INSERT or DELETE block.
let sparql_sub_queries: Vec<String> = vec![];
// Create delete statements.
let delete_statements: Vec<String> = vec![]; // The parts in the Delete block.
for del_patch in delete_patches.iter() {
let mut var_counter: i32 = 0;
let (where_statements, target) =
create_where_statements_for_patch(&del_patch, &mut var_counter, &orm_subscription);
let (subject_var, target_predicate, target_object) = target;
let delete_statement;
if let Some(target_object) = target_object {
delete_statement = format!(
" {} <{}> <{}> .",
subject_var, target_predicate, target_object
)
} else {
let delete_val = match del_patch.value {
None => {
let val = format!("?{}", var_counter);
var_counter += 1;
val
}
Some(val) => json_to_sparql_val(&val),
};
delete_statement = format!(" {} <{}> {} .", subject_var, target_predicate, delete_val)
}
sparql_sub_queries.push(format!(
"DELETE DATA {{\n{}\nWHERE\n{{\n{}\n}}",
delete_statement,
where_statements.join("\n ")
));
}
return "None";
}
fn get_tracked_subject_from_diff_op(
subject_iri: &String,
orm_subscription: &OrmSubscription,
) -> Arc<RwLock<OrmTrackedSubject>> {
let tracked_subject = orm_subscription
.tracked_subjects
.get(subject_iri)
.unwrap()
.get(&orm_subscription.shape_type.shape)
.unwrap();
return tracked_subject.clone();
}
/// Removes the current predicate from the path stack and returns the corresponding IRI.
/// If the
fn find_pred_schema_by_name(
readable_predicate: &String,
subject_schema: &OrmSchemaShape,
) -> Arc<ng_net::orm::OrmSchemaPredicate> {
// Find predicate by readable name in subject schema.
for pred_schema in subject_schema.predicates.iter() {
if pred_schema.readablePredicate == *readable_predicate {
return pred_schema.clone();
}
}
panic!("No predicate found in schema for name");
}
/// Creates sparql WHERE statements to navigate to the JSON pointer path in our ORM mapping.
/// Returns the statements as Vec<String>
/// and the subject, predicate, Option<Object> of the path's ending (to be used for DELETE / DELETE).
fn create_where_statements_for_patch(
patch: &OrmDiffOp,
var_counter: &mut i32,
orm_subscription: &OrmSubscription,
) -> (Vec<String>, (String, String, Option<String>)) {
let mut body_statements: Vec<String> = vec![];
let mut where_statements: Vec<String> = vec![];
let mut path: Vec<String> = patch
.path
.split("/")
.map(|s| decode_json_pointer(&s.to_string()))
.collect();
// Handle special case: The whole object is deleted.
if path.len() == 0 {
let mut root_iri = path.remove(0);
body_statements.push(format!("<{}> ?p ?o .", root_iri));
where_statements.push(format!("<{}> ?p ?o .", root_iri));
}
let mut subj_schema: &Arc<OrmSchemaShape> = orm_subscription
.shape_type
.schema
.get(&orm_subscription.shape_type.shape)
.unwrap();
let mut current_subj_schema: Arc<OrmSchemaShape> = subj_schema.clone();
// The root IRI might change, if the parent path segment was an IRI.
let root_iri = path.remove(0);
let mut subject_ref = format!("<{}>", root_iri);
while path.len() > 0 {
let pred_name = path.remove(0);
let pred_schema = find_pred_schema_by_name(&pred_name, &current_subj_schema);
where_statements.push(format!(
"{} <{}> ?o{} .",
subject_ref, pred_schema.iri, var_counter,
));
subject_ref = format!("?o{}", var_counter);
*var_counter = *var_counter + 1;
if pred_schema.is_multi() && pred_schema.is_object() {
let object_iri = path.remove(0);
// Path ends on an object IRI, which we return here as well.
if path.len() == 0 {
return (
where_statements,
(subject_ref, pred_schema.iri.clone(), Some(object_iri)),
);
}
current_subj_schema =
get_first_valid_subject_schema(&object_iri, &pred_schema, &orm_subscription);
// Since we have new IRI that we can use as root, we replace the current one with it.
subject_ref = format!("<{object_iri}>");
// And can clear all now unnecessary where statements.
where_statements.clear();
}
if path.len() == 0 {
return (
where_statements,
(subject_ref, pred_schema.iri.clone(), None),
);
}
}
// Can't happen.
panic!();
}
fn get_first_valid_subject_schema(
subject_iri: &String,
pred_schema: &OrmSchemaPredicate,
orm_subscription: &OrmSubscription,
) -> Arc<OrmSchemaShape> {
for data_type in pred_schema.dataTypes.iter() {
let Some(schema_shape) = data_type.shape.as_ref() else {
continue;
};
let tracked_subject = orm_subscription
.tracked_subjects
.get(subject_iri)
.unwrap()
.get(schema_shape)
.unwrap();
if tracked_subject.read().unwrap().valid == OrmTrackedSubjectValidity::Valid {
return orm_subscription
.shape_type
.schema
.get(schema_shape)
.unwrap()
.clone();
}
}
// TODO: Panicking might be too aggressive.
panic!();
}

@ -161,7 +161,7 @@ pub(crate) fn materialize_orm_object(
if pred_schema
.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaLiteralType::shape)
.any(|dt| dt.valType == OrmSchemaValType::shape)
{
// We have a nested type.

@ -7,15 +7,14 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
use lazy_static::lazy_static;
use ng_repo::errors::VerifierError;
use regex::Regex;
use std::collections::HashSet;
pub use ng_net::orm::{OrmDiff, OrmShapeType};
use crate::orm::types::*;
use crate::orm::utils::{escape_literal, is_iri};
use crate::verifier::*;
use ng_net::orm::*;
use ng_oxigraph::oxigraph::sparql::{Query, QueryResults};
@ -67,15 +66,6 @@ impl Verifier {
}
}
/// Heuristic:
/// Consider a string an IRI if it contains alphanumeric characters and then a colon within the first 13 characters
pub fn is_iri(s: &str) -> bool {
lazy_static! {
static ref IRI_REGEX: Regex = Regex::new(r"^[A-Za-z][A-Za-z0-9+\.\-]{1,12}:").unwrap();
}
IRI_REGEX.is_match(s)
}
pub fn literal_to_sparql_str(var: OrmSchemaDataType) -> Vec<String> {
match var.literals {
None => [].to_vec(),
@ -155,7 +145,7 @@ pub fn shape_type_to_sparql(
// Predicate constraints might have more than one acceptable nested shape. Traverse each.
for datatype in &predicate.dataTypes {
if datatype.valType == OrmSchemaLiteralType::shape {
if datatype.valType == OrmSchemaValType::shape {
let shape_iri = &datatype.shape.clone().unwrap();
let nested_shape = schema.get(shape_iri).unwrap();
@ -305,18 +295,3 @@ pub fn shape_type_to_sparql(
construct_body, where_body
))
}
/// SPARQL literal escape: backslash, quotes, newlines, tabs.
fn escape_literal(lit: &str) -> String {
let mut out = String::with_capacity(lit.len() + 4);
for c in lit.chars() {
match c {
'\\' => out.push_str("\\\\"),
'\"' => out.push_str("\\\""),
'\n' => out.push_str("\\n"),
'\r' => out.push_str("\\r"),
'\t' => out.push_str("\\t"),
_ => out.push(c),
}
}
return out;
}

@ -154,7 +154,7 @@ impl Verifier {
} else if p_schema
.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaLiteralType::literal)
.any(|dt| dt.valType == OrmSchemaValType::literal)
{
// If we have literals, check if all required literals are present.
// At least one datatype must match.
@ -198,7 +198,7 @@ impl Verifier {
} else if p_schema
.dataTypes
.iter()
.any(|dt| dt.valType == OrmSchemaLiteralType::shape)
.any(|dt| dt.valType == OrmSchemaValType::shape)
{
// If we have a nested shape, we need to check if the nested objects are tracked and valid.
let tracked_children = tracked_pred.as_ref().map(|tp| {
@ -309,19 +309,19 @@ impl Verifier {
// Check 3.5) Data types correct.
} else {
// Check if the data type is correct.
let allowed_types: Vec<&OrmSchemaLiteralType> =
let allowed_types: Vec<&OrmSchemaValType> =
p_schema.dataTypes.iter().map(|dt| &dt.valType).collect();
// For each new value, check that data type is in allowed_types.
for val_added in p_change.iter().map(|pc| &pc.values_added).flatten() {
let matches = match val_added {
BasicType::Bool(_) => allowed_types
.iter()
.any(|t| **t == OrmSchemaLiteralType::boolean),
.any(|t| **t == OrmSchemaValType::boolean),
BasicType::Num(_) => allowed_types
.iter()
.any(|t| **t == OrmSchemaLiteralType::number),
.any(|t| **t == OrmSchemaValType::number),
BasicType::Str(_) => allowed_types.iter().any(|t| {
**t == OrmSchemaLiteralType::string || **t == OrmSchemaLiteralType::iri
**t == OrmSchemaValType::string || **t == OrmSchemaValType::iri
}),
};
if !matches {

@ -13,6 +13,9 @@ use ng_repo::types::OverlayId;
use std::collections::HashMap;
use std::collections::HashSet;
use lazy_static::lazy_static;
use regex::Regex;
pub use ng_net::orm::{OrmDiff, OrmShapeType};
use ng_net::{app_protocol::*, orm::*};
use ng_oxigraph::oxrdf::Triple;
@ -65,6 +68,51 @@ pub fn escape_json_pointer(path_segment: &String) -> String {
path_segment.replace("~", "~0").replace("/", "~1")
}
pub fn decode_join_pointer(path: &String) -> String {
pub fn decode_json_pointer(path: &String) -> String {
path.replace("~1", "/").replace("~0", "~")
}
/// SPARQL literal escape: backslash, quotes, newlines, tabs.
pub fn escape_literal(lit: &str) -> String {
let mut out = String::with_capacity(lit.len() + 4);
for c in lit.chars() {
match c {
'\\' => out.push_str("\\\\"),
'\"' => out.push_str("\\\""),
'\n' => out.push_str("\\n"),
'\r' => out.push_str("\\r"),
'\t' => out.push_str("\\t"),
_ => out.push(c),
}
}
return out;
}
pub fn json_to_sparql_val(json: &serde_json::Value) -> String {
match json {
serde_json::Value::Array(arr) => arr
.iter()
.map(|val| json_to_sparql_val(val))
.collect::<Vec<String>>()
.join(", "),
serde_json::Value::Bool(bool) => match bool {
true => "true".to_string(),
false => "false".to_string(),
},
serde_json::Value::Number(num) => num.to_string(),
serde_json::Value::String(str) => match is_iri(str) {
true => format!("<{}>", str),
false => format!("\"{}\"", str),
},
_ => panic!(),
}
}
/// Heuristic:
/// Consider a string an IRI if it contains alphanumeric characters and then a colon within the first 13 characters
pub fn is_iri(s: &str) -> bool {
lazy_static! {
static ref IRI_REGEX: Regex = Regex::new(r"^[A-Za-z][A-Za-z0-9+\.\-]{1,12}:").unwrap();
}
IRI_REGEX.is_match(s)
}

@ -13,8 +13,8 @@ use crate::tests::{assert_json_eq, create_doc_with_data};
use async_std::stream::StreamExt;
use ng_net::app_protocol::{AppResponse, AppResponseV0, NuriV0};
use ng_net::orm::{
BasicType, OrmSchema, OrmSchemaDataType, OrmSchemaLiteralType, OrmSchemaPredicate,
OrmSchemaShape, OrmShapeType,
BasicType, OrmSchema, OrmSchemaDataType, OrmSchemaPredicate, OrmSchemaShape, OrmSchemaValType,
OrmShapeType,
};
use ng_repo::log_info;
@ -304,7 +304,7 @@ INSERT DATA {
minCardinality: 0,
maxCardinality: -1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
shape: Some("http://example.org/Person".to_string()),
literals: None,
}],
@ -555,7 +555,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/TestObject".to_string(),
)]),
@ -566,7 +566,7 @@ INSERT DATA {
OrmSchemaPredicate {
iri: "http://example.org/arr".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -658,7 +658,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "opt".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::boolean,
valType: OrmSchemaValType::boolean,
literals: None,
shape: None,
}],
@ -741,7 +741,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "lit1".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("lit 1".to_string())]),
shape: None,
}],
@ -754,7 +754,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "lit2".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("lit 2".to_string())]),
shape: None,
}],
@ -841,12 +841,12 @@ INSERT DATA {
readablePredicate: "strOrNum".to_string(),
dataTypes: vec![
OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
},
OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
},
@ -951,7 +951,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "str".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -964,7 +964,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "nestedWithExtra".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/NestedShapeWithExtra".to_string()),
}],
@ -977,7 +977,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "nestedWithoutExtra".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/NestedShapeWithoutExtra".to_string()),
}],
@ -999,7 +999,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -1012,7 +1012,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -1034,7 +1034,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -1047,7 +1047,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -1147,7 +1147,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "name".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -1160,7 +1160,7 @@ INSERT DATA {
minCardinality: 0,
readablePredicate: "knows".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/PersonShape".to_string()),
}],
@ -1293,7 +1293,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/Alice".to_string(),
)]),
@ -1309,12 +1309,12 @@ INSERT DATA {
readablePredicate: "knows".to_string(),
dataTypes: vec![
OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/BobShape".to_string()),
},
OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/ClaireShape".to_string()),
},
@ -1337,7 +1337,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("http://example.org/Bob".to_string())]),
shape: None,
}],
@ -1350,7 +1350,7 @@ INSERT DATA {
minCardinality: 0,
readablePredicate: "knows".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/ClaireShape".to_string()),
}],
@ -1371,7 +1371,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/Claire".to_string(),
)]),
@ -1471,7 +1471,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/Person".to_string(),
)]),
@ -1486,7 +1486,7 @@ INSERT DATA {
minCardinality: 0,
readablePredicate: "cats".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/CatShape".to_string()),
}],
@ -1507,7 +1507,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("http://example.org/Cat".to_string())]),
shape: None,
}],
@ -1574,7 +1574,7 @@ fn create_big_schema() -> OrmSchema {
predicates: vec![
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/TestObject".to_string(),
)]),
@ -1588,7 +1588,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -1600,7 +1600,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -1612,7 +1612,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::boolean,
valType: OrmSchemaValType::boolean,
literals: None,
shape: None,
}],
@ -1624,7 +1624,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -1636,7 +1636,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some(
"http://example.org/TestObject||http://example.org/objectValue"
@ -1651,7 +1651,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some(
"http://example.org/TestObject||http://example.org/anotherObject"
@ -1667,12 +1667,12 @@ fn create_big_schema() -> OrmSchema {
Arc::new(OrmSchemaPredicate {
dataTypes: vec![
OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
},
OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
},
@ -1686,12 +1686,12 @@ fn create_big_schema() -> OrmSchema {
Arc::new(OrmSchemaPredicate {
dataTypes: vec![
OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("lit1".to_string())]),
shape: None,
},
OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("lit2".to_string())]),
shape: None,
},
@ -1714,7 +1714,7 @@ fn create_big_schema() -> OrmSchema {
predicates: vec![
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -1726,7 +1726,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -1748,7 +1748,7 @@ fn create_big_schema() -> OrmSchema {
predicates: vec![
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -1760,7 +1760,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -1772,7 +1772,7 @@ fn create_big_schema() -> OrmSchema {
}),
Arc::new(OrmSchemaPredicate {
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],

@ -13,7 +13,7 @@ use crate::tests::{assert_json_eq, create_doc_with_data};
use async_std::stream::StreamExt;
use ng_net::app_protocol::{AppResponse, AppResponseV0, NuriV0};
use ng_net::orm::{
BasicType, OrmSchemaDataType, OrmSchemaLiteralType, OrmSchemaPredicate, OrmSchemaShape,
BasicType, OrmSchemaDataType, OrmSchemaValType, OrmSchemaPredicate, OrmSchemaShape,
OrmShapeType,
};
@ -92,7 +92,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/TestObject".to_string(),
)]),
@ -103,7 +103,7 @@ INSERT DATA {
OrmSchemaPredicate {
iri: "http://example.org/arr".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -267,7 +267,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/TestObject".to_string(),
)]),
@ -278,7 +278,7 @@ INSERT DATA {
OrmSchemaPredicate {
iri: "http://example.org/arr".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::number,
valType: OrmSchemaValType::number,
literals: None,
shape: None,
}],
@ -404,12 +404,12 @@ INSERT DATA {
readablePredicate: "multiNest".to_string(),
dataTypes: vec![
OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/MultiNestShape1".to_string()),
},
OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/MultiNestShape2".to_string()),
},
@ -423,7 +423,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "singleNest".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/SingleNestShape".to_string()),
}],
@ -444,7 +444,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -464,7 +464,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -484,7 +484,7 @@ INSERT DATA {
maxCardinality: 1,
minCardinality: 1,
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -652,7 +652,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/House".to_string(),
)]),
@ -667,7 +667,7 @@ INSERT DATA {
minCardinality: 0,
readablePredicate: "rootColor".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -680,7 +680,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "inhabitants".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/PersonShape".to_string()),
}],
@ -704,7 +704,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str(
"http://example.org/Person".to_string(),
)]),
@ -719,7 +719,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "name".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],
@ -732,7 +732,7 @@ INSERT DATA {
minCardinality: 0,
readablePredicate: "cat".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::shape,
valType: OrmSchemaValType::shape,
literals: None,
shape: Some("http://example.org/CatShape".to_string()),
}],
@ -756,7 +756,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "type".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::literal,
valType: OrmSchemaValType::literal,
literals: Some(vec![BasicType::Str("http://example.org/Cat".to_string())]),
shape: None,
}],
@ -769,7 +769,7 @@ INSERT DATA {
minCardinality: 1,
readablePredicate: "name".to_string(),
dataTypes: vec![OrmSchemaDataType {
valType: OrmSchemaLiteralType::string,
valType: OrmSchemaValType::string,
literals: None,
shape: None,
}],

Loading…
Cancel
Save