Changeset 207 for branches/new-datamodel/src
- Timestamp:
- 02/25/10 19:20:51 (15 years ago)
- Location:
- branches/new-datamodel/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/new-datamodel/src/model/datamodel.lisp ¶
r206 r207 95 95 96 96 97 ;;TODO: finalize add-reifier 97 98 ;;TODO: replace add-to-version-history in VersionedAssociationC with a pseudo 98 99 ;; initarg in make-construct … … 254 255 :documentation "A relation to all item-identifiers of 255 256 this construct.") 256 (reifier :associate (ReifierAssociationC reifi ed-construct)257 (reifier :associate (ReifierAssociationC reifiable-construct) 257 258 :inherit t 258 259 :documentation "A relation to a reifier-topic.")) … … 317 318 topic that is a theme with its scoppable 318 319 object.") 319 (reified-construct :associate (Reifie dAssociationC reifier-topic)320 (reified-construct :associate (ReifierAssociationC reifier-topic) 320 321 :documentation "Contains all association objects that 321 322 relate a topic that is a reifier with … … 412 413 :associate ReifiableConstructC 413 414 :documentation "The actual construct which is reified 414 by a topic.")415 by a topic.") 415 416 (reifier-topic :initarg :reifier-topic 416 417 :accessor reifier-topic … … 787 788 the identified-constructs are merged.") 788 789 (:method ((construct TopicC) (topic-identifier TopicIdentificationC) 789 &key (revision 0))790 &key (revision *TM-REVISION*)) 790 791 (let ((all-ids 791 792 (map 'list #'identifier (slot-p construct 'topic-identifiers))) … … 841 842 the identified-constructs are merged.") 842 843 (:method ((construct TopicC) (psi PersistentIdC) 843 &key (revision 0))844 &key (revision *TM-REVISION*)) 844 845 (let ((all-ids 845 846 (map 'list #'identifier (slot-p construct 'psis))) … … 894 895 the identified-constructs are merged.") 895 896 (:method ((construct TopicC) (locator SubjectLocatorC) 896 &key (revision 0))897 &key (revision *TM-REVISION*)) 897 898 (let ((all-ids 898 899 (map 'list #'identifier (slot-p construct 'locators))) … … 947 948 an error is thrown.") 948 949 (:method ((construct TopicC) (name NameC) 949 &key (revision 0))950 &key (revision *TM-REVISION*)) 950 951 (when (not (eql (parent name) construct)) 951 952 (error "From add-name(): ~a can't be owned by ~a since it is already owned by the topic ~a" … … 960 961 return name-assoc))) 961 962 (add-to-version-history name-assoc :start-revision revision)) 962 (make-instance 'NameAssociationC 963 :start-revision revision 964 :parent-construct construct 965 :characteristic name)) 966 construct))) 963 (let ((assoc 964 (make-instance 'NameAssociationC 965 :parent-construct construct 966 :characteristic name))) 967 (add-to-version-history assoc :start-revision revision)))) 968 construct)) 967 969 968 970 … … 996 998 an error is thrown.") 997 999 (:method ((construct TopicC) (occurrence OccurrenceC) 998 &key (revision 0))1000 &key (revision *TM-REVISION*)) 999 1001 (when (not (eql (parent occurrence) construct)) 1000 1002 (error "From add-occurrence(): ~a can't be owned by ~a since it is already owned by the topic ~a" … … 1009 1011 return occ-assoc))) 1010 1012 (add-to-version-history occ-assoc :start-revision revision)) 1011 (make-instance 'OccurrenceAssociationC 1012 :start-revision revision 1013 :parent-construct construct 1014 :characteristic occurrence)) 1015 construct))) 1013 (let ((assoc 1014 (make-instance 'OccurrenceAssociationC 1015 :parent-construct construct 1016 :characteristic occurrence))) 1017 (add-to-version-history assoc :start-revision revision)))) 1018 construct)) 1016 1019 1017 1020 … … 1062 1065 (let ((assocs (filter-slot-value-by-revision 1063 1066 construct 'reified-construct :start-revision revision))) 1064 (map 'list #'reifiable-construct assocs)))) 1067 (when assocs 1068 (reifiable-construct (first assocs)))))) 1065 1069 1066 1070 … … 1185 1189 scopable-construct.") 1186 1190 (:method ((construct NameC) (variant VariantC) 1187 &key (revision 0))1191 &key (revision *TM-REVISION*)) 1188 1192 (when (not (eql (parent variant) construct)) 1189 1193 (error "From add-variant(): ~a can't be owned by ~a since it is already owned by the name ~a" … … 1199 1203 return variant-assoc))) 1200 1204 (add-to-version-history variant-assoc :start-revision revision)) 1201 (make-instance 'VariantAssociationC 1202 :start-revision revision 1203 :characteristic variant 1204 :parent-construct construct))) 1205 (let ((assoc 1206 (make-instance 'VariantAssociationC 1207 :characteristic variant 1208 :parent-construct construct))) 1209 (add-to-version-history assoc :start-revision revision)))) 1205 1210 construct)) 1206 1211 … … 1251 1256 1252 1257 (defmethod add-parent ((construct CharacteristicC) (parent-construct TopicC) 1253 &key (revision 0))1258 &key (revision *TM-REVISION*)) 1254 1259 (let ((already-set-topic 1255 1260 (map 'list #'parent-construct … … 1265 1270 (add-to-version-history parent-assoc :start-revision revision))) 1266 1271 ((not already-set-topic) 1267 (make-instance (if (typep construct 'OccurrenceC) 1268 'OccurrenceAssociationC 1269 'NameAssociationC) 1270 :start-revision revision 1271 :parent-construct parent-construct 1272 :characteristic construct)) 1272 (let ((assoc 1273 (make-instance (if (typep construct 'OccurrenceC) 1274 'OccurrenceAssociationC 1275 'NameAssociationC) 1276 :parent-construct parent-construct 1277 :characteristic construct))) 1278 (add-to-version-history assoc :start-revision revision))) 1273 1279 (t 1274 1280 (error "From add-parent(): ~a can't be owned by ~a since it is already owned by the topic ~a" … … 1278 1284 1279 1285 (defmethod add-parent ((construct CharacteristicC) (parent-construct NameC) 1280 &key (revision 0))1286 &key (revision *TM-REVISION*)) 1281 1287 (let ((already-set-name 1282 1288 (map 'list #'characteristic … … 1291 1297 (add-to-version-history parent-assoc :start-revision revision))) 1292 1298 ((not already-set-name) 1293 (make-instance 'VariantAssociationC 1294 :start-revision revision 1295 :parent-construct parent-construct 1296 :characteristic construct)) 1299 (let ((assoc 1300 (make-instance 'VariantAssociationC 1301 :parent-construct parent-construct 1302 :characteristic construct))) 1303 (add-to-version-history assoc :start-revision revision))) 1297 1304 (t 1298 1305 (error "From add-parent(): ~a can't be owned by ~a since it is already owned by the topic ~a" … … 1449 1456 (:documentation "Adds the given role to the passed association-construct.") 1450 1457 (:method ((construct AssociationC) (role RoleC) 1451 &key (revision 0))1458 &key (revision *TM-REVISION*)) 1452 1459 (let ((all-roles 1453 1460 (map 'list #'role … … 1459 1466 return role-assoc))) 1460 1467 (add-to-version-history role-assoc :start-revision revision)) 1461 (make-instance 'RoleAssociationC 1462 :start-revision revision 1463 :role role 1464 :association construct))) 1468 (let ((assoc 1469 (make-instance 'RoleAssociationC 1470 :role role 1471 :association construct))) 1472 (add-to-version-history assoc :start-revision revision)))) 1465 1473 construct)) 1466 1474 … … 1502 1510 1503 1511 (defmethod add-parent ((construct RoleC) (parent-construct AssociationC) 1504 &key (revision 0))1512 &key (revision *TM-REVISION*)) 1505 1513 (let ((already-set-parent 1506 1514 (map 'list #'parent … … 1516 1524 (add-to-version-history parent-assoc :start-revision revision))) 1517 1525 ((not already-set-parent) 1518 ( make-instance 'RoleAssociationC1519 :start-revision revision1520 :role construct1521 :parent-construct parent-construct))1526 (let ((assoc (make-instance 'RoleAssociationC 1527 :role construct 1528 :parent-construct parent-construct))) 1529 (add-to-version-history assoc :start-revision revision))) 1522 1530 (t 1523 1531 (error "From add-parent(): ~a can't be a parent of ~a since it is already owned by the association ~a" … … 1551 1559 (:documentation "Adds a topic as a player to a role in the given revision.") 1552 1560 (:method ((construct RoleC) (player-topic TopicC) 1553 &key (revision 0))1561 &key (revision *TM-REVISION*)) 1554 1562 (let ((already-set-player 1555 1563 (map 'list #'player-topic … … 1564 1572 (add-to-version-history player-assoc :start-revision revision))) 1565 1573 ((not already-set-player) 1566 ( make-instance 'PlayerAssociationC1567 :start-revision revision1568 :parent-construct construct1569 :player-topic player-topic))1574 (let ((assoc (make-instance 'PlayerAssociationC 1575 :parent-construct construct 1576 :player-topic player-topic))) 1577 (add-to-version-history assoc :start-revision revision))) 1570 1578 (t 1571 1579 (error "From add-player(): ~a can't be a player of ~a since it has already the player ~a" … … 1603 1611 (:method ((construct ReifiableConstructC) &key (revision 0)) 1604 1612 (let ((assocs (filter-slot-value-by-revision 1605 construct ' item-identifiers:start-revision revision)))1613 construct 'reifier :start-revision revision))) 1606 1614 (when assocs ;assocs must be nil or a list with exactly one item 1607 (reifier (first assocs))))))1615 (reifier-topic (first assocs)))))) 1608 1616 1609 1617 … … 1625 1633 the identified-constructs are merged.") 1626 1634 (:method ((construct ReifiableConstructC) (item-identifier ItemIdentifierC) 1627 &key (revision 0))1635 &key (revision *TM-REVISION*)) 1628 1636 (let ((all-ids 1629 1637 (map 'list #'identifier (slot-p construct 'item-identifiers))) … … 1670 1678 the reified-constructs are merged.") 1671 1679 (:method ((construct ReifiableConstructC) (reifier-topic TopicC) 1672 &key (revision 0))1680 &key (revision *TM-REVISION*)) 1673 1681 (let ((merged-reifier-topic 1674 (when (reifier construct) 1675 (merge-constructs (reifier construct) reifier-topic)))) 1682 (if (reifier construct) 1683 (merge-constructs (reifier construct) reifier-topic) 1684 reifier-topic))) 1676 1685 (let ((all-constructs 1677 (remove-if #'marked-as-deleted-p 1678 (slot-p reifier-topic 'reified-construct)))) 1686 (let ((inner-construct (reified-construct merged-reifier-topic 1687 :revision revision))) 1688 (when inner-construct 1689 (list inner-construct))))) 1679 1690 (cond ((find construct all-constructs) 1680 1691 (let ((reifier-assoc … … 1689 1700 (merge-constructs (first all-constructs) construct)) 1690 1701 (t 1691 (make-instance 'ReifierAssociationC 1692 :start-revision revision 1693 :reifiable-construct construct 1694 :reifier-topic merged-reifier-topic) 1695 construct)))))) 1702 (let ((assoc 1703 (make-instance 'ReifierAssociationC 1704 :reifiable-construct construct 1705 :reifier-topic merged-reifier-topic))) 1706 (add-to-version-history assoc :start-revision revision)))) 1707 construct)))) 1696 1708 1697 1709 … … 1730 1742 scopable-construct.") 1731 1743 (:method ((construct ScopableC) (theme-topic TopicC) 1732 &key (revision 0))1744 &key (revision *TM-REVISION*)) 1733 1745 (let ((all-themes 1734 1746 (map 'list #'theme-topic … … 1740 1752 return theme-assoc))) 1741 1753 (add-to-version-history theme-assoc :start-revision revision)) 1742 (make-instance 'ScopeAssociationC 1743 :start-revision revision 1744 :theme-topic theme-topic 1745 :scopable-construct construct))) 1754 (let ((assoc 1755 (make-instance 'ScopeAssociationCn 1756 :theme-topic theme-topic 1757 :scopable-construct construct))) 1758 (add-to-version-history assoc :start-revision revision)))) 1746 1759 construct)) 1747 1760 … … 1783 1796 set at the same revision.") 1784 1797 (:method ((construct TypableC) (type-topic TopicC) 1785 &key (revision 0))1798 &key (revision *TM-REVISION*)) 1786 1799 (let ((already-set-type 1787 1800 (map 'list #'type-topic … … 1796 1809 (add-to-version-history type-assoc :start-revision revision))) 1797 1810 ((not already-set-type) 1798 (make-instance 'TypeAssociationC 1799 :start-revision revision 1800 :type-topic type-topic 1801 :typable-construct construct)) 1811 (let ((assoc 1812 (make-instance 'TypeAssociationC 1813 :type-topic type-topic 1814 :typable-construct construct))) 1815 (add-to-version-history assoc :start-revision revision))) 1802 1816 (t 1803 1817 (error "From add-type(): ~a can't be typed by ~a since it is already typed by the topic ~a" … … 1832 1846 1833 1847 ;;; start hacks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1834 (defgeneric merge-constructs(construc -1 construct-2 &key revision)1848 (defgeneric merge-constructs(construct-1 construct-2 &key revision) 1835 1849 (:method ((construct-1 TopicMapConstructC) (construct-2 TopicMapconstructC) 1836 &key (revision 0)) 1837 (or construct-1 construct-2 revision))) 1850 &key (revision *TM-REVISION*)) 1851 (or revision) 1852 (if construct-1 construct-1 construct-2))) 1838 1853 1839 1854 -
TabularUnified branches/new-datamodel/src/unit_tests/datamodel_test.lisp ¶
r206 r207 27 27 :test-get-item-by-item-identifier 28 28 :test-get-item-by-locator 29 :test-get-item-by-psi)) 30 31 32 ;;TODO: test merges-constructs when merging was caused by an item-dentifier 33 ;;TODO: test merges-constructs when merging was caused by an psi 34 ;;TODO: test merges-constructs when merging was caused by an subject-locator 35 ;;TODO: test merges-constructs when merging was caused by a topic-id 29 :test-get-item-by-psi 30 :test-ReifiableConstructC)) 31 32 33 ;;TODO: test delete-construct 34 ;;TODO: test merge-constructs when merging was caused by an item-dentifier 35 ;;TODO: test merge-constructs when merging was caused by an psi 36 ;;TODO: test merge-constructs when merging was caused by an subject-locator 37 ;;TODO: test merge-constructs when merging was caused by a topic-id 38 ;;TODO: test merge-constructs when merging was caused by reifiers 39 ;; (occurrences, names, variants, associations, roles) 40 ;;TODO: test ReifiableConstructC --> reifier has to be merged 36 41 37 42 … … 368 373 369 374 (test test-get-item-by-item-identifier () 370 "Tests the function test-get-item-by-i d."375 "Tests the function test-get-item-by-item-identifier." 371 376 (with-fixture with-empty-db (*db-dir*) 372 377 (let ((ii-1 (make-instance 'ItemIdentifierC … … 410 415 411 416 (test test-get-item-by-locator () 412 "Tests the function test-get-item-by- id."417 "Tests the function test-get-item-by-locator." 413 418 (with-fixture with-empty-db (*db-dir*) 414 419 (let ((sl-1 (make-instance 'SubjectLocatorC … … 452 457 453 458 (test test-get-item-by-psi () 454 "Tests the function test-get-item-by- id."459 "Tests the function test-get-item-by-psi." 455 460 (with-fixture with-empty-db (*db-dir*) 456 461 (let ((psi-1 (make-instance 'PersistentIdC … … 493 498 494 499 500 (test test-ReifiableConstructC () 501 "Tests variuas functions of the ReifialeConstructC." 502 (with-fixture with-empty-db (*db-dir*) 503 (let ((reifier-top (make-instance 'TopicC)) 504 (reified-rc (make-instance 'd::ReifiableConstructC))) 505 (is-false (reifier reified-rc)) 506 (is-false (reified-construct reifier-top)) 507 (add-reifier reified-rc reifier-top :revision 100) 508 (is (eql reifier-top (reifier reified-rc))) 509 (is (eql reified-rc (reified-construct reifier-top))) 510 (is (eql reifier-top (reifier reified-rc :revision 200))) 511 (is (eql reified-rc (reified-construct reifier-top :revision 200))) 512 (is-false (reifier reified-rc :revision 50)) 513 (is-false (reified-construct reifier-top :revision 50))))) 514 515 495 516 (defun run-datamodel-tests() 496 517 (it.bese.fiveam:run! 'test-VersionInfoC) … … 504 525 (it.bese.fiveam:run! 'test-get-item-by-locator) 505 526 (it.bese.fiveam:run! 'test-get-item-by-psi) 527 (it.bese.fiveam:run! 'test-ReifiableConstructC) 506 528 )
Note: See TracChangeset
for help on using the changeset viewer.