Change default SQL server host
[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 ;;;; This file, part of UMLisp, is
11 ;;;;    Copyright (c) 2000-2011 by Kevin M. Rosenberg, M.D.
12 ;;;;
13 ;;;; UMLisp users are granted the rights to distribute and use this software
14 ;;;; as governed by the terms of the GNU General Public License.
15 ;;;; *************************************************************************
16
17 (in-package #:umlisp)
18
19 ;;; Paths for files
20
21 (defparameter *release* "2017AA")
22
23 (defparameter *umls-path*
24   (make-pathname :directory (list :absolute "srv" "umls" *release* *release*))
25   "Path for base of UMLS data files")
26
27 (defparameter *meta-dir*
28   (make-pathname :directory '(:relative "META")))
29
30 (defparameter *lex-dir*
31   (make-pathname :directory '(:relative "LEX")))
32
33 (defparameter *net-dir*
34   (make-pathname :directory '(:relative "NET")))
35
36 (defparameter *meta-path*
37   (merge-pathnames *meta-dir* *umls-path*))
38
39 (defparameter *lex-path*
40   (merge-pathnames *lex-dir* *umls-path*))
41
42 (defparameter *net-path*
43   (merge-pathnames *net-dir* *umls-path*))
44
45 (defun set-umls-path (p)
46   (setq *umls-path* (etypecase p
47                       (string (parse-namestring p))
48                       (pathname p)))
49   (setq *meta-path* (merge-pathnames *meta-dir* *umls-path*))
50   (setq *lex-path* (merge-pathnames *lex-dir* *umls-path*))
51   (setq *net-path* (merge-pathnames *net-dir* *umls-path*)))
52
53
54 ;;; Structures for parsing UMLS text files
55
56 (defparameter *umls-files* nil
57   "List of umls file structures. Used when parsing text files.")
58 (defparameter *umls-cols* nil
59   "List of meta column structures. Used when parsing text files.")
60
61
62 ;; Special variables
63
64 (defvar *has-fixnum-class* (when (ignore-errors (find-class 'fixnum)) t))
65
66 (defvar *octet-sql-storage* t
67   "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.")
68
69 ;; Preliminary objects to replace structures
70
71 (defclass ufile ()
72   ((subdir :initarg :subdir :accessor subdir)
73    (dir :initarg :dir :accessor dir)
74    (fil :initarg :fil :accessor fil)
75    (table :initarg :table :accessor table)
76    (des :initarg :des :accessor des)
77    (fmt :initarg :fmt :accessor fmt)
78    (cls :initarg :cls :accessor cls)
79    (rws :initarg :rws :accessor rws)
80    (bts :initarg :bts :accessor bts)
81    (fields :initarg :fields :accessor fields)
82    (ucols :initarg :ucols :accessor ucols))
83   (:default-initargs :fil nil :table nil :des nil :fmt nil :cls nil :rws nil :bts nil
84                      :fields nil :ucols nil :subdir nil :dir nil)
85   (:documentation "UMLS File"))
86
87 (defclass ucol ()
88   ((col :initarg :col :accessor col)
89    (des :initarg :des :accessor des)
90    (ref :initarg :ref :accessor ref)
91    (min :initarg :min :accessor cmin)
92    (av :initarg :av :accessor av)
93    (max :initarg :max :accessor cmax)
94    (fil :initarg :fil :accessor fil)
95    (sqltype :initarg :sqltype :accessor sqltype)
96    (dty :initarg :dty :accessor dty :documentation "new in 2002: suggested SQL datatype")
97    (parse-fun :initarg :parse-fun :accessor parse-fun)
98    (quote-str :initarg :quote-str :accessor quote-str)
99    (datatype :initarg :datatype :accessor datatype)
100    (custom-value-fun :initarg :custom-value-fun :accessor custom-value-fun))
101   (:default-initargs :col nil :des nil :ref nil :min nil :av nil :max nil :fil nil
102                      :sqltype nil :dty nil :parse-fun nil :datatype nil
103                      :custom-value-fun nil)
104   (:documentation "UMLS column"))
105
106
107 (defmethod print-object ((obj ufile) s)
108   (print-unreadable-object (obj s :type t)
109     (format s "~A" (fil obj))))
110
111 (defmethod print-object ((obj ucol) s)
112   (print-unreadable-object (obj s :type t)
113     (format s "~A" (col obj))))