| | 371 | |
|---|
| | 372 | # relationships can sometimes by unary, i.e. association, flow |
|---|
| | 373 | # override in deriving class to allow unary relationship |
|---|
| | 374 | CAN_BE_UNARY = False |
|---|
| | 375 | |
|---|
| | 376 | def glue(self, handle): |
|---|
| | 377 | """ |
|---|
| | 378 | In addition to the normal check, both relationship ends may not be |
|---|
| | 379 | connected to the same element. Same goes for subjects. |
|---|
| | 380 | """ |
|---|
| | 381 | if not self.CAN_BE_UNARY: |
|---|
| | 382 | opposite = self.line.opposite(handle) |
|---|
| | 383 | line = self.line |
|---|
| | 384 | element = self.element |
|---|
| | 385 | connected_to = opposite.connected_to |
|---|
| | 386 | |
|---|
| | 387 | # Element can not be a parent for itself. |
|---|
| | 388 | if connected_to is element: |
|---|
| | 389 | return None |
|---|
| | 390 | |
|---|
| | 391 | # Same goes for subjects: |
|---|
| | 392 | if connected_to and \ |
|---|
| | 393 | (not (connected_to.subject or element.subject)) \ |
|---|
| | 394 | and connected_to.subject is element.subject: |
|---|
| | 395 | return None |
|---|
| | 396 | |
|---|
| | 397 | return super(RelationshipConnect, self).glue(handle) |
|---|
| | 398 | |
|---|
| 530 | | """ |
|---|
| 531 | | In addition to the normal check, both line ends may not be connected |
|---|
| 532 | | to the same element. Same goes for subjects. |
|---|
| 533 | | """ |
|---|
| 534 | | opposite = self.line.opposite(handle) |
|---|
| 535 | | line = self.line |
|---|
| 536 | | element = self.element |
|---|
| 537 | | connected_to = opposite.connected_to |
|---|
| 538 | | |
|---|
| 539 | | # Element can not be a parent for itself. |
|---|
| 540 | | if connected_to is element: |
|---|
| 541 | | return None |
|---|
| 542 | | |
|---|
| 543 | | # Same goes for subjects: |
|---|
| 544 | | if connected_to and \ |
|---|
| 545 | | (not (connected_to.subject or element.subject)) \ |
|---|
| 546 | | and connected_to.subject is element.subject: |
|---|
| 547 | | return None |
|---|
| | 558 | line = self.line |
|---|
| | 559 | element = self.element |
|---|
| 583 | | """ |
|---|
| 584 | | In addition to the normal check, both line ends may not be connected |
|---|
| 585 | | to the same element. Same goes for subjects. |
|---|
| 586 | | """ |
|---|
| 587 | | opposite = self.line.opposite(handle) |
|---|
| 588 | | line = self.line |
|---|
| 589 | | element = self.element |
|---|
| 590 | | connected_to = opposite.connected_to |
|---|
| 591 | | |
|---|
| 592 | | # Element can not be a parent for itself. |
|---|
| 593 | | if connected_to is element: |
|---|
| 594 | | return None |
|---|
| 595 | | |
|---|
| 596 | | # Same goes for subjects: |
|---|
| 597 | | if connected_to and \ |
|---|
| 598 | | (not (connected_to.subject or element.subject)) \ |
|---|
| 599 | | and connected_to.subject is element.subject: |
|---|
| 600 | | return None |
|---|
| | 595 | line = self.line |
|---|
| | 596 | element = self.element |
|---|
| 628 | | |
|---|
| 629 | | # # FixMe: Both ends of the generalization should be of the same type? |
|---|
| 630 | | def glue(self, handle): |
|---|
| 631 | | """ |
|---|
| 632 | | In addition to the normal check, both line ends may not be connected |
|---|
| 633 | | to the same element. Same goes for subjects. |
|---|
| 634 | | """ |
|---|
| 635 | | opposite = self.line.opposite(handle) |
|---|
| 636 | | line = self.line |
|---|
| 637 | | element = self.element |
|---|
| 638 | | connected_to = opposite.connected_to |
|---|
| 639 | | |
|---|
| 640 | | # Element can not be a parent for itself. |
|---|
| 641 | | if connected_to is element: |
|---|
| 642 | | return None |
|---|
| 643 | | |
|---|
| 644 | | # Same goes for subjects: |
|---|
| 645 | | if connected_to and \ |
|---|
| 646 | | (not (connected_to.subject or element.subject)) \ |
|---|
| 647 | | and connected_to.subject is element.subject: |
|---|
| 648 | | return None |
|---|
| 649 | | |
|---|
| 650 | | return super(GeneralizationConnect, self).glue(handle) |
|---|
| 668 | | """ |
|---|
| 669 | | In addition to the normal check, both line ends may not be connected |
|---|
| 670 | | to the same element. Same goes for subjects. |
|---|
| 671 | | """ |
|---|
| 672 | | opposite = self.line.opposite(handle) |
|---|
| 673 | | line = self.line |
|---|
| 674 | | element = self.element |
|---|
| 675 | | connected_to = opposite.connected_to |
|---|
| 676 | | |
|---|
| 677 | | # Element can not be a parent for itself. |
|---|
| 678 | | if connected_to is element: |
|---|
| 679 | | return None |
|---|
| 680 | | |
|---|
| 681 | | # Same goes for subjects: |
|---|
| 682 | | if connected_to and \ |
|---|
| 683 | | (not (connected_to.subject or element.subject)) \ |
|---|
| 684 | | and connected_to.subject is element.subject: |
|---|
| 685 | | return None |
|---|
| | 642 | line = self.line |
|---|
| | 643 | element = self.element |
|---|
| 748 | | """ |
|---|
| 749 | | In addition to the normal check, both line ends may not be connected |
|---|
| 750 | | to the same element. Same goes for subjects. |
|---|
| 751 | | """ |
|---|
| 752 | | opposite = self.line.opposite(handle) |
|---|
| 753 | | line = self.line |
|---|
| 754 | | element = self.element |
|---|
| 755 | | connected_to = opposite.connected_to |
|---|
| 756 | | |
|---|
| 757 | | # Element can not be a parent for itself. |
|---|
| 758 | | if connected_to is element: |
|---|
| 759 | | return None |
|---|
| 760 | | |
|---|
| 761 | | # Same goes for subjects: |
|---|
| 762 | | if connected_to and \ |
|---|
| 763 | | (not (connected_to.subject or element.subject)) \ |
|---|
| 764 | | and connected_to.subject is element.subject: |
|---|
| 765 | | return None |
|---|
| | 690 | line = self.line |
|---|
| | 691 | element = self.element |
|---|
| 1016 | | """ |
|---|
| 1017 | | In addition to the normal check, one end should have at most one |
|---|
| 1018 | | edge (incoming or outgoing). |
|---|
| 1019 | | """ |
|---|
| 1020 | | opposite = self.line.opposite(handle) |
|---|
| 1021 | | line = self.line |
|---|
| 1022 | | element = self.element |
|---|
| 1023 | | subject = element.subject |
|---|
| 1024 | | connected_to = opposite.connected_to |
|---|
| 1025 | | |
|---|
| 1026 | | # Element can not connect back to itself |
|---|
| 1027 | | if connected_to is element: |
|---|
| 1028 | | return None |
|---|
| 1029 | | |
|---|
| 1030 | | # Same goes for subjects: |
|---|
| 1031 | | if connected_to and \ |
|---|
| 1032 | | (not (connected_to.subject or element.subject)) \ |
|---|
| 1033 | | and connected_to.subject is element.subject: |
|---|
| 1034 | | return None |
|---|
| 1035 | | |
|---|