Revision: 3675 Author: ksprotte URL: http://bknr.net/trac/changeset/3675
factored slot-strings into a seperate file U trunk/projects/bos/m2/bos.m2.asd U trunk/projects/bos/m2/poi.lisp A trunk/projects/bos/m2/slot-strings.lisp
Modified: trunk/projects/bos/m2/bos.m2.asd =================================================================== --- trunk/projects/bos/m2/bos.m2.asd 2008-07-29 09:59:45 UTC (rev 3674) +++ trunk/projects/bos/m2/bos.m2.asd 2008-07-29 10:06:05 UTC (rev 3675) @@ -11,7 +11,7 @@ (:file "geometry" :depends-on ("packages")) (:file "config" :depends-on ("packages")) (:file "utils" :depends-on ("packages")) - (:file "news" :depends-on ("packages" "poi")) + (:file "news" :depends-on ("packages" "slot-strings")) (:file "tiled-index" :depends-on ("packages")) (:file "mail-generator" :depends-on ("packages")) (:file "make-certificate" :depends-on ("packages")) @@ -24,7 +24,8 @@ (:file "allocation" :depends-on ("geometry" "packages")) (:file "allocation-cache" :depends-on ("allocation" "initialization-subsystem" "packages" "utils")) - (:file "poi" :depends-on ("packages")) + (:file "slot-strings" :depends-on ("packages")) + (:file "poi" :depends-on ("packages" "slot-strings")) (:file "import" :depends-on ("packages")) (:file "map" :depends-on ("config" "packages" "tiled-index")) (:file "export" :depends-on ("packages"))
Modified: trunk/projects/bos/m2/poi.lisp =================================================================== --- trunk/projects/bos/m2/poi.lisp 2008-07-29 09:59:45 UTC (rev 3674) +++ trunk/projects/bos/m2/poi.lisp 2008-07-29 10:06:05 UTC (rev 3675) @@ -3,34 +3,8 @@ ;; Klassen und Funktione für die "Points of Information", die für die ;; Quadratmeter-Datenbank gespeichert werden.
-;; Die Implementation kurvt ein bisschen um den aktuellen Datastore -;; herum, da eine ästhetische Implementation der mehrsprachigen -;; Strings MOP erforderlich machen würde, die Umstellung des Datastore -;; auf MOP jedoch noch nicht fertig ist. - (in-package :bos.m2)
-;; Multilinguale Strings als Slots, werden als Hashes im Objekt -;; gespeichert und über slot-string bzw. (setf slot-string) -;; angesprochen. - -(defun make-string-hash-table () - (make-hash-table :test #'equal)) - -(defun slot-string (object slot-name language &optional (not-found-value "")) - (or (gethash language (slot-value object slot-name)) not-found-value)) - -(defun set-slot-string (object slot-name language new-value) - (unless (in-transaction-p) - (error "attempt to set string in multi-language string slot ~a of object ~a outside of transaction" slot-name object)) - (setf (gethash language (slot-value object slot-name)) new-value)) - -(defsetf slot-string set-slot-string) - -(deftransaction set-slot-string-values (object language &rest args) - (loop for (slot-name value) on args by #'cddr - do (setf (slot-string object slot-name language) value))) - ;;; POI-Anwendungsklassen und Konstruktoren
;;; poi-image @@ -75,19 +49,16 @@
;;; poi (define-persistent-class poi () - ((name :read :index-type string-unique-index + ((published :update :initform nil) + (name :read :index-type string-unique-index :index-reader find-poi :index-values all-pois :documentation "Symbolischer Name") (title :update :initform (make-string-hash-table) :documentation "Angezeigter Name") (subtitle :update :initform (make-string-hash-table) :documentation "Unterschrift") (description :update :initform (make-string-hash-table) :documentation "Beschreibungstext") (area :update :initform nil :documentation "Polygon mit den POI-Koordinaten") - (icon :update :initform "palme" :documentation "Name des Icons") - (images :update :initform nil) - (airals :update :initform nil) - (panoramas :update :initform nil) - (movies :update :initform nil) - (published :update :initform nil))) + (icon :update :initform "palme" :documentation "Name des Icons") + (medias :update :initform nil)))
(defmethod poi-movies :before ((poi poi)) "Lazily update the db schema. Method can be removed later."
Added: trunk/projects/bos/m2/slot-strings.lisp =================================================================== --- trunk/projects/bos/m2/slot-strings.lisp (rev 0) +++ trunk/projects/bos/m2/slot-strings.lisp 2008-07-29 10:06:05 UTC (rev 3675) @@ -0,0 +1,28 @@ +(in-package :bos.m2) + +;; Die Implementation kurvt ein bisschen um den aktuellen Datastore +;; herum, da eine ästhetische Implementation der mehrsprachigen +;; Strings MOP erforderlich machen würde, die Umstellung des Datastore +;; auf MOP jedoch noch nicht fertig ist. + +;; Multilinguale Strings als Slots, werden als Hashes im Objekt +;; gespeichert und über slot-string bzw. (setf slot-string) +;; angesprochen. + +(defun make-string-hash-table () + (make-hash-table :test #'equal)) + +(defun slot-string (object slot-name language &optional (not-found-value "")) + (or (gethash language (slot-value object slot-name)) not-found-value)) + +(defun set-slot-string (object slot-name language new-value) + (unless (in-transaction-p) + (error "attempt to set string in multi-language string slot ~a of object ~a outside of transaction" slot-name object)) + (setf (gethash language (slot-value object slot-name)) new-value)) + +(defsetf slot-string set-slot-string) + +(deftransaction set-slot-string-values (object language &rest args) + (loop for (slot-name value) on args by #'cddr + do (setf (slot-string object slot-name language) value))) +