read-gedcom
Version:
Gedcom file reader
196 lines • 8.78 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectionIndividualRecord = void 0;
const mixin_1 = require("./mixin");
const internal_1 = require("./internal");
const base_1 = require("./base");
/**
* An individual record.
* <table>
* <tr><th>Pointer</th><td>Yes</td></tr>
* <tr><th>Value</th><td>No</td></tr>
* </table>
*/
class SelectionIndividualRecord extends (0, mixin_1.SelectionWithMultimediaMixin)((0, mixin_1.SelectionWithNoteSourceCitationMixin)(base_1.SelectionRecord)) {
getName() {
return this.get("NAME" /* Tag.Name */, null, internal_1.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 internal_1.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 internal_1.SelectionFamilyRecord(this.rootNode, children);
}
/* Events */
getEventBirth() {
return this.get("BIRT" /* Tag.Birth */, null, internal_1.SelectionIndividualEventFamily);
}
getEventChristening() {
return this.get("CHR" /* Tag.Christening */, null, internal_1.SelectionIndividualEventFamily);
}
getEventDeath() {
return this.get("DEAT" /* Tag.Death */, null, internal_1.SelectionIndividualEvent);
}
getEventBurial() {
return this.get("BURI" /* Tag.Burial */, null, internal_1.SelectionIndividualEvent);
}
getEventCremation() {
return this.get("CREM" /* Tag.Cremation */, null, internal_1.SelectionIndividualEvent);
}
getEventAdoption() {
return this.get("ADOP" /* Tag.Adoption */, null, internal_1.SelectionIndividualEventFamilyAdoption);
}
getEventBaptism() {
return this.get("BAPM" /* Tag.Baptism */, null, internal_1.SelectionIndividualEvent);
}
getEventBarMitzvah() {
return this.get("BARM" /* Tag.BarMitzvah */, null, internal_1.SelectionIndividualEvent);
}
getEventBatMitzvah() {
return this.get("BASM" /* Tag.BatMitzvah */, null, internal_1.SelectionIndividualEvent);
}
getEventAdultChristening() {
return this.get("CHRA" /* Tag.AdultChristening */, null, internal_1.SelectionIndividualEvent);
}
getEventConfirmation() {
return this.get("CONF" /* Tag.Confirmation */, null, internal_1.SelectionIndividualEvent);
}
getEventFirstCommunion() {
return this.get("FCOM" /* Tag.FirstCommunion */, null, internal_1.SelectionIndividualEvent);
}
getEventNaturalization() {
return this.get("NATU" /* Tag.Naturalization */, null, internal_1.SelectionIndividualEvent);
}
getEventEmigration() {
return this.get("EMIG" /* Tag.Emigration */, null, internal_1.SelectionIndividualEvent);
}
getEventImmigration() {
return this.get("IMMI" /* Tag.Immigration */, null, internal_1.SelectionIndividualEvent);
}
getEventCensus() {
return this.get("CENS" /* Tag.Census */, null, internal_1.SelectionIndividualEvent);
}
getEventProbate() {
return this.get("PROB" /* Tag.Probate */, null, internal_1.SelectionIndividualEvent);
}
getEventWill() {
return this.get("WILL" /* Tag.Will */, null, internal_1.SelectionIndividualEvent);
}
getEventGraduation() {
return this.get("GRAD" /* Tag.Graduation */, null, internal_1.SelectionIndividualEvent);
}
getEventRetirement() {
return this.get("RETI" /* Tag.Retirement */, null, internal_1.SelectionIndividualEvent);
}
getEventOther() {
return this.get("EVEN" /* Tag.Event */, null, internal_1.SelectionIndividualEvent);
}
/* End events */
/* Attributes */
getAttributeCaste() {
return this.get("CAST" /* Tag.Caste */, null, internal_1.SelectionIndividualAttribute);
}
getAttributePhysicalDescription() {
return this.get("DSCR" /* Tag.PhysicalDescription */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeScholasticAchievement() {
return this.get("EDUC" /* Tag.Education */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeIdentificationNumber() {
return this.get("IDNO" /* Tag.IdentificationNumber */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeNationality() {
return this.get("NATI" /* Tag.Nationality */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeChildrenCount() {
return this.get("NCHI" /* Tag.ChildrenCount */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeRelationshipCount() {
return this.get("NMR" /* Tag.MarriageCount */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeOccupation() {
return this.get("OCCU" /* Tag.Occupation */, null, internal_1.SelectionIndividualAttribute);
}
getAttributePossessions() {
return this.get("PROP" /* Tag.Property */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeReligiousAffiliation() {
return this.get("RELI" /* Tag.Religion */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeResidence() {
return this.get("RESI" /* Tag.Residence */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeNobilityTitle() {
return this.get("TITL" /* Tag.Title */, null, internal_1.SelectionIndividualAttribute);
}
getAttributeFact() {
return this.get("FACT" /* Tag.Fact */, null, internal_1.SelectionIndividualAttribute);
}
/* End attributes */
getChildFamilyLink() {
return this.get("FAMC" /* Tag.FamilyChild */, null, internal_1.SelectionChildFamilyLink);
}
getSpouseFamilyLink() {
return this.get("FAMS" /* Tag.FamilySpouse */, null, internal_1.SelectionSpouseFamilyLink);
}
getAssociation() {
return this.get("ASSO" /* Tag.Associates */, null, internal_1.SelectionAssociation);
}
}
exports.SelectionIndividualRecord = SelectionIndividualRecord;
//# sourceMappingURL=SelectionIndividualRecord.js.map