Ejemplo n.º 1
0
        private Maybe <QueryPlan> BuildProjectReachableThroughTeamContextPlan(QueryData data, DocumentIndexTypeToken projectContextType, DocumentIndexTypeToken squadContextType)
        {
            if (data.TeamProjectRelations == null)
            {
                return(Maybe.Nothing);
            }
            Maybe <QueryPlan> result = Maybe.Nothing;

            foreach (var projectsReachableThroughTeamData in data.TeamProjectRelations)
            {
                var projectContextPlan = ContextPlansBuilder.BuildProjectContextPlan(projectsReachableThroughTeamData.ProjectIds, false, projectContextType);
                var squadPlan          = BuildSquadPlan(new[] { projectsReachableThroughTeamData.TeamId }, false, squadContextType);
                var temp = projectContextPlan.And(squadPlan);
                result = result.Or(temp);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public Maybe <QueryPlan> Build(QueryData data, DocumentIndexTypeToken projectContextType, DocumentIndexTypeToken squadContextType, DocumentIndexTypeToken entityType)
        {
            var projectContextPlan = ContextPlansBuilder.BuildProjectContextPlan(data.ProjectIds, data.IncludeNoProject, projectContextType);
            var squadPlan          = BuildSquadPlan(data.TeamIds, data.IncludeNoTeam, squadContextType);
            var projectAndSquad    = projectContextPlan.And(squadPlan);
            var noSquadEntityPlan  = BuildNoSquadEntityProjectContextPlan(data, projectContextType, entityType);
            var resultPlan         = projectAndSquad.Or(noSquadEntityPlan);
            var projectsReachableThroughTeamsPlan = BuildProjectReachableThroughTeamContextPlan(data, projectContextType, squadContextType);

            resultPlan = resultPlan.Or(projectsReachableThroughTeamsPlan);
            resultPlan = _planBuilders.Where(b => b.ShouldBuild(data)).Aggregate(resultPlan, (acc, builder) =>
            {
                var plan = builder.Build(data, projectContextType, squadContextType, entityType);
                return(acc.Or(plan));
            });
            return(resultPlan);
        }