<> a <http://www.w3.org/2000/10/swap/logic.n3#N3Document>. # Ugly!
@prefix dc: <http://purl.org/dc/elements/1.1/>.
@prefix rcs: <../../../2001/03swell/rcs#>.
@prefix man: <?man#>.
@prefix u: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix daml: <http://www.daml.org/2000/12/daml+oil#>.
@prefix dt: <http://www.w3.org/2001/XMLSchema#>. # @@cf sandro's comment about what this denotes.
@prefix pdb: <pdb#>. # @@ separate pdb: schema
@prefix : <#>.

<> dc:title "An RDF Schema for the Palm Datebook";
   rcs:id "$Id: datebook.n3,v 1.3 2001/04/26 06:21:22 connolly Exp $";
   dc:source [ man:pageName "Palm::Datebook";
		man:synopsis "Handler for Palm DateBook databases.";
		dc:date "2000-09-24";
		dc:creator [ [ u:label "name"] "Andrew Arensburger";
			 	[ u:label "mailbox"]  <mailto:arensb@ooblick.com> ];
		 ];
   u:seeAlso <http://dev.w3.org/cvsweb/2001/palmagent/>.

man:pageName u:subPropertyOf dc:identifier.
man:synopsis u:subPropertyOf dc:description.

######
# P5Palm stuff
#
# @@TODO: encode the "and that's all" property of records:
# use func: stuff from 2001/03swell/xml.n3 to do a multi-column key.

pdb:fieldName u:subPropertyOf u:label;
 u:comment "name as used in the P5Palm API".

pdb:Record u:label "Palm Pilot Record"; a u:Class.

pdb:id pdb:fieldName "id";
    u:range u:Literal. # record ID 123 becomes... <123>? <#123>? "123"?

pdb:category pdb:fieldName "category".

pdb:Private pdb:fieldName "private";
         u:subClassOf pdb:Record.
pdb:Deleted pdb:fieldName "deleted";
         u:subClassOf pdb:Record.
pdb:Expunged pdb:fieldName "expunged";
         u:subClassOf pdb:Record.

pdb:when_changed pdb:fieldName "when_changed".


#########
#
# Datebook stuff
#

:Record u:subClassOf pdb:Record.

:date u:label "date";
  u:range dt:date;
  u:subPropertyOf dc:date; #??
  u:comment "corresponds to year/month/day from p5-palm".

:description pdb:fieldName "description";
  u:subPropertyOf dc:description.

:note pdb:fieldName "note".


:OneTime u:subClassOf pdb:Record.

:start_time u:label "start_time";
  u:range [ dt:pattern "\\d\\d:\\d\\d" ];
  u:comment "corresponds to $start_hour:$start_minute from p5-palm".

:Timeless u:subClassOf :Record;
  u:comment "Timeless records have no start_time nor end_time".

:end_time u:label "end_time";
  u:range [ dt:pattern "\\d\\d:\\d\\d" ];
  u:comment "corresponds to $end_hour:$end_minute from p5-palm".

# hmm... these two properties should be combined into one.
:alarmAdvance u:label "alarm advance".
:alarmUnit u:label "alarm unit";
  u:range [ daml:oneOf (:minutes :hours :days) ]. #hmm... add bottom to make it a total function?

:NoAlarm u:subPropertyOf :Record.


:dailyInterval u:label "daily interval";
  u:comment "corresponds to {repeat}{frequency}, with repeat type 1".

:weeklyInterval u:label "weekly interval";
  u:comment "corresponds to {repeat}{frequency}, with repeat type 2".

:repeat_days u:label "repeat days";
  u:comment """corresponds to {repeat}{repeat_days}, with repeat type 2;
a list of booleans; e.g. '0 0 1 0 1 0 0' for Tue/Thu""".

:start_of_week u:label "start of week";
  u:comment """corresponds to {repeat}{start_of_week}, with repeat type 2;
@@using a numeral now, but it should be a symbolic URI""".

:weekOfMonth u:label "week of month";
  u:comment """corresponds to {repeat}{weeknum} with repeat type 3;
0-based; 5 denotes last week of the month""".

:dayOfWeek u:label "day of week";
  u:comment """corresponds to {repeat}{daynum} with repeat type 3;
0 for Sun, ... (I think; @@double-check/test)""".

:dayOfMonth u:label "day of month";
  u:comment """@@ repeate type 4 with ???""".

:yearlyInterval u:label "yearly interval";
  u:comment "corresponds to {repeat}{frequency}, with repeat type 5".

:end_date u:label "end date";
  u:range dt:date;
  u:comment "corresponds to {repeat}{end_year/month/day} from p5-palm".

:Indefinite u:subClassOf :Record;
  u:comment "class of palm datebook records with no end to their repeat".

:exceptions u:comment "@@not yet implemented".

######
# processing utility stuff

@prefix pu: <pdbUtil#>.
@prefix l: <http://www.w3.org/2000/10/swap/logic.n3#>.
@prefix v: <?var#>.
@prefix cp: <http://www.w3.org/2001/03swell/cp#>.

pu:inserts
 u:comment "a request/document inserts a record/item.".

pu:bookMin u:range dt:date;
 u:label "bookMin";
 u:comment """this isn't represented in palm datebook files;
it's administrivia used in pdkb.pl etc.; belongs
elsewhere, probably@@""".

pu:bookMax u:range dt:date;
 u:label "bookMax";
 u:comment """this isn't represented in palm datebook files;
it's administrivia used in pdkb.pl etc.; belongs
elsewhere, probably@@""".


<> l:forAll v:b, v:start, v:end, v:e, v:ed.

{ v:b pu:bookMin v:start.
  v:b pu:bookMax v:end.
  v:b cp:says { v:e :date v:ed }.
 } l:implies  { v:ed a [ u:subClassOf dt:date;
                         dt:minInclusive v:start;
			 dt:maxInclusive v:end ] }.


{ v:b :bookMaz v:end.
  v:b cp:says { v:e :date v:ed }.
 } l:implies  { v:ed :le v:end }.
