public LuceneSession(IDocumentMapper <T> mapper, Context context, IQueryable <T> queryable)
 {
     this.mapper     = mapper;
     this.context    = context;
     this.queryable  = queryable;
     documentTracker = new SessionDocumentTracker(mapper);
 }
 public LuceneQueryExecutor(Context context, ObjectLookup <TDocument> newItem, IDocumentMapper <TDocument> mapper)
     : base(context)
 {
     this.newItem      = newItem;
     this.mapper       = mapper;
     this.keyConverter = mapper as IDocumentKeyConverter;
 }
 public FieldMappingQueryParser(Version matchVersion, IDocumentMapper <T> mapper)
     : base(matchVersion, DefaultField, mapper.Analyzer)
 {
     this.initialDefaultField = DefaultField;
     this.matchVersion        = matchVersion;
     this.mapper = mapper;
 }
Exemple #4
0
 public void SetUp()
 {
     record   = new Record();
     document = new Document();
     mapper   = new MockRepository().StrictMock <IDocumentMapper <Record> >();
     executor = new TestableLuceneQueryExecutor <Record>(new Context(new RAMDirectory(), new object()), _ => record, mapper);
     context  = new QueryExecutionContext();
 }
 public FieldMappingQueryParser(Version matchVersion, string defaultSearchField, IDocumentMapper <T> mapper)
     : base(matchVersion, defaultSearchField, mapper.Analyzer)
 {
     this.initialDefaultField   = defaultSearchField;
     this.DefaultSearchProperty = defaultSearchField;
     this.matchVersion          = matchVersion;
     this.mapper = mapper;
 }
 public DocumentMapperClient(IDocumentMapper mapper)
 {
     if (mapper == null)
     {
         throw new ArgumentNullException("mapper");
     }
     documentMapper = mapper;
 }
        public LuceneSession(IDocumentMapper <T> mapper, IDocumentModificationDetector <T> detector, IIndexWriter writer, Context context, IQueryable <T> queryable)
        {
            this.mapper    = mapper;
            this.writer    = writer;
            this.context   = context;
            this.queryable = queryable;

            documentTracker = new SessionDocumentTracker(detector);
        }
        public IDocumentMapper <TModel> ToDocumentMapper(Version version)
        {
            ClassMap <TModel> classMap = new ClassMap <TModel>(version);

            this.Map(classMap);
            IDocumentMapper <TModel> documentMapper = classMap.ToDocumentMapper();

            return(documentMapper);
        }
Exemple #9
0
        /// <summary>
        /// Opens a session for staging changes and then committing them atomically.
        /// </summary>
        /// <param name="factory">Factory delegate that creates new instances of <typeparamref name="T"/></param>
        /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
        /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam>
        public ISession <T> OpenSession <T>(Func <T> factory, IDocumentMapper <T> documentMapper)
        {
            perFieldAnalyzer.Merge(documentMapper.Analyzer);

            return(new LuceneSession <T>(
                       documentMapper,
                       IndexWriter,
                       context,
                       CreateQueryable(factory, context, documentMapper)));
        }
Exemple #10
0
        /// <summary>
        /// Opens a session for staging changes and then committing them atomically.
        /// </summary>
        /// <param name="lookup">Factory delegate that resolves instances of <typeparamref name="T"/></param>
        /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
        /// <param name="documentModificationDetector">Helper to determine when instances of <typeparamref name="T"/> are modified
        ///     and need to be updated in the index when the session is committed.
        /// </param>
        /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam>
        public virtual ISession <T> OpenSession <T>(ObjectLookup <T> lookup, IDocumentMapper <T> documentMapper, IDocumentModificationDetector <T> documentModificationDetector)
        {
            perFieldAnalyzer.Merge(documentMapper.Analyzer);

            return(new LuceneSession <T>(
                       documentMapper,
                       documentModificationDetector,
                       IndexWriter,
                       context,
                       CreateQueryable(lookup, context, documentMapper)));
        }
 public HomeController(IUserService userService, IAuthenticationService authenticationService, IDocumentService documentService, 
     ITeamRepository teamRepository, IWorkshopRepository workshopRepository, IDocumentMapper documentMapper)
     : base(authenticationService)
 {
     _userService = userService;
     _documentMapper = documentMapper;
     _workshopRepository = workshopRepository;
     _teamRepository = teamRepository;
     _documentService = documentService;
     _authenticationService = authenticationService;
 }
 public DocumentController(
     IDocumentMapper documentMapper,
     IDocumentRepository documentRepository,
     IUserRepository userRepository,
     IUnitOfWork unitOfWork)
 {
     _documentRepository = documentRepository;
     _userRepository     = userRepository;
     _unitOfWork         = unitOfWork;
     _documentMapper     = documentMapper;
 }
        public void SetUp()
        {
            mapper = MockRepository.GenerateStrictMock<IDocumentMapper<Record>>();
            writer = MockRepository.GenerateStrictMock<IIndexWriter>();
            context = MockRepository.GenerateStub<Context>(null, new object());

            session = new LuceneSession<Record>(mapper, writer, context, null);

            mapper.Expect(m => m.ToKey(Arg<Record>.Is.NotNull))
                .WhenCalled(mi => mi.ReturnValue = new DocumentKey(new Dictionary<IFieldMappingInfo, object> { { new FakeFieldMappingInfo { FieldName = "Id"}, ((Record)mi.Arguments[0]).Id } }))
                .Repeat.Any();
        }
        public LuceneIndexProvider(
            LuceneConfig luceneConfig,
            IDocumentMapper mapper,
            ILoggerFactory loggerFactory,
            ILocalIndexPathFactory localIndexPathFactory)
        {
            _luceneConfig          = luceneConfig;
            _mapper                = mapper;
            _localIndexPathFactory = localIndexPathFactory;
            _logger                = loggerFactory.CreateLogger <LuceneIndexProvider>();

            // Ensures the directory exists
            EnsureDirectoryExists();
        }
Exemple #15
0
 public DocumentService(
     IDocumentRespository documentRespository,
     ILogger <IDocumentService> logger,
     IDocumentMapper documentMapper,
     IFAGTextRespository fagTextRespository,
     IPersonRespository personRespository,
     ICompanyRespository addressRespository)
 {
     _documentRespository = documentRespository;
     _logger             = logger;
     _documentMapper     = documentMapper;
     _fagTextRespository = fagTextRespository;
     _personRespository  = personRespository;
     _addressRespository = addressRespository;
 }
Exemple #16
0
        /// <summary>
        /// Opens a session for staging changes and then committing them atomically.
        /// </summary>
        /// <param name="lookup">Factory delegate that creates new instances of <typeparamref name="T"/></param>
        /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
        /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam>
        public ISession <T> OpenSession <T>(ObjectLookup <T> lookup, IDocumentMapper <T> documentMapper)
        {
            var documentModificationDetector = documentMapper as IDocumentModificationDetector <T>;

            if (documentModificationDetector == null)
            {
                throw new ArgumentException(
                          string.Format("The type {0} must implement {1} or else a separate implementation of {1} must be provided using an alternate overload.",
                                        documentMapper.GetType(),
                                        typeof(IDocumentModificationDetector <T>)),
                          "documentMapper");
            }

            return(OpenSession(lookup, documentMapper, documentModificationDetector));
        }
Exemple #17
0
        public void SetUp()
        {
            mapper  = MockRepository.GenerateStrictMock <IDocumentMapper <Record> >();
            writer  = MockRepository.GenerateStrictMock <IIndexWriter>();
            context = MockRepository.GenerateStub <Context>(null, new object());

            session = new LuceneSession <Record>(mapper, writer, context, null);

            mapper.Expect(m => m.ToKey(Arg <Record> .Is.NotNull))
            .WhenCalled(mi => mi.ReturnValue = new DocumentKey(new Dictionary <IFieldMappingInfo, object> {
                { new FakeFieldMappingInfo {
                      FieldName = "Id"
                  }, ((Record)mi.Arguments[0]).Id }
            }))
            .Repeat.Any();
        }
        private LuceneQueryable <T> CreateQueryable <T>(Func <T> factory, Context context, IDocumentMapper <T> mapper)
        {
            var executor = new LuceneQueryExecutor <T>(context, factory, mapper);

            return(new LuceneQueryable <T>(queryParser, executor));
        }
 public DocumentPositionMapper(IDocumentPositionMapper documentPositionMapper, IDocumentMapper documentMapper, IArticleMapper articleMapper)
 {
     _documentPositionMapper = documentPositionMapper;
     _documentMapper         = documentMapper;
     _articleMapper          = articleMapper;
 }
 public SessionDocumentTracker(IDocumentMapper <T> mapper)
 {
     this.mapper = mapper;
 }
Exemple #21
0
 public Importer(IDocumentMapper documentMapper)
 {
     _documentMapper = documentMapper;
 }
Exemple #22
0
 /// <summary>
 /// <see cref="AsQueryable{T}(ObjectLookup{T}, IDocumentMapper{T})"/>
 /// </summary>
 public IQueryable <T> AsQueryable <T>(IDocumentMapper <T> documentMapper) where T : new()
 {
     return(AsQueryable(() => new T(), documentMapper));
 }
Exemple #23
0
 public NuGetQueryParser(Version matchVersion, IDocumentMapper <LucenePackage> documentMapper)
     : base(matchVersion, DefaultSearchFieldName, documentMapper)
 {
 }
Exemple #24
0
 /// <summary>
 /// <see cref="RegisterCacheWarmingCallback{T}(System.Action{System.Linq.IQueryable{T}}, ObjectLookup{T}, IDocumentMapper{T})"/>
 /// </summary>
 public void RegisterCacheWarmingCallback <T>(Action <IQueryable <T> > callback, ObjectFactory <T> factory, IDocumentMapper <T> documentMapper)
 {
     RegisterCacheWarmingCallback(callback, _ => factory(), documentMapper);
 }
Exemple #25
0
        /// <summary>
        /// Registers a callback to be invoked when a new IndexSearcher is being initialized.
        /// This method allows an IndexSearcher to be "warmed up" by executing one or more
        /// queries before the instance becomes visible on other threads.
        ///
        /// While callbacks are being executed, other threads will continue to use the previous
        /// instance of IndexSearcher if this is not the first instance being initialized.
        ///
        /// If this is the first instance, other threads will block until all callbacks complete.
        /// </summary>
        public void RegisterCacheWarmingCallback <T>(Action <IQueryable <T> > callback, ObjectLookup <T> lookup, IDocumentMapper <T> documentMapper)
        {
            context.SearcherLoading += (s, e) =>
            {
                Log.Trace(m => m("Invoking cache warming callback " + lookup));

                var warmupContext = new WarmUpContext(context, e.IndexSearcher);
                var queryable     = CreateQueryable(lookup, warmupContext, documentMapper);
                callback(queryable);

                Log.Trace(m => m("Callback {0} completed.", lookup));
            };
        }
Exemple #26
0
 /// <summary>
 /// <see cref="RegisterCacheWarmingCallback{T}(Action{System.Linq.IQueryable{T}}, ObjectLookup{T}, IDocumentMapper{T})"/>
 /// </summary>
 public void RegisterCacheWarmingCallback <T>(Action <IQueryable <T> > callback, IDocumentMapper <T> documentMapper) where T : new()
 {
     RegisterCacheWarmingCallback(callback, _ => new T(), documentMapper);
 }
Exemple #27
0
 /// <summary>
 /// <see cref="AsQueryable{T}(ObjectLookup{T}, IDocumentMapper{T})"/>
 /// </summary>
 public IQueryable <T> AsQueryable <T>(ObjectFactory <T> factory, IDocumentMapper <T> documentMapper)
 {
     return(AsQueryable(_ => factory(), documentMapper));
 }
Exemple #28
0
 /// <summary>
 /// Returns an IQueryable implementation where the type being mapped
 /// from <c cref="Document"/> is constructed by a factory delegate.
 /// </summary>
 /// <typeparam name="T">The type of object that Document will be mapped onto.</typeparam>
 /// <param name="lookup">Factory method to instantiate new instances of T.</param>
 /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
 public IQueryable <T> AsQueryable <T>(ObjectLookup <T> lookup, IDocumentMapper <T> documentMapper)
 {
     return(CreateQueryable(lookup, context, documentMapper));
 }
Exemple #29
0
 public DocumentModelRepository(IAmazonDynamoDB amazonDynamoDbClient, IDocumentMapper documentMapper)
 {
     _documentMapper = documentMapper;
     _table          = Table.LoadTable(amazonDynamoDbClient, TableName);
 }
Exemple #30
0
 public TestableLuceneQueryExecutor(Context context, ObjectLookup <T> newItem, IDocumentMapper <T> mapper) : base(context, newItem, mapper)
 {
 }
Exemple #31
0
 public EditDocumentCommandHandler(IDocumentService documentService, IDocumentMapper documentMapper, ILogger <IRequest> logger)
 {
     _documentService = documentService;
     _documentMapper  = documentMapper;
     _logger          = logger;
 }
 public FieldMappingQueryParser(Version matchVersion, IDocumentMapper <T> mapper)
     : base(matchVersion, typeof(FieldMappingQueryParser <T>).FullName + ".DEFAULT_FIELD", mapper.Analyzer)
 {
     this.matchVersion = matchVersion;
     this.mapper       = mapper;
 }
Exemple #33
0
 /// <summary>
 /// Opens a session for staging changes and then committing them atomically.
 /// </summary>
 /// <param name="factory">Factory delegate that creates new instances of <typeparamref name="T"/></param>
 /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
 /// <param name="documentModificationDetector">Helper to determine when instances of <typeparamref name="T"/> are modified
 ///     and need to be updated in the index when the session is committed.
 /// </param>
 /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam>
 public ISession <T> OpenSession <T>(ObjectFactory <T> factory, IDocumentMapper <T> documentMapper, IDocumentModificationDetector <T> documentModificationDetector)
 {
     return(OpenSession(_ => factory(), documentMapper, documentModificationDetector));
 }
Exemple #34
0
 /// <summary>
 /// <see cref="OpenSession{T}(ObjectFactory{T}, IDocumentMapper{T})"/>
 /// </summary>
 public ISession <T> OpenSession <T>(IDocumentMapper <T> documentMapper) where T : new()
 {
     return(OpenSession(() => new T(), documentMapper));
 }