Ejemplo n.º 1
0
        private void ReadFile(ref FamilyTreeStoreBaseClass inFamilyTree, FamilyTreeStoreAnarkiv anarkivStore)
        {
            //IndividualClass person = anarkivStore.GetIndividual();

            IEnumerator <IndividualClass> people = anarkivStore.SearchPerson();

            AnarkivMappers mappers = new AnarkivMappers(inFamilyTree);
            IDictionary <string, XrefMapperClass> individualMapper = mappers.GetMapper(XrefType.Individual);
            IDictionary <string, XrefMapperClass> familyMapper     = mappers.GetMapper(XrefType.Family);

            int counter = 0;

            while (people.MoveNext())
            {
                IndividualClass person = people.Current;

                trace.TraceInformation("Person[" + counter++ + "]:" + person.GetPersonalName().ToString());

                IndividualXrefClass xref = new IndividualXrefClass(inFamilyTree.CreateNewXref(XrefType.Individual));

                individualMapper.Add(person.GetXrefName(), new XrefMapperClass(xref.GetXrefName(), true));
                person.SetXrefName(xref.GetXrefName());

                if (person.GetFamilyChildList() != null)
                {
                    IList <FamilyXrefClass> newChildFamilies = new List <FamilyXrefClass>();
                    foreach (FamilyXrefClass childFamily in person.GetFamilyChildList())
                    {
                        FamilyXrefClass newFamily = new FamilyXrefClass(mappers.GetLocalXRef(XrefType.Family, childFamily.GetXrefName()));
                        newChildFamilies.Add(newFamily);
                    }
                    person.SetFamilyChildList(newChildFamilies);
                }

                if (person.GetFamilySpouseList() != null)
                {
                    IList <FamilyXrefClass> newSpouseFamilies = new List <FamilyXrefClass>();
                    foreach (FamilyXrefClass spouseFamily in person.GetFamilySpouseList())
                    {
                        FamilyXrefClass newFamily = new FamilyXrefClass(mappers.GetLocalXRef(XrefType.Family, spouseFamily.GetXrefName()));
                        newSpouseFamilies.Add(newFamily);
                    }
                    person.SetFamilySpouseList(newSpouseFamilies);
                }


                inFamilyTree.AddIndividual(person);
            }

            IEnumerator <FamilyClass> familyEnumerator = anarkivStore.SearchFamily();

            counter = 0;
            while (familyEnumerator.MoveNext())
            {
                FamilyClass family    = familyEnumerator.Current;
                FamilyClass newFamily = new FamilyClass();

                trace.TraceInformation("Family[" + counter++ + "]:" + family.GetXrefName());
                newFamily.SetXrefName(mappers.GetLocalXRef(XrefType.Family, family.GetXrefName(), true));

                trace.TraceInformation("Family xref " + family.GetXrefName() + " ==> " + newFamily.GetXrefName());

                if (family.GetParentList() != null)
                {
                    //IList<IndividualXrefClass> newParentList = new List<IndividualXrefClass>();
                    foreach (IndividualXrefClass parent in family.GetParentList())
                    {
                        IndividualXrefClass newParent = new IndividualXrefClass(mappers.GetLocalXRef(XrefType.Individual, parent.GetXrefName()));
                        //newParentList.Add(newParent);
                        newFamily.AddRelation(newParent, FamilyClass.RelationType.Parent);
                        trace.TraceInformation(" add parent  " + parent.GetXrefName() + " => " + newParent.GetXrefName());
                    }
                }
                if (family.GetChildList() != null)
                {
                    //IList<IndividualXrefClass> newChildList = new List<IndividualXrefClass>();
                    foreach (IndividualXrefClass child in family.GetChildList())
                    {
                        IndividualXrefClass newChild = new IndividualXrefClass(mappers.GetLocalXRef(XrefType.Individual, child.GetXrefName()));
                        //newChildList.Add(newChild);
                        newFamily.AddRelation(newChild, FamilyClass.RelationType.Child);
                        trace.TraceInformation(" add child  " + child.GetXrefName() + " => " + newChild.GetXrefName());
                    }
                }
                //family.

                inFamilyTree.AddFamily(newFamily);
            }
        }
Ejemplo n.º 2
0
        public void AddRelative(RelativeType relation, IndividualClass person = null)
        {
            trace.TraceInformation("TreeViewPanel2::AddRelative " + relation);
            if (familyTree != null)
            {
                if (selectedIndividual != null)
                {
                    IndividualClass newPerson;
                    if (person != null)
                    {
                        newPerson = person;
                    }
                    else
                    {
                        newPerson = new IndividualClass();
                    }
                    newPerson.SetXrefName(familyTree.CreateNewXref(XrefType.Individual));

                    if (relation == RelativeType.Parent)
                    {
                        FamilyXrefClass         parentFamilyXref = null;
                        FamilyClass             parentFamily     = null;
                        IList <FamilyXrefClass> parents          = selectedIndividual.GetFamilyChildList();
                        if (parents != null)
                        {
                            if (parents.Count > 0)
                            {
                                // ToDo: Full support for multiple families..
                                parentFamilyXref = parents[0];
                                parentFamily     = familyTree.GetFamily(parentFamilyXref.GetXrefName());
                            }
                        }
                        if (parentFamilyXref == null)
                        {
                            parentFamilyXref = new FamilyXrefClass(familyTree.CreateNewXref(XrefType.Family));
                            //parentFamily.SetXrefName();
                            parentFamily = new FamilyClass();
                            parentFamily.SetXrefName(parentFamilyXref.GetXrefName());
                            parentFamily.AddRelation(new IndividualXrefClass(selectedIndividual.GetXrefName()), FamilyClass.RelationType.Child);
                            selectedIndividual.AddRelation(parentFamilyXref, IndividualClass.RelationType.Child);
                            familyTree.UpdateIndividual(selectedIndividual, PersonUpdateType.ChildFamily);
                        }
                        parentFamily.AddRelation(new IndividualXrefClass(newPerson.GetXrefName()), FamilyClass.RelationType.Parent);
                        newPerson.AddRelation(parentFamilyXref, IndividualClass.RelationType.Spouse);
                        familyTree.AddFamily(parentFamily);

                        familyTree.AddIndividual(newPerson);
                    }
                    else if (relation == RelativeType.Child)
                    {
                        FamilyXrefClass         childFamilyXref = null;
                        FamilyClass             childFamily     = null;
                        IList <FamilyXrefClass> children        = selectedIndividual.GetFamilySpouseList();
                        if (children != null)
                        {
                            if (children.Count > 0)
                            {
                                // ToDo: Full support for multiple families..
                                childFamilyXref = children[0];
                                childFamily     = familyTree.GetFamily(childFamilyXref.GetXrefName());
                            }
                        }
                        if (childFamilyXref == null)
                        {
                            childFamilyXref = new FamilyXrefClass(familyTree.CreateNewXref(XrefType.Family));
                            //parentFamily.SetXrefName();
                            childFamily = new FamilyClass();
                            childFamily.SetXrefName(childFamilyXref.GetXrefName());
                            childFamily.AddRelation(new IndividualXrefClass(selectedIndividual.GetXrefName()), FamilyClass.RelationType.Parent);
                            selectedIndividual.AddRelation(childFamilyXref, IndividualClass.RelationType.Spouse);
                            familyTree.UpdateIndividual(selectedIndividual, PersonUpdateType.SpouseFamily);
                        }
                        childFamily.AddRelation(new IndividualXrefClass(newPerson.GetXrefName()), FamilyClass.RelationType.Child);
                        newPerson.AddRelation(childFamilyXref, IndividualClass.RelationType.Child);
                        familyTree.AddFamily(childFamily);

                        familyTree.AddIndividual(newPerson);
                    }
                    else // if (relation == RelativeType.Unrelated)
                    {
                        familyTree.AddIndividual(newPerson);
                    }
                    //familyTree.AddIndividual(newPerson);
                }
                ShowActiveFamily();
            }
        }
Ejemplo n.º 3
0
        void DecodeEvent(ref IndividualClass person, ParsePersonState evType, string eventString)
        {
            switch (evType)
            {
            case ParsePersonState.Birth:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Birth, false));
            }
            break;

            case ParsePersonState.Baptism:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Baptism, false));
            }
            break;

            case ParsePersonState.Death:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Death, false));
            }
            break;

            case ParsePersonState.Burial:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Burial, false));
            }
            break;

            case ParsePersonState.Occupation:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Occupation, true));
            }
            break;

            /*case ParsePersonState.Fosterchild:
             * {
             *  IndividualEventClass occupation = new IndividualEventClass(IndividualEventClass.EventType.Adoption);
             *  occupation.AddNote(eventString);
             *  trace.TraceInformation("fosterchild " + eventString + " => " + occupation);
             *  person.AddEvent(occupation);
             * }
             * break;*/

            case ParsePersonState.Move:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Immigration, true));
            }
            break;

            case ParsePersonState.Source:
            {
                SourceDescriptionClass source = new SourceDescriptionClass(eventString);

                trace.TraceInformation("source " + eventString + " => " + source);
                person.AddSource(source);
            }
            break;

            case ParsePersonState.Lived:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Residence, true));
            }
            break;

            case ParsePersonState.Changed:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.RecordUpdate, true));
            }
            break;

            case ParsePersonState.ChildFamily:
            {
                string familyId = "";

                foreach (char ch in eventString)
                {
                    if ((ch >= '0') && (ch <= '9') || (ch == ':'))
                    {
                        familyId += ch;
                    }
                }
                string familyXref = xrefMapLists.GetMapper(XrefType.Family).GetXRef(familyId, false);
                person.AddRelation(new FamilyXrefClass(familyXref), IndividualClass.RelationType.Child);
                trace.TraceInformation("child in " + familyId + "=" + familyXref);
                FamilyClass family = familyTree.GetFamily(familyXref);

                if (family == null)
                {
                    family = new FamilyClass();
                    family.SetXrefName(familyXref);
                }
                family.AddRelation(new IndividualXrefClass(person.GetXrefName()), FamilyClass.RelationType.Child);
                familyTree.AddFamily(family);
            }
            break;

            case ParsePersonState.SpouseFamily:
            {
                string familyId = "";

                foreach (char ch in eventString)
                {
                    if ((ch >= '0') && (ch <= '9') || (ch == ':'))
                    {
                        familyId += ch;
                    }
                }
                string familyXref = xrefMapLists.GetMapper(XrefType.Family).GetXRef(familyId, false);
                person.AddRelation(new FamilyXrefClass(familyXref), IndividualClass.RelationType.Spouse);
                trace.TraceInformation("spouse in " + familyId + "=" + familyXref);
                FamilyClass family = familyTree.GetFamily(familyXref);

                if (family == null)
                {
                    family = new FamilyClass();
                    family.SetXrefName(familyXref);
                }
                family.AddRelation(new IndividualXrefClass(person.GetXrefName()), FamilyClass.RelationType.Parent);
                familyTree.AddFamily(family);
            }
            break;
            }
        }