UNPKG

read-gedcom

Version:
192 lines 8.43 kB
import { SelectionWithMultimediaMixin, SelectionWithNoteSourceCitationMixin } from './mixin'; import { SelectionFamilyRecord, SelectionName, SelectionIndividualEventFamily, SelectionIndividualEventFamilyAdoption, SelectionIndividualEvent, SelectionIndividualAttribute, SelectionChildFamilyLink, SelectionSpouseFamilyLink, SelectionAssociation } from './internal'; import { SelectionRecord } from './base'; /** * An individual record. * <table> * <tr><th>Pointer</th><td>Yes</td></tr> * <tr><th>Value</th><td>No</td></tr> * </table> */ export class SelectionIndividualRecord extends SelectionWithMultimediaMixin(SelectionWithNoteSourceCitationMixin(SelectionRecord)) { getName() { return this.get("NAME" /* Tag.Name */, null, SelectionName); } getSex() { return this.get("SEX" /* Tag.Sex */); } getFamilyAsChild() { const children = []; const rootIndex = this.rootNode._index; if (rootIndex !== undefined && rootIndex.asChild !== undefined) { for (let i = 0; i < this.length; i++) { const node = this[i]; if (node.pointer !== null) { const familiesIdx = rootIndex.asChild[node.pointer]; if (familiesIdx !== undefined) { // TODO this shouldn't happen, is it necessary? familiesIdx.forEach(familyIdx => { children.push(this.rootNode.children[familyIdx]); }); } } } } else { // Pretty bad performance when the index is not available, but we don't have any other choice // Cost could be mitigated for large selections by using a hash set (but tricky due to multiplicity) const nodesFamily = this.rootNode.children.filter(nodeFamily => nodeFamily.tag === "FAM" /* Tag.Family */); for (let i = 0; i < this.length; i++) { const node = this[i]; if (node.pointer !== null) { nodesFamily.filter(nodeFamily => nodeFamily.children.some(nodeChild => nodeChild.tag === "CHIL" /* Tag.Child */ && nodeChild.value === node.pointer)) .forEach(nodeFamily => children.push(nodeFamily)); } } } return new SelectionFamilyRecord(this.rootNode, children); } getFamilyAsSpouse() { const children = []; const rootIndex = this.rootNode._index; if (rootIndex !== undefined && rootIndex.asSpouse !== undefined) { for (let i = 0; i < this.length; i++) { const node = this[i]; if (node.pointer !== null) { const familiesIdx = rootIndex.asSpouse[node.pointer]; if (familiesIdx !== undefined) { // ditto familiesIdx.forEach(familyIdx => { children.push(this.rootNode.children[familyIdx]); }); } } } } else { const nodesFamily = this.rootNode.children.filter(nodeFamily => nodeFamily.tag === "FAM" /* Tag.Family */); for (let i = 0; i < this.length; i++) { const node = this[i]; if (node.pointer !== null) { nodesFamily.filter(nodeFamily => nodeFamily.children.some(nodeChild => (nodeChild.tag === "HUSB" /* Tag.Husband */ || nodeChild.tag === "WIFE" /* Tag.Wife */) && nodeChild.value === node.pointer)) .forEach(nodeFamily => children.push(nodeFamily)); } } } return new SelectionFamilyRecord(this.rootNode, children); } /* Events */ getEventBirth() { return this.get("BIRT" /* Tag.Birth */, null, SelectionIndividualEventFamily); } getEventChristening() { return this.get("CHR" /* Tag.Christening */, null, SelectionIndividualEventFamily); } getEventDeath() { return this.get("DEAT" /* Tag.Death */, null, SelectionIndividualEvent); } getEventBurial() { return this.get("BURI" /* Tag.Burial */, null, SelectionIndividualEvent); } getEventCremation() { return this.get("CREM" /* Tag.Cremation */, null, SelectionIndividualEvent); } getEventAdoption() { return this.get("ADOP" /* Tag.Adoption */, null, SelectionIndividualEventFamilyAdoption); } getEventBaptism() { return this.get("BAPM" /* Tag.Baptism */, null, SelectionIndividualEvent); } getEventBarMitzvah() { return this.get("BARM" /* Tag.BarMitzvah */, null, SelectionIndividualEvent); } getEventBatMitzvah() { return this.get("BASM" /* Tag.BatMitzvah */, null, SelectionIndividualEvent); } getEventAdultChristening() { return this.get("CHRA" /* Tag.AdultChristening */, null, SelectionIndividualEvent); } getEventConfirmation() { return this.get("CONF" /* Tag.Confirmation */, null, SelectionIndividualEvent); } getEventFirstCommunion() { return this.get("FCOM" /* Tag.FirstCommunion */, null, SelectionIndividualEvent); } getEventNaturalization() { return this.get("NATU" /* Tag.Naturalization */, null, SelectionIndividualEvent); } getEventEmigration() { return this.get("EMIG" /* Tag.Emigration */, null, SelectionIndividualEvent); } getEventImmigration() { return this.get("IMMI" /* Tag.Immigration */, null, SelectionIndividualEvent); } getEventCensus() { return this.get("CENS" /* Tag.Census */, null, SelectionIndividualEvent); } getEventProbate() { return this.get("PROB" /* Tag.Probate */, null, SelectionIndividualEvent); } getEventWill() { return this.get("WILL" /* Tag.Will */, null, SelectionIndividualEvent); } getEventGraduation() { return this.get("GRAD" /* Tag.Graduation */, null, SelectionIndividualEvent); } getEventRetirement() { return this.get("RETI" /* Tag.Retirement */, null, SelectionIndividualEvent); } getEventOther() { return this.get("EVEN" /* Tag.Event */, null, SelectionIndividualEvent); } /* End events */ /* Attributes */ getAttributeCaste() { return this.get("CAST" /* Tag.Caste */, null, SelectionIndividualAttribute); } getAttributePhysicalDescription() { return this.get("DSCR" /* Tag.PhysicalDescription */, null, SelectionIndividualAttribute); } getAttributeScholasticAchievement() { return this.get("EDUC" /* Tag.Education */, null, SelectionIndividualAttribute); } getAttributeIdentificationNumber() { return this.get("IDNO" /* Tag.IdentificationNumber */, null, SelectionIndividualAttribute); } getAttributeNationality() { return this.get("NATI" /* Tag.Nationality */, null, SelectionIndividualAttribute); } getAttributeChildrenCount() { return this.get("NCHI" /* Tag.ChildrenCount */, null, SelectionIndividualAttribute); } getAttributeRelationshipCount() { return this.get("NMR" /* Tag.MarriageCount */, null, SelectionIndividualAttribute); } getAttributeOccupation() { return this.get("OCCU" /* Tag.Occupation */, null, SelectionIndividualAttribute); } getAttributePossessions() { return this.get("PROP" /* Tag.Property */, null, SelectionIndividualAttribute); } getAttributeReligiousAffiliation() { return this.get("RELI" /* Tag.Religion */, null, SelectionIndividualAttribute); } getAttributeResidence() { return this.get("RESI" /* Tag.Residence */, null, SelectionIndividualAttribute); } getAttributeNobilityTitle() { return this.get("TITL" /* Tag.Title */, null, SelectionIndividualAttribute); } getAttributeFact() { return this.get("FACT" /* Tag.Fact */, null, SelectionIndividualAttribute); } /* End attributes */ getChildFamilyLink() { return this.get("FAMC" /* Tag.FamilyChild */, null, SelectionChildFamilyLink); } getSpouseFamilyLink() { return this.get("FAMS" /* Tag.FamilySpouse */, null, SelectionSpouseFamilyLink); } getAssociation() { return this.get("ASSO" /* Tag.Associates */, null, SelectionAssociation); } } //# sourceMappingURL=SelectionIndividualRecord.js.map