tracking/storage: work in progress: folder
This commit is contained in:
parent
989a380a53
commit
a3238f4c2c
4 changed files with 47 additions and 11 deletions
|
@ -8,7 +8,8 @@
|
||||||
:description "Generic data processing."
|
:description "Generic data processing."
|
||||||
:depends-on (:scopes-core :scopes-web
|
:depends-on (:scopes-core :scopes-web
|
||||||
:dbi :sxql)
|
:dbi :sxql)
|
||||||
:components ((:file "storage/msgstore" :depends-on ("storage/tracking"))
|
:components ((:file "storage/folder" :depends-on ("storage/tracking"))
|
||||||
|
(:file "storage/msgstore" :depends-on ("storage/tracking"))
|
||||||
(:file "storage/storage")
|
(:file "storage/storage")
|
||||||
(:file "storage/tracking" :depends-on ("storage/storage")))
|
(:file "storage/tracking" :depends-on ("storage/storage")))
|
||||||
:long-description "scopes: generic data processing facilities."
|
:long-description "scopes: generic data processing facilities."
|
||||||
|
|
24
storage/folder.lisp
Normal file
24
storage/folder.lisp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
;;;; cl-scopes/storage/folder - persistent folders, stored in a SQL database.
|
||||||
|
|
||||||
|
(defpackage :scopes/storage/folder
|
||||||
|
(:use :common-lisp)
|
||||||
|
(:local-nicknames (:shape :scopes/shape)
|
||||||
|
(:tracking :scopes/storage/tracking))
|
||||||
|
(:export #:folder
|
||||||
|
#:make-container))
|
||||||
|
|
||||||
|
(in-package :scopes/storage/folder)
|
||||||
|
|
||||||
|
(defclass folder (tracking:track)
|
||||||
|
((shape:head-fields :initform '(:parent :name :ref))))
|
||||||
|
|
||||||
|
(defun indexes (cont)
|
||||||
|
'((parent name ref) (ref)))
|
||||||
|
|
||||||
|
(defun make-container (storage)
|
||||||
|
(make-instance 'tracking:container
|
||||||
|
:item-class 'folder
|
||||||
|
:short-name :fldr
|
||||||
|
:table-name :folders
|
||||||
|
:index-factory #'indexes
|
||||||
|
:storage storage))
|
|
@ -1,6 +1,5 @@
|
||||||
;;; cl-scopes/storage/tracking.lisp
|
;;;; cl-scopes/storage/tracking - a simple generic (SQL-based) storage
|
||||||
|
;;;; for tracks, messages, and other stuff.
|
||||||
;;;; A simple generic (SQL-based) storage for tracks, messages, and other stuff.
|
|
||||||
|
|
||||||
(defpackage :scopes/storage/tracking
|
(defpackage :scopes/storage/tracking
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
|
@ -51,9 +50,6 @@
|
||||||
(setf (gethash (short-name cont) *containers*) cont)
|
(setf (gethash (short-name cont) *containers*) cont)
|
||||||
(setf (item-head-fields cont) (shape:head-fields (make-instance (item-class cont)))))
|
(setf (item-head-fields cont) (shape:head-fields (make-instance (item-class cont)))))
|
||||||
|
|
||||||
;(defun item-head-fields (cont)
|
|
||||||
; (shape:head-fields (make-instance (item-class cont))))
|
|
||||||
|
|
||||||
(defun make-item (cont &rest head)
|
(defun make-item (cont &rest head)
|
||||||
(make-instance (item-class cont) :head head :container cont))
|
(make-instance (item-class cont) :head head :container cont))
|
||||||
|
|
||||||
|
@ -67,10 +63,14 @@
|
||||||
|
|
||||||
(defun query-one (cont crit &key order-by)
|
(defun query-one (cont crit &key order-by)
|
||||||
;(util:lgd crit)
|
;(util:lgd crit)
|
||||||
(let ((tr (make-item cont))
|
(let ((rows (storage:query (storage cont)
|
||||||
(row (car (storage:query (storage cont)
|
(setup-select cont crit :order-by order-by :limit 1))))
|
||||||
(setup-select cont crit :order-by order-by :limit 1)))))
|
(setup-track (make-item cont) (car rows))))
|
||||||
(setup-track tr row)))
|
|
||||||
|
(defun query (cont crit &key order-by)
|
||||||
|
(let ((rows (storage:query (storage cont)
|
||||||
|
(setup-select cont crit :order-by order-by))))
|
||||||
|
(mapcar #'(lambda (row) (setup-track (make-item cont) row)) rows)))
|
||||||
|
|
||||||
(defun save (track)
|
(defun save (track)
|
||||||
(let* ((cont (container track))
|
(let* ((cont (container track))
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
|
(:folder :scopes/storage/folder)
|
||||||
(:logging :scopes/logging)
|
(:logging :scopes/logging)
|
||||||
(:message :scopes/core/message)
|
(:message :scopes/core/message)
|
||||||
(:msgstore :scopes/storage/msgstore)
|
(:msgstore :scopes/storage/msgstore)
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
(let ((ctx (core:find-service :storage)))
|
(let ((ctx (core:find-service :storage)))
|
||||||
(test-track ctx)
|
(test-track ctx)
|
||||||
(test-msgstore ctx)
|
(test-msgstore ctx)
|
||||||
|
(test-folder ctx)
|
||||||
(t:show-result)))
|
(t:show-result)))
|
||||||
|
|
||||||
(deftest test-track (ctx)
|
(deftest test-track (ctx)
|
||||||
|
@ -78,3 +80,12 @@
|
||||||
(setf (getf (shape:data pm3) :info) "changed")
|
(setf (getf (shape:data pm3) :info) "changed")
|
||||||
(msgstore:save pm3 cont)
|
(msgstore:save pm3 cont)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(deftest test-folder (ctx)
|
||||||
|
(let ((st (storage:storage ctx))
|
||||||
|
(data (make-hash-table))
|
||||||
|
cont f1 f2 f3)
|
||||||
|
(setf cont (folder:make-container st))
|
||||||
|
(storage:drop-table st :folders)
|
||||||
|
(tracking:create-table cont)
|
||||||
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue