Exemplo n.º 1
0
        public List <SearchResult> Search(string searchString, string searchType, string entityNamespace, IDbContext dataContext)
        {
            List <SearchResult> result = new List <SearchResult>();

            string[] keywords = new string[0];

            if (searchString == null)
            {
                return(result);
            }

            if (searchString.Count(c => c == ' ') >= (searchString.Length / 2))
            {
                keywords = new string[1] {
                    searchString.ToUpper().Trim()
                };
            }
            else
            {
                keywords = searchString.ToUpper().Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
            }

            if (keywords.Length > 0)
            {
                IQueryable <EntityIndex> query = _store.EntityIndexes.AsQueryable();

                if (!String.IsNullOrEmpty(searchType))
                {
                    string searchTypeName = entityNamespace + "." + searchType;
                    query = query.Where(idx => idx.EntityType.Name == searchTypeName);
                }

                if (searchString != "*")
                {
                    foreach (string keyword in keywords)
                    {
                        query = query.Where(idx => idx.Keywords.Count(kw => kw.Keyword.StartsWith(keyword)) > 0);
                    }
                }

                var queryResult = query.ToList();

                foreach (var item in queryResult)
                {
                    Type           entityType = _register.LookupEntityType(item.EntityType.Name);
                    IEntityIndexer indexer    = _register.GetIndexer(entityType);
                    object         entity     = dataContext.Set(entityType).Find(item.EntityKey);

                    if ((entity != null) && (indexer != null))
                    {
                        var resultLine = indexer.GetSearchResult(entity as IDomainEntity);
                        resultLine.Entity = (entity as IDomainEntity);
                        resultLine.Rank   = 100;
                        result.Add(resultLine);
                    }
                }
            }

            return(result.OrderBy(r => r.Rank).ThenBy(r => r.Name).ToList());
        }
 public TestStepsIndexing(IEntityIndexer entityIndexer, Func <ITestStepIndexingSagaData> data,
                          IEntityTypeProvider entityTypesProvider, Action <ITestStepIndexingSagaData> onComplete,
                          Action <TestStepQuery> sendQuery, IActivityLogger logger, Action <TestStepDTO, IEntityIndexer> indexMethod)
     : base(entityIndexer, data, entityTypesProvider, onComplete, sendQuery, logger, "testStep")
 {
     _indexMethod = indexMethod;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Class constructor for other pages.
 /// </summary>
 /// <param name="type">Page type.</param>
 /// <param name="indexer">Entity indexer.</param>
 /// <param name="comparer">Entity compaerer.</param>
 public GroupedViewNavigationArgs(CommonItemType type, IEntityIndexer indexer, IComparer <string> groupComparer, IComparer <string> itemComparer)
 {
     PageType      = type;
     SearchWord    = string.Empty;
     EntityIndexer = indexer;
     GroupComparer = groupComparer;
     ItemComparer  = itemComparer;
 }
 public IndexExistingEntitiesSaga(IEntityIndexer entityIndexer, ISagaPersister sagaPersister, IEntityTypeProvider entityTypesProvider, IDocumentIndexProvider documentIndexProvider, IPluginContext pluginContext, IActivityLogger logger)
 {
     _entityIndexer         = entityIndexer;
     _sagaPersister         = sagaPersister;
     _entityTypesProvider   = entityTypesProvider;
     _documentIndexProvider = documentIndexProvider;
     _pluginContext         = pluginContext;
     _logger = logger;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="indexer">The desired entity indexer to use.</param>
 /// <param name="groupComparer">The desired group index comparer to use.</param>
 /// <param name="itemComparer">The desired item index comparer to use.</param>
 public GroupedSource(IEntityIndexer indexer, IComparer <string> groupComparer, IComparer <string> itemComparer)
 {
     Indexer       = indexer;
     GroupComparer = groupComparer;
     ItemComparer  = itemComparer;
     IsEmpty       = true;
     _itemsIndex   = new Dictionary <string, IGroupedItems>();
     _entityCopies = new List <CommonViewItemModel>();
     Items         = new ObservableCollection <IGroupedItems>();
 }
Exemplo n.º 6
0
 public ProjectProcessChangedSaga(IEntityIndexer entityIndexer, IEntityTypeProvider entityTypesProvider, IActivityLogger logger)
 {
     _logger = logger;
     _assignablesIndexing = new AssignablesIndexing(entityIndexer, () => Data, entityTypesProvider, d => MarkAsComplete(), q
                                                    =>
     {
         q.ProjectId = Data.ProjectId;
         Send(q);
     }, _logger);
 }
Exemplo n.º 7
0
 protected IndexAlgorithm(IEntityIndexer entityIndexer, Func <TSagaData> data, IEntityTypeProvider entityTypesProvider, Action <TSagaData> onComplete, Action <TQuery> sendQuery, IActivityLogger logger, string entityName)
 {
     _entityIndexer       = entityIndexer;
     _data                = data;
     _entityTypesProvider = entityTypesProvider;
     _onComplete          = onComplete;
     _sendQuery           = sendQuery;
     _logger              = logger;
     _entityName          = entityName;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Class constructor.
        /// </summary>
        /// <param name="identifier">Indexer & Comparer pair for UI text.</param>
        /// <param name="indexer">Entity indexer.</param>
        /// <param name="comparer">Entity index comparer.</param>
        /// <param name="isGroupingRequired">Indicates whether grouping is required.</param>
        /// <remarks>Due to a recent resource design change, the constructor must be called from UI thread.</remarks>
        public IndexerComparerPair(string identifier, IEntityIndexer indexer, IComparer <string> groupComparer, IComparer <string> itemComparer, bool isGroupingRequired = false)
        {
            Identifier      = identifier;
            Indexer         = indexer;
            GroupComparer   = groupComparer;
            ItemComparer    = itemComparer;
            RequireGrouping = isGroupingRequired;

            _resLoader = ResourceLoader.GetForCurrentView();

            LoadLocalizedStrings();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Set indexer and regroup and resort all items.
        /// </summary>
        /// <param name="indexer">The indexer to be set.</param>
        public void SetIndexer(IEntityIndexer indexer)
        {
            _itemsIndex.Clear();
            Items.Clear();

            Indexer = indexer;

            foreach (var entity in _entityCopies)
            {
                AddInternal(entity, true);
            }
        }
 public GeneralProjectChangedSaga(IEntityIndexer entityIndexer, IEntityTypeProvider entityTypesProvider, IActivityLogger logger)
 {
     _entityIndexer       = entityIndexer;
     _entityTypesProvider = entityTypesProvider;
     _logger           = logger;
     _commentsIndexing = new CommentsIndexing(_entityIndexer, () => Data, _entityTypesProvider, d => MarkAsComplete(),
                                              q =>
     {
         q.GeneralId = Data.GeneralId;
         Send(q);
     }
                                              , _logger, (dto, indexer) => indexer.UpdateCommentIndex(dto, new List <CommentField>(), Maybe.Return(Data.ProjectId), Maybe.Nothing, DocumentIndexOptimizeSetup.NoOptimize));
 }
 public SearchableEntityLifecycleHandler(IEntityIndexer entityIndexer)
 {
     Mapper.CreateMap <ReleaseDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <UserStoryDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <TaskDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <BugDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <FeatureDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <TestCaseDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <TestPlanDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <TestPlanRunDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     Mapper.CreateMap <RequestDTO, GeneralDTO>().ForMember(dest => dest.ParentProjectID, opt => opt.MapFrom(src => src.ProjectID));
     _entityIndexer = entityIndexer;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Set both comparer and inexer, the index and regroup all items.
        /// </summary>
        /// <param name="indexer">The indexer to be set.</param>
        /// <param name="groupComparer">The group comparer to be set.</param>
        /// <param name="itemComparer">The item comparer to be set.</param>
        public void SetAll(IEntityIndexer indexer, IComparer <string> groupComparer, IComparer <string> itemComparer)
        {
            _itemsIndex.Clear();
            Items.Clear();

            Indexer       = indexer;
            GroupComparer = groupComparer;
            ItemComparer  = itemComparer;

            foreach (var entity in _entityCopies)
            {
                AddInternal(entity, true);
            }
        }
Exemplo n.º 13
0
 public IndexExistingEntitiesSaga(IEntityIndexer entityIndexer, IEntityTypeProvider entityTypesProvider, IDocumentIndexProvider documentIndexProvider, IPluginContext pluginContext, IActivityLogger logger, SagaServices sagaServices)
 {
     _documentIndexProvider = documentIndexProvider;
     _pluginContext         = pluginContext;
     _logger                 = logger;
     _sagaServices           = sagaServices;
     _generalsIndexing       = new GeneralsIndexing(entityIndexer, () => Data, entityTypesProvider, d => _assignablesIndexing.Start(), q => Send(q), _logger);
     _assignablesIndexing    = new AssignablesIndexing(entityIndexer, () => Data, entityTypesProvider, d => _testStepsIndexing.Start(), q => Send(q), _logger);
     _testStepsIndexing      = new TestStepsIndexing(entityIndexer, () => Data, entityTypesProvider, d => _impedimentsIndexing.Start(), q => Send(q), _logger, (dto, indexer) => indexer.AddTestStepIndex(dto, DocumentIndexOptimizeSetup.NoOptimize));
     _impedimentsIndexing    = new ImpedimentsIndexing(entityIndexer, () => Data, entityTypesProvider, d => _releaseProjectIndexing.Start(), q => Send(q), _logger);
     _releaseProjectIndexing = new ReleaseProjectIndexing(entityIndexer, () => Data, entityTypesProvider, d => _commentsIndexing.Start(), q => Send(q), _logger);
     _commentsIndexing       = new CommentsIndexing(entityIndexer, () => Data, entityTypesProvider, d =>
     {
         SendLocal(new IndexExistingEntitiesDoneLocalMessage {
             SagaId = Data.OuterSagaId
         });
         MarkAsComplete();
     }, q => Send(q), _logger, (dto, indexer) => indexer.AddCommentIndex(dto, DocumentIndexOptimizeSetup.NoOptimize));
 }
Exemplo n.º 14
0
 public EventIndexHandler(IEntityIndexer <Event> eventIndexer)
 {
     _eventIndexer = eventIndexer;
 }
Exemplo n.º 15
0
 public OddIndexHandler(IEntityIndexer <Odd> oddIndexer)
 {
     _oddIndexer = oddIndexer;
 }
Exemplo n.º 16
0
        public void IndexEntity(Type entityType, int id, bool recursive, Type contextType)
        {
            DateTime       startTime = DateTime.Now;
            IDomainEntity  entity    = GetEntity(entityType, id);
            IEntityIndexer indexer   = _registry.GetIndexer(entityType);

            if ((entity != null) && (indexer != null))
            {
                EntityIndex index = _indexContext.GetEntityIndex(entityType.FullName, id);
                if (index != null)
                {
                    _indexContext.DeleteEntityIndex(index);
                }
                else
                {
                    index = new EntityIndex();
                    _indexContext.EntityIndexes.Add(index);
                }

                HashSet <SearchKeyword> keywords = ProcessKeywords(indexer.GetKeyWords(entity));

                index.EntityTypeID = _indexContext.GetEntityTypeID(entityType.FullName);
                index.EntityKey    = id;

                //if (entity is ISegregatedEntity)
                //    index.DataAreaID = (entity as ISegregatedEntity).GetDataAreaID();
                //else
                //    index.DataAreaID = null;

                index.IndexTimeUTC = DateTime.Now.ToUniversalTime();

                foreach (var kw in keywords)
                {
                    EntityKeyword indexKW = new EntityKeyword();

                    if (kw.Keyword.Length < 50)
                    {
                        indexKW.Keyword = kw.Keyword;
                    }
                    else
                    {
                        indexKW.Keyword = kw.Keyword.Substring(0, 49);
                    }

                    if (kw.RefType != null)
                    {
                        indexKW.ReferenceEntityKey    = kw.RefID;
                        indexKW.ReferenceEntityTypeID = _indexContext.GetEntityTypeID(kw.RefType.FullName);
                    }
                    index.Keywords.Add(indexKW);
                }


                //index.IndexDuration = (DateTime.Now.TimeOfDay - startTime.TimeOfDay).Ticks;
            }

            if (recursive)
            {
                List <EntityIndex> relatedIndexes = _indexContext.GetRelatedIndexes(entityType.FullName, id);
                //Type.GetType(entityType.FullName, x => )
                foreach (var idx in relatedIndexes)
                {
                    Type relatedEntityType = _registry.LookupEntityType(idx.EntityType.Name);
                    _indexQueue.QueueIndexWork(relatedEntityType, idx.EntityKey, false, contextType);
                }
            }
        }
Exemplo n.º 17
0
 public AssignablesIndexing(IEntityIndexer entityIndexer, Func <IAssignableIndexingSagaData> data, IEntityTypeProvider entityTypesProvider, Action <IAssignableIndexingSagaData> onComplete, Action <AssignableQuery> sendQuery, IActivityLogger logger)
     : base(entityIndexer, data, entityTypesProvider, onComplete, sendQuery, logger, "assignable")
 {
 }
 public SearchableEntityLifecycleHandler(IEntityIndexer entityIndexer, DocumentIndexRebuilder documentIndexRebuilder)
 {
     _entityIndexer          = entityIndexer;
     _documentIndexRebuilder = documentIndexRebuilder;
 }
Exemplo n.º 19
0
 public SportIndexHandler(IEntityIndexer <Sport> sportIndexer)
 {
     _sportIndexer = sportIndexer;
 }
Exemplo n.º 20
0
 public AssignableSquadChangedSaga(IEntityIndexer entityIndexer)
 {
     _entityIndexer = entityIndexer;
 }
 public SportEntityIndexer(ISportRepository repo,
                           IEntityIndexer <Event> eventTracker)
 {
     _repo         = repo;
     _eventTracker = eventTracker;
 }
Exemplo n.º 22
0
 public MatchIndexHandler(IEntityIndexer <Match> matchIndexer)
 {
     _matchIndexer = matchIndexer;
 }
Exemplo n.º 23
0
 public ProjectProcessChangedSaga(IEntityIndexer entityIndexer, IActivityLogger logger)
 {
     _entityIndexer = entityIndexer;
     _logger        = logger;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="title">Group title.</param>
 /// <param name="indexer">Indexer of items.</param>
 /// <param name="comparer">Comparer of items.</param>
 public GroupedItems(string title, IEntityIndexer indexer, IComparer <string> comparer)
 {
     Title    = title;
     Indexer  = indexer;
     Comparer = comparer;
 }
 public CommentsIndexing(IEntityIndexer entityIndexer, Func <ICommentIndexingSagaData> data, IEntityTypeProvider entityTypesProvider, Action <ICommentIndexingSagaData> onComplete, Action <CommentQuery> sendQuery, IActivityLogger logger, Action <CommentDTO, IEntityIndexer> indexMethod)
     : base(entityIndexer, data, entityTypesProvider, onComplete, sendQuery, logger, "comment")
 {
     _indexMethod = indexMethod;
 }
Exemplo n.º 26
0
 public GeneralProjectChangedSaga(IEntityIndexer entityIndexer, IActivityLogger logger)
 {
     _entityIndexer = entityIndexer;
     _logger        = logger;
 }
Exemplo n.º 27
0
 public TestCasesIndexing(IEntityIndexer entityIndexer, Func <IndexExistingEntitiesSagaData> data, IEntityTypeProvider entityTypesProvider, Action <IndexExistingEntitiesSagaData> onComplete, Action <QueryBase> sendQuery, IActivityLogger logger)
     : base(entityIndexer, data, entityTypesProvider, onComplete, sendQuery, logger, "testCase")
 {
 }
Exemplo n.º 28
0
 public BetIndexHandler(IEntityIndexer <Bet> betIndexer)
 {
     _betIndexer = betIndexer;
 }