Пример #1
0
        public void TestFileWriting()
        {
            string fileName;

            using (var ms = new MemoryStream())
            {
                var file = new GedcomxOutputStream(ms, new DefaultXmlSerialization());
                var gx   = new Gx.Gedcomx();

                gx.Persons = new List <Gx.Conclusion.Person>();
                gx.Persons.Add(TestBacking.GetCreateMalePerson());

                file.AddResource(gx);

                file.Dispose();

                fileName = Path.GetTempFileName();
                var output = System.IO.File.OpenWrite(fileName);
                var bytes  = ms.ToArray();
                output.Write(bytes, 0, bytes.Length);
                output.Flush();
                output.Close();
                output.Dispose();
            }

            // Verify basic reading of the zip file created above
            using (var zip = ZipFile.OpenRead(fileName))
            {
                Assert.AreEqual(2, zip.Entries.Count);
            }
        }
        //TODO: Create FamilysearchSourceReferencesQueryState class, add it to FamilySearchStateFactory when link is created

        /*
         * public FamilySearchSourceReferencesQueryState ReadSourceReferencesQuery()
         * {
         *  Link link = GetLink( //TODO: Put Rel here when added );
         *  if (link == null || link.Href = null)
         *  {
         *      return null;
         *  }
         *
         *  IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.GET);
         *  return ((FamilySearchStateFactory)this.stateFactory).NewFamilySearchSourceReferencesQueryState(request, Invoke(request), this.Client, this.CurrentAccessToken);
         * }
         */

        /// <summary>
        /// Moves the current source description to the specified collection.
        /// </summary>
        /// <param name="collection">The target collection to contain this source description.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="FamilySearchSourceDescriptionState"/> instance containing the REST API response.
        /// </returns>
        public FamilySearchSourceDescriptionState MoveToCollection(CollectionState collection, params IStateTransitionOption[] options)
        {
            Link link = collection.GetLink(Rel.SOURCE_DESCRIPTIONS);

            if (link == null || link.Href == null)
            {
                return(null);
            }

            SourceDescription me = SourceDescription;

            if (me == null || me.Id == null)
            {
                return(null);
            }

            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.AddSourceDescription(new SourceDescription()
            {
                Id = me.Id
            });
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(gx).Build(link.Href, Method.POST);

            return((FamilySearchSourceDescriptionState)((FamilySearchStateFactory)this.stateFactory).NewSourceDescriptionStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken));
        }
Пример #3
0
        public void TestExample()
        {
            PlaceDescription         popesCreek    = CreatePopesCreek();
            PlaceDescription         mountVernon   = CreateMountVernon();
            PlaceDescription         chestnutGrove = CreateChestnutGrove();
            Person                   george        = CreateGeorge(popesCreek, mountVernon);
            Person                   martha        = CreateMartha(chestnutGrove, mountVernon);
            Relationship             marriage      = CreateMarriage(george, martha);
            List <SourceDescription> sources       = CiteGeorgeMarthaAndMarriage(george, martha, marriage);
            Agent contributor = CreateContributor();

            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.Persons = new List <Person>()
            {
                george, martha
            };
            gx.SetRelationship(marriage);
            gx.SourceDescriptions = sources;
            gx.SetAgent(contributor);
            gx.SetAttribution(new Attribution());
            gx.Attribution.SetContributor(new ResourceReference());
            gx.Attribution.Contributor.SetResource("#" + contributor.Id);
            gx.Places = new List <PlaceDescription>()
            {
                popesCreek, mountVernon, chestnutGrove
            };

            xmlSerializer.Deserialize <Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize <Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
        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));
        }
Пример #5
0
        public static ExtensibleData Resolve(ResourceReference @ref, Gx.Gedcomx document)
        {
            if (@ref.Resource == null)
            {
                return(null);
            }

            return(Resolve(@ref.Resource, document));
        }
        public Stream ToXmlStream(Gx.Gedcomx gx)
        {
            var serializer = new XmlSerializer(typeof(Gx.Gedcomx));
            var stream     = new MemoryStream();

            serializer.Serialize(stream, gx);
            stream.Seek(0, SeekOrigin.Begin);

            return(stream);
        }
Пример #7
0
        public Tree ConvertTree(UserId userId, Gx.Gedcomx gx, string treeName)
        {
            var tree = Tree.CreateNewTree(treeName, userId);

            var gxIdToPersonId = _gedcomXToDomainPersonConverter.AddPeopleToTree(gx, tree);

            _gedcomXToDomainRelationConverter.AddRelationsToTree(gx, gxIdToPersonId, tree);

            return(tree);
        }
 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 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));
        }
Пример #10
0
        /// <summary>
        /// Adds the specified GEDCOM X entity to the current GEDCOM X file.
        /// </summary>
        /// <param name="resource">The entity to add.</param>
        /// <param name="lastModified">The last modified to specify for the entity being added.</param>
        public void AddResource(Gx.Gedcomx resource, DateTime?lastModified)
        {
            StringBuilder entryName = new StringBuilder("tree");

            if (this.entryCount > 0)
            {
                entryName.Append(this.entryCount);
            }
            entryName.Append(".xml");
            AddResource(entryName.ToString(), resource, lastModified);
        }
Пример #11
0
        public void TestMultipleNamePartsOnePartPerType()
        {
            NameForm nameForm = new NameForm("José Eduardo Santos Tavares Melo Silva")
                                .SetLang("pt-BR")
                                .SetPart(NamePartType.Given, "José Eduardo")
                                .SetPart(NamePartType.Surname, "Santos Tavares Melo Silva");
            Name name = new Name().SetNameForm(nameForm);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            xmlSerializer.Deserialize <Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize <Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #12
0
        public void TestMultipleNamePartsOnePartPerType()
        {
            NameForm nameForm = new NameForm("José Eduardo Santos Tavares Melo Silva")
              .SetLang("pt-BR")
              .SetPart(NamePartType.Given, "José Eduardo")
              .SetPart(NamePartType.Surname, "Santos Tavares Melo Silva");
            Name name = new Name().SetNameForm(nameForm);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            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));
 }
Пример #14
0
        public void TestPatronymic()
        {
            NameForm nameForm = new NameForm("Björk Guðmundsdóttir")
                                .SetLang("is")
                                .SetPart(NamePartType.Given, "Björk")
                                .SetPart(new NamePart().SetValue("Guðmundsdóttir").SetQualifier(new Qualifier(NamePartQualifierType.Patronymic)));
            Name name = new Name().SetNameForm(nameForm);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            xmlSerializer.Deserialize <Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize <Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #15
0
        public static ExtensibleData Resolve(String @ref, Gx.Gedcomx document)
        {
            if ([email protected]().StartsWith("#"))
            {
                return(null);
            }

            GedcomxLocalReferenceResolver visitor = new GedcomxLocalReferenceResolver(@ref.ToString().Substring(1));

            document.Accept(visitor);
            return(visitor.Resource);
        }
        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));
        }
Пример #17
0
        public void TestBasicWesternName()
        {
            NameForm nameForm = new NameForm("John Fitzgerald Kennedy")
              .SetLang("en")
              .SetPart(NamePartType.Given, "John")
              .SetPart(NamePartType.Given, "Fitzgerald")
              .SetPart(NamePartType.Surname, "Kennedy");
            Name name = new Name().SetNameForm(nameForm);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #18
0
        public void TestBasicWesternName()
        {
            NameForm nameForm = new NameForm("John Fitzgerald Kennedy")
                                .SetLang("en")
                                .SetPart(NamePartType.Given, "John")
                                .SetPart(NamePartType.Given, "Fitzgerald")
                                .SetPart(NamePartType.Surname, "Kennedy");
            Name name = new Name().SetNameForm(nameForm);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            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));
        }
Пример #20
0
        public void AddRelationsToTree(Gx.Gedcomx gx, IDictionary <string, PersonId> gxIdToPersonId, Tree tree)
        {
            var people = tree.People;

            foreach (var relationship in gx.Relationships)
            {
                if (gxIdToPersonId.TryGetValue(relationship.Person2.Resource.Substring(1), out var from) &&
                    gxIdToPersonId.TryGetValue(relationship.Person1.Resource.Substring(1), out var to))
                {
                    var rel = _gedcomXToDomainRelationTypeConverter.ConvertRelationType(relationship.Type, people, to);
                    tree.AddRelation(from, to, rel);
                }
            }
        }
Пример #21
0
        public Dictionary <string, PersonId> AddPeopleToTree(Gx.Gedcomx gx, Tree tree)
        {
            var gxIdToPersonId = new Dictionary <string, PersonId>();

            foreach (var gxPerson in gx.Persons)
            {
                var name    = _nameExtractor.ExtractName(gxPerson, NamePartType.Given);
                var surname = _nameExtractor.ExtractName(gxPerson, NamePartType.Surname);

                if (name is null && surname is null)
                {
                    surname = _nameExtractor.ExtractFullName(gxPerson);
                }

                var person = tree.AddPerson(
                    name,
                    surname, _toDomainGenderConverter.ConvertGender(gxPerson.Gender?.KnownType ?? GenderType.NULL),
                    _dateExtractor.GetDate(gxPerson, FactType.Birth),
                    _dateExtractor.GetDate(gxPerson, FactType.Death),
                    _noteExtractor.GetNote(gxPerson.Notes, "Description"),
                    _noteExtractor.GetNote(gxPerson.Notes, "Biography")
                    );

                gxIdToPersonId.Add(gxPerson.Id ?? Guid.NewGuid().ToString(), person.Id);

                foreach (var source in gxPerson.Sources ?? Enumerable.Empty <SourceReference>())
                {
                    var mainPhoto = source.Qualifiers?.Any(q => q.Name == "MainPhoto" && bool.Parse(q.Value)) ?? false;
                    var fileName  = source.Qualifiers?.FirstOrDefault(q => q.Name == "Name")?.Value;
                    var mimeType  = source.Qualifiers?.FirstOrDefault(q => q.Name == "MimeType")?.Value;
                    var fileUri   = source.Qualifiers?.FirstOrDefault(q => q.Name == "MainPhoto")?.Value;

                    if (fileName is null || mimeType is null || fileUri is null)
                    {
                        continue;
                    }

                    if (mainPhoto)
                    {
                        person.AddOrChangeMainPhoto(fileName, mimeType, new Uri(fileUri));
                    }
                    else
                    {
                        person.AddFile(fileName, mimeType, new Uri(fileUri));
                    }
                }
            }

            return(gxIdToPersonId);
        }
 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));
 }
        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));
        }
Пример #24
0
        /// <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));
        }
Пример #25
0
        public void ReadHeadForAPerson()
        {
            var ft = new FamilySearchSDK(Settings.Default.UserName, Settings.Default.Password, Settings.Default.ApplicationKey,
                                         TestBacking.AppName, TestBacking.AppVersion, Gedcomx.Api.Lite.Environment.Integration);

            // Create a Person
            var gedcomx = new Gx.Gedcomx();

            gedcomx.AddPerson(TestBacking.GetCreateMalePerson());
            var postResults = ft.Post("/platform/tree/persons", JsonConvert.SerializeObject(gedcomx), MediaType.X_GEDCOMX_v1_JSON).Result;

            // Now get the new person.
            string personId = ((string[])postResults.Headers.Location.ToString().Split('/')).Last();
            var    response = ft.Head("/platform/tree/persons/" + personId, MediaType.APPLICATION_JSON).Result;

            Assert.IsTrue(response.StatusCode == HttpStatusCode.OK, "Resonse should indicate header retreived successfully");
        }
Пример #26
0
        public void GetAPerson()
        {
            var ft = new FamilySearchSDK(Settings.Default.UserName, Settings.Default.Password, Settings.Default.ApplicationKey,
                                         TestBacking.AppName, TestBacking.AppVersion, Gedcomx.Api.Lite.Environment.Integration);

            // Create a Person
            var gedcomx = new Gx.Gedcomx();

            gedcomx.AddPerson(TestBacking.GetCreateMalePerson());
            var postResults = ft.Post("/platform/tree/persons", JsonConvert.SerializeObject(gedcomx), MediaType.X_GEDCOMX_v1_JSON).Result;

            // Now get the new person.
            string personId = ((string[])postResults.Headers.Location.ToString().Split('/')).Last();
            var    response = ft.Get("/platform/tree/persons/" + personId).Result;

            Assert.IsNotNull(response.persons, "resonse should contain a person");
        }
Пример #27
0
        public void GetAPortrait()
        {
            var ft = new FamilySearchSDK(Settings.Default.UserName, Settings.Default.Password, Settings.Default.ApplicationKey,
                                         TestBacking.AppName, TestBacking.AppVersion, Gedcomx.Api.Lite.Environment.Integration);

            // Create a Person
            var gedcomx = new Gx.Gedcomx();

            gedcomx.AddPerson(TestBacking.GetCreateMalePerson());
            var postResults = ft.Post("/platform/tree/persons", JsonConvert.SerializeObject(gedcomx), MediaType.X_GEDCOMX_v1_JSON).Result;

            // Now get the new person.
            string personId         = ((string[])postResults.Headers.Location.ToString().Split('/')).Last();
            var    portraitResponse = ft.Get($"/platform/tree/persons/{personId}/portrait", MediaType.X_FS_v1_JSON);
            var    portrait         = portraitResponse.Result;

            Assert.IsTrue(postResults.StatusCode == HttpStatusCode.Created, "Portrait should flag the reply as created");
        }
Пример #28
0
        /// <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));
        }
Пример #29
0
        public void TestMultipleJapaneseForms()
        {
            NameForm kanji = new NameForm("山田太郎")
              .SetLang("ja-Hani")
              .SetPart(NamePartType.Surname, "山田")
              .SetPart(NamePartType.Given, "太郎");
            NameForm katakana = new NameForm("ヤマダタロー")
              .SetLang("ja-Kana")
              .SetPart(NamePartType.Surname, "ヤマダ")
              .SetPart(NamePartType.Given, "タロー");
            NameForm romanized = new NameForm("Yamada Tarō")
              .SetLang("ja-Latn")
              .SetPart(NamePartType.Surname, "Tarō")
              .SetPart(NamePartType.Given, "Yamada");
            Name name = new Name().SetNameForm(kanji).SetNameForm(katakana).SetNameForm(romanized);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #30
0
        /// <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();

            // https://familysearch.org/developers/docs/api/tree/Read_Discussion_References_(Starting_December_2016)_usecase
            //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));
        }
Пример #31
0
        public void TestMultipleJapaneseForms()
        {
            NameForm kanji = new NameForm("山田太郎")
                             .SetLang("ja-Hani")
                             .SetPart(NamePartType.Surname, "山田")
                             .SetPart(NamePartType.Given, "太郎");
            NameForm katakana = new NameForm("ヤマダタロー")
                                .SetLang("ja-Kana")
                                .SetPart(NamePartType.Surname, "ヤマダ")
                                .SetPart(NamePartType.Given, "タロー");
            NameForm romanized = new NameForm("Yamada Tarō")
                                 .SetLang("ja-Latn")
                                 .SetPart(NamePartType.Surname, "Tarō")
                                 .SetPart(NamePartType.Given, "Yamada");
            Name name = new Name().SetNameForm(kanji).SetNameForm(katakana).SetNameForm(romanized);

            Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
            xmlSerializer.Deserialize <Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize <Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #32
0
        public void AddPeopleToTree_OnePersonInGedcomXFile_ConvertersAreCalledPersonInTree()
        {
            var gx     = new Gx.Gedcomx();
            var person = new Gx.Conclusion.Person().SetGender(GenderType.Male).SetName("ASDDF");

            gx.AddPerson(person);
            var tree = _fixture.Create <Tree>();

            var genderConverter = Substitute.For <IGedcomXToDomainGenderConverter>();
            var nameExtractor   = Substitute.For <IGedcomXNameExtractor>();

            nameExtractor.ExtractName(Arg.Any <Gx.Conclusion.Person>(), NamePartType.Given).Returns("Bati");
            nameExtractor.ExtractName(Arg.Any <Gx.Conclusion.Person>(), NamePartType.Surname).Returns("Chro");
            var dateExtractor = Substitute.For <IGedcomXDateExtractor>();
            var noteExtractor = Substitute.For <IGedcomXNoteExtractor>();
            var converter     = new GedcomXToDomainPersonConverter(
                genderConverter, nameExtractor, dateExtractor, noteExtractor);

            _ = converter.AddPeopleToTree(gx, tree);

            genderConverter.ReceivedWithAnyArgs().ConvertGender(default);
        public Stream Export(Tree tree)
        {
            var idPersonDict = CreatePeople(tree);

            var gx = new Gx.Gedcomx();

            foreach (var(_, person) in idPersonDict)
            {
                gx.AddPerson(person);
            }

            foreach (var relation in tree.TreeRelations.Relations)
            {
                var from = idPersonDict[relation.From];
                var to   = idPersonDict[relation.To];

                gx.AddRelation(relation, from, to);
            }

            return(_converter.ToXmlStream(gx));
        }
Пример #34
0
        public void TestExample()
        {
            Agent             contributor       = (Agent) new Agent().SetName("Jane Doe").SetEmail("*****@*****.**").SetId("A-1");
            Agent             repository        = (Agent) new Agent().SetName("General Registry Office, Southport").SetId("A-2");
            Attribution       attribution       = new Attribution().SetContributor(contributor).SetModified(DateTime.Parse("2014-03-07"));
            SourceDescription sourceDescription = (SourceDescription) new SourceDescription()
                                                  .SetTitle("Birth Certificate of Emma Bocock, 23 July 1843, General Registry Office")
                                                  .SetCitation(new SourceCitation().SetValue("England, birth certificate for Emma Bocock, born 23 July 1843; citing 1843 Birth in District and Sub-district of Ecclesall-Bierlow in the County of York, 303; General Registry Office, Southport."))
                                                  .SetResourceType(ResourceType.PhysicalArtifact)
                                                  .SetCreated(DateTime.Parse("1843-07-27"))
                                                  .SetRepository(repository)
                                                  .SetId("S-1");
            Fact birth = new Fact()
                         .SetType(FactType.Birth)
                         .SetDate(new DateInfo().SetOriginal("23 June 1843"))
                         .SetPlace(new PlaceReference().SetOriginal("Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom"));
            Person       emma               = (Person) new Person().SetName("Emma Bocock").SetGender(GenderType.Female).SetFact(birth).SetExtracted(true).SetSource(sourceDescription).SetId("P-1");
            Person       father             = (Person) new Person().SetName("William Bocock").SetFact(new Fact().SetType(FactType.Occupation).SetValue("Toll Collector")).SetExtracted(true).SetSource(sourceDescription).SetId("P-2");
            Person       mother             = (Person) new Person().SetName("Sarah Bocock formerly Brough").SetExtracted(true).SetSource(sourceDescription).SetId("P-3");
            Relationship fatherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(father).SetPerson2(emma);
            Relationship motherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(mother).SetPerson2(emma);
            Document     analysis           = (Document) new Document().SetText("...Jane Doe's analysis document...").SetId("D-1");
            Person       emmaConclusion     = (Person) new Person().SetEvidence(emma).SetAnalysis(analysis).SetId("C-1");

            Gx.Gedcomx gx = new Gx.Gedcomx()
                            .SetAgent(contributor)
                            .SetAgent(repository)
                            .SetAttribution(attribution)
                            .SetSourceDescription(sourceDescription)
                            .SetPerson(emma)
                            .SetPerson(father)
                            .SetPerson(mother)
                            .SetRelationship(fatherRelationship)
                            .SetRelationship(motherRelationship)
                            .SetDocument(analysis)
                            .SetPerson(emmaConclusion);
            xmlSerializer.Deserialize <Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize <Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
 public void TestExample()
 {
     Agent contributor = (Agent)new Agent().SetName("Jane Doe").SetEmail("*****@*****.**").SetId("A-1");
     Agent repository = (Agent)new Agent().SetName("General Registry Office, Southport").SetId("A-2");
     Attribution attribution = new Attribution().SetContributor(contributor).SetModified(DateTime.Parse("2014-03-07"));
     SourceDescription sourceDescription = (SourceDescription)new SourceDescription()
     .SetTitle("Birth Certificate of Emma Bocock, 23 July 1843, General Registry Office")
     .SetCitation(new SourceCitation().SetValue("England, birth certificate for Emma Bocock, born 23 July 1843; citing 1843 Birth in District and Sub-district of Ecclesall-Bierlow in the County of York, 303; General Registry Office, Southport."))
     .SetResourceType(ResourceType.PhysicalArtifact)
     .SetCreated(DateTime.Parse("1843-07-27"))
     .SetRepository(repository)
     .SetId("S-1");
     Fact birth = new Fact()
     .SetType(FactType.Birth)
     .SetDate(new DateInfo().SetOriginal("23 June 1843"))
     .SetPlace(new PlaceReference().SetOriginal("Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom"));
     Person emma = (Person)new Person().SetName("Emma Bocock").SetGender(GenderType.Female).SetFact(birth).SetExtracted(true).SetSource(sourceDescription).SetId("P-1");
     Person father = (Person)new Person().SetName("William Bocock").SetFact(new Fact().SetType(FactType.Occupation).SetValue("Toll Collector")).SetExtracted(true).SetSource(sourceDescription).SetId("P-2");
     Person mother = (Person)new Person().SetName("Sarah Bocock formerly Brough").SetExtracted(true).SetSource(sourceDescription).SetId("P-3");
     Relationship fatherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(father).SetPerson2(emma);
     Relationship motherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(mother).SetPerson2(emma);
     Document analysis = (Document)new Document().SetText("...Jane Doe's analysis document...").SetId("D-1");
     Person emmaConclusion = (Person)new Person().SetEvidence(emma).SetAnalysis(analysis).SetId("C-1");
     Gx.Gedcomx gx = new Gx.Gedcomx()
     .SetAgent(contributor)
     .SetAgent(repository)
     .SetAttribution(attribution)
     .SetSourceDescription(sourceDescription)
     .SetPerson(emma)
     .SetPerson(father)
     .SetPerson(mother)
     .SetRelationship(fatherRelationship)
     .SetRelationship(motherRelationship)
     .SetDocument(analysis)
     .SetPerson(emmaConclusion);
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
        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));
        }
        public void TestExample()
        {
            PlaceDescription popesCreek = CreatePopesCreek();
            PlaceDescription mountVernon = CreateMountVernon();
            PlaceDescription chestnutGrove = CreateChestnutGrove();
            Person george = CreateGeorge(popesCreek, mountVernon);
            Person martha = CreateMartha(chestnutGrove, mountVernon);
            Relationship marriage = CreateMarriage(george, martha);
            List<SourceDescription> sources = CiteGeorgeMarthaAndMarriage(george, martha, marriage);
            Agent contributor = CreateContributor();
            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.Persons = new List<Person>() { george, martha };
            gx.SetRelationship(marriage);
            gx.SourceDescriptions = sources;
            gx.SetAgent(contributor);
            gx.SetAttribution(new Attribution());
            gx.Attribution.SetContributor(new ResourceReference());
            gx.Attribution.Contributor.SetResource("#" + contributor.Id);
            gx.Places = new List<PlaceDescription>() { popesCreek, mountVernon, chestnutGrove };

            xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
        public void TestRelationshipFacts()
        {
            Relationship couple = new Relationship()
                                  .SetType(RelationshipType.Couple)
                                  .SetFact(new Fact(FactType.CivilUnion, "...", "..."))
                                  .SetFact(new Fact(FactType.DomesticPartnership, "...", "..."))
                                  .SetFact(new Fact(FactType.Divorce, "...", "..."))
                                  .SetFact(new Fact(FactType.Marriage, "...", "..."))
                                  .SetFact(new Fact(FactType.MarriageBanns, "...", "..."))
                                  .SetFact(new Fact(FactType.MarriageContract, "...", "..."))
                                  .SetFact(new Fact(FactType.MarriageLicense, "...", "..."));

            Relationship parentChild = new Relationship()
                                       .SetType(RelationshipType.ParentChild)
                                       .SetFact(new Fact(FactType.AdoptiveParent, "...", "..."))
                                       .SetFact(new Fact(FactType.BiologicalParent, "...", "..."))
                                       .SetFact(new Fact(FactType.FosterParent, "...", "..."))
                                       .SetFact(new Fact(FactType.GuardianParent, "...", "..."))
                                       .SetFact(new Fact(FactType.StepParent, "...", "..."));

            Gx.Gedcomx gx = new Gx.Gedcomx().SetRelationship(couple).SetRelationship(parentChild);
            xmlSerializer.Deserialize <Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize <Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
        /// <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);
        }
        /// <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);
        }
        //TODO: Create FamilysearchSourceReferencesQueryState class, add it to FamilySearchStateFactory when link is created
        /*
        public FamilySearchSourceReferencesQueryState ReadSourceReferencesQuery()
        {
            Link link = GetLink( //TODO: Put Rel here when added );
            if (link == null || link.Href = null)
            {
                return null;
            }

            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.GET);
            return ((FamilySearchStateFactory)this.stateFactory).NewFamilySearchSourceReferencesQueryState(request, Invoke(request), this.Client, this.CurrentAccessToken);
        }
        */

        /// <summary>
        /// Moves the current source description to the specified collection.
        /// </summary>
        /// <param name="collection">The target collection to contain this source description.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="FamilySearchSourceDescriptionState"/> instance containing the REST API response.
        /// </returns>
        public FamilySearchSourceDescriptionState MoveToCollection(CollectionState collection, params IStateTransitionOption[] options)
        {
            Link link = collection.GetLink(Rel.SOURCE_DESCRIPTIONS);
            if (link == null || link.Href == null)
            {
                return null;
            }

            SourceDescription me = SourceDescription;
            if (me == null || me.Id == null)
            {
                return null;
            }

            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.AddSourceDescription(new SourceDescription() { Id = me.Id });
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(gx).Build(link.Href, Method.POST);
            return (FamilySearchSourceDescriptionState)((FamilySearchStateFactory)this.stateFactory).NewSourceDescriptionStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
 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));
 }
        public void TestRelationshipFacts()
        {
            Relationship couple = new Relationship()
              .SetType(RelationshipType.Couple)
              .SetFact(new Fact(FactType.CivilUnion, "...", "..."))
              .SetFact(new Fact(FactType.DomesticPartnership, "...", "..."))
              .SetFact(new Fact(FactType.Divorce, "...", "..."))
              .SetFact(new Fact(FactType.Marriage, "...", "..."))
              .SetFact(new Fact(FactType.MarriageBanns, "...", "..."))
              .SetFact(new Fact(FactType.MarriageContract, "...", "..."))
              .SetFact(new Fact(FactType.MarriageLicense, "...", "..."));

            Relationship parentChild = new Relationship()
              .SetType(RelationshipType.ParentChild)
              .SetFact(new Fact(FactType.AdoptiveParent, "...", "..."))
              .SetFact(new Fact(FactType.BiologicalParent, "...", "..."))
              .SetFact(new Fact(FactType.FosterParent, "...", "..."))
              .SetFact(new Fact(FactType.GuardianParent, "...", "..."))
              .SetFact(new Fact(FactType.StepParent, "...", "..."));

            Gx.Gedcomx gx = new Gx.Gedcomx().SetRelationship(couple).SetRelationship(parentChild);
            xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #44
0
 public void TestPatronymic()
 {
     NameForm nameForm = new NameForm("Björk Guðmundsdóttir")
       .SetLang("is")
       .SetPart(NamePartType.Given, "Björk")
       .SetPart(new NamePart().SetValue("Guðmundsdóttir").SetQualifier(new Qualifier(NamePartQualifierType.Patronymic)));
     Name name = new Name().SetNameForm(nameForm);
     
     Gx.Gedcomx gx = new Gx.Gedcomx().SetPerson(new Person().SetName(name));
     xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
     jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
 }
        public void TestExample()
        {
            //Jane Doe, the researcher.
            Agent janeDoe = (Agent)new Agent().SetName("Jane Doe").SetEmail("*****@*****.**").SetId("A-1");

            //Lin Yee Chung Cemetery
            Agent fhl = (Agent)new Agent().SetName("Family History Library").SetAddress(new Address().SetCity("Salt Lake City").SetStateOrProvince("Utah")).SetId("A-2");

            //The attribution for this research.
            Attribution researchAttribution = new Attribution().SetContributor(janeDoe).SetModified(DateTime.Parse("2014-04-25"));

            //The parish register.
            SourceDescription recordDescription = (SourceDescription)new SourceDescription()
              .SetTitle("Marriage entry for Samuel Ham and Elizabeth Spiller, Parish Register, Wilton, Somerset, England")
              .SetDescription("Marriage entry for Samuel Ham and Elizabeth in a copy of the registers of the baptisms, marriages, and burials at the church of St. George in the parish of Wilton : adjoining Taunton, in the county of Somerset from A.D. 1558 to A.D. 1837.")
              .SetCitation(new SourceCitation().SetValue("Joseph Houghton Spencer, transcriber, Church of England, Parish Church of Wilton (Somerset). <cite>A copy of the registers of the baptisms, marriages, and burials at the church of St. George in the parish of Wilton : adjoining Taunton, in the county of Somerset from A.D. 1558 to A.D. 1837</cite>; Marriage entry for Samuel Ham and Elizabeth Spiller (3 November 1828), (Taunton: Barnicott, 1890), p. 224, No. 86."))
              .SetResourceType(ResourceType.PhysicalArtifact)
              .SetRepository(fhl)
              .SetId("S-1");

            //The transcription of the grave stone.
            Document transcription = (Document)new Document()
              .SetType(DocumentType.Transcription)
              .SetText("Samuel Ham of the parish of Honiton and Elizabeth Spiller\n" +
                      "were married this 3rd day of November 1828 by David Smith\n" +
                      "Stone, Pl Curate,\n" +
                      "In the Presence of\n" +
                      "Jno Pain.\n" +
                      "R.G. Halls.  Peggy Hammet.\n" +
                      "No. 86.")
              .SetSource(recordDescription)
              .SetLang("en")
              .SetId("D-1");

            //The transcription described as a source.
            SourceDescription transcriptionDescription = (SourceDescription)new SourceDescription()
              .SetAbout("#" + transcription.Id)
              .SetTitle("Transcription of marriage entry for Samuel Ham and Elizabeth Spiller, Parish Register, Wilton, Somerset, England")
              .SetDescription("Transcription of marriage entry for Samuel Ham and Elizabeth in a copy of the registers of the baptisms, marriages, and burials at the church of St. George in the parish of Wilton : adjoining Taunton, in the county of Somerset from A.D. 1558 to A.D. 1837.")
              .SetCitation(new SourceCitation().SetValue("Joseph Houghton Spencer, transcriber, Church of England, Parish Church of Wilton (Somerset). <cite>A copy of the registers of the baptisms, marriages, and burials at the church of St. George in the parish of Wilton : adjoining Taunton, in the county of Somerset from A.D. 1558 to A.D. 1837</cite>; Marriage entry for Samuel Ham and Elizabeth Spiller (3 November 1828), (Taunton: Barnicott, 1890), p. 224, No. 86."))
              .SetResourceType(ResourceType.DigitalArtifact)
              .SetSource(new SourceReference().SetDescription(recordDescription))
              .SetId("S-2");

            //the marriage fact.
            Fact marriage = new Fact()
              .SetType(FactType.Marriage)
              .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"))
              .SetPlace(new PlaceReference().SetOriginal("Wilton St George, Wilton, Somerset, England"));

            //the groom's residence.
            Fact samsResidence = new Fact()
              .SetType(FactType.Residence)
              .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"))
              .SetPlace(new PlaceReference().SetOriginal("parish of Honiton, Devon, England"));

            //the groom's residence.
            Fact lizsResidence = new Fact()
              .SetType(FactType.Residence)
              .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"))
              .SetPlace(new PlaceReference().SetOriginal("parish of Wilton, Somerset, England"));

            //the groom
            Person sam = (Person)new Person().SetName("Samuel Ham").SetGender(GenderType.Male).SetFact(samsResidence).SetExtracted(true).SetSource(transcriptionDescription).SetId("P-1");

            //the bride.
            Person liz = (Person)new Person().SetName("Elizabeth Spiller").SetGender(GenderType.Female).SetFact(lizsResidence).SetExtracted(true).SetSource(transcriptionDescription).SetId("P-2");

            //witnesses
            Person witness1 = (Person)new Person().SetName("Jno. Pain").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-3");
            Person witness2 = (Person)new Person().SetName("R.G. Halls").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-4");
            Person witness3 = (Person)new Person().SetName("Peggy Hammet").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-5");

            //officiator
            Person officiator = (Person)new Person().SetName("David Smith Stone").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-6");

            //the relationship.
            Relationship marriageRelationship = (Relationship)new Relationship().SetType(RelationshipType.Couple).SetPerson1(sam).SetPerson2(liz).SetFact(marriage).SetExtracted(true);

            //the marriage event
            Event marriageEvent = (Event)new Event(EventType.Marriage)
              .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"))
              .SetPlace(new PlaceReference().SetOriginal("Wilton St George, Wilton, Somerset, England"))
              .SetRole(new EventRole().SetPerson(sam).SetType(EventRoleType.Principal))
              .SetRole(new EventRole().SetPerson(liz).SetType(EventRoleType.Principal))
              .SetRole(new EventRole().SetPerson(witness1).SetType(EventRoleType.Witness))
              .SetRole(new EventRole().SetPerson(witness2).SetType(EventRoleType.Witness))
              .SetRole(new EventRole().SetPerson(witness3).SetType(EventRoleType.Witness))
              .SetRole(new EventRole().SetPerson(officiator).SetType(EventRoleType.Official))
              .SetExtracted(true)
              .SetId("E-1");

            //Jane Doe's analysis.
            Document analysis = (Document)new Document().SetText("...Jane Doe's analysis document...").SetId("D-2");

            //Jane Doe's conclusions about a person.
            Person samConclusion = (Person)new Person().SetEvidence(sam).SetAnalysis(analysis).SetId("C-1");

            Gx.Gedcomx gx = new Gx.Gedcomx()
              .SetAgent(janeDoe)
              .SetAgent(fhl)
              .SetAttribution(researchAttribution)
              .SetSourceDescription(recordDescription)
              .SetDocument(transcription)
              .SetSourceDescription(transcriptionDescription)
              .SetPerson(sam)
              .SetPerson(liz)
              .SetPerson(witness1)
              .SetPerson(witness2)
              .SetPerson(witness3)
              .SetPerson(officiator)
              .SetRelationship(marriageRelationship)
              .SetEvent(marriageEvent)
              .SetDocument(analysis)
              .SetPerson(samConclusion);

            xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
Пример #46
0
        public void TestFileWriting()
        {
            string fileName;

            using (var ms = new MemoryStream())
            {
                var file = new GedcomxOutputStream(ms, new DefaultXmlSerialization());
                var gx = new Gx.Gedcomx();

                gx.Persons = new List<Gx.Conclusion.Person>();
                gx.Persons.Add(TestBacking.GetCreateMalePerson());

                file.AddResource(gx);

                file.Dispose();

                fileName = Path.GetTempFileName();
                var output = System.IO.File.OpenWrite(fileName);
                var bytes = ms.ToArray();
                output.Write(bytes, 0, bytes.Length);
                output.Flush();
                output.Close();
                output.Dispose();
            }

            // Verify basic reading of the zip file created above
            using (var zip = ZipFile.OpenRead(fileName))
            {
                Assert.AreEqual(2, zip.Entries.Count);
            }
        }
        public void TestExample()
        {
            //Jane Doe, the researcher.
            Agent janeDoe = (Agent)new Agent().SetName("Jane Doe").SetEmail("*****@*****.**").SetId("A-1");

            //Lin Yee Chung Cemetery
            Agent cemetery = (Agent)new Agent().SetName("Lin Yee Chung Cemetery").SetAddress(new Address().SetCity("Honolulu").SetStateOrProvince("Hawaii")).SetId("A-2");

            //Hanyu Pinyin, the translator.
            Agent hanyuPinyin = (Agent)new Agent().SetName("HANYU Pinyin 王大年").SetEmail("*****@*****.**").SetId("A-3");

            //The attribution for this research.
            Attribution researchAttribution = new Attribution().SetContributor(janeDoe).SetModified(DateTime.Parse("2014-03-27"));

            //The attribution for the translation.
            Attribution translationAttribution = new Attribution().SetContributor(hanyuPinyin).SetModified(DateTime.Parse("2014-03-27"));

            //The grave stone.
            SourceDescription gravestoneDescription = (SourceDescription)new SourceDescription()
              .SetTitle("Grave Marker of WONG Aloiau, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii")
              .SetCitation(new SourceCitation().SetValue("WONG Aloiau gravestone, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii; visited May 1975 by Jane Doe."))
              .SetResourceType(ResourceType.PhysicalArtifact)
              .SetRepository(cemetery)
              .SetId("S-1");

            //The image of the grave stone.
            SourceDescription gravestoneImageDescription = (SourceDescription)new SourceDescription()
              .SetTitle("Grave Marker of WONG Aloiau, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii")
              .SetCitation(new SourceCitation().SetValue("WONG Aloiau gravestone (digital photograph), Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii; visited May 1975 by Jane Doe."))
              .SetResourceType(ResourceType.DigitalArtifact)
              .SetSource(new SourceReference().SetDescription(gravestoneDescription))
              .SetId("S-2");

            //The transcription of the grave stone.
            Document transcription = (Document)new Document()
              .SetText("WONG ALOIAU\n" +
                      "NOV. 22, 1848 – AUG. 3, 1920\n" +
                      "中山  大字都  泮沙鄉\n" +
                      "生  於  前  清 戊申 年 十一 月 廿二(日)子   時\n" +
                      "終  於  民國  庚申 年     七月    十二 (日)    午    時\n" +
                      "先考  諱 羅有  字 容康 王 府 君 之 墓")
              .SetSource(gravestoneImageDescription)
              .SetLang("zh")
              .SetId("D-1");

            //The transcription described as a source.
            SourceDescription transcriptionDescription = (SourceDescription)new SourceDescription()
              .SetAbout("#" + transcription.Id)
              .SetTitle("Transcription of Grave Marker of WONG Aloiau, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii")
              .SetCitation(new SourceCitation().SetValue("WONG Aloiau gravestone (transcription), Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii; visited May 1975 by Jane Doe."))
              .SetResourceType(ResourceType.DigitalArtifact)
              .SetSource(new SourceReference().SetDescription(gravestoneImageDescription))
              .SetId("S-3");

            //The translation of the grave stone.
            Document translation = (Document)new Document()
              .SetText("WONG ALOIAU\n" +
                      "NOV. 22, 1848 – AUG. 3, 1920 [lunar dates]\n" +
                      "[Birthplace] [China, Guandong, ]Chung Shan, See Dai Doo, Pun Sha village\n" +
                      "[Date of birth] Born at former Qing 1848 year 11th month 22nd day 23-1 hour.\n" +
                      "[Life] ended at Republic of China year 1920 year 7th mo. 12th day 11-13 hour.\n" +
                      "Deceased father avoid [mention of] Lo Yau also known as Young Hong Wong [noble]residence ruler’s grave.")
              .SetSource(transcriptionDescription)
              .SetId("D-2");

            //The translation described as a source.
            SourceDescription translationDescription = (SourceDescription)new SourceDescription()
              .SetAbout("#" + translation.Id)
              .SetTitle("Translation of Grave Marker of WONG Aloiau, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii")
              .SetCitation(new SourceCitation().SetValue("WONG Aloiau gravestone, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii; visited May 1975 by Jane Doe. Translation by HANYU Pinyin 王大年."))
              .SetAttribution(translationAttribution)
              .SetResourceType(ResourceType.DigitalArtifact)
              .SetSource(new SourceReference().SetDescription(transcriptionDescription))
              .SetId("S-4");

            //the birth.
            Fact birth = new Fact()
              .SetType(FactType.Birth)
              .SetDate(new DateInfo().SetOriginal("former Qing 1848 year 11th month 22nd day 23-1 hour").SetFormal("+1848-11-22"))
              .SetPlace(new PlaceReference().SetOriginal("Pun Sha Village, See Dai Doo, Chung Shan, Guangdong, China"));

            //the death.
            Fact death = new Fact()
              .SetType(FactType.Death)
              .SetDate(new DateInfo().SetOriginal("Republic of China year 1920 year 7th mo. 12th day 11-13 hour").SetFormal("+1920-08-03"));

            //the burial.
            Fact burial = new Fact()
              .SetType(FactType.Burial)
              .SetPlace(new PlaceReference().SetOriginal("Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii"));

            //the principal person
            Person aloiau = (Person)new Person().SetName("WONG Aloiau").SetGender(GenderType.Male).SetFact(birth).SetFact(death).SetFact(burial).SetExtracted(true).SetSource(translationDescription).SetId("P-1");

            //the father of the principal (with an aka name).
            Person father = (Person)new Person().SetName("Lo Yau").SetName(new Name().SetType(NameType.AlsoKnownAs).SetNameForm(new NameForm().SetFullText("Young Hong Wong"))).SetExtracted(true).SetSource(translationDescription).SetId("P-2");

            //the relationship.
            Relationship fatherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(father).SetPerson2(aloiau);

            //Jane Doe's analysis.
            Document analysis = (Document)new Document().SetText("...Jane Doe's analysis document...").SetId("D-3");

            //Jane Doe's conclusions about a person.
            Person aloiauConclusion = (Person)new Person().SetEvidence(aloiau).SetAnalysis(analysis).SetId("C-1");

            Gx.Gedcomx gx = new Gx.Gedcomx()
              .SetAgent(janeDoe)
              .SetAgent(cemetery)
              .SetAgent(hanyuPinyin)
              .SetAttribution(researchAttribution)
              .SetSourceDescription(gravestoneDescription)
              .SetSourceDescription(gravestoneImageDescription)
              .SetDocument(transcription)
              .SetSourceDescription(transcriptionDescription)
              .SetDocument(translation)
              .SetSourceDescription(translationDescription)
              .SetPerson(aloiau)
              .SetPerson(father)
              .SetRelationship(fatherRelationship)
              .SetDocument(analysis)
              .SetPerson(aloiauConclusion);

            xmlSerializer.Deserialize<Gx.Gedcomx>(xmlSerializer.Serialize(gx));
            jsonSerializer.Deserialize<Gx.Gedcomx>(jsonSerializer.Serialize(gx));
        }
 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));
 }
 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));
 }