コード例 #1
0
ファイル: QueryTest.cs プロジェクト: sm-g/diagnosis
        public void WordQueryByTitlesUpperCase()
        {
            var w1  = session.Load <Word>(IntToGuid <Word>(1));
            var w2  = session.Load <Word>(IntToGuid <Word>(2));
            var res = WordQuery.ByTitles(session)(new[] { w1.Title.ToUpper(), w2.Title.ToUpper() });

            Assert.AreEqual(2, res.Count());
            Assert.IsTrue(res.Contains(w1));
            Assert.IsTrue(res.Contains(w2));
        }
コード例 #2
0
ファイル: OptionsLoader.cs プロジェクト: sm-g/diagnosis
        private IEnumerable <Word> LoadMeasureWords(SearchOptionsDTO dto, ISession session, out bool mWordsMissed)
        {
            var mWordTitles = (from w in dto.MeasuresAll
                               .Union(dto.MeasuresAny)
                               .Select(x => x.Word)
                               where w != null
                               select w.Title).Distinct().ToList();
            var mWords = WordQuery.ByTitles(session)(mWordTitles).ToList();

            mWordsMissed = mWordTitles.Count != mWords.Count;
            return(mWords);
        }
コード例 #3
0
ファイル: OptionsLoader.cs プロジェクト: sm-g/diagnosis
        /// <summary>
        /// Делает опции с реальными сущностями.
        /// </summary>
        protected SearchOptions LoadFromDTO(SearchOptionsDTO dto, ISession session)
        {
            Contract.Requires(dto != null);
            Contract.Ensures(dto.GetAllChildrenCount() == Contract.Result <SearchOptions>().GetAllChildrenCount());

            var result = new SearchOptions();

            // some options
            bool sscopeNotParsed = false;
            bool grOpNotParsed   = false;
            QueryGroupOperator groupOperator;

            if (!Enum.TryParse <QueryGroupOperator>(dto.GroupOperator, out groupOperator))
            {
                groupOperator = QueryGroupOperator.All;
                grOpNotParsed = true;
            }
            SearchScope sscope;

            if (!Enum.TryParse <SearchScope>(dto.SearchScope, out sscope))
            {
                sscope          = SearchScope.HealthRecord;
                sscopeNotParsed = true;
            }

            result.GroupOperator = groupOperator;
            result.SearchScope   = sscope;
            result.MinAny        = dto.MinAny;
            result.WithConf      = dto.WithConf;

            // words
            var allWordsTitles = dto.CWordsAll.Union(dto.CWordsAny).Union(dto.CWordsNot).Select(x => x.Title);
            var words          = WordQuery.ByTitles(session)(allWordsTitles);

            bool confNotParsedAll;
            bool confNotParsedAny;
            bool confNotParsedNot;

            result.CWordsAll = new List <Confindencable <Word> >(SelectConfWords(dto.CWordsAll, words, out confNotParsedAll));
            result.CWordsAny = new List <Confindencable <Word> >(SelectConfWords(dto.CWordsAny, words, out confNotParsedAny));
            result.CWordsNot = new List <Confindencable <Word> >(SelectConfWords(dto.CWordsNot, words, out confNotParsedNot));

            // measures
            bool mWordsMissed;
            bool uomsMissed;
            var  mWords = LoadMeasureWords(dto, session, out mWordsMissed);
            var  uoms   = LoadUoms(dto, session, out uomsMissed);

            bool mopNotParsed;
            var  mAll = SelectMeasures(dto.MeasuresAll, mWords, uoms, out mopNotParsed);
            var  mAny = SelectMeasures(dto.MeasuresAny, mWords, uoms, out mopNotParsed);

            result.MeasuresAll = new List <MeasureOp>(mAll);
            result.MeasuresAny = new List <MeasureOp>(mAny);

            // cats
            var cats = CategoryQuery.ByTitles(session)(dto.Categories.Select(x => x.Title));

            result.Categories = new List <HrCategory>(cats);

            // childs
            dto.Children.ForAll(x =>
            {
                var child = this.LoadFromDTO(x, session);
                result.Children.Add(child);
            });

            var smthMissed =
                result.CWordsAll.Count != dto.CWordsAll.Count ||
                result.CWordsAny.Count != dto.CWordsAny.Count ||
                result.CWordsNot.Count != dto.CWordsNot.Count ||
                result.MeasuresAll.Count != dto.MeasuresAll.Count ||
                result.MeasuresAny.Count != dto.MeasuresAny.Count ||
                result.Categories.Count != dto.Categories.Count ||
                mWordsMissed ||
                uomsMissed;

            var notParsed = confNotParsedAll || confNotParsedAny || confNotParsedNot || sscopeNotParsed || grOpNotParsed || mopNotParsed;

            if (smthMissed || notParsed || result.Children.Any(x => x.PartialLoaded))
            {
                result.SetPartialLoaded();
            }

            return(result);
        }