Changeset 290 for branches/new-datamodel


Ignore:
Timestamp:
04/29/10 10:17:20 (15 years ago)
Author:
lgiessmann
Message:

new-datamodel: fixed a problem when topic-merging was caused by reifying the same "ReifiableConstructC"; fixed a bug when two topics are merged and every of these topics reifies a construct that can't be merged with the other one.

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

Legend:

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

    r288 r290  
    30873087  (:method ((construct ReifiableConstructC) (reifier-topic TopicC)
    30883088            &key (revision *TM-REVISION*))
     3089    (when (and (reified-construct reifier-topic :revision revision)
     3090               (not (equivalent-constructs construct
     3091                                           (reified-construct
     3092                                            reifier-topic :revision revision))))
     3093      (error (make-condition 'not-mergable-error
     3094                             :message (format nil "From add-reifier(): ~a and ~a can't be merged since the reified-constructs (~a ~a) are not mergable"
     3095                                              reifier-topic (reifier construct :revision revision) (reified-construct reifier-topic :revision revision) construct)
     3096                             :construct-1 construct
     3097                             :construct-2 (reified-construct reifier-topic :revision revision))))
    30893098    (let ((merged-reifier-topic
    30903099           (if (reifier construct :revision revision)
     
    38533862          (destination-reified (reified-construct destination
    38543863                                                  :revision revision)))
    3855       (unless (eql (type-of source-reified) (type-of destination-reified))
     3864      (when (and source-reified destination-reified
     3865                 (not (eql (type-of source-reified)
     3866                           (type-of destination-reified))))
    38563867        (error (make-condition 'not-mergable-error
    38573868                               :message (format nil "From move-reified-construct(): ~a and ~a can't be merged since the reified-constructs are not of the same type ~a ~a"
     
    38693880            (source-reified
    38703881             (delete-reifier source source-reified :revision revision)
    3871              (add-reifier destination source-reified :revision revision)
     3882             (add-reifier  source-reified destination :revision revision)
    38723883             source-reified)
    38733884            (destination-reified
    3874              (add-reifier destination destination-reified :revision revision)
     3885             (add-reifier destination-reified destination :revision revision)
    38753886             destination-reified)))))
    38763887
  • TabularUnified branches/new-datamodel/src/unit_tests/datamodel_test.lisp

    r288 r290  
    8989           :test-merge-constructs-TopicC-6
    9090           :test-merge-constructs-TopicC-7
    91            :test-merge-constructs-TopicC-8))
     91           :test-merge-constructs-TopicC-8
     92           :test-merge-constructs-TopicC-9))
    9293
    9394
     
    35553556          (signals not-mergable-error (add-reifier occ-3 reifier-1))
    35563557          (is (eql (add-reifier occ-2 reifier-1) occ-1))
     3558          (is-false (set-exclusive-or (list occ-1 occ-3) (occurrences top-1)))
    35573559          (is-true (marked-as-deleted-p top-2))
    3558           (is-true (marked-as-deleted-p occ-2)))))))
     3560          (is-true (marked-as-deleted-p occ-2))
     3561          (is (= (length (d::versions top-1)) 2))
     3562          (is (= (length (d::versions top-2)) 1))
     3563          (is-true (find-if #'(lambda(vi)
     3564                                (and (= (d::end-revision vi) rev-3)
     3565                                     (= (d::start-revision vi) rev-1)))
     3566                            (d::versions top-1)))
     3567          (is-true (find-if #'(lambda(vi)
     3568                                (and (= (d::end-revision vi) 0)
     3569                                     (= (d::start-revision vi) rev-3)))
     3570                            (d::versions top-1)))
     3571          (is-true (find-if #'(lambda(vi)
     3572                                (and (= (d::end-revision vi) rev-3)
     3573                                     (= (d::start-revision vi) rev-2)))
     3574                            (d::versions top-2)))
     3575          (is (= (length (slot-value occ-2 'd::parent)) 1))
     3576          (is (= (length (slot-value occ-1 'd::parent)) 1))
     3577          (is-true (find-if #'(lambda(vi)
     3578                                (and (= (d::end-revision vi) rev-3)
     3579                                     (= (d::start-revision vi) rev-2)))
     3580                            (first (map 'list #'d::versions
     3581                                        (slot-value occ-2 'd::parent)))))
     3582          (is-true (find-if #'(lambda(vi)
     3583                                (and (= (d::end-revision vi) rev-3)
     3584                                     (= (d::start-revision vi) rev-1)))
     3585                            (first (map 'list #'d::versions
     3586                                        (slot-value occ-1 'd::parent)))))
     3587          (is-true (find-if #'(lambda(vi)
     3588                                (and (= (d::end-revision vi) 0)
     3589                                     (= (d::start-revision vi) rev-3)))
     3590                            (first (map 'list #'d::versions
     3591                                        (slot-value occ-1 'd::parent))))))))))
     3592
     3593
     3594(test test-merge-constructs-TopicC-9 ()
     3595  "Tests the generic move-referenced-constructs corresponding to TopicC."
     3596  (with-fixture with-empty-db (*db-dir*)
     3597    (let ((rev-1 100)
     3598          (rev-2 200)
     3599          (rev-3 300)
     3600          (rev-4 400)
     3601          (psi-1 (make-construct 'PersistentIdC :uri "psi-1"))
     3602          (psi-2 (make-construct 'PersistentIdC :uri "psi-2")))
     3603      (let ((top-1 (make-construct 'TopicC :start-revision rev-2
     3604                                   :psis (list psi-2)))
     3605            (top-2 (make-construct 'TopicC :start-revision rev-2))
     3606            (top-3 (make-construct 'TopicC :start-revision rev-1))
     3607            (reifier-1 (make-construct 'TopicC :start-revision rev-1))
     3608            (reifier-2 (make-construct 'TopicC :start-revision rev-2
     3609                                       :psis (list psi-1)))
     3610            (reifier-3 (make-construct 'TopicC :start-revision rev-1))
     3611            (reifier-4 (make-construct 'TopicC :start-revision rev-1))
     3612            (type-1 (make-construct 'TopicC :start-revision rev-1))
     3613            (type-2 (make-construct 'TopicC :start-revision rev-1)))
     3614        (let ((occ-1 (make-construct 'OccurrenceC
     3615                                     :start-revision rev-2
     3616                                     :instance-of type-1
     3617                                     :charvalue "occ"
     3618                                     :reifier reifier-1
     3619                                     :parent top-1))
     3620              (occ-2 (make-construct 'OccurrenceC
     3621                                     :start-revision rev-2
     3622                                     :instance-of type-2
     3623                                     :charvalue "occ"
     3624                                     :reifier reifier-3
     3625                                     :parent top-2))
     3626              (occ-3 (make-construct 'OccurrenceC
     3627                                     :start-revision rev-1
     3628                                     :instance-of type-1
     3629                                     :charvalue "occ"
     3630                                     :reifier reifier-4
     3631                                     :parent top-3)))
     3632          (setf *TM-REVISION* rev-3)
     3633          (is (eql (reifier occ-2) reifier-3))
     3634          (signals not-mergable-error (add-reifier occ-1 reifier-3))
     3635          (is (eql occ-1 (add-reifier occ-1 reifier-2)))
     3636          (is-true (marked-as-deleted-p reifier-2))
     3637          (is-false (set-exclusive-or (list psi-1) (psis reifier-1)))
     3638          (setf *TM-REVISION* rev-4)
     3639          (is (eql (add-reifier occ-1 reifier-4) occ-3))
     3640          (is-true (marked-as-deleted-p top-1))
     3641          (is-false (marked-as-deleted-p top-3))
     3642          (is-false (set-exclusive-or (list psi-2) (psis top-3)))
     3643          (is-false (marked-as-deleted-p top-2))
     3644          (is-false (set-exclusive-or (list occ-2) (occurrences top-2))))))))
    35593645
    35603646
    35613647;;TODO: merge topics caused by variant-item-identifiers
    3562 ;;TODO: mrege topics caused by reifying the same reified-construct
    35633648;;TODO: merge associations caused by a merge of their characteristics
    35643649
     
    36323717  (it.bese.fiveam:run! 'test-merge-constructs-TopicC-7)
    36333718  (it.bese.fiveam:run! 'test-merge-constructs-TopicC-8)
     3719  (it.bese.fiveam:run! 'test-merge-constructs-TopicC-9)
    36343720  )
Note: See TracChangeset for help on using the changeset viewer.