Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating core ontology prefixes #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions swipl/client.pl
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
% build_DB_URI(+Server, +User, +DB, -DB_URI)
build_DB_URI(Server, User, DB, DB_URI) :-
(ends_with(Server, '/')
-> atomic_list_concat([Server, 'db/', User, '/', DB], DB_URI)
; atomic_list_concat([Server, '/db/', User, '/', DB], DB_URI)).
-> atomic_list_concat([Server, 'api/db/', User, '/', DB], DB_URI)
; atomic_list_concat([Server, '/api/db/', User, '/', DB], DB_URI)).


% build_DB_URI2(+Server, +DB, +EndPoint, -DB_URI)
build_DB_URI2(Server, DB, EndPoint, DB_URI) :-
atomic_list_concat([DB, '/', EndPoint], Path),
atomic_list_concat([DB, '/api/', EndPoint], Path),
build_DB_URI(Server, Path, DB_URI).


Expand All @@ -97,8 +97,8 @@
non_null('User', User),
non_null('Database', DB),
(ends_with(Server, '/')
-> atomic_list_concat([Server, 'woql/', User, '/', DB, '/local/branch/master'], Query_url)
; atomic_list_concat([Server, '/woql/', User, '/', DB, '/local/branch/master'], Query_url)).
-> atomic_list_concat([Server, 'api/woql/', User, '/', DB, '/local/branch/main'], Query_url)
; atomic_list_concat([Server, '/api/woql/', User, '/', DB, '/local/branch/main'], Query_url)).


% build_graph_URL(+Server, +User, +DB, +GType, +GId, -Graph_URI)
Expand All @@ -109,8 +109,8 @@
non_null('Graph type', GType),
non_null('Graph ID', GId),
(ends_with(Server, '/')
-> atomic_list_concat([Server, 'graph/', User, '/', DB, '/local/branch/master/schema/main'], Graph_URI)
; atomic_list_concat([Server, '/graph/', User, '/', DB, '/local/branch/master/schema/main'], Graph_URI)).
-> atomic_list_concat([Server, 'api/graph/', User, '/', DB, '/local/branch/main/schema/main'], Graph_URI)
; atomic_list_concat([Server, '/api/graph/', User, '/', DB, '/local/branch/main/schema/main'], Graph_URI)).



Expand Down Expand Up @@ -209,7 +209,8 @@
(var(Result)
-> true
; logging:fatal('\'connect\' requires an unbound argument..')),
dispatch(Cli, Cli.url, 'connect', {}, Result, ''),
atomic_list_concat([Cli.url, '/api'], URL),
dispatch(Cli, URL, 'connect', {}, Result, ''),
extract_context(Result, C),
A = Cli.ac, D = Cli.db, X = Cli.url, Y = Cli.user, Z = Cli.key.

Expand Down
48 changes: 24 additions & 24 deletions swipl/swoql.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
'Class': 'owl:Class',
'DatatypeProperty': 'owl:DatatypeProperty',
'ObjectProperty': 'owl:ObjectProperty',
'Entity': 'tcs:Entity',
'Document': 'tcs:Document',
'Relationship': 'tcs:Relationship',
'temporality': 'tcs:temporality',
'geotemporality': 'tcs:geotemporality',
'geography': 'tcs:geography',
'abstract': 'tcs:abstract',
'Entity': 'system:Entity',
'Document': 'system:Document',
'Relationship': 'system:Relationship',
'temporality': 'system:temporality',
'geotemporality': 'system:geotemporality',
'geography': 'system:geography',
'abstract': 'system:abstract',
'comment': 'rdfs:comment',
'range': 'rdfs:range',
'domain': 'rdfs:domain',
Expand Down Expand Up @@ -103,8 +103,8 @@
(begins_with_pattern_colon(S, rdfs);
begins_with_pattern_colon(S, rdf);
begins_with_pattern_colon(S, owl);
begins_with_pattern_colon(S, tcs);
begins_with_pattern_colon(S, terminus);
begins_with_pattern_colon(S, api);
begins_with_pattern_colon(S, system);
begins_with_pattern_colon(S, xsd);
begins_with_pattern_colon(S, xdd)).

Expand Down Expand Up @@ -867,7 +867,7 @@
start_scope(doc, DocName, DictIn, Dict1),
jsonise_scm(DocName, JDocName),
do_ask(and([add_quad(JDocName, 'rdf:type', 'owl:Class', 'schema/main'),
add_quad(JDocName, 'rdfs:subClassOf', 'terminus:Document', 'schema/main')]),
add_quad(JDocName, 'rdfs:subClassOf', 'system:Document', 'schema/main')]),
_, Dict1, Dict2),
do_ask(Qualifier, _, Dict2, DictOut).

Expand Down Expand Up @@ -1516,17 +1516,17 @@
-> true
; logging:fatal('\'result_success\' requires a bound argument..')),
result_to_dict(Result, Dict),
(is_dict(Dict)
-> (get_dict('terminus:status', Dict, Terminus_Result)
-> (Terminus_Result == "terminus:success" %NB: have to use string quotes here, not ''
-> true
; logging:info('\'terminus:status\' = \'~w\' in result ~w passed to \'result_success\'', [Terminus_Result, Result]),
false)
; (get_dict('terminus:agent_key_hash', Dict, _)
-> true % Call was actually a 'connect', and the result looks valid
; (get_dict('bindings', Dict, _)
-> logging:info('\'bindings\' received in result passed to \'result_success\': ~w', [Result])
; logging:info('Missing response in result passed to \'result_success\': ~w', [Result]),
false)))
; logging:info('\'result_success\' has a non-dict result: ~w', [Result]),
false).
( is_dict(Dict)
-> ( get_dict('api:status', Dict, Terminus_Result)
-> ( Terminus_Result == "api:success" %NB: have to use string quotes here, not ''
-> true
; logging:info('\'api:status\' = \'~w\' in result ~w passed to \'result_success\'', [Terminus_Result, Result]),
false)
; ( get_dict('@type', Dict, "system:User")
-> true % Call was actually a 'connect', and the result looks valid
; ( get_dict('bindings', Dict, _)
-> logging:info('\'bindings\' received in result passed to \'result_success\': ~w', [Result])
; logging:info('Missing response in result passed to \'result_success\': ~w', [Result]),
false)))
; logging:info('\'result_success\' has a non-dict result: ~w', [Result]),
false).
92 changes: 40 additions & 52 deletions swipl/test1.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,47 @@
key('root').
data_url('https://raw.githubusercontent.com/Chrisjhorn/terminusDB/master/python/jupyter-tutorials/tutorial2/people.csv').


check_terminus_error(Name, Key, Dict, Error, Offset) :-
get_dict(Key, Dict, ErrMsg),
string_length(Error, Len),
string_length(ErrMsg, Len1),
((Len1 >= Len, Len > 0)
-> sub_string(ErrMsg, Offset, Len, _, XXX),
atom_string(Error,E), atom_string(XXX,X),
(E == X
-> format('- ~w got expected exception -------------------------------------------------~n', Name),
true
; false)
; false)
; false.

terminus_message(Name, Dict, ErrType, ErrMsg) :-
ErrType == 'tm'
-> check_terminus_error(Name, 'terminus:message', Dict, ErrMsg, 0)
; false.

witness_message(Name, Arg, ErrType, ErrMsg) :-
ErrType == 'vi'
-> (is_dict(Arg)
-> (get_dict('terminus:witnesses', Arg, List)
-> [Dict2|_] = List,
is_dict(Dict2),
check_terminus_error(Name, 'vio:literal', Dict2, ErrMsg, 1)
; false)
; [Dict2|_] = Arg,
is_dict(Dict2),
(get_dict('vio:message', Dict2, Dict3)
-> check_terminus_error(Name, '@value', Dict3, ErrMsg, 0)
; false))
; false.

escape_pcre(String, Escaped) :-
re_replace('[-[\\]{}()*+?.,\\\\^$|#\\s]'/g, '\\\\0', String, Escaped).

check_terminus_error_(Key, Dict, Pattern) :-
get_dict(Key, Dict, ErrMsg),
re_match(Pattern, ErrMsg).

check_terminus_error(Name, Key, Dict, Error, 0) :-
atomic_list_concat(['^',Error,'.*'], Pattern),
check_terminus_error_(Key, Dict, Pattern),
format('- ~w got expected exception -------------------------------------------------~n', Name).

error_message(Name, Dict, tm, ErrMsg) :-
check_terminus_error(Name, 'api:message', Dict, ErrMsg, 0).
error_message(Name, Arg, vi, ErrMsg) :-
( is_dict(Arg)
-> get_dict('system:witnesses', Arg, List),
[Dict2|_] = List,
is_dict(Dict2),
check_terminus_error(Name, 'vio:literal', Dict2, ErrMsg, 1)
; [Dict2|_] = Arg,
is_dict(Dict2),
get_dict('vio:message', Dict2, Dict3),
check_terminus_error(Name, '@value', Dict3, ErrMsg, 0)
).

test(Name, Client, Query, Inserts, ErrType, Error, Result) :-
format('- ~w starting --------------------------------------------------------~n', Name),
logging:info('- ~w starting --------------------------------------------------~n', [Name]),
swoql:ask(Client,
Query,
Result),
(swoql:result_success(Result)
-> (swoql:result_check_statistic('inserts', Inserts, Result)
-> true
; logging:fatal('~w failed: expected ~w inserts~n', [Name, Inserts]))
; (swoql:result_to_dict(Result, Dict),
(terminus_message(Name, Dict, ErrType, Error)
-> true
; (witness_message(Name, Dict, ErrType, Error)
-> true
; format('witness_message failed...~n'),
logging:fatal('~w failed...~w', [Name, Result]))))),
( swoql:result_success(Result)
-> ( swoql:result_check_statistic('inserts', Inserts, Result)
-> true
; logging:fatal('~w failed: expected ~w inserts~n', [Name, Inserts]))
; ( swoql:result_to_dict(Result, Dict),
( error_message(Name, Dict, ErrType, Error)
-> true
; format('witness_message failed...~n'),
logging:fatal('~w failed...~w', [Name, Result])))),
format('- ~w Done ------------------------------------------------------------~n~n', Name),
logging:info('- ~w Done ------------------------------------------------------~n~n', [Name]).

Expand Down Expand Up @@ -144,10 +132,10 @@

test('Test-Q1', Client, quad('AAA', 'BBB', 'CCC', 'DDD'), 'vi', 'Unable to compile AST query'),

test('Test-AQ1', Client, add_quad('AAA', 'BBB', 'CCC', 'DDD'), 'vi', 'Unable to compile AST query'),
test('Test-AQ2', Client, add_quad('scm:PersonType', 'BBB', 'CCC', 'DDD'), 'vi', 'Unable to compile AST query'),
test('Test-AQ3', Client, add_quad('scm:PersonType', 'rdf:type', 'CCC', 'DDD'), 'vi', 'Unable to compile AST query'),
test('Test-AQ4', Client, add_quad('scm:PersonType', 'rdf:type', 'owl:Class', 'DDD'), 'vi', 'Unable to compile AST query'),
test('Test-AQ1', Client, add_quad('AAA', 'BBB', 'CCC', 'DDD'), 'tm', 'Badly formed ast after compilation with term'),
test('Test-AQ2', Client, add_quad('scm:PersonType', 'BBB', 'CCC', 'DDD'), 'tm', 'Badly formed ast after compilation with term'),
test('Test-AQ3', Client, add_quad('scm:PersonType', 'rdf:type', 'CCC', 'DDD'), 'tm', 'Badly formed ast after compilation with term'),
test('Test-AQ4', Client, add_quad('scm:PersonType', 'rdf:type', 'owl:Class', 'DDD'), 'tm', 'Badly formed ast after compilation with term'),
test('Test-AQ5', Client, add_quad('scm:PersonType', 'rdf:type', 'owl:Class', 'schema/main'), 1),

test('Test-And1', Client, and([triple('AAA', 'BBB', 'CCC')])),
Expand Down Expand Up @@ -282,8 +270,8 @@

test('Test-Concat1', Client, concat('Journey from v:Start_ID to v:End_ID at v:Start_Time', 'v:Journey_Label')),

test('Test-TypeCast1', Client, cast('v:Duration', v('Duration_Cast')^^integer), 'tm', 'Error: \'Variable unbound in typcast to'), % server spelling mistake!
test('Test-TypeCast2', Client, cast(v('Duration'), v('Duration_Cast')^^'xsd:integer'), 'tm', 'Error: \'Variable unbound in typcast to'),
test('Test-TypeCast1', Client, cast('v:Duration', v('Duration_Cast')^^integer), 'tm', 'Error: \'Variable unbound in typecast'), % server spelling mistake!
test('Test-TypeCast2', Client, cast(v('Duration'), v('Duration_Cast')^^'xsd:integer'), 'tm', 'Error: \'Variable unbound in typecast to'),

test('Test-Opt1', Client, opt(triple('AAA', 'BBB', 'CCC'))),

Expand Down