annotate implementations/tabcode/ecolm.lisp @ 180:1a2b876b5587

ECOLM functionality for tabcode implementation darcs-hash:20080708152414-40ec0-be5878c3d42affaf70ad7d08e987ba2223f5fa59.gz
author d.lewis <d.lewis@gold.ac.uk>
date Tue, 08 Jul 2008 16:24:14 +0100
parents
children 5b2d0e5a99f1
rev   line source
d@180 1 (in-package #:amuse-tabcode)
d@180 2
d@180 3 (defun get-ecolm-connection ()
d@180 4 (clsql:connect (list "127.0.0.1" "ecolm" "basicuser" "basicuser" "29183")
d@180 5 :if-exists :old :database-type :mysql))
d@180 6
d@180 7 (defclass ecolm-identifier (identifier tabcode-object)
d@180 8 ((edition-id :initarg :ed-id :accessor edition-id)
d@180 9 (edition-text-id :initarg :ed-id :accessor %edition-text-id)
d@180 10 (piece-id :initarg :p-id :accessor piece-id)
d@180 11 (tabcode :initarg :code :accessor %tabcode)))
d@180 12
d@180 13 (defclass ecolm-search ()
d@180 14 ((piece-title :initarg :p-title :reader piece-title)
d@180 15 (source-title :initarg :s-title :reader source-title)))
d@180 16
d@180 17 (defun edition-text-id (ecolm-id)
d@180 18 (unless (or (slot-boundp ecolm-id 'edition-text-id)
d@180 19 (slot-boundp ecolm-id 'edition-id))
d@180 20 (get-best-edition ecolm-id))
d@180 21 (unless (slot-boundp ecolm-id 'edition-text-id)
d@180 22 (get-best-edition-text ecolm-id))
d@180 23 (%edition-text-id ecolm-id))
d@180 24
d@180 25 (defun get-best-edition (ecolm-id)
d@180 26 (let ((edition (clsql:query (format nil "SELECT et.`Edition ID`,
d@180 27 `EditionText ID`, `EditionText Text`
d@180 28 FROM Piece_Editions pe NATURAL JOIN Edition_Texts et
d@180 29 WHERE `Piece ID`=~D
d@180 30 ORDER BY `EditionText Stage` DESC,
d@180 31 `EditionText Date` DESC
d@180 32 LIMIT 0,1" (piece-id ecolm-id)))))
d@180 33 (setf (edition-id ecolm-id) (caar edition)
d@180 34 (%edition-text-id ecolm-id) (second (car edition))
d@180 35 (%tabcode ecolm-id) (third (car edition)))))
d@180 36
d@180 37 (defun get-best-edition-text (ecolm-id)
d@180 38 (let ((edition (clsql:query (format nil "SELECT et.`EditionText ID`,
d@180 39 `EditionText Text`
d@180 40 FROM Edition_Texts et
d@180 41 WHERE `Edition ID`=~D
d@180 42 ORDER BY `EditionText Stage` DESC, `EditionText Date` DESC
d@180 43 LIMIT 0,1" (edition-id ecolm-id)))))
d@180 44 (setf (%edition-text-id ecolm-id) (caar edition)
d@180 45 (%tabcode ecolm-id) (second (car edition)))))
d@180 46
d@180 47 (defun tabcode (identifier)
d@180 48 (if (slot-boundp identifier 'tabcode)
d@180 49 (%tabcode identifier)
d@180 50 (when (edition-text-id identifier)
d@180 51 (%tabcode identifier))))
d@180 52
d@180 53 (defmethod get-composition ((identifier ecolm-identifier))
d@180 54 (get-composition-from-tabwords
d@180 55 (tabcode::parse-tabcode-string (tabcode identifier))))