Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cogsys
Dare2Del
Demonstrator - Reasoning WebAPI
Commits
e3bc9095
Commit
e3bc9095
authored
Jun 14, 2021
by
Siebers, Michael
Browse files
move common types to type definitions file
parent
a17089b9
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/web_api/background.pl
View file @
e3bc9095
...
...
@@ -5,7 +5,10 @@
:-
use_module
(
src
/
theory_bg
).
% Error handling
:-
consult
(
error_handling
).
:-
ensure_loaded
(
error_handling
).
% Item definition
:-
ensure_loaded
(
type_defs
).
/**
...
...
@@ -65,25 +68,3 @@ all_items_external(Items) :-
all_items_external_
(
_Key
-
Value
,
Item
)
:-
is_dict
(
Value
,
Type
),
parse_type
(
Value
,
dict
([
type
:
atom
=
Type
]),
Item
,
[
extra_keys
(
add
)]).
%! item_type(-Type) is det.
%
% Generates the type definition for an item (that is a file or a directory). Type is a valid type as defined by types:check_type_def/1.
item_type
(
anyof
([
DirectoryType
,
FileType
]))
:-
abs_path_type
(
AbsPathType
),
CommonKeys
=
[
abs_path
:
AbsPathType
,
creation_time
:
integer
],
FileType
=
dict
([
type
:
atom
(
'^file$'
),
file_size
:
positive_integer
,
media_type
:
atom
,
filename_extension
:
atom
,
modification_time
:
integer
,
access_time
:
integer
,
change_time
:
integer
|
CommonKeys
]),
DirectoryType
=
dict
([
type
:
atom
(
'^directory$'
)|
CommonKeys
]).
src/web_api/irrelevance.pl
View file @
e3bc9095
:-
ensure_loaded
(
requests
).
:-
ensure_loaded
(
error_handling
).
:-
ensure_loaded
(
type_defs
).
:-
use_module
(
src
/
explanations
).
:-
multifile
user
:
irrelevant
/
1
.
...
...
@@ -9,7 +10,8 @@
% True if the item associated with the absolute path given in Parameters
% is irrelevant. The absolute path is accessed using the dict key `abs_path`.
% An error is thrown if the dict does not contain this key, if its value
% is not an atom or if the dict contains any other keys.
% is not an atom representing an absolute file path, or if the dict contains
% any other keys.
%
% @throws parse_error(Reason, Location) if Parameters cannot be parsed
% @error api_error(_, parameter_error) if the format of Parameters is erroneous,
...
...
@@ -17,7 +19,7 @@
% value read is unbound.
% @error api_error(_, implementation_error) if checking the irrelevance itself
% throws an exception.
do_handle_irrelevant_file
(
Parameters
,
AbsPath
)
:-
do_handle_irrelevant_file
(
Parameters
,
AbsPath
)
:-
abs_path_type
(
AbsPathType
),
parse_parameters
(
Parameters
,
dict
([
abs_path
:
AbsPathType
]),
...
...
@@ -67,8 +69,9 @@ do_handle_irrelevant_file(Parameters,AbsPath) :-
% any value read from Parameters is
% unbound, or Result or More are bound
do_handle_explain
(
Parameters
,
Result
,
More
)
:-
abs_path_type
(
AbsPathType
),
parse_parameters
(
Parameters
,
dict
([
abs_path
:
atom
,
limit
:
positive_integer
=
5
]),
dict
([
abs_path
:
AbsPathType
,
limit
:
positive_integer
=
5
]),
Parsed
),
(
var
(
Result
)
->
true
...
...
src/web_api/requests.pl
View file @
e3bc9095
...
...
@@ -99,8 +99,3 @@ parse_parameters(In, Type, Out) :-
throw
(
Exception
)
)
).
%! abs_path_type(-Type) is det.
%
% Return the type definition for an absolute path used to identify items.
abs_path_type
(
atom
(
'^(/|.*[^/])$'
)).
src/web_api/type_defs.pl
0 → 100644
View file @
e3bc9095
%! abs_path_type(-Type) is det.
%
% Return the type definition for an absolute path used to identify items. Type
% is a valid type as defined by types:check_type_def/1.
abs_path_type
(
atom
(
'^(/|.*[^/])$'
)).
%! item_type(-Type) is det.
%
% Generates the type definition for an item (that is a file or a directory).
% Type is a valid type as defined by types:check_type_def/1.
item_type
(
anyof
([
DirectoryType
,
FileType
]))
:-
directory_type
(
DirectoryType
),
file_type
(
FileType
).
%! file_type(-Type) is det.
%
% Generates the type definition for a file. Type is a valid type as defined by
% types:check_type_def/1.
file_type
(
dict
([
abs_path
:
AbsPathType
,
type
:
atom
(
'^file$'
),
file_size
:
positive_integer
,
media_type
:
atom
,
filename_extension
:
atom
,
creation_time
:
integer
,
modification_time
:
integer
,
access_time
:
integer
,
change_time
:
integer
]))
:-
abs_path_type
(
AbsPathType
).
%! directory_type(-Type) is det.
%
% Generates the type definition for a directory. Type is a valid type as defined
% by types:check_type_def/1.
directory_type
(
dict
([
abs_path
:
AbsPathType
,
creation_time
:
integer
,
type
:
atom
(
'^directory$'
)
]))
:-
abs_path_type
(
AbsPathType
).
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment