Changeset 298 for branches/new-datamodel/src
- Timestamp:
- 06/13/10 14:42:34 (15 years ago)
- Location:
- branches/new-datamodel/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/new-datamodel/src/model/datamodel.lisp ¶
r296 r298 161 161 162 162 163 ;;TODO: adapt changes.lisp --> changed-p164 163 ;;TODO: implement a macro with-merge-constructs, that merges constructs 165 164 ;; after all operations in the body were called … … 1587 1586 returns one of the topic-ids in that TM 1588 1587 (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)) 1591 1591 (if xtm-id 1592 1592 (let ((possible-identifiers … … 3128 3128 (when (not (eql id-owner construct)) 3129 3129 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))) 3130 3136 (let ((merged-construct construct)) 3131 3137 (cond (construct-to-be-merged … … 3486 3492 3487 3493 (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) 3489 3496 3490 3497 3491 3498 (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) 3493 3501 3494 3502 … … 3807 3815 (map 'list 3808 3816 #'(lambda(existing-pointer) 3809 (when (equivalent-construct existing-pointer uri3810 xtm-id)3817 (when (equivalent-construct existing-pointer :uri uri 3818 :xtm-id xtm-id) 3811 3819 existing-pointer)) 3812 3820 (elephant:get-instances-by-value class-symbol 'd::uri uri))))) 3813 (if existing-pointer existing-pointer 3821 (if existing-pointer 3822 (first existing-pointer) 3814 3823 (make-instance class-symbol :uri uri :xtm-id xtm-id))))) 3815 3824 (when identified-construct -
TabularUnified branches/new-datamodel/src/unit_tests/fixtures.lisp ¶
r183 r298 95 95 96 96 (def-fixture initialized-test-db (&optional (xtm *NOTIFICATIONBASE-TM*)) 97 (let 98 ((revision (get-revision))) 97 (let ((revision (get-revision))) 99 98 (declare (ignorable revision)) 99 (setf *TM-REVISION* revision) 100 100 (setf *XTM-TM* xtm) 101 101 (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))) 105 105 (declare (ignorable tm)) 106 106 (&body) -
TabularUnified branches/new-datamodel/src/unit_tests/importer_test.lisp ¶
r238 r298 23 23 (:import-from :exceptions 24 24 missing-reference-error 25 duplicate-identifier-error) 25 duplicate-identifier-error 26 not-mergable-error ) 26 27 (:export :importer-test 27 28 :test-error-detection … … 58 59 (with-fixture 59 60 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*)) 67 68 (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)) 70 71 (let 71 72 ((t100-occtype 72 (from-type-elem (first type-elems) )))73 (from-type-elem (first type-elems) rev-1))) 73 74 (format t "occtype: ~a~&" t100-occtype) 74 75 (format t "occtype: ~a~&" (psis t100-occtype)) … … 83 84 (with-fixture 84 85 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*)) 92 93 (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)) 95 96 (let 96 97 ((t101-themes 97 (from-scope-elem (first scope-elems) )))98 (from-scope-elem (first scope-elems) rev-1))) 98 99 (is (= 1 (length t101-themes))) 99 100 (is … … 106 107 (with-fixture 107 108 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*)) 115 116 (loop for name-elem in name-elems do 116 (is (typep (from-name-elem name-elem top rev ision) 'NameC)))117 (is (typep (from-name-elem name-elem top rev-1) 'NameC))) 117 118 (let 118 ((t1-name (from-name-elem (first name-elems) top rev ision))119 (t1-name-copy (from-name-elem (first name-elems) top rev ision))120 (t101-longname (from-name-elem (nth 27 name-elems) top rev ision)))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))) 121 122 (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)) 131 129 (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*) 133 132 "t50a")) 134 (is (eq t1-name t1-name-copy)) ;must be merged135 )))) 133 (is (eq t1-name t1-name-copy)))))) ;must be merged 134 136 135 137 136 (test test-from-occurrence-elem … … 139 138 (with-fixture 140 139 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*)) 149 147 (loop for occ-elem in occ-elems do 150 (is (typep (from-occurrence-elem occ-elem top rev ision)151 148 (is (typep (from-occurrence-elem occ-elem top rev-1) 149 'OccurrenceC))) 152 150 (is (= 1 (length (elephant:get-instances-by-value 153 154 155 151 'ItemIdentifierC 152 'uri 153 "http://psi.egovpt.org/itemIdentifiers#t100_o1")))) 156 154 (let 157 155 ((t100-occ1 … … 167 165 'uri 168 166 "http://psi.egovpt.org/itemIdentifiers#t100_o2")))) 169 (is (= 1 (length (item-identifiers t100-occ1 ))));just to double-check167 (is (= 1 (length (item-identifiers t100-occ1 :revision rev-1)))) ;just to double-check 170 168 (is (string= 171 (uri (first (item-identifiers t100-occ1 )))169 (uri (first (item-identifiers t100-occ1 :revision rev-1))) 172 170 "http://psi.egovpt.org/itemIdentifiers#t100_o1")) 173 171 (is (string= (charvalue t100-occ1) "http://www.budabe.de/")) … … 180 178 (with-fixture 181 179 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*)) 188 185 (loop for topic-elem in topic-elems do 189 186 (is (typep 190 (merge-topic-elem topic-elem rev ision:tm fixtures::tm)187 (merge-topic-elem topic-elem rev-1 :tm fixtures::tm) 191 188 'TopicC))) 192 189 (let 193 190 ((top-t1 (merge-topic-elem (first topic-elems) 194 rev ision:tm fixtures::tm))191 rev-1 :tm fixtures::tm)) 195 192 (top-t57 (get-item-by-id "t57")) 196 193 (top-t101 (get-item-by-id "t101")) … … 199 196 ;one of the core PSIs 200 197 (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))) 207 204 "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 213 211 (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))))))) 216 213 ;34 topics in 35 topic elements in notificationbase.xtm and 13 217 214 ;core topics … … 227 224 *XTM-TM* 228 225 '((*xtm2.0-ns* "association") 229 (*xtm2.0-ns* "role"))))) 226 (*xtm2.0-ns* "role")))) 227 (rev-1 *TM-REVISION*)) 230 228 (loop for role-elem in role-elems do 231 229 (is (typep (from-role-elem role-elem revision) 'list))) … … 235 233 (is (string= "t101" 236 234 (topic-id 237 (getf 12th-role :player) *TEST-TM*)))235 (getf 12th-role :player) rev-1 *TEST-TM*))) 238 236 (is (string= "t62" 239 237 (topic-id 240 (getf 12th-role :instance-of) *TEST-TM*))))))) 238 (getf 12th-role :instance-of) rev-1 *TEST-TM*))))))) 239 241 240 242 241 (test test-from-association-elem … … 244 243 (with-fixture 245 244 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*)) 251 250 (loop for assoc-elem in assoc-elems do 252 251 (is 253 (typep (from-association-elem assoc-elem rev ision:tm fixtures::tm)252 (typep (from-association-elem assoc-elem rev-1 :tm fixtures::tm) 254 253 '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)))) 263 260 (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*))) 265 263 (is (string= "t63" 266 (topic-id (instance-of (first (roles 6th-assoc )))267 264 (topic-id (instance-of (first (roles 6th-assoc :revision rev-1)) 265 :revision rev-1) rev-1 *TEST-TM*))) 268 266 (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*))))) 274 269 (is (= 7 275 270 (length (elephant:get-instances-by-class 'AssociationC)))))) … … 281 276 (with-fixture 282 277 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*)) 288 283 (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)) 310 296 ;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))) 312 299 ;and filter those whose roletype is "instance" 313 300 ;(returning, of course, a list) 314 315 301 ;TODO: what we'd really need 316 302 ;is a filter that works … … 318 304 ;rather than instantiating 319 305 ;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))) 324 313 ;Topic t101 (= Topic Maps 2002 325 314 ;standard) is subclass of 326 315 ;topic t3a (semantic standard) 327 328 316 (is-true t101-top) 329 317 (is (= 1 (length role-101))) 330 ;(is (= 1 (length (d::versions role-101))))331 318 (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*))) 333 323 (is (string= "type-instance" 334 324 (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 337 328 338 329 (test test-error-detection … … 357 348 :tm-id "http://www.isidor.us/unittests/baretests")))) 358 349 (with-fixture bare-test-db() 359 (signals duplicate-identifier-error350 (signals not-mergable-error 360 351 (let 361 352 ((xtm-dom … … 374 365 :tm-id "http://www.isidor.us/unittests/topic-t100") 375 366 (elephant:open-store (xml-importer:get-store-spec dir)) 376 377 367 (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 topic379 (is-true (get-item-by-id "t3a" )) ;; instanceOf380 (is-true (get-item-by-id "t50a" )) ;; scope381 (is-true (get-item-by-id "t51" )) ;; occurrence/type382 (is-true (get-item-by-id "t52" )) ;; occurrence/resourceRef383 (is-true (get-item-by-id "t53" )) ;; occurrence/type384 (is-true (get-item-by-id "t54" )) ;; occurrence/type385 (is-true (get-item-by-id "t55" )) ;; occurrence/type386 (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))) 387 377 ;; 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"))) 398 390 ;; checks subjectIdentifier 399 (is (= 1 (length (psis t100 ))))391 (is (= 1 (length (psis t100 :revision 0)))) 400 392 (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 part403 393 (uri (first (psis t100 :revision 0))))) 394 (is (equal (identified-construct (first (psis t100 :revision 0)) 395 :revision 0) t100)) ;;other association part 404 396 ;; 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) 407 399 do (is (or (string= (charvalue item) "ISO 19115") 408 400 (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 414 409 ;; checks occurrences 410 (setf *TM-REVISION* 0) 415 411 (is (= 4 (length (occurrences (get-item-by-id "t100"))))) 416 412 (loop for item in (occurrences t100) … … 434 430 do (progn 435 431 (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")))))))) 442 433 443 434 … … 451 442 :tm-id "http://www.isidor.us/unittests/xtm1.0-tests" 452 443 :xtm-id *TEST-TM* :xtm-format '1.0) 453 444 (setf *TM-REVISION* 0) 454 445 (elephant:open-store (xml-importer:get-store-spec dir)) 455 446 (is (= 36 (length (elephant:get-instances-by-class 'TopicC)))) ;13 + (23 core topics) … … 508 499 509 500 510 511 501 (test test-variants 512 502 (let … … 515 505 (xml-importer:setup-repository 516 506 *notificationbase.xtm* dir :xtm-id *TEST-TM*) 517 507 (setf *TM-REVISION* 0) 518 508 (elephant:open-store (xml-importer:get-store-spec dir)) 519 509 (let ((variants (elephant:get-instances-by-class 'VariantC))) … … 524 514 (string-type "http://www.w3.org/2001/XMLSchema#string") 525 515 (itemIdentities (map 'list #'uri (item-identifiers variant))) 526 (parent-name-value (charvalue ( namevariant)))516 (parent-name-value (charvalue (parent variant))) 527 517 (scopes (map 'list #'uri 528 518 (map 'list #'(lambda(x) … … 535 525 ((string= resourceData "Long-Version") 536 526 (is (string= parent-name-value "long version of a name")) 537 (is (= (length (variants ( namevariant))) 1))538 (is (eql variant (first (variants ( namevariant)))))527 (is (= (length (variants (parent variant))) 1)) 528 (is (eql variant (first (variants (parent variant))))) 539 529 (check-for-duplicate-identifiers variant) 540 530 (is-false itemIdentities) … … 544 534 ((string= resourceData "Geographic Information - Metadata") 545 535 (is (string= parent-name-value "ISO 19115")) 546 (is (= (length (variants ( namevariant))) 2))547 (is (or (eql variant (first (variants ( namevariant))))548 (eql variant (second (variants ( namevariant))))))536 (is (= (length (variants (parent variant))) 2)) 537 (is (or (eql variant (first (variants (parent variant)))) 538 (eql variant (second (variants (parent variant)))))) 549 539 (check-for-duplicate-identifiers variant) 550 540 (is (= (length scopes) 1)) … … 562 552 ((string= resourceData "ISO/IEC-13250:2002") 563 553 (is (string= parent-name-value "ISO/IEC 13250:2002: Topic Maps")) 564 (is (= (length (variants ( namevariant))) 1))565 (is (eql variant (first (variants ( namevariant)))))554 (is (= (length (variants (parent variant))) 1)) 555 (is (eql variant (first (variants (parent variant))))) 566 556 (check-for-duplicate-identifiers variant) 567 557 (check-for-duplicate-identifiers variant) … … 655 645 "http://www.topicmaps.org/xtm/1.0/core.xtm") 656 646 (mapcan (lambda (tm) 657 (mapcar #'uri (item-identifiers tm )))647 (mapcar #'uri (item-identifiers tm :revision 0))) 658 648 tms) :test #'string=))))) 659 649 -
TabularUnified branches/new-datamodel/src/xml/xtm/importer.lisp ¶
r296 r298 197 197 :start-revision start-revision 198 198 :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 35 35 (declare (integer start-revision)) 36 36 (let 37 ((id (make- instanceclasssymbol37 ((id (make-construct classsymbol 38 38 :uri (get-attribute elem "href") 39 39 :start-revision start-revision))) … … 131 131 (let ((name (make-construct 'NameC 132 132 :start-revision start-revision 133 : topictop133 :parent top 134 134 :charvalue namevalue 135 135 :instance-of instance-of … … 201 201 :datatype (getf variant-value :type) 202 202 :reifier reifier-topic 203 : namename)))203 :parent name))) 204 204 205 205 … … 227 227 (make-construct 'OccurrenceC 228 228 :start-revision start-revision 229 : topictop229 :parent top 230 230 :themes themes 231 231 :item-identifiers item-identifiers … … 253 253 (make-identifiers 'PersistentIdC topic-elem "subjectIdentifier" start-revision)) 254 254 (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))))) 256 260 (make-construct 'TopicC 257 261 :start-revision start-revision … … 259 263 :locators subjectlocators 260 264 :psis subjectidentifiers 261 :topic id (get-attribute topic-elem "id")265 :topic-identifiers topic-ids 262 266 :xtm-id xtm-id)))) 263 267 … … 284 288 (*xtm2.0-ns* "topicRef")))))) 285 289 (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)) 287 292 (map 'list 288 293 (lambda … … 336 341 *xtm2.0-ns* 337 342 "topicRef")))) 338 (list :reifier reifier-topic 343 (list :start-revision start-revision 344 :reifier reifier-topic 339 345 :instance-of instance-of 340 346 :player player
Note: See TracChangeset
for help on using the changeset viewer.