Changeset 235 for branches/new-datamodel/src/model
- Timestamp:
- 03/20/10 22:00:40 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/new-datamodel/src/model/datamodel.lisp ¶
r234 r235 664 664 665 665 666 (defun merge-all-constructs(constructs-to-be-merged) 667 "Merges all constructs contained in the given list." 668 (declare (list constructs-to-be-merged)) 669 (let ((constructs-to-be-merged (subseq constructs-to-be-merged 1)) 670 (merged-construct (elt constructs-to-be-merged 0))) 671 (loop for construct-to-be-merged in constructs-to-be-merged 672 do (setf merged-construct 673 (merge-constructs merged-construct construct-to-be-merged))))) 674 675 666 676 ;;; generic definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 667 677 (defgeneric get-all-characteristics (parent-construct characteristic-symbol) … … 2379 2389 (make-characteristic class-symbol (getf args :charvalue) args)) 2380 2390 ((TopicC-p class-symbol) 2381 (make-topic args))))) 2391 (make-topic args)) 2392 ((TopicMapC-p class-symbol) 2393 (make-tm args)) 2394 ((RoleC-p class-symbol) 2395 (make-role args)) 2396 ((AssociationC-p class-symbol) 2397 (make-association args))))) 2382 2398 construct)) 2383 2399 2384 2400 2385 (defun merge-all-constructs(constructs-to-be-merged) 2386 "Merges all constructs contained in the given list." 2387 (declare (list constructs-to-be-merged)) 2388 (let ((constructs-to-be-merged (subseq constructs-to-be-merged 1)) 2389 (merged-construct (elt constructs-to-be-merged 0))) 2390 (loop for construct-to-be-merged in constructs-to-be-merged 2391 do (setf merged-construct 2392 (merge-constructs merged-construct construct-to-be-merged))))) 2393 2394 2395 (defun make-tm (&rest args) 2396 "Returns a topic map object. If the topic map has already existed the 2401 (defun make-association (args) 2402 "Returns an association object. If the association has already existed the 2397 2403 existing one is returned otherwise a new one is created. 2398 2404 This function exists only for being used by make-construct!" 2399 2405 (let ((item-identifiers (getf (first args) :item-identifiers)) 2400 2406 (reifier (getf (first args) :reifier)) 2401 (topics (getf (first args) :topics)) 2402 (assocs (getf (first args) :associations)) 2403 (start-revision (getf (first args) :start-revision))) 2407 (instance-of (getf (first args) :instance-of)) 2408 (start-revision (getf (first args) :start-revision)) 2409 (themes (get (first args) :themes)) 2410 (roles (get (first args) :roles)) 2411 (err "From make-association(): ")) 2412 (unless start-revision (error "~astart-revision must be set" err)) 2413 (unless roles (error "~aroles must be set" err)) 2414 (unless instance-of (error "~ainstance-of must be set" err)) 2415 (let ((association 2416 (let ((existing-association 2417 (remove-if 2418 #'null 2419 (map 'list #'(lambda(existing-association) 2420 (when (equivalent-construct 2421 existing-association 2422 :start-revision start-revision 2423 :roles roles :themes themes 2424 :instance-of instance-of) 2425 existing-association)) 2426 (elephant:get-instances-by-class 'AssociationC))))) 2427 (if existing-association 2428 existing-association 2429 (make-instance 'AssociationC))))) 2430 (initialize-typable association instance-of :start-revision 2431 start-revision) 2432 (dolist (role roles) 2433 (add-role association role :revision start-revision)) 2434 (dolist (theme themes) 2435 (add-theme association theme :revision start-revision)) 2436 (initialize-reifiable association item-identifiers reifier 2437 :start-revision start-revision)))) 2438 2439 2440 (defun make-role (args) 2441 "Returns a role object. If the role has already existed the 2442 existing one is returned otherwise a new one is created. 2443 This function exists only for being used by make-construct!" 2444 (let ((item-identifiers (getf args :item-identifiers)) 2445 (reifier (getf args :reifier)) 2446 (parent (getf args :parent)) 2447 (instance-of (getf args :instance-of)) 2448 (player (getf args :player)) 2449 (start-revision (getf args :start-revision)) 2450 (err "From make-role(): ")) 2451 (unless start-revision (error "~astart-revision must be set" err)) 2452 (unless instance-of (error "~ainstance-of must be set" err)) 2453 (unless player (error "~aplayer must be set" err)) 2454 (let ((role 2455 (let ((existing-role 2456 (remove-if 2457 #'null 2458 (map 'list #'(lambda(existing-role) 2459 (when (equivalent-construct 2460 existing-role 2461 :player player 2462 :instance-of instance-of) 2463 existing-role)) 2464 (slot-p parent 'roles))))) 2465 (if existing-role 2466 existing-role 2467 (make-instance 'RoleC))))) 2468 (when player 2469 (add-player role player :revision start-revision)) 2470 (initialize-typable role instance-of :start-revision start-revision) 2471 (when parent 2472 (add-parent role parent :revision start-revision)) 2473 (initialize-reifiable role item-identifiers reifier 2474 :start-revision start-revision)))) 2475 2476 2477 (defun make-tm (args) 2478 "Returns a topic map object. If the topic map has already existed the 2479 existing one is returned otherwise a new one is created. 2480 This function exists only for being used by make-construct!" 2481 (let ((item-identifiers (getf args :item-identifiers)) 2482 (reifier (getf args :reifier)) 2483 (topics (getf args :topics)) 2484 (assocs (getf args :associations)) 2485 (start-revision (getf args :start-revision)) 2486 (err "From make-tm(): ")) 2487 (unless item-identifiers (error "~aitem-identifiers must be set" err)) 2488 (unless start-revision (error "~astart-revision must be set" err)) 2404 2489 (let ((tm 2405 2490 (let ((existing-tms … … 2421 2506 (dolist (top-or-assoc (union topics assocs)) 2422 2507 (add-to-tm tm top-or-assoc)) 2423 ( add-to-version-history tm :start-revision start-revision)2424 tm)))2508 (initialize-reifiable tm item-identifiers reifier 2509 :start-revision start-revision)))) 2425 2510 2426 2511 … … 2429 2514 returned otherwise a new one is created. 2430 2515 This function exists only for being used by make-construct!" 2431 (let ((start-revision (getf (first args) :start-revision)) 2432 (psis (getf (first args) :psis)) 2433 (locators (getf (first args) :locators)) 2434 (item-identifiers (getf (first args) :item-identifiers)) 2435 (topic-identifiers (getf (first args) :topic-identifiers)) 2436 (names (getf (first args) :names)) 2437 (occurrences (getf (first args) :occurrences))) 2516 (let ((start-revision (getf args :start-revision)) 2517 (psis (getf args :psis)) 2518 (locators (getf args :locators)) 2519 (item-identifiers (getf args :item-identifiers)) 2520 (topic-identifiers (getf args :topic-identifiers)) 2521 (names (getf args :names)) 2522 (occurrences (getf args :occurrences)) 2523 (err "From make-topic(): ")) 2524 (unless topic-identifiers (error "~atopic-identifiers must be set" err)) 2525 (unless start-revision (error "~astart-revision must be set" err)) 2438 2526 (let ((topic 2439 2527 (let ((existing-topics … … 2455 2543 (t 2456 2544 (make-instance 'TopicC)))))) 2457 (initialize-reifiable topic item-identifiers nil2458 :start-revision start-revision)2459 2545 (let ((merged-topic topic)) 2546 (setf merged-topic 2547 (initialize-reifiable topic item-identifiers nil 2548 :start-revision start-revision)) 2460 2549 (dolist (psi psis) 2461 2550 (setf merged-topic (add-psi merged-topic psi … … 2465 2554 :revision start-revision))) 2466 2555 (dolist (name names) 2467 (setf merged-topic (add-name topic name :revision start-revision))) 2556 (setf merged-topic (add-name merged-topic name 2557 :revision start-revision))) 2468 2558 (dolist (occ occurrences) 2469 2559 (add-occurrence merged-topic occ :revision start-revision)) 2470 (add-to-version-history merged-topic :start-revision start-revision)2471 2560 merged-topic)))) 2472 2561 … … 2485 2574 (variants (getf (first args) :variants)) 2486 2575 (reifier (getf (first args) :reifier)) 2487 (parent-construct (getf (first args) :parent-construct)) 2488 (item-identifiers (getf (first args) :item-identifiers))) 2576 (parent (getf (first args) :parent)) 2577 (item-identifiers (getf (first args) :item-identifiers)) 2578 (err "From make-characteristic(): ")) 2579 (unless start-revision (error "~astart-revision must be set" err)) 2580 (unless charvalue (error "~acharvalue must be set" err)) 2581 (when (and (or (OccurrenceC-p class-symbol) (NameC-p class-symbol)) 2582 (not instance-of)) 2583 (error "~ainstance-of must be set" err)) 2489 2584 (let ((characteristic 2490 2585 (let ((existing-characteristic 2491 (when parent -construct2586 (when parent 2492 2587 (remove-if 2493 2588 #'null … … 2500 2595 :instance-of instance-of) 2501 2596 existing-characteristic)) 2502 (get-all-characteristics parent-construct 2503 class-symbol)))))) 2597 (get-all-characteristics parent class-symbol)))))) 2504 2598 (if existing-characteristic 2505 2599 existing-characteristic 2506 2600 (make-instance class-symbol :charvalue charvalue 2507 2601 :datatype datatype))))) 2508 (let ((merged-characteristic characteristic)) 2509 (setf merged-characteristic 2510 (initialize-reifiable merged-characteristic item-identifiers 2511 reifier :start-revision start-revision)) 2512 (initialize-scopable merged-characteristic themes 2513 :start-revision start-revision) 2514 (initialize-typable merged-characteristic instance-of 2515 :start-revision start-revision) 2516 (initialize-name merged-characteristic variants 2517 :start-revision start-revision) 2518 (when parent-construct 2519 (add-parent merged-characteristic parent-construct 2520 :revision start-revision)) 2521 merged-characteristic)))) 2602 (initialize-scopable characteristic themes :start-revision start-revision) 2603 (initialize-typable characteristic instance-of 2604 :start-revision start-revision) 2605 (initialize-name characteristic variants :start-revision start-revision) 2606 (when parent 2607 (add-parent characteristic parent :revision start-revision)) 2608 (initialize-reifiable characteristic item-identifiers 2609 reifier :start-revision start-revision)))) 2522 2610 2523 2611 … … 2529 2617 (xtm-id (getf (first args) :xtm-id)) 2530 2618 (start-revision (getf (first args) :start-revision)) 2531 (identified-construct (getf (first args) :identified-construct))) 2619 (identified-construct (getf (first args) :identified-construct)) 2620 (err "From make-pointer(): ")) 2621 (when (and identified-construct (not start-revision)) 2622 (error "~astart-revision must be set" err)) 2532 2623 (let ((identifier 2533 2624 (let ((existing-pointer
Note: See TracChangeset
for help on using the changeset viewer.