;;;;
;;;; A simple example file for hyperobjects
;;;;
-;;;; $Id: person.lisp,v 1.2 2002/12/13 05:44:19 kevin Exp $
+;;;; $Id: person.lisp,v 1.6 2002/12/14 21:52:48 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
;;;;
(in-package :hyperobject-user)
-
(defclass person (hyperobject)
- ((first-name :type string :initarg :first-name :reader first-name)
- (last-name :type string :initarg :last-name :reader last-name
- :hyperlink find-person-by-last-name)
- (dob :type integer :initarg :dob :reader dob :print-formatter format-date)
- (resume :type cdata :initarg :resume :reader resume)
- (addresses :initarg :addresses :reader addresses :subobject t))
+ ((first-name :value-type (varchar 20) :initarg :first-name :accessor first-name
+ :value-constraint stringp :null-allowed nil)
+ (last-name :value-type (varchar 30) :initarg :last-name :accessor last-name
+ :value-constraint stringp
+ :hyperlink find-person-by-last-name :null-allowed nil)
+ (full-name :value-type string :stored nil)
+ (dob :value-type integer :initarg :dob :accessor dob :print-formatter format-date
+ :value-constraint integerp :input-filter convert-to-date)
+ (resume :value-type string :initarg :resume :accessor resume
+ :value-constraint stringp)
+;; (addresses :value-type (list-of subobject) :initarg :addresses :accessor addresses))
+ (addresses :subobject t :initarg :addresses :accessor addresses))
(:metaclass hyperobject-class)
- (:default-initargs :first-name nil :last-name nil :dob 0 :resume nil)
+ (:default-initargs :first-name "" :last-name "" :dob 0 :resume nil)
(:default-print-slots first-name last-name dob resume)
(:user-name "Person")
- (:description "A Person"))
+ (:description "A Person")
+ (:direct-rules
+ (:rule-1 (:dependants (last-name first-name) :volatile full-name)
+ (setf full-name (concatenate 'string first-name " " last-name)))))
(defun format-date (ut)
(when (typep ut 'integer)
hr min sec))))
(defclass address (hyperobject)
- ((title :type string :initarg :title :reader title)
- (street :type string :initarg :street :reader street)
- (phones :initarg :phones :reader phones :subobject t))
+ ((title :value-type (varchar 20) :initarg :title :accessor title
+ :value-constraint stringp)
+ (street :value-type (varchar 30) :initarg :street :accessor street
+ :value-constraint stringp)
+ (phones :subobject t :initarg :phones :accessor phones))
(:metaclass hyperobject-class)
(:default-initargs :title nil :street nil)
(:user-name "Address")
(:description "An address"))
(defclass phone (hyperobject)
- ((title :type string :initarg :title :reader title)
- (phone-number :type string :initarg :phone-number :reader phone-number))
+ ((title :value-type (varchar 20) :initarg :title :accessor title
+ :value-constraint stringp)
+ (phone-number :value-type (varchar 16) :initarg :phone-number :accessor phone-number
+ :value-constraint stringp))
(:metaclass hyperobject-class)
(:user-name "Phone Number")
(:default-initargs :title nil :phone-number nil)