From 9c78cd5e2206edf8400dd895a181cd9c676d6354 Mon Sep 17 00:00:00 2001 From: macie Date: Sun, 10 Mar 2019 21:43:27 +0100 Subject: [PATCH] Define resources --- src/rules/reservation/resources.pl | 34 +++++++++++++++++++++++++++++ src/rules/reservation/resources.plt | 15 +++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/rules/reservation/resources.pl create mode 100644 src/rules/reservation/resources.plt diff --git a/src/rules/reservation/resources.pl b/src/rules/reservation/resources.pl new file mode 100644 index 0000000..cc1194b --- /dev/null +++ b/src/rules/reservation/resources.pl @@ -0,0 +1,34 @@ + +reservation(Location) :- atom_string(Location, "reservation://"). + +reservation(Resource, Location) :- % reservation:/// + reservation(Base_uri), + atom_concat(Resource, "/", Resource_uri), + atom_concat(Base_uri, Resource_uri, Location). + +reservation_rooms(Location) :- % reservation://rooms/ + reservation("rooms", Location). + +reservation_rooms(Room, Location) :- % reservation://rooms// + reservation_rooms(Base_uri), + atom_concat(Room, "/", Room_uri), + atom_concat(Base_uri, Room_uri, Location). + +reservation_owner(Location) :- % reservation://rooms/owners/ + reservation_owner("", Location). + +reservation_owner(Room, Location) :- % reservation://rooms//owners/ + reservation_rooms(Room, Base_uri), + atom_concat(Base_uri, "owners/", Location). + +reservation_free(Location) :- % reservation://rooms/free/ + reservation_free("", Location). + +reservation_free(Room, Location) :- % reservation://rooms//free/ + reservation_rooms(Room, Base_uri), + atom_concat(Base_uri, "free/", Location). + +% reservation://users +% reservation://users// +% reservation://users//reservations +% ... diff --git a/src/rules/reservation/resources.plt b/src/rules/reservation/resources.plt new file mode 100644 index 0000000..01eeb10 --- /dev/null +++ b/src/rules/reservation/resources.plt @@ -0,0 +1,15 @@ +:- begin_tests(resources). +:- include(resources). + +test(reservation) :- reservation('reservation://'). + +test(reservation_rooms) :- reservation_rooms('reservation://rooms/'). +test(reservation_rooms) :- reservation_rooms(11, 'reservation://rooms/11/'). + +test(reservation_owner) :- reservation_owner('reservation://rooms/owners/'). +test(reservation_owner) :- reservation_owner(5, 'reservation://rooms/5/owners/'). + +test(reservation_free) :- reservation_free('reservation://rooms/free/'). +test(reservation_free) :- reservation_free(3, 'reservation://rooms/3/free/'). + +:- end_tests(resources).