Changeset 156 for trunk/src/xml
- Timestamp:
- 12/01/09 12:50:56 (15 years ago)
- Location:
- trunk/src/xml/rdf
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/xml/rdf/exporter.lisp ¶
r155 r156 27 27 *tm2rdf-topic-type-uri* 28 28 *tm2rdf-association-type-uri* 29 *tm2rdf-role-type-uri*) 29 *tm2rdf-role-type-uri* 30 *tm2rdf-association-reifier-property*) 30 31 (:import-from :isidorus-threading 31 32 with-reader-lock … … 443 444 (cxml:attribute "rdf:nodeID" (make-object-id association)) 444 445 (make-isi-type *tm2rdf-association-type-uri*) 446 (when (reifier association) 447 (cxml:with-element *tm2rdf-association-reifier-property* 448 (make-topic-reference (reifier association)))) 445 449 (cxml:with-element "isi:associationtype" 446 450 (make-topic-reference association-type)) … … 459 463 (cxml:with-element "rdf:Description" 460 464 (cxml:attribute "rdf:nodeID" (make-object-id construct)) 461 ;(cxml:attribute "rdf:parseType" "Resource") 465 (when (reifier construct) 466 (cxml:with-element *tm2rdf-association-reifier-property* 467 (make-topic-reference (reifier construct)))) 462 468 (make-isi-type *tm2rdf-role-type-uri*) 463 469 (map 'list #'to-rdf-elem ii) … … 472 478 This is indicated by the existence of exactly two roles. One 473 479 of the type isi:object, the other of the type isi:subject. 474 Scopes or itemIdentifiers are also forbidden." 480 Scopes or itemIdentifiers are also forbidden. 481 If the contained roles own any reifiers they are ignored." 475 482 (declare (AssociationC association)) 476 483 (let ((isi-subject (get-item-by-psi *rdf2tm-subject*)) … … 486 493 (= (length association-roles) 2)) 487 494 (with-property association 495 (when (reifier association) 496 (let ((reifier-uri (get-reifier-uri (reifier association)))) 497 (when reifier-uri 498 (cxml:attribute "rdf:ID" reifier-uri)))) 488 499 (make-topic-reference (player object-role))))))) 489 500 -
TabularUnified trunk/src/xml/rdf/map_to_tm.lisp ¶
r155 r156 106 106 *tm2rdf-role-property* 107 107 *rdf2tm-subject*))) 108 (let ((players 109 (get-players- by-role-type role-assocs start-revision110 *rdf2tm-object*)))108 (let ((players-and-reifiers 109 (get-players-and-reifiers-by-role-type 110 role-assocs start-revision *rdf2tm-object*))) 111 111 (map 'list #'d::delete-construct role-assocs) 112 players )))113 114 115 (defun map-isi-role(role-top start-revision)112 players-and-reifiers))) 113 114 115 (defun map-isi-role(role-top reifier-topic start-revision) 116 116 "Maps a passed topic with all its isidorus:types to a 117 117 property list representing an association-role." … … 145 145 (list :instance-of (first types) 146 146 :player (first role-players) 147 :item-identifiers ids))))) 147 :item-identifiers ids 148 :reifier reifier-topic))))) 148 149 149 150 … … 160 161 assoc-top start-revision *tm2rdf-associationtype-property* 161 162 *rdf2tm-subject*)) 163 (reifier-assocs 164 (get-associations-by-type 165 assoc-top start-revision *tm2rdf-association-reifier-property* 166 *rdf2tm-subject*)) 162 167 (scope-assocs 163 168 (get-associations-by-type 164 169 assoc-top start-revision *tm2rdf-scope-property* 165 170 *rdf2tm-subject*)) 166 (role- tops (get-isi-roles assoc-top start-revision)))171 (role-and-reifier-topics (get-isi-roles assoc-top start-revision))) 167 172 (let ((types (get-players-by-role-type 168 173 type-assocs start-revision *rdf2tm-object*)) 169 174 (scopes (get-players-by-role-type 170 175 scope-assocs start-revision *rdf2tm-object*)) 176 (reifier-topics (get-players-by-role-type 177 reifier-assocs start-revision *rdf2tm-object*)) 171 178 (assoc-roles 172 179 (remove-if #'null (map 'list 173 #'(lambda(role-top) 174 (map-isi-role role-top start-revision)) 175 role-tops)))) 180 #'(lambda(role-and-reifier) 181 (map-isi-role (getf role-and-reifier :player) 182 (getf role-and-reifier :reifier) 183 start-revision)) 184 role-and-reifier-topics)))) 176 185 (elephant:ensure-transaction (:txn-nosync t) 177 186 (map 'list #'d::delete-construct type-assocs) … … 188 197 (add-to-topicmap 189 198 xml-importer::tm 190 (make-construct 'AssociationC 191 :start-revision start-revision 192 :item-identifiers ids 193 :instance-of (first types) 194 :themes scopes 195 :roles assoc-roles))))))) 199 (let ((association 200 (make-construct 'AssociationC 201 :start-revision start-revision 202 :item-identifiers ids 203 :instance-of (first types) 204 :themes scopes 205 :roles assoc-roles))) 206 (map 'list #'(lambda(association-role) 207 (let ((found-item 208 (find-if #'(lambda(list-item) 209 (and (eql (instance-of association-role) 210 (getf list-item :instance-of)) 211 (eql (player association-role) 212 (getf list-item :player)) 213 (getf list-item :reifier))) 214 assoc-roles))) 215 (when found-item 216 (add-reifier association-role (getf found-item :reifier))))) 217 (roles association)) 218 (when reifier-topics 219 (add-reifier association (first reifier-topics))) 220 association))))))) 196 221 197 222 … … 208 233 :id-type-uri *tm2rdf-subjectlocator-property*)) 209 234 (new-item-ids (map-isi-identifiers top start-revision)) 210 (occurrence- topics (get-isi-occurrences top start-revision))211 (name- topics (get-isi-names top start-revision)))235 (occurrence-and-reifier-topics (get-isi-occurrences top start-revision)) 236 (name-and-reifier-topics (get-isi-names top start-revision))) 212 237 (bound-subject-identifiers top new-psis) 213 238 (bound-subject-locators top new-locators) 214 239 (bound-item-identifiers top new-item-ids) 215 (map 'list #'(lambda(occ-top) 216 (map-isi-occurrence top occ-top start-revision)) 217 occurrence-topics) 218 (map 'list #'(lambda(name-top) 219 (map-isi-name top name-top start-revision)) 220 name-topics)) 240 (map 'list #'(lambda(occurrence-and-reifier) 241 (map-isi-occurrence top (getf occurrence-and-reifier :player) 242 (getf occurrence-and-reifier :reifier) 243 start-revision)) 244 occurrence-and-reifier-topics) 245 (map 'list #'(lambda(name-and-reifier) 246 (map-isi-name top (getf name-and-reifier :player) 247 (getf name-and-reifier :reifier) 248 start-revision)) 249 name-and-reifier-topics)) 221 250 top) 222 251 … … 230 259 *tm2rdf-variant-property* 231 260 *rdf2tm-subject*))) 232 (let ((players 233 (get-players- by-role-type variant-assocs start-revision234 261 (let ((players-and-reifiers 262 (get-players-and-reifiers-by-role-type 263 variant-assocs start-revision *rdf2tm-object*))) 235 264 (map 'list #'d::delete-construct variant-assocs) 236 players )))237 238 239 (defun map-isi-variant (name variant-top start-revision)265 players-and-reifiers))) 266 267 268 (defun map-isi-variant (name variant-top reifier-topic start-revision) 240 269 "Maps the passed variant-topic to a TM variant." 241 270 (declare (TopicC variant-top)) … … 265 294 (delete-related-associations variant-top) 266 295 (d::delete-construct variant-top) 267 (make-construct 'VariantC 268 :start-revision start-revision 269 :item-identifiers ids 270 :themes scopes 271 :charvalue (getf value-and-datatype :value) 272 :datatype (getf value-and-datatype :datatype) 273 :name name))))) 274 275 276 (defun map-isi-name (top name-top start-revision) 296 (let ((variant 297 (make-construct 'VariantC 298 :start-revision start-revision 299 :item-identifiers ids 300 :themes scopes 301 :charvalue (getf value-and-datatype :value) 302 :datatype (getf value-and-datatype :datatype) 303 :name name))) 304 (add-reifier variant reifier-topic) 305 variant))))) 306 307 308 (defun map-isi-name (top name-top reifier-topic start-revision) 277 309 "Maps the passed occurrence-topic to a TM occurrence." 278 310 (declare (TopicC top name-top)) … … 289 321 (value-type-topic 290 322 (get-item-by-psi *tm2rdf-value-property*)) 291 (variant- topics (get-isi-variants name-top start-revision)))292 (let ((type s(let ((fn-types323 (variant-and-reifier-topics (get-isi-variants name-top start-revision))) 324 (let ((type (let ((fn-types 293 325 (get-players-by-role-type 294 326 type-assocs start-revision *rdf2tm-object*))) … … 312 344 :topic top 313 345 :charvalue value 314 :instance-of type s346 :instance-of type 315 347 :item-identifiers ids 316 348 :themes scopes))) 317 (map 'list #'(lambda(variant-top) 318 (map-isi-variant name variant-top start-revision)) 319 variant-topics) 349 (add-reifier name reifier-topic) 350 (map 'list #'(lambda(variant-and-reifier) 351 (map-isi-variant name (getf variant-and-reifier :player) 352 (getf variant-and-reifier :reifier) 353 start-revision)) 354 variant-and-reifier-topics) 320 355 (delete-related-associations name-top) 321 356 (d::delete-construct name-top) … … 330 365 top start-revision *tm2rdf-name-property* 331 366 *rdf2tm-subject*))) 332 (let ((occ-tops (get-players-by-role-type 333 assocs start-revision *rdf2tm-object*))) 367 (let ((name-and-reifier-topics 368 (get-players-and-reifiers-by-role-type 369 assocs start-revision *rdf2tm-object*))) 334 370 (map 'list #'d::delete-construct assocs) 335 occ-tops)))336 337 338 (defun map-isi-occurrence(top occ-top start-revision)371 name-and-reifier-topics))) 372 373 374 (defun map-isi-occurrence(top occ-top reifier-topic start-revision) 339 375 "Maps all topics that represents occurrences of the passed topic top 340 376 to occurrence objects." … … 375 411 (delete-related-associations occ-top) 376 412 (d::delete-construct occ-top) 377 (make-construct 'OccurrenceC 378 :start-revision start-revision 379 :topic top 380 :themes scopes 381 :item-identifiers ids 382 :instance-of (first types) 383 :charvalue (getf value-and-datatype :value) 384 :datatype (getf value-and-datatype :datatype)))))) 413 (let ((occurrence 414 (make-construct 'OccurrenceC 415 :start-revision start-revision 416 :topic top 417 :themes scopes 418 :item-identifiers ids 419 :instance-of (first types) 420 :charvalue (getf value-and-datatype :value) 421 :datatype (getf value-and-datatype :datatype)))) 422 (add-reifier occurrence reifier-topic) 423 occurrence))))) 385 424 386 425 … … 392 431 top start-revision *tm2rdf-occurrence-property* 393 432 *rdf2tm-subject*))) 394 (let ((occ-tops (get-players-by-role-type 395 assocs start-revision *rdf2tm-object*))) 433 (let ((occurrences-and-reifiers 434 (get-players-and-reifiers-by-role-type 435 assocs start-revision *rdf2tm-object*))) 396 436 (map 'list #'d::delete-construct assocs) 397 occ -tops)))437 occurrences-and-reifiers))) 398 438 399 439 … … 469 509 associations)))) 470 510 players))) 511 512 513 (defun get-players-and-reifiers-by-role-type (associations start-revision 514 role-type-psi) 515 "Returns tuples of the form (:player <player> :reifier <reifier>)" 516 (declare (list associations)) 517 (declare (integer start-revision)) 518 (declare (string role-type-psi)) 519 (let ((role-type (get-item-by-psi role-type-psi 520 :revision start-revision))) 521 (let ((tuples 522 (remove-if 523 #'null 524 (map 'list 525 #'(lambda(assoc) 526 (let ((role 527 (find-if #'(lambda(role) 528 (eql role-type (instance-of role))) 529 (roles assoc)))) 530 (when role 531 (let ((reifier-topic (reifier assoc))) 532 (list :player (player role) 533 :reifier reifier-topic))))) 534 associations)))) 535 tuples))) 471 536 472 537 -
TabularUnified trunk/src/xml/rdf/rdf_tools.lisp ¶
r139 r156 55 55 *tm2rdf-player-property* 56 56 *tm2rdf-associationtype-property* 57 *rdf2tm-blank-node-prefix*) 57 *rdf2tm-blank-node-prefix* 58 *tm2rdf-association-reifier-property*) 58 59 (:import-from :xml-constants 59 60 *rdf_core_psis.xtm*
Note: See TracChangeset
for help on using the changeset viewer.