Пример #1
0
 public HomeController(IBusinessManagerContainer businessManagerContainer,
     IQueryContainer queryContainer)
 {
     this.businessManagerContainer = businessManagerContainer;
     this.queryContainer = queryContainer;
     this.authenticationService = ObjectFactory.GetInstance<AuthenticationService>();
 }
Пример #2
0
		internal QueryEagerEnumerator(IQueryContainer queryContainer, Type type)
		{
			_queryContainer = queryContainer;
			_type = type;
			_elements = new ArrayList();
			_counter = 0;
			Load();
		}
		private static IEnumerable<QueryContainer> OrphanFilters(IQueryContainer container)
		{
			var lBoolQuery = container.Bool;
			if (lBoolQuery == null || !lBoolQuery.Filter.HasAny()) return null;

			var filters = lBoolQuery.Filter.ToList();
			lBoolQuery.Filter = null;
			return filters;
		}
		private static IEnumerable<IQueryContainer> OrphanMustNots(IQueryContainer container)
		{
			var lBoolQuery = container.Bool;
			if (lBoolQuery == null || !lBoolQuery.MustNot.HasAny()) return null;
			
			var mustNotQueries = lBoolQuery.MustNot.ToList();
			lBoolQuery.MustNot = null;
			return mustNotQueries;
		}
		internal InternalContainerContainer(IQueryContainer pre)
		{
			AccessLayer = pre.AccessLayer;
			ForType = pre.ForType;
			AutoParameterCounter = pre.AutoParameterCounter;
			Parts = pre.Parts.ToList();
			EnumerationMode = pre.EnumerationMode;
			AllowParamterRenaming = pre.AllowParamterRenaming;
		}
Пример #6
0
 public HomeController(IBusinessManagerContainer businessManagerContainer,
     IQueryContainer queryContainer, 
     IFlashMessenger flashMessenger,
     IFormAuthenticationService formAuthenticationService)
 {
     this.businessManagerContainer = businessManagerContainer;
     this.queryContainer = queryContainer;
     this.flashMessenger = flashMessenger;
     this.formAuthenticationService = formAuthenticationService;
 }
Пример #7
0
		internal QueryLazyEnumerator(IQueryContainer queryContainer, Type type)
		{
			_type = queryContainer.AccessLayer.GetClassInfo(type);
			_accessLayer = new DbAccessLayer(queryContainer.AccessLayer.Database);
			_accessLayer.Database.Connect(IsolationLevel.ReadCommitted);
			var command = queryContainer.Compile();
			queryContainer.AccessLayer.RaiseSelect(command);

			_executeReader = command.ExecuteReader();
		}
		private static IEnumerable<IQueryContainer> CreateMustClauses(IQueryContainer container)
		{
			var boolQuery = container.Bool;
			var hasMustClauses = boolQuery != null && boolQuery.Must.HasAny();
			if (hasMustClauses) return boolQuery.Must;
			if (boolQuery != null && boolQuery.IsConditionless)
				return Enumerable.Empty<IQueryContainer>();

			return new[] {container};
		}
		internal static IEnumerable<IQueryContainer> MergeShouldQueries(this IQueryContainer lbq, IQueryContainer rbq)
		{
			var lBoolDescriptor = lbq.Bool;
			var lHasShouldQueries = lBoolDescriptor != null &&
			                        lBoolDescriptor.Should.HasAny();

			var rBoolDescriptor = rbq.Bool;
			var rHasShouldQueries = rBoolDescriptor != null &&
			                        rBoolDescriptor.Should.HasAny();

			var lq = lHasShouldQueries ? lBoolDescriptor.Should : new[] { lbq };
			var rq = rHasShouldQueries ? rBoolDescriptor.Should : new[] { rbq };

			return lq.Concat(rq);
		}
		internal static QueryContainer MergeShouldQueries(this IQueryContainer leftContainer, IQueryContainer rightContainer)
		{
			if (!leftContainer.CanMergeShould() || !leftContainer.CanMergeShould())
				return CreateShouldContainer(new List<IQueryContainer> { leftContainer, rightContainer }); 

			var lBoolQuery = leftContainer.Bool;
			var rBoolQuery = rightContainer.Bool;

			var lHasShouldQueries = lBoolQuery != null && lBoolQuery.Should.HasAny();
			var rHasShouldQueries = rBoolQuery != null && rBoolQuery.Should.HasAny();

			var lq = lHasShouldQueries ? lBoolQuery.Should : new[] { leftContainer };
			var rq = rHasShouldQueries ? rBoolQuery.Should : new[] { rightContainer };

			var shouldClauses =  lq.EagerConcat(rq);
			return CreateShouldContainer(shouldClauses);
		}
		internal static QueryContainer MergeMustQueries(this IQueryContainer leftContainer, IQueryContainer rightContainer)
		{
			if (!leftContainer.CanMergeMustAndMustNots() || !rightContainer.CanMergeMustAndMustNots())
			{
				if (rightContainer.IsBoolQueryWithOnlyMustNots()) 
					return CreateMustContainer(new [] { leftContainer }, rightContainer.Bool.MustNot );
				if (leftContainer.IsBoolQueryWithOnlyMustNots()) 
					return CreateMustContainer(new [] { rightContainer }, leftContainer.Bool.MustNot );
				return CreateMustContainer(new [] { leftContainer, rightContainer }, null);
			}
			
			var mustNots = OrphanMustNots(leftContainer)
				.EagerConcat(OrphanMustNots(rightContainer));
			
			var leftClauses = CreateMustClauses(leftContainer);
			var rightClauses = CreateMustClauses(rightContainer);
			
			var mustClauses = leftClauses.EagerConcat(rightClauses);
			var container = CreateMustContainer(mustClauses, mustNots);
			return container;
		}
Пример #12
0
		internal abstract void WrapInContainer(IQueryContainer container);
Пример #13
0
 public CommitmentController(IBusinessManagerContainer businessManagerContainer, IQueryContainer queryContainer)
 {
     this.businessManagerContainer = businessManagerContainer;
     this.queryContainer = queryContainer;
 }
Пример #14
0
		public QueryElement(IQueryContainer database) : base(database)
		{
		}
Пример #15
0
 public CountDescriptor <T> Query(Func <QueryDescriptor <T>, QueryContainer> querySelector)
 {
     this._Query = querySelector(new QueryDescriptor <T>());
     return(this);
 }
 protected override void WrapInContainer(IQueryContainer container)
 {
     container.SpanNot = this;
 }
Пример #17
0
		protected override void WrapInContainer(IQueryContainer container)
		{
			container.MatchAllQuery = this;
		}
Пример #18
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.Prefix = this;
Пример #19
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.Match = this;
 private void LotsOfAnds(IQueryContainer lotsOfAnds, int iterations = 100)
 {
     lotsOfAnds.Should().NotBeNull();
     lotsOfAnds.Bool.Should().NotBeNull();
     lotsOfAnds.Bool.Must.Should().NotBeEmpty().And.HaveCount(iterations);
 }
 public virtual void Visit(IQueryContainer baseQuery)
 {
     IsConditionless = baseQuery.IsConditionless;
     IsStrict        = baseQuery.IsStrict;
     IsVerbatim      = baseQuery.IsVerbatim;
 }
Пример #22
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.Indices = this;
Пример #23
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.ParentId = this;
Пример #24
0
 protected override void WrapInContainer(IQueryContainer container)
 {
     container.Range = this;
 }
		private void LotsOfUnaryAdds(IQueryContainer lotsOfUnaryAdds)
		{
			lotsOfUnaryAdds.Should().NotBeNull();
			lotsOfUnaryAdds.Bool.Should().NotBeNull();
			lotsOfUnaryAdds.Bool.Filter.Should().NotBeEmpty().And.HaveCount(100);
		}
 protected override void WrapInContainer(IQueryContainer container)
 {
     container.SimpleQueryString = this;
 }
Пример #27
0
 public ReportsController(IQueryContainer queryContainer)
 {
     this.queryContainer = queryContainer;
 }
 internal override void WrapInContainer(IQueryContainer c) => c.GeoShape = this;
Пример #29
0
 internal override void WrapInContainer(IQueryContainer c) => c.HasParent = this;
Пример #30
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.Script = this;
 internal override void InternalWrapInContainer(IQueryContainer container) => container.GeoShape = this;
Пример #32
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.SpanNear = this;
 public PaymentPeriodController(IBusinessManagerContainer businessManagerContainer, IQueryContainer queryContainer)
 {
     this.businessManagerContainer = businessManagerContainer;
     this.queryContainer           = queryContainer;
 }
Пример #34
0
 public MenuController(IBusinessManagerContainer businessManagerContainer, IQueryContainer queryContainer)
 {
     this.queryContainer = queryContainer;
 }
		//hide
		private void AssertShape(IQueryContainer container)
		{
			//top level bool
			container.Bool.Should().NotBeNull();
			container.Bool.Should.Should().HaveCount(2);
			container.Bool.MustNot.Should().BeNull();
			container.Bool.Filter.Should().BeNull();
			container.Bool.Must.Should().BeNull();

			//first bool
			var firstBool = (container.Bool.Should.First() as IQueryContainer)?.Bool;
			firstBool.Should().NotBeNull();
			firstBool.Must.Should().HaveCount(2);
			firstBool.MustNot.Should().BeNull();
			firstBool.Filter.Should().BeNull();
			firstBool.Should.Should().BeNull();

			//second bool
			var secondBool = (container.Bool.Should.Last() as IQueryContainer)?.Bool;
			secondBool.Should().NotBeNull();
			secondBool.Must.Should().HaveCount(3); //the last bool query was all conditionless
			secondBool.MustNot.Should().BeNull();
			secondBool.Filter.Should().BeNull();
			secondBool.Should.Should().BeNull();

			//complex nested bool
			var complexNestedBool = (secondBool.Must.First() as IQueryContainer)?.Bool;
			complexNestedBool.Should().NotBeNull();
			complexNestedBool.Should.Should().HaveCount(3);

			//inner must nots
			var mustNotsBool = (complexNestedBool.Should.Cast<IQueryContainer>().FirstOrDefault(q => q.Bool != null && q.Bool.MustNot != null))?.Bool;
			mustNotsBool.Should().NotBeNull();
			mustNotsBool.MustNot.Should().HaveCount(2); //one of the three must nots was conditionless
		}
Пример #36
0
 internal override void WrapInContainer(IQueryContainer c) => c.CommonTerms = this;
 private void LotsOfOrs(IQueryContainer lotsOfOrs)
 {
     lotsOfOrs.Should().NotBeNull();
     lotsOfOrs.Bool.Should().NotBeNull();
     lotsOfOrs.Bool.Should.Should().NotBeEmpty().And.HaveCount(Iterations);
 }
Пример #38
0
        public void Walk(IQueryContainer qd, IQueryVisitor visitor)
        {
            visitor.Visit(qd);
            VisitQuery(qd.MatchAll, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.MatchNone, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.MoreLikeThis, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.MultiMatch, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.CommonTerms, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Fuzzy, visitor, (v, d) =>
            {
                v.Visit(d);
                VisitQuery(d as IFuzzyStringQuery, visitor, (vv, dd) => v.Visit(dd));
                VisitQuery(d as IFuzzyNumericQuery, visitor, (vv, dd) => v.Visit(dd));
                VisitQuery(d as IFuzzyDateQuery, visitor, (vv, dd) => v.Visit(dd));
            });
            VisitQuery(qd.Range, visitor, (v, d) =>
            {
                v.Visit(d);
                VisitQuery(d as IDateRangeQuery, visitor, (vv, dd) => v.Visit(dd));
                VisitQuery(d as INumericRangeQuery, visitor, (vv, dd) => v.Visit(dd));
                VisitQuery(d as ILongRangeQuery, visitor, (vv, dd) => v.Visit(dd));
                VisitQuery(d as ITermRangeQuery, visitor, (vv, dd) => v.Visit(dd));
            });
            VisitQuery(qd.GeoShape, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Ids, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Prefix, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.QueryString, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Range, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Regexp, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.SimpleQueryString, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Term, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Terms, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Wildcard, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Match, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.MatchPhrase, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.MatchPhrasePrefix, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Script, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Exists, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.GeoPolygon, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.GeoDistance, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.GeoBoundingBox, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.RawQuery, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.Percolate, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.ParentId, visitor, (v, d) => v.Visit(d));
            VisitQuery(qd.TermsSet, visitor, (v, d) => v.Visit(d));

            VisitQuery(qd.Bool, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Filter, VisitorScope.Filter);
                Accept(v, d.Must, VisitorScope.Must);
                Accept(v, d.MustNot, VisitorScope.MustNot);
                Accept(v, d.Should, VisitorScope.Should);
            });

            VisitSpan(qd, visitor);

            VisitQuery(qd.Boosting, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.PositiveQuery, VisitorScope.PositiveQuery);
                Accept(v, d.NegativeQuery, VisitorScope.NegativeQuery);
            });
            VisitQuery(qd.ConstantScore, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Filter);
            });
            VisitQuery(qd.DisMax, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Queries);
            });
            VisitQuery(qd.FunctionScore, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Query);
            });
            VisitQuery(qd.HasChild, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Query);
            });
            VisitQuery(qd.HasParent, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Query);
            });
            VisitQuery(qd.Nested, visitor, (v, d) =>
            {
                v.Visit(d);
                Accept(v, d.Query);
            });
        }
Пример #39
0
		public virtual void Visit(IQueryContainer query) { }
 internal override void InternalWrapInContainer(IQueryContainer c) => c.QueryString = this;
		private void DefaultMustAssert(IQueryContainer lotsOfAnds)
		{
			lotsOfAnds.Should().NotBeNull();
			lotsOfAnds.Bool.Should().NotBeNull();
			lotsOfAnds.Bool.Must.Should().NotBeEmpty().And.HaveCount(Iterations);
		}
Пример #42
0
 internal override void InternalWrapInContainer(IQueryContainer c) => c.TermsSet = this;
Пример #43
0
 public DonationCaseController(IBusinessManagerContainer businessManagerContainer, IQueryContainer queryContainer)
 {
     this.businessManagerContainer = businessManagerContainer;
     this.queryContainer = queryContainer;
 }
Пример #44
0
 internal void WrapInContainer(IQueryContainer container)
 {
     container.IsVerbatim = this.IsVerbatim;
     container.IsStrict   = this.IsStrict;
     InternalWrapInContainer(container);
 }
Пример #45
0
		private static void AssertDoesNotJoinOntoLockedBool(IQueryContainer c, string firstName)
		{
			c.Bool.Should.Should().HaveCount(2);
			var nestedBool = c.Bool.Should.Cast<IQueryContainer>().First(b=>!string.IsNullOrEmpty(b.Bool?.Name));
			nestedBool.Bool.Should.Should().HaveCount(1);
			nestedBool.Bool.Name.Should().Be(firstName);
		}
		private void AssertShape(IQueryContainer container)
		{
			//top level bool
			container.Bool.Should().NotBeNull();
			container.Bool.Should.Should().HaveCount(2);
			container.Bool.MustNot.Should().BeNull();
			container.Bool.Filter.Should().BeNull();
			container.Bool.Must.Should().BeNull();

			//first bool
			var firstBool = (container.Bool.Should.First() as IQueryContainer)?.Bool;
			firstBool.Should().NotBeNull();
			firstBool.Must.Should().HaveCount(2);
			firstBool.MustNot.Should().BeNull();
			firstBool.Filter.Should().BeNull();
			firstBool.Should.Should().BeNull();

			//second bool
			var secondBool = (container.Bool.Should.Last() as IQueryContainer)?.Bool;
			secondBool.Should().NotBeNull();
			secondBool.Must.Should().HaveCount(2); //the last bool query was all conditionless
			secondBool.MustNot.Should().BeNull();
			secondBool.Filter.Should().BeNull();
			secondBool.Should.Should().BeNull();

			//complex nested bool
			var complexBool = (secondBool.Must.First() as IQueryContainer)?.Bool;
			complexBool.Should().NotBeNull();
			//complex bool is 3 ors and the next simple nested or bool query also has 3 should clauses
			//this can be rewritten to one boolquery with 6 clauses
			complexBool.Should.Should().HaveCount(6); 

			//inner must nots
			var mustNotsBool = (complexBool.Should.Cast<IQueryContainer>().FirstOrDefault(q=>q.Bool != null && q.Bool.MustNot != null))?.Bool;
			mustNotsBool.Should().NotBeNull();
			mustNotsBool.MustNot.Should().HaveCount(2); //one of the three must nots was conditionless
		}
Пример #47
0
		/// <summary>
		/// </summary>
		/// <param name="container"></param>
		public QueryFactoryResult(IQueryContainer container)
		{
			var compileFlat = container.CompileFlat();
			Query = compileFlat.Item1;
			Parameters = compileFlat.Item2;
		}
 internal override void InternalWrapInContainer(IQueryContainer container) => container.Intervals = this;
Пример #49
0
 protected override void WrapInContainer(IQueryContainer container)
 {
     container.CustomScore = this;
 }
Пример #50
0
 internal override void WrapInContainer(IQueryContainer c) => c.And = this;
Пример #51
0
 //
 // GET: /Donor/
 public DonorController(IBusinessManagerContainer businessManagerContainer, IQueryContainer queryContainer, IFlashMessenger flashMessenger)
 {
     this.businessManagerContainer = businessManagerContainer;
     this.queryContainer = queryContainer;
     this.flashMessenger = flashMessenger;
 }
Пример #52
0
		internal void WrapInContainer(IQueryContainer container)
		{
			container.IsVerbatim = this.IsVerbatim;
			container.IsStrict = this.IsStrict;
			InternalWrapInContainer(container);
		}
		private void LotsOfOrs(IQueryContainer lotsOfOrs)
		{
			lotsOfOrs.Should().NotBeNull();
			lotsOfOrs.Bool.Should().NotBeNull();
			lotsOfOrs.Bool.Should.Should().NotBeEmpty().And.HaveCount(100);
		}
 internal override void InternalWrapInContainer(IQueryContainer c) => c.Range = this;
Пример #55
0
 private void LotsOfUnaryAdds(IQueryContainer lotsOfUnaryAdds)
 {
     lotsOfUnaryAdds.Should().NotBeNull();
     lotsOfUnaryAdds.Bool.Should().NotBeNull();
     lotsOfUnaryAdds.Bool.Filter.Should().NotBeEmpty().And.HaveCount(100);
 }
Пример #56
0
		protected abstract void WrapInContainer(IQueryContainer container);
Пример #57
0
 internal abstract void InternalWrapInContainer(IQueryContainer container);
Пример #58
0
 protected override void WrapInContainer(IQueryContainer container)
 {
     container.GeoShape = this;
 }
 public virtual void Visit(IQueryContainer baseQuery)
 {
     this.IsConditionless = baseQuery.IsConditionless;
     this.IsStrict = baseQuery.IsStrict;
     this.IsVerbatim = baseQuery.IsVerbatim;
 }
Пример #60
0
 public virtual void Visit(IQueryContainer query)
 {
 }