-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed commit of the following: commit b9363ec Author: Rafael Espinoza <rafael@rafaelespinoza.com> Date: Sat Nov 25 14:35:48 2023 -0800 feat(cmd): Present MutualRelationship as JSON commit 25497eb Author: Rafael Espinoza <rafael@rafaelespinoza.com> Date: Tue Nov 7 14:43:33 2023 -0800 feat(srv): Relate people via a union commit eee10b4 Author: Rafael Espinoza <rafael@rafaelespinoza.com> Date: Tue Nov 7 14:34:50 2023 -0800 feat(entity): Add affinity-related types These types are for relating two people via a marriage commit ae03338 Author: Rafael Espinoza <rafael@rafaelespinoza.com> Date: Fri Nov 10 13:18:19 2023 -0800 srv: Allow relating of same people Using this simple case to recognize spouses. commit c66a2ee Author: Rafael Espinoza <rafael@rafaelespinoza.com> Date: Sat Nov 4 21:13:19 2023 -0700 feat: Add Spouses field to Person
- Loading branch information
1 parent
2875fb5
commit 5abb62f
Showing
8 changed files
with
1,072 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,5 @@ type Person struct { | |
Deathdate *time.Time | ||
Parents []*Person | ||
Children []*Person | ||
Spouses []*Person | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package entity | ||
|
||
// MutualRelationship describes a relationship from person A to person B and its | ||
// complementary relationship from person B to person A. | ||
// | ||
// If person A and person B have a blood relationship, then CommonPerson is a | ||
// shared common ancestor. The Path fields in each Relationship denote the | ||
// ancestral path to the CommonPerson, where the first person in the Path is | ||
// starting person and the last person is the CommonPerson. | ||
// | ||
// If person A and person B are related by marriage, then Union is non-empty. | ||
// The Path fields in each Relationship describe how the starting person relates | ||
// to a person in the Union. | ||
type MutualRelationship struct { | ||
CommonPerson *Person | ||
Union *Union | ||
R1, R2 Relationship | ||
} | ||
|
||
// Relationship is a unidirectional descriptor how a person at SourceID relates | ||
// to a person at TargetID. The connection may have a consanguineous (by blood) | ||
// nature, or may be affinal (by law, or via marriage). | ||
type Relationship struct { | ||
// SourceID identifies the person representing the vantage point in this Relationship. | ||
SourceID string | ||
// TargetID identifies the person who is being related to by the person at SourceID. | ||
TargetID string | ||
// Type may indicate if the relationship is consanguineous (by blood), | ||
// affinal (by law, or via marriage), or is unknown. | ||
Type RelationshipType | ||
// Description elaborates on the Type. | ||
Description string | ||
GenerationsRemoved int | ||
// Path is the path to a common person if the Type field indicates a | ||
// consanguineous relationship. If the Type indiciates an affinal | ||
// relationship, then Path is the path from the person at SourceID to a | ||
// person in a Union. | ||
Path []Person | ||
} | ||
|
||
type RelationshipType int | ||
|
||
const ( | ||
Unknown RelationshipType = iota | ||
|
||
// These values indicate a consanguineous (by blood) relationship. | ||
Self | ||
Sibling | ||
Child | ||
Parent | ||
AuntUncle | ||
Cousin | ||
NieceNephew | ||
|
||
// These values indicate an affinal (by marriage) relationship. | ||
Spouse | ||
SiblingInLaw | ||
ChildInLaw | ||
ParentInLaw | ||
AuntUncleInLaw | ||
CousinInLaw | ||
NieceNephewInLaw | ||
) | ||
|
||
var relationshipNames = []string{ | ||
"unknown", | ||
|
||
"self", | ||
"sibling", | ||
"child", | ||
"parent", | ||
"aunt/uncle", | ||
"cousin", | ||
"niece/nephew", | ||
|
||
"spouse", | ||
"sibling in-law", | ||
"child in-law", | ||
"parent in-law", | ||
"aunt/uncle in-law", | ||
"cousin in-law", | ||
"niece/nephew in-law", | ||
} | ||
|
||
func (t RelationshipType) String() string { | ||
if t < 0 || int(t) >= len(relationshipNames) { | ||
return "" | ||
} | ||
|
||
return relationshipNames[t] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.