| | 391 | (defclass poi-xml-handler (object-handler) |
|---|
| | 392 | () |
|---|
| | 393 | (:default-initargs :object-class 'poi :query-function #'find-poi)) |
|---|
| | 394 | |
|---|
| | 395 | |
|---|
| | 396 | (defmethod handle-object ((handler poi-xml-handler) poi) |
|---|
| | 397 | (labels ((format-hash-table (element-name hash-table) |
|---|
| | 398 | (with-element element-name |
|---|
| | 399 | (maphash (lambda (k v) |
|---|
| | 400 | (with-element "content" |
|---|
| | 401 | (attribute "lang" k) |
|---|
| | 402 | (text v))) |
|---|
| | 403 | hash-table))) |
|---|
| | 404 | (format-store-image (element-name store-image) |
|---|
| | 405 | (with-element element-name |
|---|
| | 406 | (with-element "id" (text (princ-to-string (store-object-id store-image)))) |
|---|
| | 407 | (with-element "name" (text (store-image-name store-image))) |
|---|
| | 408 | (with-element "width" (text (princ-to-string (store-image-width store-image)))) |
|---|
| | 409 | (with-element "height" (text (princ-to-string (store-image-height store-image))))))) |
|---|
| | 410 | (with-accessors ((id store-object-id) |
|---|
| | 411 | (name poi-name) |
|---|
| | 412 | (title poi-title) |
|---|
| | 413 | (subtitle poi-subtitle) |
|---|
| | 414 | (description poi-description) |
|---|
| | 415 | (airals poi-airals) |
|---|
| | 416 | (images poi-images) |
|---|
| | 417 | (panoramas poi-panoramas) |
|---|
| | 418 | (movies poi-movies)) poi |
|---|
| | 419 | (with-xml-response (:root-element "poi") |
|---|
| | 420 | (with-element "id" (text (princ-to-string id))) |
|---|
| | 421 | (with-element "name" (text name)) |
|---|
| | 422 | (format-hash-table "title" title) |
|---|
| | 423 | (format-hash-table "subtitle" subtitle) |
|---|
| | 424 | (format-hash-table "description" description) |
|---|
| | 425 | (with-element "airals" |
|---|
| | 426 | (mapc (alexandria:curry #'format-store-image "airal") airals)) |
|---|
| | 427 | (with-element "images" |
|---|
| | 428 | (mapc (alexandria:curry #'format-store-image "image") images)) |
|---|
| | 429 | (with-element "panoramas" |
|---|
| | 430 | (mapc (alexandria:curry #'format-store-image "panorama") panoramas)) |
|---|
| | 431 | (with-element "movies" |
|---|
| | 432 | (dolist (url movies) |
|---|
| | 433 | (with-element "movie" |
|---|
| | 434 | (with-element "url" (text url))))))))) |
|---|
| | 435 | |
|---|