public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); var modelConfiguration = new ModelConfiguration(); Configuration.GetSection("Model").Bind(modelConfiguration); OrleansStartup.Configuration = Configuration; //modelConfiguration.Entities = new [] { modelConfiguration.Entities.First() }; //modelConfiguration.Attributes = new[] { modelConfiguration.Attributes.First() }; ModelMap = new ModelMap { SourceToModelMap = new Dictionary <DataSource, Dictionary <SourceName, EntityAttribute> > { { new DataSource(Guid.Parse("4055083b-c6be-4902-a209-7d2dba99abae")), modelConfiguration.Entities.SelectMany(entityGuid => modelConfiguration.Attributes.Select(attributeGuid => new { entityGuid, attributeGuid })).ToDictionary(x => new SourceName($"{x.entityGuid}:{x.attributeGuid}"), x => new EntityAttribute { Entity = Guid.Parse(x.entityGuid), Attribute = Guid.Parse(x.attributeGuid) }) } } }; }
/// <summary> /// Initialize a new instance of SelectStage class /// </summary> /// <param name="Arguments"></param> /// <param name="Map"></param> public SelectStage(SelectArgument Argument, IModelMap Map) { this.Argument = Argument; this.Map = Map; KeyPairs = new Dictionary <string, object>(); UseSimplerMatch = false; }
/// <summary> /// Generate the stage query /// </summary> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; List <MongoDBOperator> OperatorsToExecute = new List <MongoDBOperator>(); OperatorsToExecute.Add(new LimitOperator(Count)); return(new AlgebraOperatorResult(OperatorsToExecute)); }
public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; MatchOperator MatchOp = new MatchOperator(LogicalExpression.ToExpr()); return(new AlgebraOperatorResult(new List <MongoDBOperator>() { MatchOp })); }
/// <summary> /// Process stage and generates the corresponding commands /// </summary> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; // Store operators to execute List <MongoDBOperator> OperatorsToExecute = new List <MongoDBOperator>(); // Store attributes and their sort option Dictionary <string, MongoDBSort> SortByTheseFields = new Dictionary <string, MongoDBSort>(); // Iterate arguments foreach (SortArgument Argument in Arguments) { // Retrieve attribute map // Check if the MapRules is an instance of ModelMapping // If so, fetch the main mapping string AttributeMap = string.Empty; if (MapRules is ModelMapping) { MapRule Rule = (MapRules as ModelMapping).Rules.FirstOrDefault(R => R.Source.Name == Argument.Entity.GetName() && R.IsMain); if (Rule == null) { throw new ImpossibleOperationException($"A main mapping is required for entity {Argument.Entity.GetName()}"); } else { AttributeMap = Rule.Rules.FirstOrDefault(R => R.Key == Argument.Attribute.Name).Value; } } else { AttributeMap = MapRules.GetRuleValue(Argument.Entity.GetAliasOrName(), Argument.Attribute.Name); } if (string.IsNullOrWhiteSpace(AttributeMap)) { continue; } SortByTheseFields.Add($"\"{AttributeMap}\"", Argument.SortOption); } // Create sort operator SortOperator SortOp = new SortOperator(SortByTheseFields); // Add to list OperatorsToExecute.Add(SortOp); // Return new Result instance return(new AlgebraOperatorResult(OperatorsToExecute)); }
/// <summary> /// Run the operation /// </summary> /// <param name="LastResult"></param> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; AddFieldsOperator AddFieldsOperator = new AddFieldsOperator(Attributes); List <MongoDBOperator> OperationsToExecute = new List <MongoDBOperator>(); if (Attributes.Count > 0) { OperationsToExecute.Add(AddFieldsOperator); } return(new AlgebraOperatorResult(OperationsToExecute)); }
/// <summary> /// Run the operation adding MongoDB operators to the pipeline /// </summary> /// <param name="LastResult"></param> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { if (inMap is VirtualMap) { Map = inMap; RuleMap = inMap; } // Store operators to run List <MongoDBOperator> OperatorsToExecute = new List <MongoDBOperator>(); // All we need to do is find the correct map for each attribute // Argument already provides which expression to apply Dictionary <string, ProjectExpression> AttributesAndExpressions = new Dictionary <string, ProjectExpression>(); // Iterate all arguments foreach (ProjectArgument Argument in Arguments) { // Skip if Argument.Attribute is null if (Argument.Attribute == null) { continue; } // Each argument provides all necessary data string AttributeMap = Map.GetRuleValue(Argument.ParentEntity.Alias ?? Argument.ParentEntity.GetName(), Argument.Attribute.Name); if (string.IsNullOrWhiteSpace(AttributeMap)) { continue; } // Add to attribute list // Including quotation marks to prevent trouble with dot notation AttributesAndExpressions.Add($"\"{AttributeMap}\"", Argument.Expression); } // Only add projection if AttributesAndExpressions have content if (AttributesAndExpressions.Count > 0) { // Create project operator ProjectOperator ProjectOp = new ProjectOperator(AttributesAndExpressions); // Add to execution list // TODO: This process can be simplified to a single ProjectOperator OperatorsToExecute.Add(ProjectOp); } // Return operators return(new AlgebraOperatorResult(OperatorsToExecute)); }
/// <summary> /// Generate stage code /// </summary> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; MatchOperator MatchOp; if (UseSimplerMatch) { MatchOp = new MatchOperator(KeyPairs); } else { MatchOp = new MatchOperator(new Expr(Argument.Expression)); } return(new AlgebraOperatorResult(new List <MongoDBOperator>() { MatchOp })); }
/// <summary> /// Run operator /// </summary> /// <returns></returns> public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; // This operator is quite simple // basically a lookup with an empty pipeline (no join condition) // No support for embedded entities List <MongoDBOperator> OperatorsToExecute = new List <MongoDBOperator>(); // Fetch rules MapRule TargetRule = ModelMap.Rules.First(Rule => Rule.Source.Name == TargetEntity.Element.Name && Rule.IsMain); // Create operator LookupOperator LookupOp = new LookupOperator(true) { From = TargetRule.Target.Name, Pipeline = new List <MongoDBOperator>(), As = $"data_{TargetEntity.Element.Name}" }; // Add to list OperatorsToExecute.Add(LookupOp); return(new AlgebraOperatorResult(OperatorsToExecute)); }
/// <summary> /// Initialize a new instance of ProjectStage class /// </summary> /// <param name="Arguments"></param> /// <param name="Map"></param> public ProjectStage(IEnumerable <ProjectArgument> Arguments, IModelMap Map) { this.Arguments = Arguments; this.Map = Map; }
/// <summary> /// Run operation /// </summary> /// <returns></returns> public virtual AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { return(new AlgebraOperatorResult(new List <MongoDBOperator>())); }
public InMemoryModelMapProvider(IModelMap modelMap) { _modelMap = modelMap; }
/// <summary> /// Initialize a new instance of SortStage /// </summary> /// <param name="Arguments"></param> /// <param name="MapRules"></param> public SortStage(List <SortArgument> Arguments, IModelMap MapRules) { this.Arguments = Arguments; this.MapRules = MapRules; }
public override AlgebraOperatorResult Run(IModelMap inMap, IEnumerable <ProjectArgument> inAttributesToProject = null) { RuleMap = inMap; return(new AlgebraOperatorResult(new List <MongoDBOperator>())); }
/// <summary> /// Initializes a new instance of the <see cref="Context"/> class. /// </summary> public Module() { m_eventDispatcher = new EventDispatcher(); m_modelMap = new ModelMap(); m_mediatorMap = new MediatorMap(); }