Ignore:
Timestamp:
06/13/10 14:42:34 (15 years ago)
Author:
lgiessmann
Message:

new-datamodel: adpted all unit-test for the xtm-importer (xtm2.0); fixed two bug in make-pointerc; fixed a bug when importing topics, names, occurrences, variants and tm-identifiers; fixed a bug in add-to-tm; fixed a bug when mergin was caused by an item-identifier

Location:
branches/new-datamodel/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/new-datamodel/src/model/datamodel.lisp

    r296 r298  
    161161
    162162
    163 ;;TODO: adapt changes.lisp --> changed-p
    164163;;TODO: implement a macro with-merge-constructs, that merges constructs
    165164;;      after all operations in the body were called
     
    15871586                   returns one of the topic-ids in that TM
    15881587                   (which must then exist).")
    1589   (:method ((construct TopicC) &optional (xtm-id nil) (revision *TM-REVISION*))
    1590     (declare (type (or null string) xtm-id) (integer revision))
     1588  (:method ((construct TopicC) &optional (revision *TM-REVISION*) (xtm-id nil))
     1589    (declare (type (or string null) xtm-id)
     1590             (type (or integer null) revision))
    15911591    (if xtm-id
    15921592        (let ((possible-identifiers
     
    31283128             (when (not (eql id-owner construct))
    31293129               id-owner))))
     3130      (when (and construct-to-be-merged
     3131                 (not (eql (type-of construct-to-be-merged)
     3132                           (type-of construct))))
     3133        (error (make-not-mergable-condition (format nil "From add-item-identifier(): ~a and ~a can't be merged since the identified-constructs are not of the same type"
     3134                                                    construct construct-to-be-merged)
     3135                                            construct construct-to-be-merged)))
    31303136      (let ((merged-construct construct))
    31313137        (cond (construct-to-be-merged
     
    34863492
    34873493(defmethod add-to-tm ((construct TopicMapC) (construct-to-add TopicC))
    3488   (add-association construct 'topics construct-to-add))
     3494  (add-association construct 'topics construct-to-add)
     3495  construct-to-add)
    34893496
    34903497
    34913498(defmethod add-to-tm ((construct TopicMapC) (construct-to-add AssociationC))
    3492   (add-association construct 'associations construct-to-add))
     3499  (add-association construct 'associations construct-to-add)
     3500  construct-to-add)
    34933501
    34943502
     
    38073815                   (map 'list
    38083816                        #'(lambda(existing-pointer)
    3809                             (when (equivalent-construct existing-pointer uri
    3810                                                         xtm-id)
     3817                            (when (equivalent-construct existing-pointer :uri uri
     3818                                                        :xtm-id xtm-id)
    38113819                              existing-pointer))
    38123820                        (elephant:get-instances-by-value class-symbol 'd::uri uri)))))
    3813              (if existing-pointer existing-pointer
     3821             (if existing-pointer
     3822                 (first existing-pointer)
    38143823                 (make-instance class-symbol :uri uri :xtm-id xtm-id)))))
    38153824      (when identified-construct
  • TabularUnified branches/new-datamodel/src/unit_tests/fixtures.lisp

    r183 r298  
    9595
    9696(def-fixture initialized-test-db (&optional (xtm *NOTIFICATIONBASE-TM*))
    97   (let
    98       ((revision (get-revision)))
     97  (let ((revision (get-revision)))
    9998    (declare (ignorable revision))
     99    (setf *TM-REVISION* revision)
    100100    (setf *XTM-TM* xtm)
    101101    (set-up-test-db revision)
    102     (let
    103         ((tm
    104           (get-item-by-item-identifier "http://www.isidor.us/unittests/testtm" :revision (d:get-revision))))
     102    (let ((tm
     103           (get-item-by-item-identifier "http://www.isidor.us/unittests/testtm"
     104                                        :revision revision)))
    105105      (declare (ignorable tm))
    106106      (&body)
  • TabularUnified branches/new-datamodel/src/unit_tests/importer_test.lisp

    r238 r298  
    2323  (:import-from :exceptions
    2424                missing-reference-error
    25                 duplicate-identifier-error)
     25                duplicate-identifier-error
     26                not-mergable-error )
    2627  (:export :importer-test
    2728           :test-error-detection
     
    5859  (with-fixture
    5960      initialized-test-db()
    60     (let
    61         ((type-elems
    62           (xpath-select-location-path
    63            *XTM-TM*
    64            '((*xtm2.0-ns* "topic")
    65              (*xtm2.0-ns* "occurrence")
    66              (*xtm2.0-ns* "type")))))
     61    (let ((type-elems
     62           (xpath-select-location-path
     63            *XTM-TM*
     64            '((*xtm2.0-ns* "topic")
     65              (*xtm2.0-ns* "occurrence")
     66              (*xtm2.0-ns* "type"))))
     67          (rev-1 *TM-REVISION*))
    6768      (loop for type-elem in type-elems do
    68            (is (typep (from-type-elem type-elem) 'TopicC)))
    69       (is-false (from-type-elem nil))
     69           (is (typep (from-type-elem type-elem rev-1) 'TopicC)))
     70      (is-false (from-type-elem nil rev-1))
    7071      (let
    7172          ((t100-occtype
    72             (from-type-elem (first type-elems))))       
     73            (from-type-elem (first type-elems) rev-1)))       
    7374        (format t "occtype: ~a~&" t100-occtype)
    7475        (format t "occtype: ~a~&" (psis t100-occtype))
     
    8384  (with-fixture
    8485      initialized-test-db()
    85     (let
    86         ((scope-elems
    87           (xpath-select-location-path
    88            *XTM-TM*
    89            '((*xtm2.0-ns* "topic")
    90              (*xtm2.0-ns* "name")
    91              (*xtm2.0-ns* "scope")))))
     86    (let ((scope-elems
     87           (xpath-select-location-path
     88            *XTM-TM*
     89            '((*xtm2.0-ns* "topic")
     90              (*xtm2.0-ns* "name")
     91              (*xtm2.0-ns* "scope"))))
     92          (rev-1 *TM-REVISION*))
    9293      (loop for scope-elem in scope-elems do
    93            (is (>= (length (from-scope-elem scope-elem)) 1)))
    94       (is-false (from-scope-elem nil))
     94           (is (>= (length (from-scope-elem scope-elem rev-1)) 1)))
     95      (is-false (from-scope-elem nil rev-1))
    9596      (let
    9697          ((t101-themes
    97             (from-scope-elem (first scope-elems))))
     98            (from-scope-elem (first scope-elems) rev-1)))
    9899        (is (= 1 (length t101-themes)))
    99100        (is
     
    106107  (with-fixture
    107108      initialized-test-db()
    108     (let
    109         ((name-elems
    110           (xpath-select-location-path
    111            *XTM-TM*
    112            '((*xtm2.0-ns* "topic")
    113              (*xtm2.0-ns* "name"))))
    114          (top (get-item-by-id "t1"))) ;an arbitrary topic
     109    (let ((name-elems
     110           (xpath-select-location-path
     111            *XTM-TM*
     112            '((*xtm2.0-ns* "topic")
     113              (*xtm2.0-ns* "name"))))
     114          (top (get-item-by-id "t1")) ;an arbitrary topic
     115          (rev-1 *TM-REVISION*))
    115116      (loop for name-elem in name-elems do
    116            (is (typep (from-name-elem name-elem top revision) 'NameC)))
     117           (is (typep (from-name-elem name-elem top rev-1) 'NameC)))
    117118      (let
    118           ((t1-name (from-name-elem (first name-elems) top revision))
    119            (t1-name-copy (from-name-elem (first name-elems) top revision))
    120            (t101-longname (from-name-elem (nth 27 name-elems) top revision)))
     119          ((t1-name (from-name-elem (first name-elems) top rev-1))
     120           (t1-name-copy (from-name-elem (first name-elems) top rev-1))
     121           (t101-longname (from-name-elem (nth 27 name-elems) top rev-1)))
    121122        (is (string= (charvalue t1-name) "Topic Type"))
    122         (is (string=
    123              (charvalue t101-longname)
    124              "ISO/IEC 13250:2002: Topic Maps"))
    125         (is (= 1 (length (item-identifiers t101-longname))))
    126  
    127         (is (string=
    128              (uri (first (psis (instance-of t101-longname))))
    129              "http://psi.egovpt.org/types/long-name"))
    130         (is (themes t101-longname))
     123        (is (string= (charvalue t101-longname)
     124                     "ISO/IEC 13250:2002: Topic Maps"))
     125        (is (= 1 (length (item-identifiers t101-longname :revision rev-1))))
     126        (is (string= (uri (first (psis (instance-of t101-longname))))
     127                     "http://psi.egovpt.org/types/long-name"))
     128        (is (themes t101-longname :revision rev-1))
    131129        (is (string=
    132              (topic-id (first (themes t101-longname)) *TEST-TM*)
     130             (topic-id (first (themes t101-longname :revision rev-1))
     131                       rev-1 *TEST-TM*)
    133132             "t50a"))
    134         (is (eq t1-name t1-name-copy)) ;must be merged
    135             ))))
     133        (is (eq t1-name t1-name-copy)))))) ;must be merged
     134
    136135
    137136(test test-from-occurrence-elem
     
    139138  (with-fixture
    140139      initialized-test-db()
    141     (let
    142         ((occ-elems
    143           (xpath-select-location-path
    144            *XTM-TM*
    145            '((*xtm2.0-ns* "topic")
    146              (*xtm2.0-ns* "occurrence"))))
    147          (top (get-item-by-id "t1"))) ;an abritrary topic
    148 
     140    (let ((occ-elems
     141           (xpath-select-location-path
     142            *XTM-TM*
     143            '((*xtm2.0-ns* "topic")
     144              (*xtm2.0-ns* "occurrence"))))
     145          (top (get-item-by-id "t1")) ;an abritrary topic
     146          (rev-1 *TM-REVISION*))
    149147      (loop for occ-elem in occ-elems do
    150            (is (typep (from-occurrence-elem occ-elem top revision)
    151                     'OccurrenceC)))
     148           (is (typep (from-occurrence-elem occ-elem top rev-1)
     149                      'OccurrenceC)))
    152150      (is (= 1 (length (elephant:get-instances-by-value
    153               'ItemIdentifierC
    154               'uri
    155               "http://psi.egovpt.org/itemIdentifiers#t100_o1"))))
     151                        'ItemIdentifierC
     152                        'uri
     153                        "http://psi.egovpt.org/itemIdentifiers#t100_o1"))))
    156154      (let
    157155          ((t100-occ1
     
    167165              'uri
    168166              "http://psi.egovpt.org/itemIdentifiers#t100_o2"))))
    169         (is (= 1 (length (item-identifiers t100-occ1))));just to double-check
     167        (is (= 1 (length (item-identifiers t100-occ1 :revision rev-1)))) ;just to double-check
    170168        (is (string=
    171              (uri (first (item-identifiers t100-occ1)))
     169             (uri (first (item-identifiers t100-occ1 :revision rev-1)))
    172170             "http://psi.egovpt.org/itemIdentifiers#t100_o1"))
    173171        (is (string= (charvalue t100-occ1) "http://www.budabe.de/"))
     
    180178  (with-fixture
    181179      initialized-test-db()
    182     (let
    183         ((topic-elems
    184           (xpath-select-location-path
    185            *XTM-TM*
    186            '((*xtm2.0-ns* "topic")))))
    187                                              
     180    (let ((topic-elems
     181           (xpath-select-location-path
     182            *XTM-TM*
     183            '((*xtm2.0-ns* "topic"))))
     184          (rev-1 *TM-REVISION*))
    188185      (loop for topic-elem in topic-elems do
    189186           (is (typep
    190                 (merge-topic-elem topic-elem revision :tm fixtures::tm)
     187                (merge-topic-elem topic-elem rev-1 :tm fixtures::tm)
    191188                    'TopicC)))
    192189      (let
    193190          ((top-t1 (merge-topic-elem (first topic-elems)
    194                                      revision :tm fixtures::tm))
     191                                     rev-1 :tm fixtures::tm))
    195192           (top-t57 (get-item-by-id "t57"))
    196193           (top-t101 (get-item-by-id "t101"))
     
    199196           ;one of the core PSIs
    200197           (top-sup-sub (get-item-by-id "supertype-subtype" :xtm-id "core.xtm")))
    201         (is (= (internal-id top-t301)
    202                (internal-id top-t301a)))
    203         (is (= (length (occurrences top-t1)) 0))
    204         (is (= (length (occurrences top-t101)) 4))
    205         (is (= (length (names top-t57)) 1))
    206         (is (string= (uri (first (item-identifiers top-t57)))
     198        (is (= (elephant::oid top-t301) (elephant::oid top-t301a)))
     199        (is-true top-t301a)
     200        (is (= (length (occurrences top-t1 :revision rev-1)) 0))
     201        (is (= (length (occurrences top-t101 :revision rev-1)) 4))
     202        (is (= (length (names top-t57 :revision rev-1)) 1))
     203        (is (string= (uri (first (item-identifiers top-t57 :revision rev-1)))
    207204                     "http://psi.egovpt.org/itemIdentifiers#t57"))
    208         (is (= 2 (length (names top-t101))))
    209         (is (= 2 (length (names top-t301)))) ;after merge
    210         (is-true (item-identifiers (first (names top-t301)))) ;after merge
    211         (is (= 2 (length (psis top-t301)))) ;after merge
    212         (is (= 3 (length (occurrences top-t301)))) ;after merge
     205        (is (= 2 (length (names top-t101 :revision rev-1))))
     206        (is (= 2 (length (names top-t301 :revision rev-1)))) ;after merge
     207        (is-true (item-identifiers (first (names top-t301 :revision rev-1))
     208                                   :revision rev-1)) ;after merge
     209        (is (= 2 (length (psis top-t301 :revision rev-1)))) ;after merge
     210        (is (= 3 (length (occurrences top-t301 :revision rev-1)))) ;after merge
    213211        (is (string= "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype-subtype"
    214                      (uri (first (psis top-sup-sub)))))))
    215 
     212                     (uri (first (psis top-sup-sub :revision rev-1)))))))
    216213    ;34 topics in 35 topic elements in notificationbase.xtm and 13
    217214    ;core topics
     
    227224           *XTM-TM*
    228225           '((*xtm2.0-ns* "association")
    229              (*xtm2.0-ns* "role")))))
     226             (*xtm2.0-ns* "role"))))
     227         (rev-1 *TM-REVISION*))
    230228      (loop for role-elem in role-elems do
    231229           (is (typep (from-role-elem role-elem revision) 'list)))
     
    235233        (is (string= "t101"
    236234                     (topic-id
    237                       (getf 12th-role :player) *TEST-TM*)))
     235                      (getf 12th-role :player) rev-1 *TEST-TM*)))
    238236        (is (string=  "t62"
    239237                      (topic-id
    240                        (getf 12th-role :instance-of) *TEST-TM*)))))))
     238                       (getf 12th-role :instance-of) rev-1 *TEST-TM*)))))))
     239
    241240
    242241(test test-from-association-elem
     
    244243  (with-fixture
    245244      initialized-test-db()
    246     (let
    247         ((assoc-elems
    248           (xpath-select-location-path
    249            *XTM-TM*
    250            '((*xtm2.0-ns* "association")))))
     245    (let ((assoc-elems
     246           (xpath-select-location-path
     247            *XTM-TM*
     248            '((*xtm2.0-ns* "association"))))
     249          (rev-1 *TM-REVISION*))
    251250      (loop for assoc-elem in assoc-elems do
    252251           (is
    253             (typep (from-association-elem assoc-elem revision :tm fixtures::tm)
     252            (typep (from-association-elem assoc-elem rev-1 :tm fixtures::tm)
    254253                'AssociationC)))
    255       ;(trace datamodel:item-identifiers datamodel::filter-slot-value-by-revision)
    256       (let
    257           ((6th-assoc
    258             (sixth (elephant:get-instances-by-class 'AssociationC)))
    259            (last-assoc
    260             (seventh (elephant:get-instances-by-class 'AssociationC))))
    261         (is (= 2 (length (roles last-assoc))))
    262         (is (= 1 (length (item-identifiers last-assoc))))
     254      (let ((6th-assoc
     255             (sixth (elephant:get-instances-by-class 'AssociationC)))
     256            (last-assoc
     257             (seventh (elephant:get-instances-by-class 'AssociationC))))
     258        (is (= 2 (length (roles last-assoc :revision rev-1))))
     259        (is (= 1 (length (item-identifiers last-assoc :revision rev-1))))
    263260        (is (string= "t300"
    264              (topic-id (player (first (roles 6th-assoc)))  *TEST-TM*)))
     261             (topic-id (player (first (roles 6th-assoc :revision rev-1))
     262                               :revision rev-1) rev-1 *TEST-TM*)))
    265263        (is (string= "t63"
    266              (topic-id (instance-of (first (roles 6th-assoc)))
    267                       *TEST-TM*)))
     264             (topic-id (instance-of (first (roles 6th-assoc :revision rev-1))
     265                                    :revision rev-1) rev-1 *TEST-TM*)))
    268266        (is (string= "t301"
    269              (topic-id (player (first (roles last-assoc)))
    270                       *TEST-TM*))))
    271       ;(untrace datamodel:item-identifiers datamodel::filter-slot-value-by-revision))
    272       )
    273     ;(map 'list (lambda (a) (format t "~a" (exporter:to-string a))) (elephant:get-instances-by-class 'AssociationC))
     267             (topic-id (player (first (roles last-assoc :revision rev-1))
     268                               :revision rev-1) rev-1 *TEST-TM*)))))
    274269    (is (= 7
    275270           (length (elephant:get-instances-by-class 'AssociationC))))))
     
    281276  (with-fixture
    282277      initialized-test-db()
    283     (let
    284         ((topic-elems
    285           (xpath-select-location-path
    286            *XTM-TM*
    287            '((*xtm2.0-ns* "topic")))))
     278    (let ((topic-elems
     279           (xpath-select-location-path
     280            *XTM-TM*
     281            '((*xtm2.0-ns* "topic"))))
     282          (rev-1 *TM-REVISION*))
    288283      (loop for topic-elem in topic-elems do
    289            (let
    290                (
    291                 ;this already implicitly creates the instanceOf
    292                 ;associations as needed
    293                 (topic (merge-topic-elem topic-elem revision :tm fixtures::tm)))
    294              ;(format t "instanceof-topicrefs: ~a~&" instanceof-topicrefs)
    295              (dolist (io-role
    296                        (elephant:get-instances-by-value
    297                         'RoleC
    298                         'player topic))
    299                (let
    300                    ((io-assoc (parent io-role)))
    301                  ;(format t "(io-topicref: ~a, topic: ~a)~&" io-topicref topic)
    302                  (is
    303                   (typep io-assoc
    304                       'AssociationC))
    305                  (is (string= (topic-id topic)
    306                             (topic-id (player (second (roles io-assoc))))))))))
    307 
    308       (let*
    309           ((t101-top (get-item-by-id "t101"))
     284           (let (;this already implicitly creates the instanceOf
     285                 ;associations as needed
     286                 (topic (merge-topic-elem topic-elem rev-1 :tm fixtures::tm)))
     287              (dolist (io-role (map 'list #'d::parent-construct
     288                                    (d::slot-p topic 'd::player-in-roles)))
     289                (let ((io-assoc (parent io-role :revision rev-1)))
     290                  (is (typep io-assoc 'AssociationC))
     291                  (is (string= (topic-id topic rev-1)
     292                               (topic-id (player (second
     293                                                  (roles io-assoc :revision rev-1))
     294                                                 :revision rev-1) rev-1)))))))
     295      (let* ((t101-top (get-item-by-id "t101" :revision rev-1))
    310296                                        ;get all the roles t101 is involved in
    311            (roles-101 (elephant:get-instances-by-value 'RoleC 'player t101-top))
     297             (roles-101 (map 'list #'d::parent-construct
     298                             (d::slot-p t101-top 'd::player-in-roles)))
    312299                                        ;and filter those whose roletype is "instance"
    313300                                        ;(returning, of course, a list)
    314            
    315301                                        ;TODO: what we'd really need
    316302                                        ;is a filter that works
     
    318304                                        ;rather than instantiating
    319305                                        ;many unnecessary role objects
    320            (role-101 (remove-if-not
    321                       (lambda (role)
    322                         (string= (uri (first (psis (instance-of role))))
    323                                  "http://psi.topicmaps.org/iso13250/model/instance")) roles-101)))
     306             (role-101 (remove-if-not
     307                        (lambda (role)
     308                          (string= (uri (first (psis
     309                                                (instance-of role :revision rev-1)
     310                                                :revision rev-1)))
     311                                   "http://psi.topicmaps.org/iso13250/model/instance"))
     312                        roles-101)))
    324313                                        ;Topic t101 (= Topic Maps 2002
    325314                                        ;standard) is subclass of
    326315                                        ;topic t3a (semantic standard)
    327 
    328316        (is-true t101-top)
    329317        (is (= 1 (length role-101)))
    330         ;(is (= 1 (length (d::versions role-101))))
    331318        (is (string= "t3a"
    332                      (topic-id (player (first (roles (parent (first role-101))))) *TEST-TM*)))
     319                     (topic-id (player (first (roles (parent (first role-101))
     320                                                     :revision rev-1))
     321                                       :revision rev-1)
     322                               rev-1 *TEST-TM*)))
    333323        (is (string= "type-instance"
    334324                     (topic-id (instance-of
    335                                (parent (first role-101))) "core.xtm")))
    336         ))))
     325                                (parent (first role-101) :revision rev-1))
     326                               rev-1 "core.xtm")))))))
     327
    337328
    338329(test test-error-detection
     
    357348                  :tm-id "http://www.isidor.us/unittests/baretests"))))
    358349  (with-fixture bare-test-db()
    359     (signals duplicate-identifier-error
     350    (signals not-mergable-error
    360351      (let
    361352          ((xtm-dom
     
    374365                                     :tm-id "http://www.isidor.us/unittests/topic-t100")
    375366      (elephant:open-store (xml-importer:get-store-spec dir))
    376 
    377367      (is (= 25 (length (elephant:get-instances-by-class 'TopicC)))) ;; are all topics in the db +std topics
    378       (is-true (get-item-by-id "t100")) ;; main topic
    379       (is-true (get-item-by-id "t3a"))  ;; instanceOf
    380       (is-true (get-item-by-id "t50a")) ;; scope
    381       (is-true (get-item-by-id "t51"))   ;; occurrence/type
    382       (is-true (get-item-by-id "t52"))   ;; occurrence/resourceRef
    383       (is-true (get-item-by-id "t53"))   ;; occurrence/type
    384       (is-true (get-item-by-id "t54"))   ;; occurrence/type
    385       (is-true (get-item-by-id "t55"))  ;; occurrence/type
    386       (let ((t100 (get-item-by-id "t100")))
     368      (is-true (get-item-by-id "t100" :revision 0)) ;; main topic
     369      (is-true (get-item-by-id "t3a" :revision 0))  ;; instanceOf
     370      (is-true (get-item-by-id "t50a" :revision 0)) ;; scope
     371      (is-true (get-item-by-id "t51" :revision 0))   ;; occurrence/type
     372      (is-true (get-item-by-id "t52" :revision 0))   ;; occurrence/resourceRef
     373      (is-true (get-item-by-id "t53" :revision 0))   ;; occurrence/type
     374      (is-true (get-item-by-id "t54" :revision 0))   ;; occurrence/type
     375      (is-true (get-item-by-id "t55" :revision 0))  ;; occurrence/type
     376      (let ((t100 (get-item-by-id "t100" :revision 0)))
    387377        ;; checks instanceOf
    388         (is (= 1 (length (player-in-roles t100))))
    389         (let*
    390             ((role-t100 (first (player-in-roles t100)))
    391              (assoc (parent role-t100))
    392              (role-t3a (first (roles assoc))))
    393           (is (= 1 (length (psis (instance-of role-t100)))))
    394           (is (string= (uri (first (psis (instance-of role-t100)))) "http://psi.topicmaps.org/iso13250/model/instance"))
    395           (is (= 1 (length (psis (instance-of role-t3a)))))
    396           (is (string= (uri (first (psis (instance-of role-t3a)))) "http://psi.topicmaps.org/iso13250/model/type")))
    397        
     378        (is (= 1 (length (player-in-roles t100 :revision 0))))
     379        (let* ((role-t100 (first (player-in-roles t100 :revision 0)))
     380               (assoc (parent role-t100 :revision 0))
     381               (role-t3a (first (roles assoc :revision 0))))
     382          (is (= 1 (length (psis (instance-of role-t100 :revision 0) :revision 0))))
     383          (is (string= (uri (first (psis (instance-of role-t100 :revision 0)
     384                                         :revision 0)))
     385                       "http://psi.topicmaps.org/iso13250/model/instance"))
     386          (is (= 1 (length (psis (instance-of role-t3a :revision 0) :revision 0))))
     387          (is (string= (uri (first (psis (instance-of role-t3a :revision 0)
     388                                         :revision 0)))
     389                       "http://psi.topicmaps.org/iso13250/model/type")))
    398390        ;; checks subjectIdentifier
    399         (is (= 1 (length (psis t100))))
     391        (is (= 1 (length (psis t100 :revision 0))))
    400392        (is (string= "http://psi.egovpt.org/standard/ISO+19115%3A+Geographic+Information+-+Metadata"
    401                      (uri (first (psis t100)))))
    402         (is (equal (identified-construct (first (psis t100))) t100)) ;;other association part
    403          
     393                     (uri (first (psis t100 :revision 0)))))
     394        (is (equal (identified-construct (first (psis t100 :revision 0))
     395                                         :revision 0) t100)) ;;other association part
    404396        ;; checks names
    405         (is (= 2 (length (names t100))))
    406         (loop for item in (names t100)
     397        (is (= 2 (length (names t100 :revision 0))))
     398        (loop for item in (names t100 :revision 0)
    407399           do (is (or (string= (charvalue item) "ISO 19115")
    408400                      (and (string= (charvalue item) "ISO 19115:2003 Geographic Information - Metadata")
    409                            (= (length (themes item)) 1)
    410                            (= (length (psis (first (themes item)))))
    411                            (string= (uri (first (psis (first (themes item))))) "http://psi.egovpt.org/types/long-name")))))
    412         (is-true (used-as-theme (get-item-by-id "t50a"))) ;checks the other part of the association -> fails
    413 
     401                           (= (length (themes item :revision 0)) 1)
     402                           (= (length (psis (first (themes item :revision 0))
     403                                            :revision 0)))
     404                           (string= (uri (first (psis (first (themes item :revision 0))
     405                                                      :revision 0)))
     406                                    "http://psi.egovpt.org/types/long-name")))))
     407        (is-true (used-as-theme (get-item-by-id "t50a" :revision 0)
     408                                :revision 0)) ;checks the other part of the association -> fails
    414409        ;; checks occurrences
     410        (setf *TM-REVISION* 0)
    415411        (is (= 4 (length (occurrences (get-item-by-id "t100")))))
    416412        (loop for item in (occurrences t100)
     
    434430           do (progn
    435431                (is (string= (charvalue item) "http://www.editeur.org/standards/ISO19115.pdf"))
    436                 (is (string= (uri (first (psis (instance-of item)))) "http://psi.egovpt.org/types/links")))
    437            when (and (not (elephant:associatedp (get-item-by-id "t51") 'datamodel::used-as-type item))
    438                      (not (elephant:associatedp (get-item-by-id "t53") 'datamodel::used-as-type item))
    439                      (not (elephant:associatedp (get-item-by-id "t54") 'datamodel::used-as-type item))
    440                      (not (elephant:associatedp (get-item-by-id "t55") 'datamodel::used-as-type item)))
    441            do (is-true nil))))))
     432                (is (string= (uri (first (psis (instance-of item)))) "http://psi.egovpt.org/types/links"))))))))
    442433
    443434
     
    451442       :tm-id "http://www.isidor.us/unittests/xtm1.0-tests"
    452443       :xtm-id *TEST-TM* :xtm-format '1.0)
    453 
     444      (setf *TM-REVISION* 0)
    454445      (elephant:open-store (xml-importer:get-store-spec dir))
    455446      (is (=  36 (length (elephant:get-instances-by-class 'TopicC)))) ;13 + (23 core topics)
     
    508499
    509500
    510 
    511501(test test-variants
    512502  (let
     
    515505      (xml-importer:setup-repository
    516506       *notificationbase.xtm* dir :xtm-id *TEST-TM*)
    517 
     507      (setf *TM-REVISION* 0)
    518508      (elephant:open-store (xml-importer:get-store-spec dir))
    519509      (let ((variants (elephant:get-instances-by-class 'VariantC)))
     
    524514                    (string-type "http://www.w3.org/2001/XMLSchema#string")
    525515                    (itemIdentities (map 'list #'uri (item-identifiers variant)))
    526                     (parent-name-value (charvalue (name variant)))
     516                    (parent-name-value (charvalue (parent variant)))
    527517                    (scopes (map 'list #'uri
    528518                                  (map 'list #'(lambda(x)
     
    535525                  ((string= resourceData "Long-Version")
    536526                   (is (string= parent-name-value "long version of a name"))
    537                    (is (= (length (variants (name variant))) 1))
    538                    (is (eql variant (first (variants (name variant)))))
     527                   (is (= (length (variants (parent variant))) 1))
     528                   (is (eql variant (first (variants (parent variant)))))
    539529                   (check-for-duplicate-identifiers variant)
    540530                   (is-false itemIdentities)
     
    544534                  ((string= resourceData "Geographic Information - Metadata")
    545535                   (is (string= parent-name-value "ISO 19115"))
    546                    (is (= (length (variants (name variant))) 2))
    547                    (is (or (eql variant (first (variants (name variant))))
    548                            (eql variant (second (variants (name variant))))))
     536                   (is (= (length (variants (parent variant))) 2))
     537                   (is (or (eql variant (first (variants (parent variant))))
     538                           (eql variant (second (variants (parent variant))))))
    549539                   (check-for-duplicate-identifiers variant)
    550540                   (is (= (length scopes) 1))
     
    562552                  ((string= resourceData "ISO/IEC-13250:2002")
    563553                   (is (string= parent-name-value "ISO/IEC 13250:2002: Topic Maps"))
    564                    (is (= (length (variants (name variant))) 1))
    565                    (is (eql variant (first (variants (name variant)))))
     554                   (is (= (length (variants (parent variant))) 1))
     555                   (is (eql variant (first (variants (parent variant)))))
    566556                   (check-for-duplicate-identifiers variant)
    567557                   (check-for-duplicate-identifiers variant)               
     
    655645          "http://www.topicmaps.org/xtm/1.0/core.xtm")
    656646        (mapcan (lambda (tm)
    657                  (mapcar #'uri (item-identifiers tm)))
     647                 (mapcar #'uri (item-identifiers tm :revision 0)))
    658648                tms) :test #'string=)))))
    659649
  • TabularUnified branches/new-datamodel/src/xml/xtm/importer.lisp

    r296 r298  
    197197      :start-revision start-revision
    198198      :instance-of associationtype
    199       :roles (list (list :instance-of roletype1 :player player1)
    200                    (list :instance-of roletype2 :player player2-obj))))))
     199      :roles (list (list :start-revision start-revision
     200                         :instance-of roletype1
     201                         :player player1)
     202                   (list :start-revision start-revision
     203                         :instance-of roletype2
     204                         :player player2-obj))))))
  • TabularUnified branches/new-datamodel/src/xml/xtm/importer_xtm2.0.lisp

    r296 r298  
    3535  (declare (integer start-revision))
    3636  (let
    37       ((id (make-instance classsymbol
     37      ((id (make-construct classsymbol
    3838                          :uri (get-attribute elem "href")
    3939                          :start-revision start-revision)))
     
    131131    (let ((name (make-construct 'NameC
    132132                                :start-revision start-revision
    133                                 :topic top
     133                                :parent top
    134134                                :charvalue namevalue
    135135                                :instance-of instance-of
     
    201201                    :datatype (getf variant-value :type)
    202202                    :reifier reifier-topic
    203                     :name name)))
     203                    :parent name)))
    204204                           
    205205
     
    227227    (make-construct 'OccurrenceC
    228228                    :start-revision start-revision
    229                     :topic top
     229                    :parent top
    230230                    :themes themes
    231231                    :item-identifiers item-identifiers
     
    253253          (make-identifiers 'PersistentIdC topic-elem "subjectIdentifier" start-revision))
    254254         (subjectlocators
    255           (make-identifiers 'SubjectLocatorC topic-elem "subjectLocator" start-revision)))
     255          (make-identifiers 'SubjectLocatorC topic-elem "subjectLocator" start-revision))
     256         (topic-ids (when (get-attribute topic-elem "id")
     257                      (list (make-construct 'TopicIdentificationC
     258                                            :uri (get-attribute topic-elem "id")
     259                                            :xtm-id xtm-id)))))
    256260      (make-construct 'TopicC
    257261                      :start-revision start-revision
     
    259263                      :locators subjectlocators
    260264                      :psis subjectidentifiers
    261                       :topicid (get-attribute topic-elem "id")
     265                      :topic-identifiers topic-ids
    262266                      :xtm-id xtm-id))))
    263267         
     
    284288                  (*xtm2.0-ns* "topicRef"))))))
    285289      (unless top
    286         (error "topic ~a could not be found" (get-attribute topic-elem "id")))
     290        (error "topic ~a could not be found (xtm-id: ~a, revision: ~a)"
     291               (get-attribute topic-elem "id") xtm-id start-revision))
    287292      (map 'list
    288293       (lambda
     
    336341             *xtm2.0-ns*
    337342             "topicRef"))))
    338       (list :reifier reifier-topic
     343      (list :start-revision start-revision
     344            :reifier reifier-topic
    339345            :instance-of instance-of
    340346            :player player
Note: See TracChangeset for help on using the changeset viewer.