diff implementations/midi-db/methods.lisp @ 236:a5d065905f6d

Add midi-db. Ignore-this: c6f4fc32efa4453ddbdc478793eedd52 A basic implementation for working with MIDI files stored in the database. It is a test case for `versioned' data, but only partially implemented at the moment. darcs-hash:20100223152703-16a00-4388d2720907d777a1c6c6b3a010885ce0fe06a7.gz committer: Jamie Forth <j.forth@gold.ac.uk>
author j.forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents
children c454b4fc9aad
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/implementations/midi-db/methods.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -0,0 +1,38 @@
+(cl:in-package #:amuse-midi-db)
+
+(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 77))
+	     (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 filename timebase start
+					      duration owner version
+					      creation-timestamp
+					      deletion-timestamp)
+	      composition-header
+	    (format stream "~%Collection-id: ~A filename: ~A timebase: ~A start: ~A duration: ~A owner: ~A version: ~A created: ~A deleted: ~A~%"
+		    collection-id filename timebase start duration owner
+		    version creation-timestamp deletion-timestamp)))))