Mercurial > hg > amuse
view base/datasets/datasets-db/methods.lisp @ 251:6a3adca16910
Refactor dataset stuff out of amuse-database-admin, and add midifile-dataset.
author | Jamie Forth <j.forth@gold.ac.uk> |
---|---|
date | Thu, 24 Feb 2011 11:23:18 +0000 |
parents | |
children |
line wrap: on
line source
(cl:in-package #:amuse-datasets) (defmethod make-dataset ((identifier db-dataset-identifier) composition-identifiers &optional description) (make-instance 'db-dataset :%data composition-identifiers :identifier identifier :description description)) (defmethod get-dataset ((dataset-identifier db-dataset-identifier)) (let ((dataset-header (clsql:query (format nil " SELECT description FROM amuse_datasets WHERE dataset_id = ~S" (dataset-id dataset-identifier)) :database amuse-database-admin:*amuse-database* :flatp t :field-names nil)) (dataset-rows (clsql:query (format nil " SELECT implementation_name, composition_id FROM amuse_datasets_join LEFT JOIN amuse_implementations USING (implementation_id) WHERE dataset_id = ~S" (dataset-id dataset-identifier)) :flatp t :field-names nil :database amuse-database-admin:*amuse-database*))) (make-dataset dataset-identifier (%init-dataset-rows dataset-rows) (car dataset-header)))) (defun %init-dataset-rows (dataset-rows) (loop for row in dataset-rows collect (make-composition-identifier (find-package (first row)) (second row)) into composition-identifiers finally (return composition-identifiers))) (defmethod assign-composition-to-dataset (composition-identifier (dataset-identifier db-dataset-identifier)) (clsql:execute-command (format nil " INSERT INTO amuse_datasets_join SET dataset_id := ~S, implementation_id := (SELECT get_impl_id('~A')), composition_id := ~S;" (dataset-id dataset-identifier) (amuse-database-admin:implementation-namestring composition-identifier) (composition-id composition-identifier))) :database amuse-database-admin:*amuse-database*)