Example #1
0
        /// <summary>
        /// Lookup possible information on child legal status.
        /// It is stored in separate chunks outside the Individual and Family chunks.
        /// </summary>
        private static void AddStatus(this ResultContainer resultContainer, ChildRelation childRelation)
        {
            var childChunk = resultContainer.GetIdChunk(childRelation.From.Id);

            if (childChunk != null)
            {
                foreach (var chunk1 in childChunk.SubChunks)
                {
                    switch (chunk1.Type)
                    {
                    case "FAMC":
                        foreach (var chunk2 in chunk1.SubChunks)
                        {
                            switch (chunk2.Type)
                            {
                            case "PEDI":
                                childRelation.Pedigree = chunk2.Data;
                                break;

                            case "STAT":
                                childRelation.Validity = chunk2.Data;
                                break;

                            case "ADOP":
                                var adoptionInfo = new List <string>();
                                foreach (var chunk3 in chunk1.SubChunks)
                                {
                                    switch (chunk3.Type)
                                    {
                                    case "DATE":
                                        adoptionInfo.Add(chunk3.ParseDateTime());
                                        break;

                                    case "STAT":
                                    case "NOTE":
                                        adoptionInfo.Add(chunk3.Data);
                                        break;
                                    }
                                }

                                childRelation.Adoption = string.Join(", ", adoptionInfo);
                                break;

                            default:
                                resultContainer.Errors.Add($"Failed to handle Status Type='{chunk2.Type}");
                                break;
                            }
                        }

                        break;
                    }
                }
            }
        }
Example #2
0
 public ChildRelationPropertyDescriptor(ChildRelation relation, DataContext context) : base(relation.Name)
 {
     this.Relation = relation; this.Context = context;
 }
Example #3
0
        internal static void ParseFamily(this ResultContainer resultContainer, GedcomChunk famChunk)
        {
            DatePlace marriage = null;
            string    relation = null;
            string    note     = null;
            DatePlace divorce  = null;
            var       parents  = new List <Person>();
            var       children = new List <Person>();

            foreach (var chunk in famChunk.SubChunks)
            {
                switch (chunk.Type)
                {
                case "CHIL":
                    var child = resultContainer.Persons.SingleOrDefault(p => p.Id == chunk.Reference);
                    if (child != null)
                    {
                        children.Add(child);
                    }

                    break;

                case "DIV":
                    divorce = resultContainer.ParseDatePlace(chunk);
                    break;

                case "HUSB":
                    var husband = resultContainer.Persons.SingleOrDefault(p => p.Id == chunk.Reference);
                    if (husband != null)
                    {
                        parents.Add(husband);
                    }

                    break;

                case "_REL":
                    relation = chunk.Data;
                    break;

                case "MARR":
                    marriage = resultContainer.ParseDatePlace(chunk);
                    break;

                case "NOTE":
                    note = resultContainer.ParseNote(note, chunk);
                    break;

                case "WIFE":
                    var wife = resultContainer.Persons.SingleOrDefault(p => p.Id == chunk.Reference);
                    if (wife != null)
                    {
                        parents.Add(wife);
                    }

                    break;

                // Deliberately skipped for now
                case "CHAN":
                case "DSCR":
                case "EVEN":
                case "FAMS":
                case "FAMC":
                case "HIST":
                case "MARS":
                case "NCHI":
                case "NMR":
                case "OBJE":
                case "PAGE":
                case "SOUR":
                    resultContainer.Warnings.Add($"Skipped Family Type='{chunk.Type}");
                    break;

                default:
                    resultContainer.Errors.Add($"Failed to handle Family Type='{chunk.Type}");
                    break;
                }
            }

            // Spouses
            if (parents.Count == 2)
            {
                resultContainer.SpouseRelations.Add(new SpouseRelation
                {
                    FamilyId = famChunk.Id,
                    From     = parents[0],
                    To       = parents[1],
                    Marriage = marriage,
                    Divorce  = divorce,
                    Relation = relation,
                    Note     = note
                });
            }

            // Parents / Children
            foreach (var parent in parents)
            {
                foreach (var child in children)
                {
                    var childRelation = new ChildRelation {
                        FamilyId = famChunk.Id, From = child, To = parent
                    };
                    AddStatus(resultContainer, childRelation);
                    resultContainer.ChildRelations.Add(childRelation);
                }
            }

            // Siblings
            foreach (var child1 in children)
            {
                foreach (var child2 in children.Where(c => c.Id != child1.Id))
                {
                    resultContainer.SiblingRelations.Add(new SiblingRelation {
                        FamilyId = famChunk.Id, From = child1, To = child2
                    });
                }
            }
        }
Example #4
0
        private void ParseFamily(GedcomChunk famChunk)
        {
            GedcomEvent marriage    = null;
            GedcomEvent divorce     = null;
            string      relation    = null;
            string      note        = null;
            var         parentsIds  = new List <string>();
            var         childrenIds = new List <string>();

            foreach (var chunk in famChunk.Subchunks)
            {
                switch (chunk.Key)
                {
                case "CHIL":
                    childrenIds.AddRange(chunk.Value.Select(value => value.Reference));
                    break;

                case "HUSB":
                case "WIFE":
                    parentsIds.AddRange(chunk.Value.Select(value => value.Reference));
                    break;

                case "DIV":
                    TryParseEvent(chunk.Key, chunk.Value.FirstOrDefault(), out divorce);
                    break;

                case "_REL":
                    relation = chunk.Value.FirstOrDefault()?.Data;
                    break;

                case "MARR":
                    TryParseEvent(chunk.Key, chunk.Value.FirstOrDefault(), out marriage);
                    break;

                case "NOTE":
                    note = ParseNote(note, chunk.Value.FirstOrDefault());
                    break;

                default:
                    Logger?.LogInfo(ToString(chunk) + " skipped");
                    break;
                }
            }

            // Spouses
            if (parentsIds.Count == 2)
            {
                _parseResult.Relations.Add(new SpouseRelation(famChunk.Id, parentsIds[0], parentsIds[1])
                {
                    Marriage = marriage,
                    Divorce  = divorce,
                    Relation = relation,
                    Note     = note
                });
            }

            // Parents / Children
            foreach (string parent in parentsIds)
            {
                foreach (string child in childrenIds)
                {
                    var childRelation = new ChildRelation(famChunk.Id, child, parent);
                    AddStatus(childRelation);
                    _parseResult.Relations.Add(childRelation);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Lookup possible information on child legal status.
        /// It is stored in separate chunks outside the Individual and Family chunks.
        /// </summary>
        private void AddStatus(ChildRelation childRelation)
        {
            if (!_idChunks.TryGetValue(childRelation.FromId, out GedcomChunk childChunk))
            {
                return;
            }

            foreach (var chunk1 in childChunk.Subchunks)
            {
                if (chunk1.Key != "FAMC")
                {
                    continue;
                }

                foreach (var chunk in chunk1.Value)
                {
                    foreach (var subchunk in chunk.Subchunks)
                    {
                        switch (subchunk.Key)
                        {
                        case "PEDI":
                            childRelation.Pedigree = subchunk.Value.FirstOrDefault()?.Data;
                            break;

                        case "STAT":
                            childRelation.Validity = subchunk.Value.FirstOrDefault()?.Data;
                            break;

                        case "ADOP":
                            var adoptionInfo = new List <string>();

                            foreach (GedcomChunk chunk2 in chunk1.Value)
                            {
                                foreach (var chunk3 in chunk2.Subchunks)
                                {
                                    switch (chunk3.Key)
                                    {
                                    case "DATE":
                                        adoptionInfo.Add(ParseDateTime(chunk3.Value.FirstOrDefault()));
                                        break;

                                    case "STAT":
                                    case "NOTE":
                                        adoptionInfo.Add(chunk3.Value.FirstOrDefault().Data);
                                        break;
                                    }
                                }
                            }

                            childRelation.Adoption = string.Join(", ", adoptionInfo);
                            break;

                        default:
                            Logger?.LogInfo(ToString(subchunk) + " skipped");
                            break;
                        }
                    }
                    break;
                }
            }
        }
 ///<summary>Creates a new ChildRowDependency.</summary>
 public ChildRowDependency(RowDependencySetup setup, ChildRelation childRelation)
     : base(setup)
 {
     ChildRelation       = childRelation;
     RequiresDataContext = true;
 }
 ///<summary>Creates a new ChildRowDependency.</summary>
 public ChildRowDependency(RowDependencySetup setup, ChildRelation childRelation)
     : base(setup)
 {
     ChildRelation = childRelation;
     RequiresDataContext = true;
 }