예제 #1
0
        public TreePerson(PersonType Type, string idString = "", Person familySearchPerson = null)
        {
            switch (Type)
            {
                case PersonType.Null:
                    Name = Death = "";
                    Sex = PersonSex.NotSet;
                    Birth = idString;
                    break;

                case PersonType.Unique:
                    var perRandom = StaticRandom.RandomNumber(0, 100);
                    //Debug.WriteLine("Random " + perRandom);
                    if (perRandom > 49)
                    {
                        Sex = PersonSex.Male;
                        Name = MaleNames[StaticRandom.RandomNumber(0, MaleNames.Length)];
                        Birth = idString;
                    }
                    else
                    {
                        Sex = PersonSex.Female;
                        Name = FemaleNames[StaticRandom.RandomNumber(0, FemaleNames.Length)];
                        Birth = idString;
                    }
                    break;

                case PersonType.Adam:
                    Sex = PersonSex.Male;
                    Name = "Adam";
                    Birth = idString;
                    BirthFamilyIndex = 0; // from Generation 0
                    break;

                case PersonType.Eve:
                    Sex = PersonSex.Female;
                    Name = "Eve";
                    Birth = idString;
                    BirthFamilyIndex = 0; // from Generation 0
                    break;

                case PersonType.FamilySearch:
                    if (familySearchPerson != null)
                    {
                        _familSearchPerson = familySearchPerson;

                        // Just the basics of the person are set now
                        Name = familySearchPerson.DisplayExtension.Name;
                        Sex = GetSexEnum(familySearchPerson.DisplayExtension.Gender);                      
                        Birth = familySearchPerson.DisplayExtension.BirthDate ?? "";
                        Death = familySearchPerson.DisplayExtension.DeathDate ?? "";
                        Lifespan = familySearchPerson.DisplayExtension.Lifespan;
                        _familySearchID = familySearchPerson.Id;
                    }

                    break;
            }

            myEvents = new List<FamilyEvent>();
        }
예제 #2
0
 /// <summary>
 /// Visits the person.
 /// </summary>
 /// <param name="person">The person to visit.</param>
 public override void VisitPerson(Gx.Conclusion.Person person)
 {
     if (person.Id != null)
     {
         this.dictionary.Add(person.Id, person);
     }
     base.VisitPerson(person);
 }
예제 #3
0
        public int AddChild(int familyIndex, string PID, Person familySearchPerson = null)
        {
            TreePerson myChild = new TreePerson(TreePerson.PersonType.FamilySearch, PID, familySearchPerson);
            int childPersonIndex = myPeople.addToAllPeople(myChild);
            allFamilies[familyIndex].AddChildIndex(childPersonIndex);
            myChild.BirthFamilyIndex = familyIndex;
            return childPersonIndex;

        }
        /// <summary>
        /// Removes the declared non match person from this collection.
        /// </summary>
        /// <param name="nonMatch">The person that was previously declared as a non-match.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="PersonNonMatchesState"/> instance containing the REST API response.
        /// </returns>
        public PersonNonMatchesState RemoveNonMatch(Person nonMatch, params IStateTransitionOption[] options)
        {
            Link link = nonMatch.GetLink(Rel.NOT_A_MATCH);
            if (link == null || link.Href == null)
            {
                return null;
            }

            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.DELETE);
            return ((FamilySearchStateFactory)this.stateFactory).NewPersonNonMatchesState(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
 public void TestEducationAndOccupationFacts()
 {
     Person person = new Person()
       .SetFact(new Fact(FactType.Apprenticeship, "...", "..."))
       .SetFact(new Fact(FactType.Education, "...", "..."))
       .SetFact(new Fact(FactType.Occupation, "...", "..."))
       .SetFact(new Fact(FactType.Retirement, "...", "..."));
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(person);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
 public void TestMilitaryServiceFacts()
 {
     Person person = new Person()
       .SetFact(new Fact(FactType.MilitaryAward, "...", "..."))
       .SetFact(new Fact(FactType.MilitaryDischarge, "...", "..."))
       .SetFact(new Fact(FactType.MilitaryDraftRegistration, "...", "..."))
       .SetFact(new Fact(FactType.MilitaryInduction, "...", "..."))
       .SetFact(new Fact(FactType.MilitaryService, "...", "..."));
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(person);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
 public void TestCensusAndResidenceLikeFacts()
 {
     Person person = new Person()
       .SetFact(new Fact(FactType.Census, "...", "..."))
       .SetFact(new Fact(FactType.Emigration, "...", "..."))
       .SetFact(new Fact(FactType.Immigration, "...", "..."))
       .SetFact(new Fact(FactType.LandTransaction, "...", "..."))
       .SetFact(new Fact(FactType.MoveTo, "...", "..."))
       .SetFact(new Fact(FactType.MoveFrom, "...", "..."))
       .SetFact(new Fact(FactType.Residence, "...", "..."));
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(person);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
 private Relationship CreateMarriage(Person george, Person martha)
 {
     Relationship relationship = new Relationship();
     relationship.SetId("DDD-DDDD");
     relationship.SetPerson1(new ResourceReference("#" + george.Id));
     relationship.SetPerson2(new ResourceReference("#" + martha.Id));
     Fact marriage = new Fact();
     marriage.SetDate(new DateInfo());
     marriage.Date.SetOriginal("January 6, 1759");
     marriage.Date.SetFormal("+01-06-1759");
     marriage.SetPlace(new PlaceReference());
     marriage.Place.SetOriginal("White House Plantation");
     relationship.SetFact(marriage);
     return relationship;
 }
예제 #9
0
 /// <summary>
 /// Embed the specified person into this one.
 /// </summary>
 /// <param name="person">The person to embed.</param>
 public void Embed(Person person)
 {
     this._private = this._private == null ? person._private : this._private;
     this._living = this._living == null ? person._living : this._living;
     this._principal = this._principal == null ? person._principal : this._principal;
     this._gender = this._gender == null ? person._gender : this._gender;
     if (this._displayExtension != null && person._displayExtension != null)
     {
         this._displayExtension.Embed(person._displayExtension);
     }
     else if (person._displayExtension != null)
     {
         this._displayExtension = person._displayExtension;
     }
     if (person._names != null)
     {
         this._names = this._names == null ? new List<Name>() : this._names;
         this._names.AddRange(person._names);
     }
     if (person._facts != null)
     {
         this._facts = this._facts == null ? new List<Fact>() : this._facts;
         this._facts.AddRange(person._facts);
     }
     if (person._fields != null)
     {
         this._fields = this._fields == null ? new List<Field>() : this._fields;
         this._fields.AddRange(person._fields);
     }
     base.Embed(person);
 }
        public virtual void VisitPerson(Person person)
        {
            this.contextStack.Push(person);
            VisitSubject(person);

            if (person.Gender != null)
            {
                person.Gender.Accept(this);
            }

            List<Name> names = person.Names;
            if (names != null)
            {
                foreach (Name name in names)
                {
                    name.Accept(this);
                }
            }

            List<Fact> facts = person.Facts;
            if (facts != null)
            {
                foreach (Fact fact in facts)
                {
                    fact.Accept(this);
                }
            }

            List<Field> fields = person.Fields;
            if (fields != null)
            {
                foreach (Field field in fields)
                {
                    field.Accept(this);
                }
            }
            this.contextStack.Pop();
        }
 /**
  * Build out this relationship with a reference to the mother.
  *
  * @param mother the mother.
  * @return this.
  */
 public ChildAndParentsRelationship SetMother(Person mother)
 {
     if (mother.Id == null)
     {
         throw new ArgumentException("Cannot reference mother: no id.");
     }
     Mother = new ResourceReference("#" + mother.Id);
     return this;
 }
 /// <summary>
 /// Adds a person as a non match to this collection.
 /// </summary>
 /// <param name="person">The person that is not a match (from potential duplicate search results).</param>
 /// <param name="options">The options to apply before executing the REST API call.</param>
 /// <returns>
 /// A <see cref="PersonNonMatchesState"/> instance containing the REST API response.
 /// </returns>
 public PersonNonMatchesState AddNonMatch(Person person, params IStateTransitionOption[] options)
 {
     return (PersonNonMatchesState)Post(new Gx.Gedcomx() { Persons = new List<Person>() { person } }, options);
 }
        private Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription deathPlace)
        {
            Person person = new Person();
            person.SetGender(new Gender(GenderType.Male));

            Fact fact = new Fact();
            fact.SetId("123");
            fact.SetType(FactType.Birth);

            fact.SetDate(new DateInfo());
            fact.Date.SetOriginal("February 22, 1732");
            fact.Date.SetFormal("+1732-02-22");

            fact.SetPlace(new PlaceReference());
            fact.Place.SetOriginal(birthPlace.Names[0].Value.ToLower());
            fact.Place.DescriptionRef = "#" + birthPlace.Id;

            person.AddFact(fact);

            fact = new Fact();
            fact.SetId("456");
            fact.SetType(FactType.Death);

            fact.SetDate(new DateInfo());
            fact.Date.SetOriginal("December 14, 1799");
            fact.Date.SetFormal("+1799-12-14T22:00:00");

            fact.SetPlace(new PlaceReference());
            fact.Place.SetOriginal(deathPlace.Names[0].Value.ToLower());
            fact.Place.DescriptionRef = "#" + deathPlace.Id;

            person.AddFact(fact);

            List<Name> names = new List<Name>();
            Name name = new Name();
            NameForm nameForm = new NameForm();
            nameForm.SetFullText("George Washington");
            List<NamePart> parts = new List<NamePart>();
            NamePart part = new NamePart();
            part.SetType(NamePartType.Given);
            part.SetValue("George");
            parts.Add(part);
            part = new NamePart();
            part.SetType(NamePartType.Surname);
            part.SetValue("Washington");
            parts.Add(part);
            nameForm.Parts = parts;
            name.SetNameForm(nameForm);
            name.SetId("789");
            names.Add(name);
            person.Names = names;

            person.SetId("BBB-BBBB");

            return person;
        }
 /// <summary>
 /// Finds the child and parents relationship to the specified spouse. See remarks for more information.
 /// </summary>
 /// <param name="spouse">The spouse for which the relationship is sought.</param>
 /// <returns>
 /// The <see cref="ChildAndParentsRelationship"/> the spouse is in, or <c>null</c> if a relationship was not found.
 /// </returns>
 /// <remarks>
 /// This method iterates over the current <see cref="P:ChildAndParentsRelationship"/>, and each item is examined
 /// to determine if the spouse ID in the relationship matches the spouse ID for the specified child. If one is found,
 /// that relationship object containing that spouse ID is returned, and no other relationships are examined further.
 /// </remarks>
 public ChildAndParentsRelationship FindChildAndParentsRelationshipTo(Person spouse)
 {
     List<ChildAndParentsRelationship> relationships = ChildAndParentsRelationships;
     if (relationships != null)
     {
         foreach (ChildAndParentsRelationship relationship in relationships)
         {
             ResourceReference personReference = relationship.Father;
             if (personReference != null)
             {
                 String reference = personReference.Resource;
                 if (reference.Equals("#" + spouse.Id))
                 {
                     return relationship;
                 }
             }
             personReference = relationship.Mother;
             if (personReference != null)
             {
                 String reference = personReference.Resource;
                 if (reference.Equals("#" + spouse.Id))
                 {
                     return relationship;
                 }
             }
         }
     }
     return null;
 }
예제 #15
0
 /**
  * Build out this relationship with a reference to person 2.
  *
  * @param person2 person 2.
  * @return this.
  */
 public Relationship SetPerson2(Person person2)
 {
     if (person2.Id == null)
     {
         throw new ArgumentException("Cannot reference person2: no id.");
     }
     SetPerson2(new ResourceReference("#" + person2.Id));
     return this;
 }
 public override void VisitPerson(Person person)
 {
     BindIfNeeded(person);
     base.VisitPerson(person);
 }
예제 #17
0
        public Person SetEvidence(Person evidence)
        {
            if (evidence.Id == null)
            {
                throw new ArgumentException("Unable to add person as evidence: no id.");
            }

            return (Person)base.SetEvidence(new EvidenceReference("#" + evidence.Id));
        }
 public void TestReligiousOrCulturalFacts()
 {
     Person person = new Person()
       .SetFact(new Fact(FactType.AdultChristening, "...", "..."))
       .SetFact(new Fact(FactType.Baptism, "...", "..."))
       .SetFact(new Fact(FactType.BarMitzvah, "...", "..."))
       .SetFact(new Fact(FactType.BatMitzvah, "...", "..."))
       .SetFact(new Fact(FactType.Caste, "...", "..."))
       .SetFact(new Fact(FactType.Christening, "...", "..."))
       .SetFact(new Fact(FactType.Circumcision, "...", "..."))
       .SetFact(new Fact(FactType.Clan, "...", "..."))
       .SetFact(new Fact(FactType.Confirmation, "...", "..."))
       .SetFact(new Fact(FactType.Excommunication, "...", "..."))
       .SetFact(new Fact(FactType.FirstCommunion, "...", "..."))
       .SetFact(new Fact(FactType.Nationality, "...", "..."))
       .SetFact(new Fact(FactType.Ordination, "...", "..."))
       .SetFact(new Fact(FactType.Religion, "...", "..."))
       .SetFact(new Fact(FactType.Yahrzeit, "...", "..."));
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(person);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
        private List<SourceDescription> CiteGeorgeMarthaAndMarriage(Person george, Person martha, Relationship relationship)
        {
            SourceDescription georgeSource = new SourceDescription();
            georgeSource.SetId("EEE-EEEE");
            georgeSource.SetAbout("http://en.wikipedia.org/wiki/George_washington");
            SourceCitation georgeCitation = new SourceCitation();
            georgeCitation.SetValue("\"George Washington.\" Wikipedia, The Free Encyclopedia. Wikimedia Foundation, Inc. 24 October 2012.");
            georgeSource.SetCitation(georgeCitation);

            SourceDescription marthaSource = new SourceDescription();
            marthaSource.SetId("FFF-FFFF");
            marthaSource.SetAbout("http://en.wikipedia.org/wiki/Martha_washington");
            SourceCitation marthaCitation = new SourceCitation();
            marthaCitation.SetValue("\"Martha Washington.\" Wikipedia, The Free Encyclopedia. Wikimedia Foundation, Inc. 24 October 2012.");
            marthaSource.SetCitation(marthaCitation);

            SourceReference reference = new SourceReference();
            reference.SetDescriptionRef("#" + georgeSource.Id);
            george.SetSource(reference);

            reference = new SourceReference();
            reference.SetDescriptionRef("#" + marthaSource.Id);
            martha.SetSource(reference);

            relationship.SetSource(reference);

            return new List<SourceDescription>() { georgeSource, marthaSource };
        }
 public void TestFactQualifiers()
 {
     Person person = new Person()
       .SetFact(new Fact(FactType.Christening, "...", "...").SetQualifier(new Qualifier(FactQualifierType.Religion, "Catholic")))
       .SetFact(new Fact(FactType.Census, "...", "...").SetQualifier(new Qualifier(FactQualifierType.Age, "44")))
       .SetFact(new Fact(FactType.Death, "...", "...").SetQualifier(new Qualifier(FactQualifierType.Cause, "Heart failure")));
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(person);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
예제 #21
0
 /**
  * Build this out with a person.
  * @param person The person.
  * @return this.
  */
 public Gedcomx SetPerson(Person person)
 {
     AddPerson(person);
     return this;
 }
        /// <summary>
        /// Visits the person.
        /// </summary>
        /// <param name="person">The person to visit.</param>
        public virtual void VisitPerson(Person person)
        {
            this.contextStack.Push(person);
            VisitSubject(person);

            if (person.Gender != null)
            {
                VisitGender(person.Gender);
            }

            if (person.Names != null)
            {
                foreach (Name name in person.Names)
                {
                    VisitName(name);
                }
            }

            if (person.Facts != null)
            {
                foreach (Fact fact in person.Facts)
                {
                    VisitFact(fact);
                }
            }

            if (person.Fields != null)
            {
                foreach (Field field in person.Fields)
                {
                    VisitField(field);
                }
            }
            this.contextStack.Pop();
        }
예제 #23
0
        public static string GetFactId(Person person, string factType)
        {
            string result = null;

            if (person != null && person.Facts != null)
            {
                result = person.Facts.Where(x => x.Type == factType).Select(x => x.Id).FirstOrDefault();
            }

            return result;
        }
 /**
  * Build out this relationship with a reference to the child.
  *
  * @param child the child.
  * @return this.
  */
 public ChildAndParentsRelationship SetChild(Person child)
 {
     if (child.Id == null)
     {
         throw new ArgumentException("Cannot reference child: no id.");
     }
     Child = new ResourceReference("#" + child.Id);
     return this;
 }
        /// <summary>
        /// Updates the discussion reference on the specified person.
        /// </summary>
        /// <param name="person">The person with a discussion reference to update.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="FamilyTreePersonState"/> instance containing the REST API response.
        /// </returns>
        public FamilyTreePersonState UpdateDiscussionReference(Person person, params IStateTransitionOption[] options)
        {
            String target = GetSelfUri();
            Link discussionsLink = GetLink(Rel.DISCUSSION_REFERENCES);
            if (discussionsLink != null && discussionsLink.Href != null)
            {
                target = discussionsLink.Href;
            }

            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.Persons = new List<Person>() { person };
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedGedcomxRequest()).SetEntity(gx).Build(target, Method.POST);
            return (FamilyTreePersonState)((FamilyTreeStateFactory)this.stateFactory).NewPersonStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
예제 #26
0
        public void AddPerson(Person person)
        {
            if (person != null)
            {
                if (Persons == null)
                {
                    Persons = new List<Person>();
                }

                Persons.Add(person);
            }
        }
        /// <summary>
        /// Declares a possible duplicate of the current person as not a duplicate.
        /// </summary>
        /// <param name="person">The person that was possibly a duplicate of the current person.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="PersonNonMatchesState"/> instance containing the REST API response.
        /// </returns>
        public PersonNonMatchesState AddNonMatch(Person person, params IStateTransitionOption[] options)
        {
            Link link = GetLink(Rel.NOT_A_MATCHES);
            if (link == null || link.Href == null)
            {
                return null;
            }

            Gx.Gedcomx entity = new Gx.Gedcomx();
            entity.AddPerson(person);
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(entity).Build(link.Href, Method.POST);
            return ((FamilyTreeStateFactory)this.stateFactory).NewPersonNonMatchesState(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
예제 #28
0
 public override void VisitPerson(Person person)
 {
     CreateSubRecordVisit(() => base.VisitPerson(person));
 }
 public void TestCustomFact()
 {
     Person person = new Person()
       .SetFact(new Fact().SetType("data:,Eagle%20Scout").SetPlace(new PlaceReference().SetOriginal("...")).SetDate(new DateInfo().SetOriginal("...")));
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(person);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
예제 #30
0
 /**
  * Build up this event role with a person.
  * @param person The person.
  * @return this.
  */
 public EventRole SetPerson(Person person)
 {
     if (person.Id == null)
     {
         throw new ArgumentException("Cannot reference person: no id.");
     }
     SetPerson(new ResourceReference("#" + person.Id));
     return this;
 }
        private Person CreateMartha(PlaceDescription birthPlace, PlaceDescription deathPlace)
        {
            Person person = new Person();
            person.SetGender(new Gender(GenderType.Male));

            Fact fact = new Fact();
            fact.SetId("321");
            fact.SetType(FactType.Birth);

            fact.SetDate(new DateInfo());
            fact.Date.SetOriginal("June 2, 1731");
            fact.Date.SetFormal("+1731-06-02");

            fact.SetPlace(new PlaceReference());
            fact.Place.SetOriginal(birthPlace.Names[0].Value.ToLower());
            fact.Place.DescriptionRef = "#" + birthPlace.Id;

            person.AddFact(fact);

            fact = new Fact();
            fact.SetId("654");
            fact.SetType(FactType.Death);

            fact.SetDate(new DateInfo());
            fact.Date.SetOriginal("May 22, 1802");
            fact.Date.SetFormal("+1802-05-22");

            fact.SetPlace(new PlaceReference());
            fact.Place.SetOriginal(deathPlace.Names[0].Value.ToLower());
            fact.Place.DescriptionRef = "#" + deathPlace.Id;

            person.AddFact(fact);

            List<Name> names = new List<Name>();
            Name name = new Name();
            NameForm nameForm = new NameForm();
            nameForm.SetFullText("Martha Dandridge Custis");
            List<NamePart> parts = new List<NamePart>();
            NamePart part = new NamePart();
            part.SetType(NamePartType.Given);
            part.SetValue("Martha Dandridge");
            parts.Add(part);
            part = new NamePart();
            part.SetType(NamePartType.Surname);
            part.SetValue("Custis");
            parts.Add(part);
            nameForm.Parts = parts;
            name.SetNameForm(nameForm);
            name.SetId("987");
            names.Add(name);
            person.Names = names;

            person.SetId("CCC-CCCC");

            return person;
        }