Mercurial > hg > amuse
comparison implementations/mtp/methods.lisp @ 53:ce4a90427366
implementations/mtp/: add interface to datasets
darcs-hash:20070621120721-c0ce4-54d29dd03ab4d7d61c70ed808d0fd3277687929e.gz
author | Marcus Pearce <m.pearce@gold.ac.uk> |
---|---|
date | Thu, 21 Jun 2007 13:07:21 +0100 |
parents | 894fb5156603 |
children | 8b31d54c95be |
comparison
equal
deleted
inserted
replaced
52:e0acd4c37121 | 53:ce4a90427366 |
---|---|
1 (cl:in-package #:amuse-mtp) | 1 (cl:in-package #:amuse-mtp) |
2 | 2 |
3 ;;; Compositions | 3 ;;; Compositions |
4 | 4 |
5 #.(clsql:locally-enable-sql-reader-syntax) | 5 #.(clsql:locally-enable-sql-reader-syntax) |
6 | |
7 (defgeneric get-dataset (identifer)) | |
8 | |
9 (defmethod get-dataset ((identifier mtp-dataset-identifier)) | |
10 (let* ((dataset-id (dataset-id identifier)) | |
11 (where-clause [= [dataset-id] dataset-id]) | |
12 (data (clsql:select [*] :from [mtp-dataset] :where where-clause)) | |
13 (dataset (make-mtp-dataset :dataset-id (first data) | |
14 :description (second data) | |
15 :timebase (third data) | |
16 :midc (fourth data))) | |
17 (compositions nil) | |
18 (composition-count | |
19 (1+ | |
20 (car | |
21 (clsql:select [max [composition-id]] :from [mtp-composition] | |
22 :where where-clause :flatp t :field-names nil))))) | |
23 (dotimes (composition-id composition-count) | |
24 (push (get-composition | |
25 (make-mtp-composition-identifier dataset-id composition-id)) | |
26 compositions)) | |
27 (sequence:adjust-sequence dataset (length compositions) | |
28 :initial-contents (nreverse compositions)) | |
29 dataset)) | |
6 | 30 |
7 (defmethod get-composition ((identifier mtp-composition-identifier)) | 31 (defmethod get-composition ((identifier mtp-composition-identifier)) |
8 (let* ((dataset-id (dataset-id identifier)) | 32 (let* ((dataset-id (dataset-id identifier)) |
9 (composition-id (composition-id identifier)) | 33 (composition-id (composition-id identifier)) |
10 (where-clause [and [= [dataset-id] dataset-id] | 34 (where-clause [and [= [dataset-id] dataset-id] |