Chris@0
|
1 /* This file is part of ClioPatria.
|
Chris@0
|
2
|
Chris@0
|
3 Author:
|
Chris@0
|
4 HTTP: http://e-culture.multimedian.nl/
|
Chris@0
|
5 GITWEB: http://gollem.science.uva.nl/git/ClioPatria.git
|
Chris@0
|
6 GIT: git://gollem.science.uva.nl/home/git/ClioPatria.git
|
Chris@0
|
7 GIT: http://gollem.science.uva.nl/home/git/ClioPatria.git
|
Chris@0
|
8 Copyright: 2007, E-Culture/MultimediaN
|
Chris@0
|
9
|
Chris@0
|
10 ClioPatria is free software: you can redistribute it and/or modify
|
Chris@0
|
11 it under the terms of the GNU General Public License as published by
|
Chris@0
|
12 the Free Software Foundation, either version 2 of the License, or
|
Chris@0
|
13 (at your option) any later version.
|
Chris@0
|
14
|
Chris@0
|
15 ClioPatria is distributed in the hope that it will be useful,
|
Chris@0
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
18 GNU General Public License for more details.
|
Chris@0
|
19
|
Chris@0
|
20 You should have received a copy of the GNU General Public License
|
Chris@0
|
21 along with ClioPatria. If not, see <http://www.gnu.org/licenses/>.
|
Chris@0
|
22 */
|
Chris@0
|
23
|
Chris@0
|
24 :- module(serql_parms,
|
Chris@0
|
25 [ serql_setting/3
|
Chris@0
|
26 ]).
|
Chris@0
|
27 :- use_module(library(settings)).
|
Chris@0
|
28 :- use_module(library(error)).
|
Chris@0
|
29 :- use_module(library('semweb/rdf_db')).
|
Chris@0
|
30 :- use_module(library('http/html_write')).
|
Chris@0
|
31
|
Chris@0
|
32
|
Chris@0
|
33 /*******************************
|
Chris@0
|
34 * TYPES *
|
Chris@0
|
35 *******************************/
|
Chris@0
|
36
|
Chris@0
|
37 % make the type 'uri' work such that we can write NS:Local in
|
Chris@0
|
38 % settings defaults.
|
Chris@0
|
39
|
Chris@0
|
40 :- multifile
|
Chris@0
|
41 error:has_type/2,
|
Chris@0
|
42 settings:eval_default/3,
|
Chris@0
|
43 settings:convert_text/3,
|
Chris@0
|
44 http_settings:input_item/5.
|
Chris@0
|
45
|
Chris@0
|
46 error:has_type(uri, X) :- % URI is an atom. We do not use atom
|
Chris@0
|
47 atom(X). % to allow for conversion
|
Chris@0
|
48
|
Chris@0
|
49 % Convert NS:Local
|
Chris@0
|
50 settings:eval_default(URI, uri, URI) :-
|
Chris@0
|
51 atom(URI), !.
|
Chris@0
|
52 settings:eval_default(NS:Local, uri, URI) :-
|
Chris@0
|
53 rdf_global_id(NS:Local, URI).
|
Chris@0
|
54
|
Chris@0
|
55 settings:convert_text(uri, Text, URI) :- !,
|
Chris@0
|
56 ( sub_atom(Text, B, _, A, :),
|
Chris@0
|
57 sub_atom(Text, 0, B, _, NS),
|
Chris@0
|
58 sub_atom(Text, _, A, 0, Local),
|
Chris@0
|
59 identifier(NS),
|
Chris@0
|
60 identifier(Local)
|
Chris@0
|
61 -> rdf_global_id(NS:Local, URI)
|
Chris@0
|
62 ; URI = Text
|
Chris@0
|
63 ).
|
Chris@0
|
64
|
Chris@0
|
65 %% identifier(+Atom) is semidet.
|
Chris@0
|
66 %
|
Chris@0
|
67 % True if Atom contains only alphanumerical characters or
|
Chris@0
|
68 % undercores.
|
Chris@0
|
69 %
|
Chris@0
|
70 % @tbd Must we support unicode here? Check with Turtle.
|
Chris@0
|
71
|
Chris@0
|
72 identifier(Text) :-
|
Chris@0
|
73 atom_codes(Text, Codes),
|
Chris@0
|
74 identifier_codes(Codes).
|
Chris@0
|
75
|
Chris@0
|
76 identifier_codes([]).
|
Chris@0
|
77 identifier_codes([H|T]) :-
|
Chris@0
|
78 identifier_code(H),
|
Chris@0
|
79 identifier_codes(T).
|
Chris@0
|
80
|
Chris@0
|
81 identifier_code(C) :-
|
Chris@0
|
82 code_type(C, csym).
|
Chris@0
|
83
|
Chris@0
|
84 % Render as plain atom
|
Chris@0
|
85 http_settings:input_item(uri, Value, Name) -->
|
Chris@0
|
86 html(input([name(Name), size(40), value(Value)])).
|
Chris@0
|
87
|
Chris@0
|
88
|
Chris@0
|
89 /*******************************
|
Chris@0
|
90 * SETTINGS *
|
Chris@0
|
91 *******************************/
|
Chris@0
|
92
|
Chris@0
|
93 %% serql_setting(+Name, -Old, +New)
|
Chris@0
|
94 %
|
Chris@0
|
95 % Change a setting. Not all settings are changeable without
|
Chris@0
|
96 % restarting the server.
|
Chris@0
|
97 %
|
Chris@0
|
98 % @tbd Handle setting broadcasts to update server statistics
|
Chris@0
|
99
|
Chris@0
|
100 serql_setting(Name, Old, New) :-
|
Chris@0
|
101 setting(Name, Old),
|
Chris@0
|
102 set_setting(Name, New).
|
Chris@0
|
103
|
Chris@0
|
104 /*******************************
|
Chris@0
|
105 * HTTP *
|
Chris@0
|
106 *******************************/
|
Chris@0
|
107
|
Chris@0
|
108 :- setting(http:port, nonneg, env('PORT', 2105),
|
Chris@0
|
109 'Port the http server listens to').
|
Chris@0
|
110 :- setting(http:workers, between(1, 20), env('SERQL_WORKERS', 2),
|
Chris@0
|
111 'Number of server threads').
|
Chris@0
|
112 :- setting(http:worker_options, list(any), [ local(50000),
|
Chris@0
|
113 global(50000),
|
Chris@0
|
114 trail(50000)
|
Chris@0
|
115 ],
|
Chris@0
|
116 'Additional options to pass to the HTTP server').
|
Chris@0
|
117 :- setting(http:max_idle_time, nonneg, 3600,
|
Chris@0
|
118 'Session timeout. If 0, session never times out').
|
Chris@0
|
119 :- setting(http:server_url, atom, 'http://localhost:'+setting(http:port),
|
Chris@0
|
120 'Url of the server itself').
|
Chris@0
|
121
|
Chris@0
|
122
|
Chris@0
|
123 /*******************************
|
Chris@0
|
124 * OTHER SETTINGS *
|
Chris@0
|
125 *******************************/
|
Chris@0
|
126
|
Chris@0
|
127 :- setting(user_data, atom, 'users.db',
|
Chris@0
|
128 'File holding account information').
|
Chris@0
|
129 :- setting(documentation_url, atom, 'http://www.openrdf.org/doc/users/',
|
Chris@0
|
130 'URL for OpenRDF documentation').
|
Chris@0
|
131 :- setting(serql_documentation_url, atom, 'http://www.openrdf.org/doc/sesame/users/ch06.html',
|
Chris@0
|
132 'URL for SeRQL language').
|
Chris@0
|
133 :- setting(default_entailment, atom, rdfs,
|
Chris@0
|
134 'Default entailment rules applied').
|
Chris@0
|
135 :- setting(optimise_query, boolean, true,
|
Chris@0
|
136 'Optimise queries before execution').
|
Chris@0
|
137 :- setting(rdf_db_namespaces, boolean, true,
|
Chris@0
|
138 'Allow registered namespaces in queries').
|
Chris@0
|
139 :- setting(title, atom, 'SWI-Prolog Semantic Web Server',
|
Chris@0
|
140 'Title of the web-page').
|
Chris@0
|
141 :- setting(persistent_store, atom, 'SeRQL-store',
|
Chris@0
|
142 'Directory for persistent copy of in-memory RDF').
|
Chris@0
|
143 :- setting(base_ontologies, list(any), [serql(rdfs)],
|
Chris@0
|
144 'Load these files into a virgin database').
|