Changeset 390 for trunk/src/TM-SPARQL


Ignore:
Timestamp:
02/06/11 10:17:44 (14 years ago)
Author:
lgiessmann
Message:

TM-SPARQL: added a method to process the special uri tms:player

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/TM-SPARQL/sparql_special_uris.lisp

    r389 r390  
    4848                ((and (has-identifier (value pred) *tms-player*)
    4949                      (typep subj-value 'd:RoleC))
    50                  nil) ;TODO: implement
    51                 )))))
     50                 (filter-for-player construct :revision revision)))))))
    5251
    5352
     
    6564    ;; *tms-player*
    6665    ))
     66
     67
     68(defgeneric filter-for-player (construct &key revision)
     69  (:documentation "Returns a list with triples where the subject
     70                   represents a role and the object represents a player.")
     71  (:method ((construct SPARQL-Triple) &key (revision *TM-REVISION*))
     72      (unless (literal-p (object construct))
     73        (let* ((subj (subject construct))
     74               (pred (predicate construct))
     75               (obj (object construct))
     76               (subj-uri (unless (variable-p subj)
     77                           (when-do id (any-id (value subj) :revision revision)
     78                                    (embrace-uri (uri id)))))
     79               (pred-uri (unless (variable-p pred)
     80                           (when-do id (any-id (value pred) :revision revision)
     81                                    (embrace-uri (uri id)))))
     82               (obj-uri (unless (variable-p obj)
     83                          (when-do id (any-id (value obj) :revision revision)
     84                                   (embrace-uri (uri id))))))
     85          (cond ((and (not (variable-p subj))
     86                      (not (variable-p obj)))
     87                 (when (eql (player (value subj) :revision revision)
     88                            (value obj))
     89                   (list (list :subject subj-uri
     90                               :predicate pred-uri
     91                               :object obj-uri))))
     92                ((not (variable-p subj))
     93                 (let ((player-top
     94                        (player (value subj) :revision revision)))
     95                   (when player-top
     96                     (list :subject subj-uri
     97                           :predicate pred-uri
     98                           :object (when-do id (any-id player-top :revision revision)
     99                                            (embrace-uri (uri id)))))))
     100                ((not (variable-p obj))
     101                 (let ((parent-roles
     102                        (player-in-roles (value obj) :revision revision)))
     103                   (loop for role in parent-roles
     104                      collect (list :subject (when-do id (any-id role :revision revision)
     105                                                      (embrace-uri id))
     106                                    :predicate pred-uri
     107                                    :object
     108                                    (when-do id (any-id (player role :revision revision)
     109                                                        :revision revision)
     110                                             (embrace-uri id))))))
     111                (t ; only pred is given
     112                 (let ((all-roles
     113                        (remove-null
     114                         (map 'list #'(lambda(role)
     115                                        (when (player role :revision revision)
     116                                          role))
     117                              (get-all-roles revision)))))
     118                   (loop for role in all-roles
     119                      collect (list :subject
     120                                    (when-do id (any-id role :revision revision)
     121                                             (embrace-uri (uri id)))
     122                                    :predicate pred-uri
     123                                    :object
     124                                    (when-do id (any-id (player role :revision revision)
     125                                                        :revision revision)
     126                                             (embrace-uri id)))))))))))
    67127
    68128
     
    295355
    296356  (defgeneric filter-for-reifier (construct &key revision)
    297     (:documentation "Returns a list with one triple representing a reifier
    298                    and the corresponding reified construct.")
     357    (:documentation "Returns a list with triples representing a reifier
     358                     and the corresponding reified construct.")
    299359    (:method ((construct SPARQL-Triple) &key (revision *TM-REVISION*))
    300360      (unless (literal-p (object construct))
Note: See TracChangeset for help on using the changeset viewer.