--------------------------------------------------------------------------- 
    Copyright ( c ) 2021 University of Bern . All rights reserved . 
    Distributed under the ISC license , see terms at the end of the file . 
   ---------------------------------------------------------------------------
   Copyright (c) 2021 University of Bern. All rights reserved.
   Distributed under the ISC license, see terms at the end of the file.
  ---------------------------------------------------------------------------*)

* Containers . 

     Containers of references .  in a more serious system like an 
     ILS that would be a reference itself .

    Containers of references. N.B. in a more serious system like an
    ILS that would be a reference itself. *)

open Hyperbib.Std

(** {1 Containers} *)

type id = Id.t
(** The type for container ids. These are allocated by the database. *)

type t
(** The type for containers. *)

type container = t
(** See {!t}. *)

val v :
  id:id -> title:string -> isbn:string -> issn:string ->
  note:string -> private_note:string -> public:bool ->
  unit -> t
(** [v …] is a container with given attributes, see accessors for semantics. *)

val row : id -> string -> string -> string -> string -> string -> bool -> t
(** [row] is {!v} unlabelled. *)

val new' : t
(** [new'] is a new container. *)

val id : t -> id
(** [id c] is the unique identifier of [c]. *)

val title : t -> string
(** [title c] is the title of [c]. *)

val isbn : t -> string
(** [isbn c] is the ISBN of [c]. *)

val issn : t -> string
* [  c ] is the ISSN of [ c ] .

val note : t -> string
(** [note c] is the note of [c]. *)

val private_note : t -> string
(** [private_note c] is the private note of [c]. *)

val public : t -> bool
(** [public c] is [true] iff [c]'s existence is made visible to the
    public *)

* { 1 : ops Operations }

val duplicate_data : t -> t
* [ duplicate_data c ] is [ c ] with its title altered and { ! public } set 
     to none . The { !   id } is the one of [ c ] .
    to none. The {!val-id} is the one of [c]. *)

* { 1 : predcomp Predicates and comparisons }

val order_by_title : t -> t -> int
(** [order_by_title c0 c1] orders [c0] and [c1] in lexicographic order
    by title. *)

* { 1 : derived Derived data }

val index_letter : t -> char option
* [ index_letter c ] is the letter under which [ c ] can be found 
     in the index . { b FIXME } this should be made Unicode aware .
    in the index. {b FIXME} this should be made Unicode aware. *)

* { 1 : tables Tables }

open Rel

val id' : (t, id) Col.t
* [ i d ' ] is the column for { !   id } .

val title' : (t, string) Col.t
* [ title ' ] is the column for { !  - title } .

val isbn' : (t, string) Col.t
* [  ' ] is the column for { !    } .

val issn' : (t, string) Col.t
* [  ' ] is the column for { !    } .

val note' : (t, string) Col.t
* [ note ' ] is the column for { !  - note } .

val private_note' : (t, string) Col.t
* [ private_note ' ] is the column for { !    ' } .

val public' : (t, bool) Col.t
* [ public ' ] is the column for { !  - public ' } .

val table : t Table.t
(** [table] is the container table. *)

(** Container label applications. *)
module Label : Label.APPLICATION
  with type entity := t and type entity_id := id

* { 1 : queries Queries }

include Entity.PUBLICABLE_QUERIES with type t := t and type id := id

val match' :
  title:string Rel_query.value ->
  isbn:string Rel_query.value -> issn:string Rel_query.value ->
  (t, Bag.unordered) Rel_query.Bag.t

val match_stmt :
  title:string -> isbn:string -> issn:string -> t Rel_sql.Stmt.t

val select : string Rel_query.value -> (t, Bag.unordered) Rel_query.Bag.t
val select_stmt : string -> t Rel_sql.Stmt.t

* { 1 : urls URLs }

(** Container URL requests. *)
module Url : sig

* { 1 : url_req URL request }

  type named_id = string option * id

  type t =
  | Confirm_delete of id
  | Create
  | Delete of id
  | Duplicate of id
  | Duplicate_form of id
  | Edit_form of id
  | Index
  | Input of Entity.Url.input_name * id
  | Input_create of Entity.Url.input_name * container
  | Input_finder of Entity.Url.input_name
  | Input_finder_find of Entity.Url.input_name * string
  | New_form of { cancel : Entity.Url.cancel_url }
  | Page of named_id
  | Replace of id
  | Replace_form of id
  | Update of id
  | View_fields of id (** *)
  (** The type for container URL requests. *)

  val kind : t Kurl.kind
  (** The type for container URL request kinds. *)

  val v : t -> Kurl.t
  (** [v u] is [Kurl.v kind u]. *)

* { 1 : cons Convenience constructors }

  val res_name : container -> string
  (** [res_name c] is an URL path segment for naming [c]. *)

  val page : container -> Kurl.t
* [ page c ] is a { ! Url.type - t. Page } URL request for [ c ] .
end

--------------------------------------------------------------------------- 
    Copyright ( c ) 2021 University of Bern 

    Permission to use , copy , modify , and/or distribute this software for any 
    purpose with or without fee is hereby granted , provided that the above 
    copyright notice and this permission notice appear in all copies . 

    THE SOFTWARE IS PROVIDED " AS IS " AND THE AUTHOR DISCLAIMS ALL WARRANTIES 
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 
    MERCHANTABILITY AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 
    ANY SPECIAL , DIRECT , INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
     RESULTING FROM LOSS OF USE , DATA OR PROFITS , WHETHER IN AN 
    ACTION OF CONTRACT , NEGLIGENCE OR OTHER TORTIOUS ACTION , ARISING OUT OF 
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE . 
   ---------------------------------------------------------------------------
   Copyright (c) 2021 University of Bern

   Permission to use, copy, modify, and/or distribute this software for any
   purpose with or without fee is hereby granted, provided that the above
   copyright notice and this permission notice appear in all copies.

   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  ---------------------------------------------------------------------------*)

* {1 Containers} 
* The type for container ids. These are allocated by the database. 
* The type for containers. 
* See {!t}. 
* [v …] is a container with given attributes, see accessors for semantics. 
* [row] is {!v} unlabelled. 
* [new'] is a new container. 
* [id c] is the unique identifier of [c]. 
* [title c] is the title of [c]. 
* [isbn c] is the ISBN of [c]. 
* [note c] is the note of [c]. 
* [private_note c] is the private note of [c]. 
* [public c] is [true] iff [c]'s existence is made visible to the
    public 
* [order_by_title c0 c1] orders [c0] and [c1] in lexicographic order
    by title. 
* [table] is the container table. 
* Container label applications. 
* Container URL requests. 
* 
* The type for container URL requests. 
* The type for container URL request kinds. 
* [v u] is [Kurl.v kind u]. 
* [res_name c] is an URL path segment for naming [c]. 
--------------------------------------------------------------------------- 
    Copyright ( c ) 2021 University of Bern . All rights reserved . 
    Distributed under the ISC license , see terms at the end of the file . 
   ---------------------------------------------------------------------------
   Copyright (c) 2021 University of Bern. All rights reserved.
   Distributed under the ISC license, see terms at the end of the file.
  ---------------------------------------------------------------------------*)

* Containers . 

     Containers of references .  in a more serious system like an 
     ILS that would be a reference itself .

    Containers of references. N.B. in a more serious system like an
    ILS that would be a reference itself. *)

open Hyperbib.Std


type id = Id.t

type t

type container = t

val v :
  id:id -> title:string -> isbn:string -> issn:string ->
  note:string -> private_note:string -> public:bool ->
  unit -> t

val row : id -> string -> string -> string -> string -> string -> bool -> t

val new' : t

val id : t -> id

val title : t -> string

val isbn : t -> string

val issn : t -> string
* [  c ] is the ISSN of [ c ] .

val note : t -> string

val private_note : t -> string

val public : t -> bool

* { 1 : ops Operations }

val duplicate_data : t -> t
* [ duplicate_data c ] is [ c ] with its title altered and { ! public } set 
     to none . The { !   id } is the one of [ c ] .
    to none. The {!val-id} is the one of [c]. *)

* { 1 : predcomp Predicates and comparisons }

val order_by_title : t -> t -> int

* { 1 : derived Derived data }

val index_letter : t -> char option
* [ index_letter c ] is the letter under which [ c ] can be found 
     in the index . { b FIXME } this should be made Unicode aware .
    in the index. {b FIXME} this should be made Unicode aware. *)

* { 1 : tables Tables }

open Rel

val id' : (t, id) Col.t
* [ i d ' ] is the column for { !   id } .

val title' : (t, string) Col.t
* [ title ' ] is the column for { !  - title } .

val isbn' : (t, string) Col.t
* [  ' ] is the column for { !    } .

val issn' : (t, string) Col.t
* [  ' ] is the column for { !    } .

val note' : (t, string) Col.t
* [ note ' ] is the column for { !  - note } .

val private_note' : (t, string) Col.t
* [ private_note ' ] is the column for { !    ' } .

val public' : (t, bool) Col.t
* [ public ' ] is the column for { !  - public ' } .

val table : t Table.t

module Label : Label.APPLICATION
  with type entity := t and type entity_id := id

* { 1 : queries Queries }

include Entity.PUBLICABLE_QUERIES with type t := t and type id := id

val match' :
  title:string Rel_query.value ->
  isbn:string Rel_query.value -> issn:string Rel_query.value ->
  (t, Bag.unordered) Rel_query.Bag.t

val match_stmt :
  title:string -> isbn:string -> issn:string -> t Rel_sql.Stmt.t

val select : string Rel_query.value -> (t, Bag.unordered) Rel_query.Bag.t
val select_stmt : string -> t Rel_sql.Stmt.t

* { 1 : urls URLs }

module Url : sig

* { 1 : url_req URL request }

  type named_id = string option * id

  type t =
  | Confirm_delete of id
  | Create
  | Delete of id
  | Duplicate of id
  | Duplicate_form of id
  | Edit_form of id
  | Index
  | Input of Entity.Url.input_name * id
  | Input_create of Entity.Url.input_name * container
  | Input_finder of Entity.Url.input_name
  | Input_finder_find of Entity.Url.input_name * string
  | New_form of { cancel : Entity.Url.cancel_url }
  | Page of named_id
  | Replace of id
  | Replace_form of id
  | Update of id

  val kind : t Kurl.kind

  val v : t -> Kurl.t

* { 1 : cons Convenience constructors }

  val res_name : container -> string

  val page : container -> Kurl.t
* [ page c ] is a { ! Url.type - t. Page } URL request for [ c ] .
end

--------------------------------------------------------------------------- 
    Copyright ( c ) 2021 University of Bern 

    Permission to use , copy , modify , and/or distribute this software for any 
    purpose with or without fee is hereby granted , provided that the above 
    copyright notice and this permission notice appear in all copies . 

    THE SOFTWARE IS PROVIDED " AS IS " AND THE AUTHOR DISCLAIMS ALL WARRANTIES 
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 
    MERCHANTABILITY AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 
    ANY SPECIAL , DIRECT , INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
     RESULTING FROM LOSS OF USE , DATA OR PROFITS , WHETHER IN AN 
    ACTION OF CONTRACT , NEGLIGENCE OR OTHER TORTIOUS ACTION , ARISING OUT OF 
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE . 
   ---------------------------------------------------------------------------
   Copyright (c) 2021 University of Bern

   Permission to use, copy, modify, and/or distribute this software for any
   purpose with or without fee is hereby granted, provided that the above
   copyright notice and this permission notice appear in all copies.

   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  ---------------------------------------------------------------------------*)
