public OracleRepository(string connectionString)
        {
            OracleInsightDbProvider.RegisterProvider();
            db = new OracleConnectionStringBuilder(connectionString);

            searchRepository = new SearchRepository(db);
            historyRepository = new AccessHistoryRepository(db);
            dashboardRepository = new DashboardRepository(db);
        }
 public CompositeController()
 {
     _articleRepository = new ArticleRepository(UnitOfWork);
     _bioRepository = new BioRepository(UnitOfWork);
     _eventRepository = new EventRepository(UnitOfWork);
     _qaRepository = new QARepository(UnitOfWork);
     _downloadRepository = new DownloadRepository(UnitOfWork);
     _searchRepository = new SearchRepository(UnitOfWork);
 }
Beispiel #3
0
 public SearchPresenter(
     ISearchView view,
     IApplicationController applicationController,
     ISearchRepository searchRepository)
 {
     _view = view;
     _applicationController = applicationController;
     _searchRepository = searchRepository;
 }
        public FlightService()
        {
            // data
            searchRepository = new SearchRepository(ConfigurationManager.ConnectionStrings["Destination2"].ConnectionString);

            // business
            cacheService = new CacheService(MemoryCache.Default);
            gatewayService = new GatewayService(InitializeService.Settings, cacheService);
            search = new SearchService(searchRepository, gatewayService);
        }
        public SearchService(ISearchRepository searchRepository, IStatusGeneratorFactory statusGeneratorFactory, IPipelinePositionGenerator pipelinePositionGenerator)
        {
            Check.If(searchRepository).IsNotNull();
            Check.If(statusGeneratorFactory).IsNotNull();
            Check.If(pipelinePositionGenerator).IsNotNull();

            _searchRepository = searchRepository;
            _statusGeneratorFactory = statusGeneratorFactory;
            _pipelinePositionGenerator = pipelinePositionGenerator;
        }
Beispiel #6
0
 protected TraktCommandBase(
     ITraktApiClient traktApiClient,
     ISearchRepository searchRepository,
     ISearchIndex searchIndex,
     ILogger logger)
 {
     _searchRepository = searchRepository;
     _searchIndex      = searchIndex;
     _logger           = logger;
     TraktApiClient    = traktApiClient;
 }
Beispiel #7
0
        public async Task SearchDatasetDefinition_GivenValidModelWithMultipleFilterValuesWhichIsMultiValueFacet_ThenSearchIsPerformed()
        {
            //Arrange
            SearchModel model = new SearchModel
            {
                PageNumber    = 1,
                Top           = 50,
                IncludeFacets = true,
                Filters       = new Dictionary <string, string[]>()
                {
                    { "providerIdentifier", new string [] { "test", "test2" } }
                },
                SearchTerm = "testTerm",
            };

            string json = JsonConvert.SerializeObject(model);

            byte[]       byteArray = Encoding.UTF8.GetBytes(json);
            MemoryStream stream    = new MemoryStream(byteArray);

            HttpRequest request = Substitute.For <HttpRequest>();

            request
            .Body
            .Returns(stream);

            SearchResults <DatasetDefinitionIndex> searchResults = new SearchResults <DatasetDefinitionIndex>();

            ILogger logger = CreateLogger();

            ISearchRepository <DatasetDefinitionIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .Search(Arg.Any <string>(), Arg.Any <SearchParameters>())
            .Returns(searchResults);

            DatasetDefinitionSearchService service = CreateDatasetSearchService(logger: logger, searchRepository: searchRepository);

            //Act
            IActionResult result = await service.SearchDatasetDefinitions(request);

            //Assert
            result
            .Should()
            .BeOfType <OkObjectResult>();

            await
            searchRepository
            .Received(1)
            .Search(model.SearchTerm, Arg.Is <SearchParameters>(c =>
                                                                model.Filters.Keys.All(f => c.Filter.Contains(f)) &&
                                                                !string.IsNullOrWhiteSpace(c.Filter)
                                                                ));
        }
        public ResultsSearchService(ILogger logger,
                                    ISearchRepository <ProviderIndex> searchRepository,
                                    IResultsResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _logger           = logger;
            _searchRepository = searchRepository;
            _resultsSearchRepositoryPolicy = resiliencePolicies.ResultsSearchRepository;
        }
 public CompositeController(IUnitOfWork unitOfWork, IArticleRepository articleRepository, IBioRepository bioRepository,
     IEventRepository eventRepository, IQARepository qaRepository, IDownloadRepository downloadRepository, ISearchRepository searchRepository)
     : base(unitOfWork)
 {
     _articleRepository = articleRepository;
     _bioRepository = bioRepository;
     _eventRepository = eventRepository;
     _qaRepository = qaRepository;
     _downloadRepository = downloadRepository;
     _searchRepository = searchRepository;
 }
        public async Task GetProviderById_WhenProviderIdExistsForDate_ProviderReturned(int day, int month, int year)
        {
            // Arrange
            ProviderVersionViewModel providerVersionViewModel = CreateProviderVersion();

            Provider provider = GetProvider();

            providerVersionViewModel.Providers   = providerVersionViewModel.Providers.Concat(new[] { provider });
            providerVersionViewModel.VersionType = ProviderVersionType.Custom;

            ICacheProvider cacheProvider = CreateCacheProvider();

            SearchResults <ProvidersIndex> searchResults = new SearchResults <ProvidersIndex> {
                Results = new List <Repositories.Common.Search.SearchResult <ProvidersIndex> > {
                    new Repositories.Common.Search.SearchResult <ProvidersIndex> {
                        Result = new ProvidersIndex {
                            ProviderVersionId = provider.ProviderVersionId, UKPRN = provider.UKPRN
                        }
                    }
                }
            };

            IProviderVersionService providerVersionService = CreateProviderVersionService();

            ISearchRepository <ProvidersIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .Search(Arg.Any <string>(), Arg.Any <SearchParameters>())
            .Returns(searchResults);

            IProviderVersionSearchService providerService = CreateProviderVersionSearchService(cacheProvider: cacheProvider, searchRepository: searchRepository, providerVersionService: providerVersionService);

            providerVersionService
            .GetProviderVersionByDate(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>())
            .Returns <ProviderVersionByDate>(new ProviderVersionByDate {
                Day = day, Month = month, Year = year, ProviderVersionId = provider.ProviderVersionId
            });

            // Act
            IActionResult okRequest = await providerService.GetProviderById(year, month, day, provider.ProviderId);

            await searchRepository.Received(1)
            .Search(Arg.Any <string>(), Arg.Is <SearchParameters>(c => c.Filter.Contains(provider.ProviderId)));

            okRequest
            .Should()
            .BeOfType <OkObjectResult>();

            ((OkObjectResult)okRequest).Value
            .Should()
            .BeOfType <ProviderVersionSearchResult>();

            Assert.AreEqual(((ProviderVersionSearchResult)((OkObjectResult)okRequest).Value).Id, provider.ProviderVersionId + "_" + provider.UKPRN);
        }
        public void GetAll_GetAll_Return_EqualCount()
        {
            sut = new LuceneSearchRepository(true);
            foreach (var user in users)
            {
                sut.Insert(user);
            }

            var userCollectionFromRepo = sut.GetAll <TestUser>();

            Assert.AreEqual(users.Count(), userCollectionFromRepo.Count());
        }
Beispiel #12
0
        public DatasetSearchService(ILogger logger,
                                    ISearchRepository <DatasetIndex> searchRepository,
                                    ISearchRepository <DatasetVersionIndex> searchVersionRepository)
        {
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(searchVersionRepository, nameof(searchVersionRepository));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _logger                  = logger;
            _searchRepository        = searchRepository;
            _searchVersionRepository = searchVersionRepository;
        }
 static ScenariosSearchService CreateSearchService(
     ISearchRepository <ScenarioIndex> searchRepository = null,
     IScenariosRepository scenariosRepository           = null,
     ISpecificationsRepository specificationsRepository = null,
     ILogger logger = null)
 {
     return(new ScenariosSearchService(
                searchRepository ?? CreateSearchRepository(),
                scenariosRepository ?? CreateScenariosRepository(),
                specificationsRepository ?? CreateSpecificationsRepository(),
                logger ?? CreateLogger()));
 }
Beispiel #14
0
        public TestResultsSearchService(ILogger logger,
                                        ISearchRepository <TestScenarioResultIndex> searchRepository,
                                        ITestRunnerResiliencePolicies resiliencePolicies)
        {
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.TestResultsSearchRepository, nameof(resiliencePolicies.TestResultsSearchRepository));

            _logger                 = logger;
            _searchRepository       = searchRepository;
            _searchRepositoryPolicy = resiliencePolicies.TestResultsSearchRepository;
        }
Beispiel #15
0
        public async Task ReIndex_GivenIndexingThrowsException_ReturnsInternalServerError()
        {
            //Arrange
            IEnumerable <SpecificationSearchModel> specifications = new[]
            {
                new SpecificationSearchModel
                {
                    Id             = SpecificationId,
                    Name           = SpecificationName,
                    FundingStreams = new List <Reference> {
                        new Reference("fs-id", "fs-name")
                    },
                    FundingPeriod = new Reference("18/19", "2018/19"),
                    UpdatedAt     = DateTime.Now
                }
            };

            ISearchRepository <SpecificationIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .When(x => x.Index(Arg.Any <List <SpecificationIndex> >()))
            .Do(x => { throw new Exception(); });

            ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository();

            specificationsRepository
            .GetSpecificationsByRawQuery <SpecificationSearchModel>(Arg.Any <SqlQuerySpec>())
            .Returns(specifications);

            ILogger logger = CreateLogger();

            ISpecificationsService service = CreateService(searchRepository: searchRepository, logs: logger,
                                                           specificationsRepository: specificationsRepository);

            //Act
            IActionResult result = await service.ReIndex();

            //Assert
            logger
            .Received(1)
            .Error(Arg.Any <Exception>(), Arg.Is("Failed re-indexing specifications"));

            result
            .Should()
            .BeOfType <StatusCodeResult>();

            StatusCodeResult statusCodeResult = result as StatusCodeResult;

            statusCodeResult
            .StatusCode
            .Should()
            .Be(500);
        }
        public async Task GetFacetValues_WhenValidFacetProvided_FacetDistinctValuesReturned()
        {
            // Arrange

            string authorityFacet = "authority";

            string facetValue1 = "Kent";
            string facetValue2 = "Essex";

            SearchResults <ProvidersIndex> searchResults = new SearchResults <ProvidersIndex>
            {
                Facets = new List <Facet>
                {
                    new Facet
                    {
                        Name        = authorityFacet,
                        FacetValues = new List <FacetValue>
                        {
                            new FacetValue {
                                Name = facetValue1
                            },
                            new FacetValue {
                                Name = facetValue2
                            }
                        }
                    }
                }
            };

            ISearchRepository <ProvidersIndex> searchRepository = CreateSearchRepository();

            searchRepository
            .Search(string.Empty, Arg.Any <SearchParameters>())
            .Returns(searchResults);

            IProviderVersionSearchService providerService = CreateProviderVersionSearchService(searchRepository: searchRepository);

            // Act
            IActionResult okObjectRequest = await providerService.GetFacetValues(authorityFacet);

            // Assert
            okObjectRequest
            .Should()
            .BeOfType <OkObjectResult>();

            await searchRepository
            .Received(1)
            .Search(string.Empty, Arg.Is <SearchParameters>(x => x.Top == 0 && x.Facets.Count == 1 && x.Facets.First().Contains(authorityFacet)));

            ((okObjectRequest as OkObjectResult).Value as IEnumerable <string>)
            .Should()
            .HaveCount(2);
        }
Beispiel #17
0
 public SearchBusinessLogic(
     ISearchRepository <EmployerSearchModel> employerSearchRepository,
     ISearchRepository <SicCodeSearchModel> sicCodeSearchRepository,
     IOrganisationBusinessLogic organisationBusinessLogic,
     [KeyFilter(Filenames.SearchLog)] IAuditLogger searchLog
     )
 {
     EmployerSearchRepository   = employerSearchRepository;
     SicCodeSearchRepository    = sicCodeSearchRepository;
     _organisationBusinessLogic = organisationBusinessLogic;
     SearchLog = searchLog;
 }
        public void Update_NotExistingObject_Return_EqualKeyValue()
        {
            sut = new LuceneSearchRepository(true);
            foreach (var user in users)
            {
                sut.Insert(user);
            }

            var oldUser = new TestUser();

            Assert.Throws <LuceneSearchRepositoryException>(() => sut.Update <TestUser>(oldUser));
        }
Beispiel #19
0
        public AdminModuleViewModel()
        {
            _repo = MainViewModel.SearchRepo;

            EventManager.GetEvent <SectionSelectionEvent>()
            .Subscribe(evt =>
            {
                this.Navigate(evt.Section);
            });
            //EventManager.GetEvent<FoldersSelectedVM>()
            //    .Subscribe(vm =>
            //    {

            //    });

            EventManager.GetEvent <FolderSettingsUpdatedEvent>()
            .Subscribe(evt =>
            {
                var vm = ((FolderSettingsViewModel)(SelectedSectionViewModel));
                try
                {
                    var folderSet = new Domain.FolderSet
                    {
                        SelectedAnalyticFolders  = vm.AnalyticFolderSet,
                        SelectedEverydayFolders  = vm.EverydayFolderSet,
                        SelectedPromotionFolders = vm.PromoFolderSet,
                        SelectedKitFolders       = vm.KitFolderSet
                    };
                    _repo.SaveFolders(folderSet);
                }
                catch (Exception)
                {
                    throw;
                }

                //if saved update in memory so search screen is updated
                //var mainFolderSet = ((HomeSearchViewModel)MainViewModel.SubModuleCache[Domain.SubModuleType.Search]);

                //mainFolderSet.FolderSet.SelectedAnalyticFolders = vm.AnalyticFolderSet;
                //mainFolderSet.FolderSet.SelectedEverydayFolders = vm.EverydayFolderSet;
                //mainFolderSet.FolderSet.SelectedPromotionFolders = vm.PromoFolderSet;
                //mainFolderSet.FolderSet.SelectedKitFolders = vm.KitFolderSet;

                //EventManager.Publish<NavigateEvent>(
                //    new NavigateEvent
                //    {
                //        Module = Domain.ModuleType.Planning,
                //        SubModule = Domain.SubModuleType.Search,
                //        Section = Domain.SectionType.PlanningHomeMyHomePage

                //    });
            });
        }
Beispiel #20
0
 protected DiscountSearchService(ISearchRepository <DiscountSearch> searchRepository,
                                 IDiscountRepository discountRepository,
                                 ILocationService locationService,
                                 ICategoryService categoryService,
                                 ITagService tagService)
 {
     SearchRepository   = searchRepository;
     DiscountRepository = discountRepository;
     _locationService   = locationService;
     _categoryService   = categoryService;
     _tagService        = tagService;
 }
 static CalculationProviderResultsSearchService CreateTestResultsSearchService(
     ILogger logger = null,
     ISearchRepository <CalculationProviderResultsIndex> serachRepository = null,
     IResultsResiliencePolicies resiliencePolicies = null,
     ISearchRepository <ProviderCalculationResultsIndex> providerCalculationResultsSearchRepository = null,
     IFeatureToggle featureToggle = null)
 {
     return(new CalculationProviderResultsSearchService(
                logger ?? CreateLogger(),
                serachRepository ?? CreateSearchRepository(),
                resiliencePolicies ?? ResultsResilienceTestHelper.GenerateTestPolicies()));
 }
        public void Get_GetUser_Return_NoException()
        {
            var user = new TestUser()
            {
                Id = "1", Login = "******"
            };

            sut = new LuceneSearchRepository(true);
            sut.Insert(user);

            var userFromRepo = sut.Get <TestUser>("user1", "login");
        }
 public SearchOwnedQueryHandler(ISearchRepository <TEntity> searchRepository,
                                ITranslator <TEntity, TViewModel> translator,
                                IActivity activity,
                                IActivityAuthorizer authorizer,
                                Func <IEnumerable <TEntity>, IOrderedEnumerable <TEntity> > resultSorter = null)
 {
     SearchRepository = searchRepository ?? throw new ArgumentNullException(nameof(searchRepository));
     Translator       = translator ?? throw new ArgumentNullException(nameof(translator));
     Activity         = activity ?? throw new ArgumentNullException(nameof(activity));
     Authorizer       = authorizer ?? throw new ArgumentNullException(nameof(authorizer));
     ResultSorter     = resultSorter;
 }
 public AddTraktListHandler(
     ITraktApiClient traktApiClient,
     ISearchRepository searchRepository,
     ISearchIndex searchIndex,
     IDbContextFactory <TvContext> dbContextFactory,
     ILogger <AddTraktListHandler> logger,
     IEntityLocker entityLocker)
     : base(traktApiClient, searchRepository, searchIndex, logger)
 {
     _dbContextFactory = dbContextFactory;
     _entityLocker     = entityLocker;
 }
Beispiel #25
0
    public async Task <Unit> RebuildItems(ISearchRepository searchRepository, List <int> itemIds)
    {
        foreach (int id in itemIds)
        {
            foreach (MediaItem mediaItem in await searchRepository.GetItemToIndex(id))
            {
                switch (mediaItem)
                {
                case Movie movie:
                    await UpdateMovie(searchRepository, movie);

                    break;

                case Show show:
                    await UpdateShow(searchRepository, show);

                    break;

                case Season season:
                    await UpdateSeason(searchRepository, season);

                    break;

                case Artist artist:
                    await UpdateArtist(searchRepository, artist);

                    break;

                case MusicVideo musicVideo:
                    await UpdateMusicVideo(searchRepository, musicVideo);

                    break;

                case Episode episode:
                    await UpdateEpisode(searchRepository, episode);

                    break;

                case OtherVideo otherVideo:
                    await UpdateOtherVideo(searchRepository, otherVideo);

                    break;

                case Song song:
                    await UpdateSong(searchRepository, song);

                    break;
                }
            }
        }

        return(Unit.Default);
    }
        public async Task EditSpecificationStatus_GivenSpecificationISApprovedButNewStatusIsDraft_ThenBadRequestReturned()
        {
            //Arrange
            EditStatusModel specificationEditStatusModel = new EditStatusModel
            {
                PublishStatus = PublishStatus.Draft
            };

            ILogger logger = CreateLogger();

            Specification specification = CreateSpecification();

            specification.Current.PublishStatus = PublishStatus.Approved;

            ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository();

            specificationsRepository
            .GetSpecificationById(Arg.Is(SpecificationId))
            .Returns(specification);

            specificationsRepository
            .UpdateSpecification(Arg.Any <Specification>())
            .Returns(HttpStatusCode.OK);

            ISearchRepository <SpecificationIndex> searchRepository = CreateSearchRepository();

            SpecificationsService service = CreateService(
                logs: logger, specificationsRepository: specificationsRepository, searchRepository: searchRepository);

            // Act
            IActionResult result = await service.EditSpecificationStatus(SpecificationId, specificationEditStatusModel, null);

            // Arrange
            result
            .Should()
            .BeOfType <BadRequestObjectResult>()
            .Which
            .Value
            .Should()
            .Be("Publish status can't be changed to Draft from Updated or Approved");

            specification
            .Current
            .PublishStatus
            .Should()
            .Be(PublishStatus.Approved);

            await
            searchRepository
            .Received(0)
            .Index(Arg.Any <IEnumerable <SpecificationIndex> >());
        }
        public void Update_UpdateObject_Return_NoException()
        {
            sut = new LuceneSearchRepository(true);
            foreach (var user in users)
            {
                sut.Insert(user);
            }
            var oldUser = users.ToList()[1];

            oldUser.Login = "******";

            sut.Update <TestUser>(oldUser);
        }
 public EmbyCollectionScanner(
     IEmbyCollectionRepository embyCollectionRepository,
     IEmbyApiClient embyApiClient,
     ISearchRepository searchRepository,
     ISearchIndex searchIndex,
     ILogger <EmbyCollectionScanner> logger)
 {
     _embyCollectionRepository = embyCollectionRepository;
     _embyApiClient            = embyApiClient;
     _searchRepository         = searchRepository;
     _searchIndex = searchIndex;
     _logger      = logger;
 }
 public TopicService(ITopicRepository topicRepository, IPostRepository postRepository, ISettingsManager settingsManager, IModerationLogService moderationLogService, IForumService forumService, IEventPublisher eventPublisher, ISearchRepository searchRepository, IUserRepository userRepository, ISearchIndexQueueRepository searchIndexQueueRepository, ITenantService tenantService)
 {
     _topicRepository            = topicRepository;
     _postRepository             = postRepository;
     _settingsManager            = settingsManager;
     _moderationLogService       = moderationLogService;
     _forumService               = forumService;
     _eventPublisher             = eventPublisher;
     _searchRepository           = searchRepository;
     _userRepository             = userRepository;
     _searchIndexQueueRepository = searchIndexQueueRepository;
     _tenantService              = tenantService;
 }
Beispiel #30
0
        public SearchTests()
        {
            _serviceCollection.AddScoped <ISearchRepository, SearchRepository>();
            _serviceCollection.AddScoped <IContactsRepository, ContactsRepository>();
            _serviceCollection.AddScoped <IProposalsRepository, ProposalsRepository>();
            // Build the service
            _serviceProvider  = _serviceCollection.BuildServiceProvider();
            _finderRepository = (ISearchRepository)_serviceProvider.GetService(typeof(ISearchRepository));

            // Modify the mock object in case needed like  _mockContext.Object.Identity.UserName = "******";
            _mockContext.Object.Identity.BrokerId      = "13240178";
            _mockContext.Object.Identity.InstitutionId = "6083";
        }
Beispiel #31
0
 public JellyfinCollectionScanner(
     IJellyfinCollectionRepository jellyfinCollectionRepository,
     IJellyfinApiClient jellyfinApiClient,
     ISearchRepository searchRepository,
     ISearchIndex searchIndex,
     ILogger <JellyfinCollectionScanner> logger)
 {
     _jellyfinCollectionRepository = jellyfinCollectionRepository;
     _jellyfinApiClient            = jellyfinApiClient;
     _searchRepository             = searchRepository;
     _searchIndex = searchIndex;
     _logger      = logger;
 }
 public RebuildSearchIndexHandler(
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     IConfigElementRepository configElementRepository,
     ILocalFileSystem localFileSystem,
     ILogger <RebuildSearchIndexHandler> logger)
 {
     _searchIndex             = searchIndex;
     _logger                  = logger;
     _searchRepository        = searchRepository;
     _configElementRepository = configElementRepository;
     _localFileSystem         = localFileSystem;
 }
 private IProviderVersionSearchService CreateProviderVersionSearchService(
     ICacheProvider cacheProvider = null,
     ISearchRepository <ProvidersIndex> searchRepository = null,
     IProviderVersionsMetadataRepository providerVersionMetadataRepository = null,
     IProviderVersionService providerVersionService = null)
 {
     return(new ProviderVersionSearchService(
                CreateLogger(),
                searchRepository ?? CreateSearchRepository(),
                providerVersionMetadataRepository ?? CreateProviderVersionMetadataRepository(),
                CreateResiliencePolicies(),
                providerVersionService ?? CreateProviderVersionService()));
 }
Beispiel #34
0
 public DocumentService(ISearchRepository searchRepository,
                        IResourceChangeRepository changeRepository,
                        IStructureDefinitionSummaryProvider schemaProvider,
                        ILogger <DocumentService> logger)
 {
     Check.NotNull(searchRepository, nameof(searchRepository));
     Check.NotNull(changeRepository, nameof(changeRepository));
     Check.NotNull(logger, nameof(logger));
     _searchRepository = searchRepository;
     _changeRepository = changeRepository;
     _schemaProvider   = schemaProvider;
     _logger           = logger;
 }
Beispiel #35
0
    private async Task UpdateArtist(ISearchRepository searchRepository, Artist artist)
    {
        Option <ArtistMetadata> maybeMetadata = artist.ArtistMetadata.HeadOrNone();

        if (maybeMetadata.IsSome)
        {
            ArtistMetadata metadata = maybeMetadata.ValueUnsafe();

            try
            {
                var doc = new Document
                {
                    new StringField(IdField, artist.Id.ToString(), Field.Store.YES),
                    new StringField(TypeField, ArtistType, Field.Store.YES),
                    new TextField(TitleField, metadata.Title, Field.Store.NO),
                    new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO),
                    new TextField(LibraryNameField, artist.LibraryPath.Library.Name, Field.Store.NO),
                    new StringField(LibraryIdField, artist.LibraryPath.Library.Id.ToString(), Field.Store.NO),
                    new StringField(TitleAndYearField, GetTitleAndYear(metadata), Field.Store.NO),
                    new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
                };

                List <string> languages = await searchRepository.GetLanguagesForArtist(artist);
                await AddLanguages(searchRepository, doc, languages);

                doc.Add(new StringField(AddedDateField, metadata.DateAdded.ToString("yyyyMMdd"), Field.Store.NO));

                foreach (Genre genre in metadata.Genres)
                {
                    doc.Add(new TextField(GenreField, genre.Name, Field.Store.NO));
                }

                foreach (Style style in metadata.Styles)
                {
                    doc.Add(new TextField(StyleField, style.Name, Field.Store.NO));
                }

                foreach (Mood mood in metadata.Moods)
                {
                    doc.Add(new TextField(MoodField, mood.Name, Field.Store.NO));
                }

                _writer.UpdateDocument(new Term(IdField, artist.Id.ToString()), doc);
            }
            catch (Exception ex)
            {
                metadata.Artist = null;
                _logger.LogWarning(ex, "Error indexing artist with metadata {@Metadata}", metadata);
            }
        }
    }
Beispiel #36
0
        public async Task UpdateTestResultsForSpecification_GivenNoResultsFoundInSearch_DoesNotUpdateSearch()
        {
            //Arrange
            const string specificationId = "spec-id";

            Models.Specs.SpecificationVersionComparisonModel specificationVersionComparison = new Models.Specs.SpecificationVersionComparisonModel()
            {
                Id      = specificationId,
                Current = new Models.Specs.SpecificationVersion {
                    Name = "new name"
                },
                Previous = new Models.Specs.SpecificationVersion {
                    Name = "any name"
                }
            };

            string json = JsonConvert.SerializeObject(specificationVersionComparison);

            Message message = new Message(Encoding.UTF8.GetBytes(json));

            ILogger logger = CreateLogger();

            SearchResults <TestScenarioResultIndex> searchResult = new SearchResults <TestScenarioResultIndex>();

            ISearchRepository <TestScenarioResultIndex> searchRepository = CreateSearchRespository();

            searchRepository
            .Search(Arg.Is(""), Arg.Any <SearchParameters>())
            .Returns(searchResult);

            TestResultsService service = CreateTestResultsService(logger: logger, searchRepository: searchRepository);

            //Act
            await service.UpdateTestResultsForSpecification(message);

            //Assert
            await
            searchRepository
            .Received(1)
            .Search(Arg.Is(""), Arg.Is <SearchParameters>(
                        m => m.Skip == 0 &&
                        m.Top == 1000 &&
                        m.SearchMode == SearchMode.Any &&
                        m.Filter == $"specificationId eq '{specificationVersionComparison.Id}' and specificationName ne '{specificationVersionComparison.Current.Name}'"
                        ));

            await
            searchRepository
            .DidNotReceive()
            .Index(Arg.Any <IEnumerable <TestScenarioResultIndex> >());
        }
Beispiel #37
0
 public SearchServices(IRepository repository, 
     ICategoryRepository categoryRepository, 
     ISearchRepository searchRepository, 
     IHelperService helperService, 
     IReferenceServices referenceServices,
     ILocationServices locationServices)
 {
     _repository = repository;
     _categoryRepository = categoryRepository;
     _searchRepository = searchRepository;
     _helperService = helperService;
     _referenceServices = referenceServices;
     _locationServices = locationServices;
 }
        public QuoteService(IQuoteRepository quoteRepository, 
                            IPriceRangeRepository priceRangeRepository, 
                            ISearchRepository searchRepository, 
                            IReferenceGenerator referenceGenerator)
        {
            Check.If(quoteRepository).IsNotNull();
            Check.If(priceRangeRepository).IsNotNull();
            Check.If(searchRepository).IsNotNull();
            Check.If(referenceGenerator).IsNotNull();

            _quoteRepository = quoteRepository;
            _referenceGenerator = referenceGenerator;
            _searchRepository = searchRepository;
            _priceRangeRepository = priceRangeRepository;
        }
Beispiel #39
0
		public TopicService(IForumRepository forumRepository, ITopicRepository topicRepository, IPostRepository postRepository, IProfileRepository profileRepository, ITextParsingService textParsingService, ISettingsManager settingsManager, ISubscribedTopicsService subscribedTopicsService, IModerationLogService moderationLogService, IForumService forumService, IEventPublisher eventPublisher, IBroker broker, ISearchRepository searchRepository, IUserRepository userRepository)
		{
			_forumRepository = forumRepository;
			_topicRepository = topicRepository;
			_postRepository = postRepository;
			_profileRepository = profileRepository;
			_settingsManager = settingsManager;
			_textParsingService = textParsingService;
			_subscribedTopicService = subscribedTopicsService;
			_moderationLogService = moderationLogService;
			_forumService = forumService;
			_eventPublisher = eventPublisher;
			_broker = broker;
			_searchRepository = searchRepository;
			_userRepository = userRepository;
		}
Beispiel #40
0
 public SearchService(ISearchRepository repository)
 {
     this.repository = repository;
 }
Beispiel #41
0
        public static void CountForSingleWord(List<string> topWordsList, ISearchRepository searchRepository)
        {
            List<TopOneWord> resultOneWord = new List<TopOneWord>();
            int progress = 0;

            Console.WriteLine(progress);

            var watch = Stopwatch.StartNew();

            foreach (var word in topWordsList)
            {
                resultOneWord.Add(new TopOneWord(word, searchRepository.CountForSingleWord(word)));
                Console.Clear();
                progress++;
                Console.WriteLine(progress);
            }
            watch.Stop();
            Console.Clear();
            Console.WriteLine("Time elapsed: {0:hh\\:mm\\:ss}", watch.Elapsed);

            resultOneWord = resultOneWord.OrderByDescending(x => x.count).ToList();

            foreach (var word in resultOneWord)
            {
                Console.WriteLine(word.word + " " + word.count);
            }
        }
        public ActionResult Search(string paramSearch)
        {
            this._searchRepository = new SearchRepository(this._dbContext);

            var result = this._searchRepository.Search(paramSearch);
            return View(result);
            //return View(this._searchRepository.Search(paramSearch));
            //return Json(result, JsonRequestBehavior.AllowGet);
        }
 public SearchService(ISearchRepository searchRepository)
 {
     _searchRepository = searchRepository;
 }
Beispiel #44
0
		public SearchService(ISearchRepository searchRepository, ISettingsManager settingsManager, IForumService forumService)
		{
			_searchRepository = searchRepository;
			_settingsManager = settingsManager;
			_forumService = forumService;
		}
 public SearchServiceLayer(ISearchRepository repo)
 {
     _repo = repo;
 }
Beispiel #46
0
 public SearchController()
 {
     _searchRep = new SearchRepository();
 }
Beispiel #47
0
 public SearchLogic(ISearchRepository searchRepository, ISearchHistoryLogRepository searchHistoryLogRepository)
 {
     _searchRepository = searchRepository;
     _searchHistoryLogRepository = searchHistoryLogRepository;
 }
 public SearchService(ISearchRepository aSearchRepo, IMarketplaceService aMarketplaceServce)
 {
     theSearchRepository = aSearchRepo;
     theMarketplaceSerivce = aMarketplaceServce;
 }
        public void Setup()
        {
            _mockDbSettings.Setup(x => x.ConnectionString).Returns("TestConnectionString");
            _mockContext.Setup(x => x.Applications).Returns(_mockDbSet.Object);
            _mockContext.Setup(x => x.SaveChanges()).Returns(1);

            _searchRepository = new SearchRepository(_mockContext.Object, _searchQueryFactory);
        }
Beispiel #50
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            //  TODO: Add handler for OnSuspending to save the search stuff to localfolder.  IF WE CAN????????

            //  Instantiate the Unity IoC container
            _ioCcontainer = new UnityContainer();
            //  Now configure it,set up the mappings
            UnityConfiguration.RegisterTypes(_ioCcontainer);

            //  Instantiate the Library Repository
            _libraryRepository = _ioCcontainer.Resolve<ILibraryRepository>();

            //  INstantiage the Search Repository.
            _searchRepository = _ioCcontainer.Resolve<ISearchRepository>();
            //  Instantiate another repository, to check that the lifetime is OK,
            //  it shouldn't run the contructor of the Library module.  IT DOESN'T YEH!!!!!!!!!!
            //var _testRepository = _ioCcontainer.Resolve<ILibraryRepository>();
        }
Beispiel #51
0
 public SearchController(ISkillRepository skillRepository, ICategoryRepository categoryRepository, ISearchRepository searchR)
 {
     _skillRepository = skillRepository;
     _categoryRepository = categoryRepository;
     _searchR = searchR;
 }
Beispiel #52
0
        public static void CountForPairWords(List<string> topWordsList, ISearchRepository searchRepository)
        {
            List<TopPairWords> resultPairWords = new List<TopPairWords>();
            int[,] tab = new int[100, 100];
            int progress = 0;
            Console.WriteLine(progress);

            var watch = Stopwatch.StartNew();
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    string wordOne = topWordsList.ElementAt(i);
                    string wordTwo = topWordsList.ElementAt(j);
                    resultPairWords.Add(new TopPairWords(wordOne, wordTwo, searchRepository.CountForPairWord(wordOne, wordTwo)));
                    Console.Clear();
                    progress++;
                    Console.WriteLine(progress);
                }
            }
            watch.Stop();
            Console.Clear();
            Console.WriteLine("Time elapsed: {0:hh\\:mm\\:ss}", watch.Elapsed);

            resultPairWords = resultPairWords.OrderByDescending(x => x.count).ToList();

            foreach (var pair in resultPairWords)
            {
                Console.WriteLine(pair.wordOne + ", " + pair.wordTwo + " " + pair.count);
            }
        }
Beispiel #53
0
 public SearchManager(IUnitOfWork uow)
 {
     this.searchRepo = uow.SearchProgramRepository();
 }
 public SearchService(ISearchRepository searchRepository, IGatewayService gatewayService)
 {
     this.searchRepository = searchRepository;
     this.gatewayService = gatewayService;
 }
        public SearchService(ISearchRepository searchRepository)
        {
            Check.If(searchRepository).IsNotNull();

            _searchRepository = searchRepository;
        }