// TODO lost the "individual number" when doing marriage events private static string PersonName(IndiRecord indi) { if (indi == null) // e.g. Marriage may not have father/mother info { return(null); } string name = string.Format("{0}[{1}]", indi.FullName, indi.Ident); return(name); }
public void TestIndiSour() { // SOUR record on the INDI var indi1 = "0 @I1@ INDI\n1 SOUR @p1@"; IndiRecord rec = parseInd(indi1); Assert.AreEqual(1, rec.Cits.Count); Assert.AreEqual("p1", rec.Cits[0].Xref); var indi2 = "0 @I1@ INDI\n1 SOUR @p1@\n1 SOUR @p2@"; IndiRecord rec2 = parseInd(indi2); Assert.AreEqual(2, rec2.Cits.Count); Assert.AreEqual("p1", rec2.Cits[0].Xref); Assert.AreEqual("p2", rec2.Cits[1].Xref); }
public void SourEmbSourPage() { // During GedValid development, INDI.SOUR.TEXT error did not have correct end line var txt = "0 @I1@ INDI\n1 NAME /Blah/\n1 SOUR description\n2 TEXT Blah\n2 PAGE event\n1 BIRT\n2 DATE 21 Feb 1696\n2 PLAC North Hampton, Rockingham County, New Hampshire"; var res = ReadIt(txt); Assert.AreEqual(1, res.Count); IndiRecord rec = res[0] as IndiRecord; Assert.AreEqual(1, rec.Events.Count); Assert.AreEqual(1, rec.Errors.Count); Assert.AreEqual(UnkRec.ErrorCode.EmbSourPage, rec.Errors[0].Error); Assert.AreEqual(3, rec.Errors[0].Beg); Assert.AreEqual(5, rec.Errors[0].End); }
private IndiWrap MakeFillerIndi(string ident, out IndiRecord hack) { // There is a reference to an individual who doesn't exist in // the GEDCOM. Create a placeholder. IndiWrap hack0 = new IndiWrap(); // TODO need a library method to do this!!! hack = new IndiRecord(null, ident, null); var hack2 = new NameRec(); hack2.Surname = "Missing"; hack.Names.Add(hack2); hack0.Indi = hack; hack0.Ahnen = -1; return(hack0); }
private void ScanIt(Forest f) { dataSet = new List <One>(); foreach (var person in f.AllPeople) { IndiRecord ged = person.Indi; foreach (var familyEvent in ged.Events) { string tag = familyEvent.Tag; if (!string.IsNullOrEmpty(familyEvent.Place)) { dataSet.Add(new One { Location = familyEvent.Place, Tag = tag, PersonId = ged.Ident, Indi = person }); } } foreach (var familyEvent in ged.Attribs) { string tag = familyEvent.Tag; if (!string.IsNullOrEmpty(familyEvent.Place)) { dataSet.Add(new One { Location = familyEvent.Place, Tag = tag, PersonId = ged.Ident, Indi = person }); } } } foreach (var union in f.AllUnions) { FamRecord fam = union.FamRec; foreach (var familyEvent in fam.FamEvents) { string tag = familyEvent.Tag; if (!string.IsNullOrEmpty(familyEvent.Place)) { dataSet.Add(new One { Location = familyEvent.Place, Tag = tag, FamId = fam.Ident, Fam = union }); } } } }
public void MultiUID() { IndiRecord recI = TestIndiMultiId("UID"); Assert.IsNotNull(recI.UID); Assert.AreEqual("number", recI.UID); recI = TestIndiMultiId("_UID"); Assert.IsNotNull(recI.UID); Assert.AreEqual("number", recI.UID); FamRecord recF = TestFamMultiId("UID"); Assert.IsNotNull(recF.UID); Assert.AreEqual("number", recF.UID); recF = TestFamMultiId("_UID"); Assert.IsNotNull(recF.UID); Assert.AreEqual("number", recF.UID); TestFamMultiId("_UID"); }
public void SourCitTextOwner() { // Errors were only going to 'owning' structure. E.g. errors were tracked in NameRec, not the Indi. // The following errors exist: (RefSourText being a TEXT tag used with a reference SOUR) // 1. RefSourText for the NAME // 2. RefSourText for the INDI // 3. RefSourText for BIRT // 4. RefSourText for BIRT // 5. RefSourText for BIRT var txt = "0 @I1246@ INDI\n1 NAME Mehitable /DEARBORN/\n2 SOUR @S36@\n3 TEXT Mehitable Dearborn\n1 SEX F\n1 SOUR @S37@\n2 TEXT Mehetabel Dearborn" + "\n1 BIRT\n2 DATE 21 Feb 1696/97\n2 PLAC North Hampton, Rockingham County, New Hampshire\n2 SOUR @S37@\n3 TEXT 21 Feb 1696/97 (Rauch Files, Adam Rauch, manuscript)" + "\n2 SOUR @S36@\n3 TEXT 21 Feb 1696/97\n2 SOUR @S44@\n3 TEXT 21 Feb 1696/97, North Hampton, Rockingham County, New Hampshire\n1 DEAT\n2 DATE 1 AUG 1758" + "2 SOUR @S44@\n1 FAMC @F565@\n1 FAMS @F964@\n1 CHAN\n2 DATE 28 MAR 2001"; var res = ReadIt(txt); Assert.AreEqual(1, res.Count); IndiRecord rec = res[0] as IndiRecord; Assert.AreEqual(5, rec.Errors.Count); // all errors owned by parent }
private static void dumpDates(Forest f) { int [] counts = new int[6]; //bool hasWFTEst = false; foreach (var person in f.AllPeople) { IndiRecord ged = person.Indi; foreach (var familyEvent in ged.Events) { var state = dumpDate(familyEvent); IncrCount(state, counts); } foreach (var familyEvent in ged.Attribs) { var state = dumpDate(familyEvent); IncrCount(state, counts); } } foreach (var union in f.AllUnions) { FamRecord ged = union.FamRec; foreach (var familyEvent in ged.FamEvents) { var state = dumpDate(familyEvent); IncrCount(state, counts); } } Console.WriteLine("\t Success:{0}", counts[0]); Console.WriteLine("\tSuccess (exact):{0}", counts[5]); Console.WriteLine("\t WFT Est:{0}", counts[1]); Console.WriteLine("\t Fail:{0}", counts[2]); Console.WriteLine("\t Fail/Dump:{0}", counts[3]); //if (hasWFTEst) // Console.WriteLine("\tWFT Est not shown"); }
public Person(IndiRecord indi) : this() { Indi = indi; _spouseIn = new HashSet <Union>(); _childIn = new HashSet <Union>(); }
private static void dump(Forest f, bool showErrors) { if (f.Errors.Count > 0) { foreach (var unkRec in f.Errors) { if (unkRec.Error == UnkRec.ErrorCode.EmptyFile) { Console.WriteLine("Empty file"); return; } } } if (f.AllRecords.Count == 0) { Console.WriteLine("*****Failed to parse"); return; } Dictionary <string, int> tagCounts = new Dictionary <string, int>(); foreach (var record in f.AllRecords) { incr(tagCounts, record.Tag); } Dictionary <string, int> indiEventCounts = new Dictionary <string, int>(); int indiEventLoc = 0; Dictionary <string, int> indiAttribCounts = new Dictionary <string, int>(); int attribLoc = 0; Dictionary <string, int> famEventCounts = new Dictionary <string, int>(); int famEventLoc = 0; foreach (var person in f.AllPeople) { IndiRecord ged = person.Indi; foreach (var familyEvent in ged.Events) { string tag = familyEvent.Tag; incr(indiEventCounts, tag); if (!string.IsNullOrEmpty(familyEvent.Place)) { indiEventLoc++; } } foreach (var familyEvent in ged.Attribs) { string tag = familyEvent.Tag; incr(indiAttribCounts, tag); if (!string.IsNullOrEmpty(familyEvent.Place)) { attribLoc++; } } } foreach (var union in f.AllUnions) { FamRecord ged = union.FamRec; foreach (var familyEvent in ged.FamEvents) { string tag = familyEvent.Tag; incr(famEventCounts, tag); if (!string.IsNullOrEmpty(familyEvent.Place)) { famEventLoc++; } } } HeadRecord head = f.Header; if (head == null) { Console.WriteLine("No head"); } else { Console.WriteLine(" {0}-{1}:{2} ({3})", head.GedVersion, head.Product, head.ProductVersion, head.GedDate.ToString("yyyyMMdd")); } Console.Write("\t"); foreach (var tag in tagCounts.Keys) { if (!string.IsNullOrEmpty(tag)) { Console.Write("{0}:{1};", tag, tagCounts[tag]); } } Console.WriteLine(); Console.WriteLine("\t\t----------"); Console.Write("\t"); foreach (var tag in indiEventCounts.Keys) { Console.Write("{0}:{1};", tag, indiEventCounts[tag]); } if (indiEventLoc > 0) { Console.Write("Locations:{0}", indiEventLoc); } Console.WriteLine(); Console.WriteLine("\t\t----------"); //foreach (var tag in indiAttribCounts.Keys) //{ // Console.WriteLine("\t\t{0}:{1}", tag, indiAttribCounts[tag]); //} //if (attribLoc > 0) // Console.WriteLine("\t\tLocations:{0}", attribLoc); //Console.WriteLine("\t\t----------"); Console.WriteLine("\t\t----------"); Console.Write("\t"); foreach (var tag in famEventCounts.Keys) { Console.Write("{0}:{1};", tag, famEventCounts[tag]); } if (famEventLoc > 0) { Console.Write("Locations:{0}", famEventLoc); } Console.WriteLine(); if (f.NumberOfTrees > 1) { Console.WriteLine("Number of trees:{0}", f.NumberOfTrees); } }
// TODO more closely match PAF order? - specifically _UID // INDI records are written to be as close to PAF order as possible private static void WriteOneIndi(StreamWriter file, IndiRecord indiRecord) { file.WriteLine("0 @{0}@ INDI", indiRecord.Ident); WriteCommon.writeIfNotEmpty(file, "RESN", indiRecord.Restriction, 1); foreach (var nameRec in indiRecord.Names) { writeName(file, nameRec); // this convolution below due to: // 1 NAME Joe /Blow/ Jr. // vs // 1 NAME Joe // 2 GIVN Joe // 2 SURN Blow // TODO nice to output parts in specific order despite how they came in bool didGivn = false; bool didSurn = false; bool didNSFX = false; foreach (var tuple in nameRec.Parts) { file.WriteLine("2 {0} {1}", tuple.Item1, tuple.Item2); if (tuple.Item1 == "SURN") { didSurn = true; } if (tuple.Item1 == "GIVN") { didGivn = true; } if (tuple.Item1 == "NSFX") { didNSFX = true; } } if (!didGivn && !string.IsNullOrEmpty(nameRec.Names)) { file.WriteLine("2 GIVN {0}", nameRec.Names); } if (!didSurn && !string.IsNullOrEmpty(nameRec.Surname)) { file.WriteLine("2 SURN {0}", nameRec.Surname); } if (!didNSFX && !string.IsNullOrEmpty(nameRec.Suffix)) { file.WriteLine("2 NSFX {0}", nameRec.Suffix); } // TODO other name pieces WriteCommon.writeSubNotes(file, nameRec, 2); WriteCommon.writeSourCit(file, nameRec, 2); } // TODO want to init sex to 'U' but don't want to output it if not initialized as such if (string.IsNullOrEmpty(indiRecord.FullSex) && indiRecord.Sex != '\0' && indiRecord.Sex != 'U') { WriteCommon.writeIfNotEmpty(file, "SEX", indiRecord.Sex.ToString(), 1); } else { WriteCommon.writeIfNotEmpty(file, "SEX", indiRecord.FullSex, 1); } WriteEvent.writeEvents(file, indiRecord.Events, 1); WriteEvent.writeEvents(file, indiRecord.Attribs, 1); // Insure FAMS/FAMC output in consistent order if (indiRecord.Links != null) { foreach (var indiLink in indiRecord.Links.Where(indiLink => indiLink.Type == IndiLink.FAMS_TYPE)) { writeLink(file, indiLink); } foreach (var indiLink in indiRecord.Links.Where(indiLink => indiLink.Type == IndiLink.FAMC_TYPE)) { writeLink(file, indiLink); } } // TODO LDS events foreach (var aliasLink in indiRecord.AliasLinks) { WriteCommon.writeXrefIfNotEmpty(file, "ALIA", aliasLink, 1); } foreach (var assoRec in indiRecord.Assocs) { WriteCommon.writeXrefIfNotEmpty(file, "ASSO", assoRec.Ident, 1); WriteCommon.writeIfNotEmpty(file, "RELA", assoRec.Relation, 2); WriteCommon.writeSubNotes(file, assoRec, 2); WriteCommon.writeSourCit(file, assoRec, 2); } // Different from FAM because there are different types foreach (var submitter in indiRecord.Submitters) { string tag = ""; switch (submitter.SubmitterType) { case Submitter.SubmitType.SUBM: tag = "SUBM"; break; case Submitter.SubmitType.ANCI: tag = "ANCI"; break; case Submitter.SubmitType.DESI: tag = "DESI"; break; } file.WriteLine("1 {0} @{1}@", tag, submitter.Xref); } WriteCommon.writeRecordTrailer(file, indiRecord, 1); }