/// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            CorrPseudonymsPart part = new CorrPseudonymsPart();

            SetPartMetadata(part, roleId, item);

            part.Pseudonyms.Add(new Faker <CorrPseudonym>()
                                .RuleFor(p => p.Language, f => f.PickRandom("lat", "ita"))
                                .RuleFor(p => p.Value, f => f.Lorem.Word())
                                .RuleFor(p => p.IsAuthor, f => f.Random.Bool())
                                .RuleFor(p => p.Sources, SeederHelper.GetDocReferences(1, 3))
                                .Generate());

            return(part);
        }
Example #2
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            CorrExchangesPart part = new CorrExchangesPart();

            SetPartMetadata(part, roleId, item);

            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Exchanges.Add(new Faker <CorrExchange>()
                                   .RuleFor(e => e.IsDubious, f => f.Random.Bool(0.3f))
                                   .RuleFor(e => e.IsIndirect, f => f.Random.Bool())
                                   .RuleFor(e => e.IsFromParticipant, f => f.Random.Bool())
                                   .RuleFor(e => e.Chronotopes,
                                            new List <Chronotope> {
                    SeederHelper.GetChronotope("from", 1200)
                })
                                   .RuleFor(e => e.Participants, SeederHelper.GetDecoratedIds(1, 2))
                                   .RuleFor(e => e.Sources, SeederHelper.GetDocReferences(1, 3))
                                   .RuleFor(e => e.Attachments, SeederHelper.GetAttachments(1, 3))
                                   .Generate());
            }

            return(part);
        }
Example #3
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            MsPlacePart part = new Faker <MsPlacePart>()
                               .RuleFor(p => p.Area,
                                        f => f.PickRandom("France", "Germany", "Italy"))
                               .RuleFor(p => p.Address, f => $"{f.Lorem.Word()}, {f.Lorem.Word()}")
                               .RuleFor(p => p.City, f => f.Address.City())
                               .RuleFor(p => p.Site, f => f.PickRandom("A library", "A monastery"))
                               .RuleFor(p => p.Subscriber, f => f.Lorem.Word())
                               .RuleFor(p => p.SubscriptionLoc, f =>
                                        new MsLocation
            {
                N = (short)f.Random.Number(20, 60),
                S = f.Random.Bool() ?
                    "v" : "r",
                L = (short)f.Random.Number(1, 20)
            })
                               .RuleFor(p => p.Sources, SeederHelper.GetDocReferences(1, 3))
                               .Generate();

            SetPartMetadata(part, roleId, item);

            return(part);
        }
Example #4
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            PersonWorksPart part = new PersonWorksPart();

            SetPartMetadata(part, roleId, item);
            string[] languages = new[] { "eng", "ita", "fra", "deu", "spa" };

            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Works.Add(new Faker <PersonWork>()
                               .RuleFor(a => a.Language, f => f.PickRandom(languages))
                               .RuleFor(a => a.IsDubious, f => f.Random.Bool(0.2f))
                               .RuleFor(a => a.IsLost, f => f.Random.Bool(0.2f))
                               .RuleFor(a => a.Genre, f => f.Lorem.Word())
                               .RuleFor(a => a.Titles, f => new List <string>(new[] { f.Lorem.Sentence() }))
                               .RuleFor(a => a.Chronotopes, SeederHelper.GetChronotopes(1, 3))
                               .RuleFor(a => a.References, SeederHelper.GetDocReferences(1, 3))
                               .RuleFor(a => a.Note,
                                        f => f.Random.Bool(0.2f)? f.Lorem.Sentence() : null)
                               .Generate());
            }

            return(part);
        }
 private MsDecorationArtist GetArtist()
 {
     return(new Faker <MsDecorationArtist>()
            .RuleFor(a => a.Type, f => f.PickRandom("draftsman", "miniator"))
            .RuleFor(a => a.Id, f => f.Lorem.Word())
            .RuleFor(a => a.Name, f => f.Person.FirstName)
            .RuleFor(a => a.Note, f => f.Lorem.Sentence())
            .RuleFor(a => a.Sources, SeederHelper.GetDocReferences(1, 3))
            .Generate());
 }
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            MsDecorationsPart part = new MsDecorationsPart();

            SetPartMetadata(part, roleId, item);

            int count = Randomizer.Seed.Next(1, 3);

            for (int n = 1; n <= count; n++)
            {
                int sn = (n - 1) * 2;

                part.Decorations.Add(new Faker <MsDecoration>()
                                     .RuleFor(d => d.Id, f => "d" + f.UniqueIndex)
                                     .RuleFor(d => d.Name, f => f.Lorem.Word())
                                     .RuleFor(d => d.Type, f => f.PickRandom(_types))
                                     .RuleFor(d => d.Date, HistoricalDate.Parse($"{1300 + n} AD"))
                                     .RuleFor(d => d.Flags,
                                              f => new List <string>(new[] { f.PickRandom(_flags) }))
                                     .RuleFor(d => d.Place, f => f.Address.Country())
                                     .RuleFor(d => d.Artist, GetArtist())
                                     .RuleFor(d => d.Note, f => f.Random.Bool(0.25f)
                        ? f.Lorem.Sentence() : null)
                                     .RuleFor(d => d.References, SeederHelper.GetDocReferences(1, 3))
                                     .RuleFor(d => d.Elements, f => GetElements(f.Random.Number(1, 3), f))
                                     .Generate());
            }

            return(part);
        }
Example #7
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            PersonHandPart part = new Faker <PersonHandPart>()
                                  .RuleFor(p => p.PersonId, f => f.Lorem.Word())
                                  .RuleFor(p => p.Job, f => f.PickRandom("copyst", "writer", "poet"))
                                  .RuleFor(p => p.Others, SeederHelper.GetDocReferences(0, 3))
                                  .Generate();

            SetPartMetadata(part, roleId, item);

            return(part);
        }
Example #8
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            PersonEventsPart part = new PersonEventsPart();

            SetPartMetadata(part, roleId, item);

            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Events.Add(new Faker <BioEvent>()
                                .RuleFor(e => e.Type, f => n == 1?
                                         "birth" : f.PickRandom("work", "marriage"))
                                .RuleFor(e => e.Date, HistoricalDate.Parse($"{n} AD"))
                                .RuleFor(e => e.Places,
                                         f => new List <string>(new[] { f.Lorem.Word() }))
                                .RuleFor(e => e.Description, f => f.Lorem.Sentence())
                                .RuleFor(e => e.Sources, SeederHelper.GetDocReferences(1, 3))
                                .RuleFor(e => e.Participants, SeederHelper.GetDecoratedIds(1, 3))
                                .RuleFor(e => e.Work, f => f.Lorem.Sentence(1, 3))
                                .RuleFor(e => e.Rank, f => f.Random.Short(0, 3))
                                .RuleFor(e => e.IsWorkDubious, f => f.Random.Bool(0.2f))
                                .RuleFor(e => e.IsWorkLost, f => f.Random.Bool(0.2f))
                                .RuleFor(e => e.ExternalIds, SeederHelper.GetExternalIds(1, 3))
                                .Generate());
            }

            return(part);
        }
Example #9
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            MsHistoryPart part = new Faker <MsHistoryPart>()
                                 .RuleFor(p => p.Provenances, GetProvenances(2))
                                 .RuleFor(p => p.History, f => f.Lorem.Sentence())
                                 .Generate();

            SetPartMetadata(part, roleId, item);

            // persons
            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Persons.Add(new Faker <MsHistoryPerson>()
                                 .RuleFor(p => p.Role,
                                          f => f.PickRandom("scribe", "corrector", "owner"))
                                 .RuleFor(p => p.Name, new Faker <PersonName>()
                                          .RuleFor(pn => pn.Language, "lat")
                                          .RuleFor(pn => pn.Parts, f =>
                                                   new List <PersonNamePart>(new[]
                {
                    new PersonNamePart
                    {
                        Type  = "first",
                        Value = f.Lorem.Word(),
                    },
                    new PersonNamePart
                    {
                        Type  = "last",
                        Value = f.Lorem.Word(),
                    }
                }))
                                          .Generate())
                                 .RuleFor(p => p.Date, HistoricalDate.Parse($"{1200 + n} AD"))
                                 .RuleFor(p => p.Note, f => f.PickRandom(null, f.Lorem.Sentence()))
                                 .RuleFor(p => p.ExternalIds, f => new List <string>(new[]
                {
                    $"www.someurl.org/entities/{f.Random.Number()}"
                }))
                                 .RuleFor(p => p.Sources, SeederHelper.GetDocReferences(1, 3))
                                 .Generate());
            }

            // annotations
            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Annotations.Add(new Faker <MsAnnotation>()
                                     .RuleFor(a => a.Language, f => f.PickRandom("lat", "ita"))
                                     .RuleFor(a => a.Type, f => f.Lorem.Word())
                                     .RuleFor(a => a.Text, f => f.Lorem.Sentence())
                                     .RuleFor(a => a.PersonId, f => f.Person.FirstName)
                                     .RuleFor(r => r.Ranges, new List <MsLocationRange>(new[]
                {
                    new MsLocationRange
                    {
                        Start = new MsLocation
                        {
                            N = n,
                            S = n % 2 == 0 ? "v" : "r",
                            L = n * 5
                        },
                        End = new MsLocation
                        {
                            N = n + 1,
                            S = n % 2 == 0 ? "r" : "v",
                            L = n * 5
                        }
                    }
                }))
                                     .RuleFor(f => f.Sources, SeederHelper.GetDocReferences(1, 3))
                                     .Generate());
            }

            // restorations
            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Restorations.Add(new Faker <MsRestoration>()
                                      .RuleFor(r => r.Type, f => f.Lorem.Word())
                                      .RuleFor(r => r.Place, f => f.Lorem.Word())
                                      .RuleFor(r => r.Date, HistoricalDate.Parse($"{1200 + n} AD"))
                                      .RuleFor(r => r.PersonId, f => f.Person.FirstName)
                                      .RuleFor(r => r.Note, f => f.PickRandom(null, f.Lorem.Sentence()))
                                      .RuleFor(r => r.Sources, SeederHelper.GetDocReferences(1, 3))
                                      .Generate());
            }

            return(part);
        }