j@251
|
1 (cl:in-package #:amuse-datasets)
|
j@251
|
2
|
j@251
|
3 (defmethod make-dataset ((identifier db-dataset-identifier)
|
j@251
|
4 composition-identifiers &optional
|
j@251
|
5 description)
|
j@251
|
6 (make-instance 'db-dataset
|
j@251
|
7 :%data composition-identifiers
|
j@251
|
8 :identifier identifier
|
j@251
|
9 :description description))
|
j@251
|
10
|
j@251
|
11 (defmethod get-dataset ((dataset-identifier db-dataset-identifier))
|
j@251
|
12 (let ((dataset-header (clsql:query (format nil "
|
j@251
|
13 SELECT description
|
j@251
|
14 FROM amuse_datasets
|
j@251
|
15 WHERE dataset_id = ~S" (dataset-id dataset-identifier))
|
j@251
|
16 :database
|
j@251
|
17 amuse-database-admin:*amuse-database*
|
j@251
|
18 :flatp t
|
j@251
|
19 :field-names nil))
|
j@251
|
20 (dataset-rows (clsql:query (format nil "
|
j@251
|
21 SELECT implementation_name, composition_id
|
j@251
|
22 FROM amuse_datasets_join
|
j@251
|
23 LEFT JOIN amuse_implementations
|
j@251
|
24 USING (implementation_id)
|
j@251
|
25 WHERE dataset_id = ~S"
|
j@251
|
26 (dataset-id
|
j@251
|
27 dataset-identifier))
|
j@251
|
28 :flatp t
|
j@251
|
29 :field-names nil
|
j@251
|
30 :database
|
j@251
|
31 amuse-database-admin:*amuse-database*)))
|
j@251
|
32 (make-dataset dataset-identifier
|
j@251
|
33 (%init-dataset-rows dataset-rows)
|
j@251
|
34 (car dataset-header))))
|
j@251
|
35
|
j@251
|
36 (defun %init-dataset-rows (dataset-rows)
|
j@251
|
37 (loop for row in dataset-rows
|
j@251
|
38 collect (make-composition-identifier
|
j@251
|
39 (find-package (first row)) (second row))
|
j@251
|
40 into composition-identifiers
|
j@251
|
41 finally (return composition-identifiers)))
|
j@251
|
42
|
j@251
|
43 (defmethod assign-composition-to-dataset (composition-identifier
|
j@251
|
44 (dataset-identifier
|
j@251
|
45 db-dataset-identifier))
|
j@251
|
46 (clsql:execute-command (format nil "
|
j@251
|
47 INSERT INTO amuse_datasets_join
|
j@251
|
48 SET dataset_id := ~S,
|
j@251
|
49 implementation_id := (SELECT get_impl_id('~A')),
|
j@251
|
50 composition_id := ~S;"
|
j@251
|
51 (dataset-id dataset-identifier)
|
j@251
|
52 (amuse-database-admin:implementation-namestring
|
j@251
|
53 composition-identifier)
|
j@251
|
54 (composition-id
|
j@251
|
55 composition-identifier)))
|
j@251
|
56 :database amuse-database-admin:*amuse-database*)
|