public void IndexFrameworks(string indexName, ICollection <Provider> indexEntries)
        {
            var frameworkProviderList = new List <ProviderDocument>();

            try
            {
                foreach (var provider in indexEntries)
                {
                    foreach (var framework in provider.Frameworks)
                    {
                        var deliveryLocationsOnly100 = framework.DeliveryLocations
                                                       .Where(_onlyAtEmployer)
                                                       .Where(x => x.DeliveryLocation.Address.GeoPoint != null)
                                                       .ToArray();

                        if (deliveryLocationsOnly100.Any())
                        {
                            var frameworkProvider = ElasticsearchMapper.CreateFrameworkProviderDocument(provider, framework, deliveryLocationsOnly100);
                            frameworkProviderList.Add(frameworkProvider);
                        }

                        frameworkProviderList.AddRange(from location in framework.DeliveryLocations.Where(_anyNotAtEmployer) where location.DeliveryLocation.Address.GeoPoint != null select ElasticsearchMapper.CreateFrameworkProviderDocument(provider, framework, location));
                    }
                }

                Client.BulkAllGeneric(frameworkProviderList, indexName);
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Something failed indexing framework providers:" + ex.Message);
                throw;
            }
        }
Ejemplo n.º 2
0
        public void ShouldCreateFrameworkProviderDocumentWithListOfLocationPoints()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            var document = mapper.CreateFrameworkProviderDocument(testProvider, testProvider.Frameworks.First(), testProvider.Frameworks.First().DeliveryLocations);

            document.LocationPoints.Count().Should().Be(1);
        }
Ejemplo n.º 3
0
        public void ShouldThrowMappingExceptionOnMappingErrorForFrameworkProviderMapping()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            // Remove Delivery modes
            testProvider.Frameworks.First().DeliveryLocations.First().DeliveryModes = null;

            Assert.Throws <MappingException>(() =>
                                             mapper.CreateFrameworkProviderDocument(
                                                 testProvider,
                                                 testProvider.Frameworks.First(),
                                                 testProvider.Frameworks.First().DeliveryLocations.First()));
        }
Ejemplo n.º 4
0
        public void ShouldCreateValidFrameworkProviderDocument()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            var document = mapper.CreateFrameworkProviderDocument(testProvider, testProvider.Frameworks.First(), testProvider.Frameworks.First().DeliveryLocations.First());

            document.FrameworkCode.Should().Be(99);
            document.PathwayCode.Should().Be(1122);
            document.FrameworkId.Should().Be(string.Format(_frameworkIdFormat, 99, 20, 1122));
            document.Level.Should().Be(4);

            document.Ukprn.Should().Be(4556);
            document.ProviderName.Should().Be("Test Provider");
            document.TrainingLocations.First().LocationId.Should().Be(77);
            document.TrainingLocations.First().LocationName.Should().Be("Framework Test Location");
            document.ProviderMarketingInfo.Should().Be("Provider Marketing");
            document.ApprenticeshipMarketingInfo.Should().Be("Framework Apprenticeship Marketing");
            document.Phone.Should().Be("12324-5678");
            document.Email.Should().Be("*****@*****.**");
            document.ContactUsUrl.Should().Be("http://contact-us.com");
            document.ApprenticeshipInfoUrl.Should().Be("http://standard-info.com");
            document.LearnerSatisfaction.Should().Be(8.2);
            document.EmployerSatisfaction.Should().Be(9.2);
            document.DeliveryModes.Should().BeEquivalentTo("BlockRelease", "DayRelease");
            document.Website.Should().Be("http://location-site");
            document.TrainingLocations.First().Address.Address1.Should().Be("Framework Test Address1");
            document.TrainingLocations.First().Address.Address2.Should().Be("Framework Test Address2");
            document.TrainingLocations.First().Address.Town.Should().Be("Framework Test Town");
            document.TrainingLocations.First().Address.County.Should().Be("Framework Test County");
            document.TrainingLocations.First().Address.PostCode.Should().Be("TE3 5ES");

            document.TrainingLocations.FirstOrDefault()?.LocationPoint.Latitude.Should().Be(53.213);
            document.TrainingLocations.FirstOrDefault()?.LocationPoint.Longitude.Should().Be(-50.123);
            document.TrainingLocations.FirstOrDefault()?.Location.Coordinates.Latitude.Should().Be(53.213);
            document.TrainingLocations.FirstOrDefault()?.Location.Coordinates.Longitude.Should().Be(-50.123);
            document.TrainingLocations.FirstOrDefault()?.Location.Radius.Should().Be("25mi");
        }