Changeset 142 for trunk/src/model


Ignore:
Timestamp:
11/17/09 11:21:40 (15 years ago)
Author:
lgiessmann
Message:

added the generic function add-reifier which adds a reifier to a reifiable object. currently this function does not merge reifier-topics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/model/datamodel.lisp

    r141 r142  
    104104           :reified
    105105           :reifier
     106           :add-reifier
    106107
    107108           :*current-xtm* ;; special variables
     
    620621    (setf (slot-value construct 'reifier) topic)
    621622    (setf (reified topic) construct)))
     623
     624(defgeneric add-reifier (construct reifier-uri)
     625  (:method ((construct ReifiableConstructC) reifier-uri)
     626    (let ((err "From add-reifier(): "))
     627      (let ((item-identifier
     628             (elephant:get-instance-by-value 'Item-IdentifierC 'uri reifier-uri)))
     629        (unless item-identifier
     630          (error "~ano item-identifier could be found with the uri ~a"
     631                 err reifier-uri))
     632        (let ((reifier-topic (identified-construct item-identifier)))
     633          (unless (typep reifier-topic 'TopicC)
     634            (error "~aitem-identifier ~a must be bound to a topic, but is ~a"
     635                   err reifier-uri (type-of reifier-topic)))
     636          (cond
     637            ((and (not (reifier construct))
     638                  (not (reified reifier-topic)))
     639             (setf (reifier construct) reifier-topic)
     640             (setf (reified reifier-topic) construct))
     641            ((and (not (reified reifier-topic))
     642                  (reifier construct))
     643             ;merge topics
     644             t)
     645            ((and (not (reifier construct))
     646                  (reified reifier-topic))
     647             (error "~a~a reifies already another object ~a"
     648                    err reifier-uri (reified reifier-topic)))
     649            (t
     650             (when (not (eql (reified reifier-topic) construct))
     651               (error "~a~a reifies already another object ~a"
     652                      err reifier-uri (reified reifier-topic)))
     653             ;merge both topics or throw an error
     654             t)))))
     655    construct))
     656
     657
     658(defgeneric merge-reifier-topics (old-topic new-topic)
     659  (:method ((old-topic TopicC) (new-topic TopicC))
     660    ;move all item-identifiers to the new topic ;check if they are already existing
     661    ;move all subject-locators to the new topic ;check if they are already existing
     662    ;move all subject-identifiers to the new topic ;check if they are already existing
     663    ;move all names to the new topic ;check if they are already existing
     664    ;move all occurrences to the new topic ;check if they are already existing
     665    ;check all objects where the topic is the type of
     666    ;check all roles where the topic is a player of
     667    ;check all objects where the topic is a scope of
     668    (format t "~a~a" old-topic new-topic)
     669    ))
     670
    622671
    623672(defgeneric item-identifiers (construct &key revision)
Note: See TracChangeset for help on using the changeset viewer.