;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: base-class.lisp,v 1.6 2003/05/14 04:28:09 kevin Exp $
+;;;; $Id: base-class.lisp,v 1.7 2003/05/14 05:29:48 kevin Exp $
;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: connect.lisp,v 1.2 2002/12/02 15:57:17 kevin Exp $
+;;;; $Id: connect.lisp,v 1.3 2003/05/14 05:29:48 kevin Exp $
;;;;
-;;;; This file, part of Hyperobject-SQL, is
-;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
;;;;
;;;; A simple example file for hyperobjects
;;;;
-;;;; $Id: person.lisp,v 1.6 2002/12/14 21:52:48 kevin Exp $
+;;;; $Id: person.lisp,v 1.7 2003/05/14 05:29:48 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
;;;;
(:default-initargs :first-name "" :last-name "" :dob 0 :resume nil)
(:default-print-slots first-name last-name dob resume)
(:user-name "Person")
+ (:user-name-plural "Persons")
(:description "A Person")
(:direct-rules
(:rule-1 (:dependants (last-name first-name) :volatile full-name)
(:metaclass hyperobject-class)
(:default-initargs :title nil :street nil)
(:user-name "Address")
+ (:user-name-plural "Addresses")
(:default-print-slots title street)
(:description "An address"))
:value-constraint stringp))
(:metaclass hyperobject-class)
(:user-name "Phone Number")
+ (:user-name-plural "Phone Numbers")
(:default-initargs :title nil :phone-number nil)
(:default-print-slots title phone-number)
(:description "A phone number"))
;;;; Date Started: Apr 2000
;;;;
;;;;
-;;;; $Id: metaclass.lisp,v 1.6 2002/12/14 02:30:58 kevin Exp $
-;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; $Id: metaclass.lisp,v 1.7 2003/05/14 05:29:48 kevin Exp $
;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
;;;; in Text, HTML, and XML formats. This includes hyperlinking
;;;; capability and sub-objects.
;;;;
-;;;; $Id: mop.lisp,v 1.69 2003/05/06 22:19:09 kevin Exp $
-;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; $Id: mop.lisp,v 1.70 2003/05/14 05:29:48 kevin Exp $
;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
(user-name :initarg :user-name :type string :initform nil
:accessor user-name
:documentation "User name for class")
+ (user-name-plural :initarg :user-name-plural :type string :initform nil
+ :accessor user-name-plural
+ :documentation "Plural user name for class")
(default-print-slots :initarg :default-print-slots :type list :initform nil
:accessor default-print-slots
:documentation "Defaults slots for a view")
:hyperlink-parameters (slot-value dsd 'hyperlink-parameters)
:description (slot-value dsd 'description)
:user-name (slot-value dsd 'user-name)
+ :user-name-plural (slot-value dsd 'user-name-plural)
:index (slot-value dsd 'index)
:value-constraint (slot-value dsd 'value-constraint)
:null-allowed (slot-value dsd 'null-allowed)
(setf (slot-value esd 'length) length)
(setf (slot-value esd 'type) (value-type-to-lisp-type value-type))
(setf (slot-value esd 'value-type) value-type)
- (dolist (name '(print-formatter subobject hyperlink hyperlink-parameters description user-name
- value-constraint index null-allowed))
+ (dolist (name '(print-formatter subobject hyperlink hyperlink-parameters
+ description value-constraint index null-allowed user-name))
(setf (slot-value esd name) (slot-value dsd name)))
esd)))
#-(or cmu sbcl) (nreverse subobjects)
)))
+
+(defun finalize-class-slots (cl)
+ "Make sure all class slots have an expected value"
+ (unless (user-name cl)
+ (setf (user-name cl) (format nil "~:(~A~)" (class-name cl))))
+
+ (setf (user-name-plural cl)
+ (if (and (consp (user-name cl)) (cadr (user-name cl)))
+ (cadr (user-name cl))
+ (format nil "~A~P" (if (consp (user-name cl))
+ (car (user-name cl))
+ (user-name cl))
+ 2)))
+
+ (dolist (name '(description))
+ (awhen (slot-value cl name)
+ (setf (slot-value cl name)
+ (etypecase (slot-value cl name)
+ (cons (car it))
+ ((or string symbol) it))))))
+
(defun finalize-documentation (cl)
"Calculate class documentation slot"
- (awhen (slot-value cl 'user-name)
- (setf (slot-value cl 'user-name)
- (etypecase (slot-value cl 'user-name)
- (cons (car it))
- ((or string symbol) it))))
- (awhen (slot-value cl 'description)
- (setf (slot-value cl 'description)
- (etypecase (slot-value cl 'description)
- (cons (car it))
- ((or string symbol) it))))
-
(let ((*print-circle* nil))
(setf (documentation (class-name cl) 'class)
(format nil "Hyperobject~A~A~A~A"
(finalize-hyperlinks cl)
(finalize-sql cl)
(finalize-rules cl)
+ (finalize-class-slots cl)
(finalize-documentation cl))
(find name (class-slots cl) :key #'slot-definition-name))
(defun hyperobject-class-user-name (obj)
- (awhen (user-name (class-of obj))
- (if (consp it)
- (car it)
- it)))
+ (user-name (class-of obj)))
+
+(defun hyperobject-class-user-name-plural (obj)
+ (user-name-plural (class-of obj)))
(defun hyperobject-class-subobjects (obj)
(subobjects (class-of obj)))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: package.lisp,v 1.45 2003/05/07 16:01:48 kevin Exp $
+;;;; $Id: package.lisp,v 1.46 2003/05/14 05:29:48 kevin Exp $
;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(eval-when (:compile-toplevel :execute)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: rules.lisp,v 1.38 2003/05/04 03:30:28 kevin Exp $
-;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; $Id: rules.lisp,v 1.39 2003/05/14 05:29:48 kevin Exp $
;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: run-tests.lisp
+;;;; Purpose: Regression suite for hyperobject
+;;;; Programmer: Kevin M. Rosenberg
+;;;; Date Started: Apr 2000
+;;;;
+;;;; $Id: run-tests.lisp,v 1.2 2003/05/14 05:29:48 kevin Exp $
+;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
+;;;; *************************************************************************
+
(defpackage #:run-tests (:use #:cl))
(in-package #:run-tests)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: sql.lisp,v 1.4 2003/03/29 04:10:44 kevin Exp $
+;;;; $Id: sql.lisp,v 1.5 2003/05/14 05:29:48 kevin Exp $
;;;;
-;;;; This file, part of Hyperobject-SQL, is
-;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2003
;;;;
-;;;; $Id: tests.lisp,v 1.4 2003/04/29 09:47:10 kevin Exp $
+;;;; $Id: tests.lisp,v 1.5 2003/05/14 05:29:48 kevin Exp $
;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(defpackage #:hyperobject-tests
:subobject t))
(:metaclass hyperobject-class)
(:default-initargs :title nil :street nil)
- (:user-name "Address")
+ (:user-name "Address" "Addresses")
(:default-print-slots title street)
(:description "An address"))
(deftest p2 (view-to-string mary :subobjects t) " Person:
Mary Jackson Thu, 4 May 2000 03:02:01 Style & Grace
- Addresss:
+ Addresses:
Home 321 Shady Lane
Phone Numbers:
Voice 367-9812
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: views.lisp,v 1.35 2003/05/14 04:45:05 kevin Exp $
-;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; $Id: views.lisp,v 1.36 2003/05/14 05:29:48 kevin Exp $
;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)
(defvar +newline-string+ (format nil "~%"))
+(defun write-user-name-maybe-plural (obj nitems strm)
+ (write-string
+ (if (> nitems 1)
+ (hyperobject-class-user-name-plural obj)
+ (hyperobject-class-user-name obj))
+ strm))
+
(defun initialize-text-view (view)
(setf (list-start-str-or-func view)
(compile nil
(eval '(lambda (obj nitems strm)
- (format strm "~a~P:~%"
- (hyperobject-class-user-name obj) nitems)))))
+ (write-user-name-maybe-plural obj nitems strm)
+ (write-char #\: strm)
+ (write-char #\Newline strm)))))
(setf (list-start-indent view) t)
(setf (obj-data-indent view) t)
(setf (obj-data-end-str view) +newline-string+))
(defun html-list-start-func (obj nitems strm)
- (format strm "<p><b>~a~p:</b></p><div class=\""
- (hyperobject-class-user-name obj) nitems)
+ (write-string "<p><b>" strm)
+ (write-user-name-maybe-plural obj nitems strm)
+ (write-string ":</b></p><div class=\"" strm)
(write-string (class-name-of obj) strm)
(write-string "\"><ul>" strm)
(write-char #\newline strm))
(write-char #\< strm)
(write-string (class-name-of x) strm)
(write-string "list><title>" strm)
- (format strm "~A~P:</title> ~%"
- (hyperobject-class-user-name x) nitems))
+ (write-user-name-maybe-plural obj nitems strm)
+ (write-string ":</title>" strm)
+ (write-char #\newline strm))
(defun initialize-xml-view (view)
(initialize-text-view view)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: wrapper.lisp,v 1.3 2002/12/13 07:33:54 kevin Exp $
+;;;; $Id: wrapper.lisp,v 1.4 2003/05/14 05:29:48 kevin Exp $
;;;;
-;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
(in-package :hyperobject)