private ConditionExpression GetCondition(NullFilter filter, out Column attColumn)
        {
            var condition = new ConditionExpression();

            var left = filter.LeftHand;

            attColumn = left as Column;

            // default attribute name for the filter condition.
            if (attColumn != null)
            {
                condition.AttributeName = attColumn.Name.ToLower();
            }
            else
            {
                throw new NotSupportedException("Null operator only works agains a column value.");
            }

            condition.Operator = ConditionOperator.Null;
            if (filter.Not)
            {
                condition.Operator = ConditionOperator.NotNull;
            }
            return(condition);
        }
Exemple #2
0
        private IFilter InitializeFilter()
        {
            IFilter xyFilter;

            switch (_filterSettings.ActiveFilter)
            {
            case FilterType.GainFilter:
                xyFilter = new GainFilter(_filterSettings);
                break;

            case FilterType.StampeFilter:
                xyFilter = new StampeFilter(_filterSettings);
                break;

            case FilterType.NullFilter:
                xyFilter = new NullFilter();
                break;

            case FilterType.OneEuroFilter:
                xyFilter = new OneEuroFilter(_filterSettings);
                break;

            default:
                throw new ArgumentException("Unknown filter type");
            }
            xyFilter.Initialize();
            return(xyFilter);
        }
Exemple #3
0
        public NullFilter Deserialize(XElement xFilter, List <Column> columns)
        {
            var column = GetColumn(xFilter, ColumnIdTag, columns);

            var filter = new NullFilter(column);

            return(filter);
        }
Exemple #4
0
        public XElement Serialize(NullFilter filter)
        {
            var xFilter = new XElement(FilterTag);

            AddColumn(xFilter, ColumnIdTag, filter.Column);

            return(xFilter);
        }
Exemple #5
0
        public void TestCreateShouldCreateNullFilter()
        {
            var filter = new NullFilter(null);
            var result = _factory.Create(filter);

            Assert.That(result, Is.TypeOf <NullFilterViewModel>());
            Assert.That(result.Filter, Is.EqualTo(filter));
        }
Exemple #6
0
        public void TestSerializeShouldSerializeNullFilters()
        {
            var filter  = new NullFilter(_column);
            var xFilter = new XElement("null-filter");

            _mockNullSerializer.Setup(p => p.Serialize(filter)).Returns(xFilter);
            var result = _serializer.Serialize(filter);

            Assert.That(result, Is.EqualTo(xFilter));
        }
        public void CalculateSummary()
        {
            NullFilter.CalculateSummary(Trades);
            foreach (var filter in Filters)
            {
                filter.CalculateSummary(Trades);
            }

            IsEnabled = true;
        }
        public void SetUp()
        {
            _filter = new NullFilter(null);

            _mockCommandBus = new Mock <ICommandBus>();

            _viewModel = new NullFilterViewModel(
                _mockCommandBus.Object,
                _filter);
        }
Exemple #9
0
        public FilterNode Create(FilterDto filter, PropertyInfo propertyInfo)
        {
            if (Enums.TryParse(propertyInfo.PropertyType, filter.Values.FirstOrDefault(), true, out object @enum) == false)
            {
                return(NullFilter.Create(filter, "Cannot parse enum."));
            }

            var value = Enums.ToInt32(propertyInfo.PropertyType, @enum);

            return(new Filter(filter.Field, Operator.Equals, filter.IsNegated, value.ToString()));
        }
        protected override void VisitNullFilter(NullFilter item)
        {
            Column attColumn;
            var    condition = GetCondition(item, out attColumn);

            if (this.NegateOperator)
            {
                condition.NegateOperator();
            }
            AddFilterCondition(condition, attColumn);
            return;
        }
Exemple #11
0
        public void SetUp()
        {
            _column  = new ColumnBuilder().WithId(1).Build();
            _columns = new List <Column> {
                _column
            };
            _filter = new NullFilter(_column);

            _xFilter = new XElement("null-filter",
                                    new XElement("column-id", _column.Id));

            _serializer = new NullFilterSerializer(
                new PropertySerializer(null));
        }
Exemple #12
0
        /// <summary>
        /// Generates the text for a NullFilter builder.
        /// </summary>
        /// <param name="item">The NullFilter builder to generate the text for.</param>
        protected internal override void VisitNullFilter(NullFilter item)
        {
            Action visitor = () =>
            {
                item.LeftHand.Accept(forSubCommand());
                writer.Write(" IS ");
                if (item.Not)
                {
                    writer.Write("NOT ");
                }
                writer.Write("NULL");
            };

            visitFilter(item, visitor);
        }
        public void TestGetWhereExpression_IsNotNullCheck_NullablePropertyHasValue()
        {
            var list     = new List <NullFilterTestClass>();
            var instance = new NullFilterTestClass
            {
                S = "hello"
            };

            list.Add(instance);
            var filter = new NullFilter <NullFilterTestClass>("S", true);

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(1, results.Count);
        }
        public void TestGetWhereExpression_DefaultIsNullCheck_NullablePropertyIsNull()
        {
            var list     = new List <NullFilterTestClass>();
            var instance = new NullFilterTestClass
            {
                S = null
            };

            list.Add(instance);
            var filter = new NullFilter <NullFilterTestClass>("S");

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(1, results.Count);
        }
 private MetadataConditionExpression GetCondition(NullFilter filter, out Column attColumn)
 {
     throw new NotSupportedException("'Null' filter not supported for entity metadata queries.");
 }
        public void TestConstructor_DefaultIsNotNull()
        {
            var filter = new NullFilter <NullFilterTestClass>("S");

            Assert.IsFalse(filter.IsNotNull);
        }
        public void TestConstructor_IsNotNullFalse()
        {
            var filter = new NullFilter <NullFilterTestClass>("S", false);

            Assert.IsFalse(filter.IsNotNull);
        }
Exemple #18
0
 public FindFilter KeyIsNotNull(StringField field)
 {
     ValidateStringFilters(field, SearchKeys);
     _stringFilters[field] = new NullFilter(false);
     return(this);
 }
Exemple #19
0
        public void PersistMatchersEtc()
        {
            // BaseMatcher is abstract
            // IntMatcher is abstract
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(5, 23);

            rangeIntMatch.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            ITsString tssLabel = m_cache.MakeAnalysisTss("label1");

            rangeIntMatch.Label = tssLabel;
            OwnIntPropFinder    ownIntFinder   = new OwnIntPropFinder(m_sda, 551);
            FilterBarCellFilter rangeIntFilter = new FilterBarCellFilter(ownIntFinder, rangeIntMatch);
            AndFilter           andFilter      = new AndFilter();

            andFilter.Add(rangeIntFilter);

            ITsStrFactory tsf       = TsStrFactoryClass.Create();
            int           ws        = m_cache.DefaultAnalWs;
            IVwPattern    m_pattern = VwPatternClass.Create();

            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;

            andFilter.Add(new FilterBarCellFilter(ownIntFinder, new NotEqualIntMatcher(77)));

            OwnMlPropFinder mlPropFinder = new OwnMlPropFinder(m_cache.MainCacheAccessor, 788, 23);

            m_pattern.Pattern = tsf.MakeString("hello", ws);
            andFilter.Add(new FilterBarCellFilter(mlPropFinder, new ExactMatcher(m_pattern)));

            OwnMonoPropFinder monoPropFinder = new OwnMonoPropFinder(m_cache.MainCacheAccessor, 954);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("goodbye", ws);
            andFilter.Add(new FilterBarCellFilter(monoPropFinder, new BeginMatcher(m_pattern)));

            OneIndirectMlPropFinder oneIndMlPropFinder =
                new OneIndirectMlPropFinder(m_cache.MainCacheAccessor, 221, 222, 27);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("exit", ws);
            andFilter.Add(new FilterBarCellFilter(oneIndMlPropFinder, new EndMatcher(m_pattern)));

            MultiIndirectMlPropFinder mimlPropFinder = new MultiIndirectMlPropFinder(
                m_cache.MainCacheAccessor, new int[] { 444, 555 }, 666, 87);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("whatever", ws);
            andFilter.Add(new FilterBarCellFilter(mimlPropFinder, new AnywhereMatcher(m_pattern)));

            OneIndirectAtomMlPropFinder oneIndAtomFinder =
                new OneIndirectAtomMlPropFinder(m_cache.MainCacheAccessor, 543, 345, 43);

            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder, new BlankMatcher()));

            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder, new NonBlankMatcher()));

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("pattern", ws);
            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder,
                                                  new InvertMatcher(new RegExpMatcher(m_pattern))));

            andFilter.Add(new NullFilter());

            XmlDocument docPaf = new XmlDocument();

            docPaf.LoadXml("<root targetClasses=\"LexEntry, LexSense\"></root>");
            ProblemAnnotationFilter paf = new ProblemAnnotationFilter();

            paf.Init(m_cache, docPaf.DocumentElement);
            andFilter.Add(paf);

            // Save and restore!
            string xml = DynamicLoader.PersistObject(andFilter, "filter");

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            // And check all the pieces...
            AndFilter andFilterOut =
                DynamicLoader.RestoreObject(doc.DocumentElement) as AndFilter;

            andFilterOut.Cache = m_cache;

            Assert.IsNotNull(andFilterOut);

            FilterBarCellFilter rangeIntFilterOut =
                andFilterOut.Filters[0] as FilterBarCellFilter;                 // todo

            Assert.IsNotNull(rangeIntFilterOut);

            OwnIntPropFinder ownIntFinderOut = rangeIntFilterOut.Finder as OwnIntPropFinder;

            Assert.IsNotNull(ownIntFinderOut);
            Assert.AreEqual(551, ownIntFinderOut.Flid);

            RangeIntMatcher rangeIntMatchOut = rangeIntFilterOut.Matcher as RangeIntMatcher;

            Assert.IsNotNull(rangeIntMatchOut);
            Assert.AreEqual(5, rangeIntMatchOut.Min);
            Assert.AreEqual(23, rangeIntMatchOut.Max);
            Assert.IsTrue(tssLabel.Equals(rangeIntMatchOut.Label));

            NotEqualIntMatcher notEqualMatchOut = GetMatcher(andFilter, 1) as NotEqualIntMatcher;

            Assert.IsNotNull(notEqualMatchOut);
            Assert.AreEqual(77, notEqualMatchOut.NotEqualValue);

            ExactMatcher exactMatchOut = GetMatcher(andFilter, 2) as ExactMatcher;

            Assert.IsNotNull(exactMatchOut);
            Assert.AreEqual("hello", exactMatchOut.Pattern.Pattern.Text);

            BeginMatcher beginMatchOut = GetMatcher(andFilter, 3) as BeginMatcher;

            Assert.IsNotNull(beginMatchOut);
            Assert.AreEqual("goodbye", beginMatchOut.Pattern.Pattern.Text);

            EndMatcher endMatchOut = GetMatcher(andFilter, 4) as EndMatcher;

            Assert.IsNotNull(endMatchOut);
            Assert.AreEqual("exit", endMatchOut.Pattern.Pattern.Text);

            AnywhereMatcher anywhereMatchOut = GetMatcher(andFilter, 5) as AnywhereMatcher;

            Assert.IsNotNull(anywhereMatchOut);
            Assert.AreEqual("whatever", anywhereMatchOut.Pattern.Pattern.Text);

            BlankMatcher blankMatchOut = GetMatcher(andFilter, 6) as BlankMatcher;

            Assert.IsNotNull(blankMatchOut);

            NonBlankMatcher nonBlankMatchOut = GetMatcher(andFilter, 7) as NonBlankMatcher;

            Assert.IsNotNull(nonBlankMatchOut);

            InvertMatcher invertMatchOut = GetMatcher(andFilter, 8) as InvertMatcher;

            Assert.IsNotNull(invertMatchOut);

            OwnMlPropFinder mlPropFinderOut = GetFinder(andFilter, 2) as OwnMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, mlPropFinderOut.DataAccess);
            Assert.AreEqual(788, mlPropFinderOut.Flid);
            Assert.AreEqual(23, mlPropFinderOut.Ws);

            OwnMonoPropFinder monoPropFinderOut = GetFinder(andFilter, 3) as OwnMonoPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, monoPropFinderOut.DataAccess);
            Assert.AreEqual(954, monoPropFinderOut.Flid);

            OneIndirectMlPropFinder oneIndMlPropFinderOut =
                GetFinder(andFilter, 4) as OneIndirectMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, oneIndMlPropFinderOut.DataAccess);
            Assert.AreEqual(221, oneIndMlPropFinderOut.FlidVec);
            Assert.AreEqual(222, oneIndMlPropFinderOut.FlidString);
            Assert.AreEqual(27, oneIndMlPropFinderOut.Ws);

            MultiIndirectMlPropFinder mimlPropFinderOut =
                GetFinder(andFilter, 5) as MultiIndirectMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, mimlPropFinderOut.DataAccess);
            Assert.AreEqual(444, mimlPropFinderOut.VecFlids[0]);
            Assert.AreEqual(555, mimlPropFinderOut.VecFlids[1]);
            Assert.AreEqual(666, mimlPropFinderOut.FlidString);
            Assert.AreEqual(87, mimlPropFinderOut.Ws);

            OneIndirectAtomMlPropFinder oneIndAtomFinderOut =
                GetFinder(andFilter, 6) as OneIndirectAtomMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, oneIndAtomFinderOut.DataAccess);
            Assert.AreEqual(543, oneIndAtomFinderOut.FlidAtom);
            Assert.AreEqual(345, oneIndAtomFinderOut.FlidString);
            Assert.AreEqual(43, oneIndAtomFinderOut.Ws);

            // 7, 8 are duplicates

            NullFilter nullFilterOut = andFilter.Filters[9] as NullFilter;

            Assert.IsNotNull(nullFilterOut);

            ProblemAnnotationFilter pafOut = andFilter.Filters[10] as ProblemAnnotationFilter;

            Assert.IsNotNull(pafOut);
            Assert.AreEqual(5002, pafOut.ClassIds[0]);
            Assert.AreEqual(5016, pafOut.ClassIds[1]);
        }
Exemple #20
0
 public FindFilter KeyIsNotNull(NumberField field)
 {
     _numberFilters[field] = new NullFilter(false);
     return(this);
 }
Exemple #21
0
 public FilterNode Create(FilterDto filter, PropertyInfo propertyInfo)
 {
     return(NullFilter.Create(filter, "Unknown."));
 }
 public NullFilterViewModel(ICommandBus commandBus, NullFilter filter)
     : base(commandBus, filter)
 {
 }
 public void SetUp()
 {
     _column = new ColumnBuilder().Build();
     _filter = new NullFilter(_column);
 }
 public FilterComponentVisitorBuilder() : base()
 {
     Params = new NullFilter();
 }