view implementations/midi-db/methods.lisp @ 330:2fbff655ba47 tip

Removed cpitch-adj and cents SQL columns
author Jeremy Gow <jeremy.gow@gmail.com>
date Mon, 21 Jan 2013 11:08:11 +0000
parents d1ff5dad3f8d
children
line wrap: on
line source
(cl:in-package #:amuse-midi-db)

;;;=====================================================================
;;; Specialized constructors
;;;=====================================================================

(defmethod make-composition-identifier ((package (eql *package*))
				       composition-id)
  (make-midi-db-composition-identifier composition-id))



;;;=====================================================================
;;; Specialized database-admin methods
;;;=====================================================================

(defmethod list-collections ((package (eql *package*)) &key
			     compositions (stream *standard-output*))
  "FIXME: better formatting."
  (let ((collection-rows (%get-all-collection-headers)))
    (flet ((print-separator (&optional (columns 70))
	     (format stream "~%~A~%"
		     (make-sequence 'string columns :initial-element #\-))))
      (loop for collection-row in collection-rows
	 do (destructuring-bind (collection-id collection-name description)
		collection-row
	      (format stream "~%Collection-id: ~A~% Name: ~A~% Description: ~A~%"
		      collection-id collection-name description)
	      (when compositions
		(list-compositions package
				   :collection-identifier
				   (make-midi-db-collection-identifier
				    collection-id))))
	 do (print-separator)))))

(defmethod list-compositions ((package (eql *package*)) &key
			      collection-identifier
			      (stream *standard-output*))
  (let ((composition-headers
	 (if collection-identifier
	     (%get-all-collection-composition-headers
	      collection-identifier)
	     (%get-all-composition-headers))))
    (loop for composition-header in composition-headers
       do (destructuring-bind (collection-id composition-id filename
       timebase start duration owner version creation-timestamp
       deletion-timestamp) composition-header
	    (format stream "~%Collection-id: ~A Composition-id: ~A filename: ~A timebase: ~A start: ~A duration: ~A owner: ~A version: ~A created: ~A deleted: ~A~%"
		    collection-id composition-id filename timebase
		    start duration owner version creation-timestamp
		    deletion-timestamp)))))