/// <summary> /// Computes the resulting virtual map after processing this operator /// </summary> /// <returns></returns> public virtual VirtualMap ComputeVirtualMap(VirtualMap ExistingVirtualMap = null) { if (!RuleMap.IsEmpty()) { if (RuleMap is VirtualMap) { return(RuleMap as VirtualMap); } else { return(VirtualMap.FromModelMap(RuleMap as ModelMapping)); } } return(new VirtualMap(new List <VirtualRule>())); }
/// <summary> /// Generates a virtual map for this operator /// </summary> /// <param name="ExistingVirtualMap"></param> /// <returns></returns> public override VirtualMap ComputeVirtualMap(VirtualMap ExistingVirtualMap = null) { // If the virtual map is not set we will use the IModelObject object if (ExistingVirtualMap == null && Map is ModelMapping) { ExistingVirtualMap = VirtualMap.FromModelMap((ModelMapping)Map); } else if (ExistingVirtualMap == null && Map is VirtualMap) { ExistingVirtualMap = Map as VirtualMap; } // Store new rules List <VirtualRule> NewRules = new List <VirtualRule>(); // Iterate arguments and keep rules that are either a BooleanExpr(true) or define a value to an attribute foreach (ProjectArgument Argument in Arguments.Where(Arg => Arg.Expression.IsAddingOrForcingAFieldVisible)) { // Check if rule already exists and update it VirtualRule ElementRule = NewRules.Find(R => R.SourceERElement.Name == Argument.ParentEntity.GetName() && R.Alias == Argument.ParentEntity.Alias); string RuleValue = ExistingVirtualMap.GetRuleValue(Argument.ParentEntity.GetAliasOrName(), Argument.Attribute.Name); if (ElementRule == null) { // Create new entry VirtualRule ArgRule = new VirtualRule(Argument.ParentEntity.Element, Argument.ParentEntity.Alias); ArgRule.Rules.Add(Argument.Attribute.Name, RuleValue); NewRules.Add(ArgRule); } else { ElementRule.Rules.Add(Argument.Attribute.Name, RuleValue); } } return(new VirtualMap(NewRules)); }