r11704: can not use keywords in :subobject functions
[umlisp.git] / data-structures.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:    data-structures.lisp
6 ;;;; Purpose:  Basic data objects for UMLisp
7 ;;;; Author:   Kevin M. Rosenberg
8 ;;;; Created:  Apr 2000
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of UMLisp, is
13 ;;;;    Copyright (c) 2000-2006 by Kevin M. Rosenberg, M.D.
14 ;;;;
15 ;;;; UMLisp users are granted the rights to distribute and use this software
16 ;;;; as governed by the terms of the GNU General Public License.
17 ;;;; *************************************************************************
18
19 (in-package #:umlisp)
20
21 ;;; Paths for files
22
23 (defparameter *release* "2006AD")
24
25 (defparameter *umls-path*
26   (make-pathname :directory (list :absolute "srv" "umls" *release*))
27   "Path for base of UMLS data files")
28
29 (defparameter *meta-dir*
30   (make-pathname :directory '(:relative "META")))
31
32 (defparameter *lex-dir*
33   (make-pathname :directory '(:relative "LEX")))
34
35 (defparameter *net-dir*
36   (make-pathname :directory '(:relative "NET")))
37
38 (defparameter *meta-path*
39   (merge-pathnames *meta-dir* *umls-path*))
40
41 (defparameter *lex-path*
42   (merge-pathnames *lex-dir* *umls-path*))
43
44 (defparameter *net-path*
45   (merge-pathnames *net-dir* *umls-path*))
46
47 (defun umls-path! (p)
48   (setq *umls-path* (etypecase p
49                       (string (parse-namestring p))
50                       (pathname p)))
51   (setq *meta-path* (merge-pathnames *meta-dir* *umls-path*))
52   (setq *lex-path* (merge-pathnames *lex-dir* *umls-path*))
53   (setq *net-path* (merge-pathnames *net-dir* *umls-path*)))
54
55
56 ;;; Structures for parsing UMLS text files
57
58 (defparameter *umls-files* nil
59   "List of umls file structures. Used when parsing text files.")
60 (defparameter *umls-cols* nil
61   "List of meta column structures. Used when parsing text files.")
62
63
64 ;; Special variables
65
66 (defvar *has-fixnum-class* (when (ignore-errors (find-class 'fixnum)) t))
67
68 (defvar *octet-sql-storage* t
69   "Used to deciding field lengths. Use nil if using UTF-8 database encoding. But, UTF-8 will cause MySQL to double the bytes used for fixed field sizes.")
70
71 ;; Preliminary objects to replace structures
72
73 (defclass ufile ()
74   ((subdir :initarg :subdir :accessor subdir)
75    (dir :initarg :dir :accessor dir)
76    (fil :initarg :fil :accessor fil)
77    (table :initarg :table :accessor table)
78    (des :initarg :des :accessor des)
79    (fmt :initarg :fmt :accessor fmt)
80    (cls :initarg :cls :accessor cls)
81    (rws :initarg :rws :accessor rws)
82    (bts :initarg :bts :accessor bts)
83    (fields :initarg :fields :accessor fields)
84    (ucols :initarg :ucols :accessor ucols))
85   (:default-initargs :fil nil :table nil :des nil :fmt nil :cls nil :rws nil :bts nil
86                      :fields nil :ucols nil :subdir nil :dir nil)
87   (:documentation "UMLS File"))
88
89 (defclass ucol ()
90   ((col :initarg :col :accessor col)
91    (des :initarg :des :accessor des)
92    (ref :initarg :ref :accessor ref)
93    (min :initarg :min :accessor cmin)
94    (av :initarg :av :accessor av)
95    (max :initarg :max :accessor cmax)
96    (fil :initarg :fil :accessor fil)
97    (sqltype :initarg :sqltype :accessor sqltype)
98    (dty :initarg :dty :accessor dty :documentation "new in 2002: suggested SQL datatype")
99    (parse-fun :initarg :parse-fun :accessor parse-fun)
100    (quote-str :initarg :quote-str :accessor quote-str)
101    (datatype :initarg :datatype :accessor datatype)
102    (custom-value-fun :initarg :custom-value-fun :accessor custom-value-fun))
103   (:default-initargs :col nil :des nil :ref nil :min nil :av nil :max nil :fil nil
104                      :sqltype nil :dty nil :parse-fun nil :datatype nil
105                      :custom-value-fun nil)
106   (:documentation "UMLS column"))
107
108
109 (defmethod print-object ((obj ufile) (s stream))
110   (print-unreadable-object (obj s :type t)
111     (format s "~A" (fil obj))))
112
113 (defmethod print-object ((obj ucol) (s stream))
114   (print-unreadable-object (obj s :type t)
115     (format s "~A" (col obj))))
116
117